Quickstart using middleware
To streamline the use of Agora RESTful APIs within your infrastructure, Agora’s developer community offers the open-source Agora Go Backend Middleware. This backend provides RESTful APIs for tasks such as token generation, cloud recording management, and real-time transcription. It simplifies the integration of Agora’s cloud services into your real-time voice and video applications. This guide shows you how to implement cloud recording using the community middleware.
Understand the tech
The following figure illustrates the cloud recording workflow you implement by integrating the middleware micro service.
Set up and run the Go backend middleware
Take the following steps to set up and run the middleware project:
-
Clone the repository
-
Install dependencies
Ensure you have Go installed on your system. Navigate to the project directory and install the project dependencies: -
Configure environment variables
Copy the example
.env
file and update it with your Agora App ID, App Certificate, and cloud storage parameters:Update the following variables in the
.env
file:APP_ID
: Your Agora App ID.APP_CERTIFICATE
: Your Agora App Certificate.CUSTOMER_ID
: Your customer IDCUSTOMER_SECRET
: Your Customer SecretSTORAGE_VENDOR
: Cloud storage vendor (e.g., AWS, GCP).STORAGE_REGION
: Region of your cloud storage.STORAGE_BUCKET
: Bucket name.STORAGE_ACCESS_KEY
: Cloud storage access key.STORAGE_SECRET_KEY
: Cloud storage secret key.
-
Run the middleware:
Start the middleware using the following command:The middleware runs on the default port, for example
localhost:8080
.
Implement Cloud Recording using middleware
This section explains the RESTful API calls to the backend middleware for starting, managing, and stopping a Cloud Recording session.
Start recording
To start a Cloud Recording session refer to the following examples:
The command-line examples in this guide are for demonstration purposes only. Do not use them directly in a production environment. Implement RESTful API requests through your application server.
-
Basic example
-
Advanced example
Stop recording
To stop an ongoing cloud recording session:
Get Recording Status
During the recording, call the status
endpoint to query the recording status as required.
Update Subscriber List
To update the subscriber list during a recording session, refer to the following example:
Update Layout
To update the layout of a recording session, refer to the following example:
Cloud Recording Middleware API Reference
This section provides details about the Go middleware Cloud Recording API endpoints.
Start Recording
Starts a cloud recording session.
Endpoint
POST: /cloud_recording/start
Request Body
Response
Stop Recording
Stops an ongoing cloud recording session.
Endpoint
POST: /cloud_recording/stop
Request Body
Response
Get Recording Status
Retrieves the status of a cloud recording session.
Endpoint
GET: /cloud_recording/status
Query Parameters
resourceId
: stringsid
: stringmode
: string
Response
Update Subscriber List
Updates the subscriber list for a cloud recording session.
Endpoint
POST: /cloud_recording/update/subscriber-list
Request Body
Response
Update Layout
Updates the layout of a cloud recording session.
Endpoint
POST: /cloud_recording/update/layout
Request Body
Response
Replace localhost:8080
with your server's address, if it is different.