Analytics REST API reference
Before working with the RESTful APIs, review the Agora Analytics features in Agora Console to gain a visual understanding of the quality and usage metrics that are available. For details, see the following user guides:
Authentication
Before using the Agora RESTful API, you need to pass the basic HTTP authentication.
Data format
All requests are sent to the host: api.agora.io
.
-
Request: The request uses query string parameters in the URL.
-
Response: The response content is in JSON format.
Call Inspector
With the Call Inspector RESTful APIs, you can search for calls with quality issues and obtain detailed metrics about call quality.
API limits
The limits of the Call Inspector RESTful APIs depend on the pricing plan you subscribe to.
The Starter, Standard, Premium, and Enterprise pricing plans have the following differences in terms of API limits:
-
Endpoint is /beta/analytics/call/lists:
Starter Standard Premium Enterprise Request frequency N/A No more than 1/second and 1,000/day No more than 3/second and 2,000/day No more than 10/second and 10,000/day Available data N/A Within the past 3 days Within the past 7 days Within the past 15 days Response content N/A A maximum of 8 hours of data A maximum of 16 hours of data A maximum of 24 hours of data Data delay N/A 60 seconds -
Endpoint is /beta/analytics/call/sessions or /beta/analytics/call/metrics:
Starter Standard Premium Enterprise Request frequency N/A No more than 1/second and 1,000/day No more than 3/second and 2,000/day No more than 10/second and 10,000/day Available data N/A Within the past 1 days Within the past 7 days Within the past 15 days Response content N/A A maximum of 1 hours of data A maximum of 3 hours of data A maximum of 6 hours of data Data delay N/A 300 seconds
Get call list
This method gets a list of the calls that meet the search criteria.
-
Method: GET
-
Endpoint: /beta/analytics/call/lists
Request parameters
The following query string parameters are required in the URL as search criteria:
Parameter | Type | Description |
---|---|---|
start_ts | Number | The starting time of the search time frame. Unix time (in seconds since 1 January 1970) in UTC. |
end_ts | Number | The ending time of the search time frame. Unix time (in seconds since 1 January 1970) in UTC. |
cname | String | (Optional) The channel name. |
appid | String | App ID of your project. |
page_no | Number | (Optional) The page number. The default is 1. |
page_size | Number | (Optional) The number of calls on each page. The default is 20 and the maximum is 100. |
HTTP request example
Response example
Where:
-
code
: Number. The status code. -
message
: String. The error message. -
requestId
: String. The unique identifier of the HTTP request corresponding to this HTTP response. -
total_size
: Number. The total number of returned calls. -
page_no
: Number. The page number. -
page_size
: Number. The number of calls on each page. -
has_more
: Boolean. Whether there are calls not included incall_lists
.true
represents that some calls that meet the search criteria are not listed. If the call you need is not incall_lists
, try narrowing the search and resend the request. -
call_lists
: JSONArray. The returned calls in descending order of the starting time. Each call has the following properties: -
call_id
: String. The unique ID of the call. -
cname
: String. The channel name. -
created_ts
: Number. The starting time of the call. Unix time (in seconds since 1 January 1970) in UTC. -
destroyed_ts
: Number. The ending time of the call. Unix time (in seconds since 1 January 1970) in UTC. -
finished
: Boolean. Whether the call has finished or is still ongoing.
Get session details
This method gets the detailed call statistics of users by specifying the unique ID of the call.
-
Method: GET
-
Endpoint: /beta/analytics/call/sessions
Request parameters
The following query string parameters are required in the URL to specify the call ID and statistics:
Parameter | Type | Description |
---|---|---|
start_ts | Number | The starting time of the call. Unix time (in seconds since 1 January 1970) in UTC. |
end_ts | Number | The ending time of the call. Unix time (in seconds since 1 January 1970) in UTC. |
call_id | String | The unique ID of the call. |
page_no | Number | (Optional) The page number. The default is 1. |
page_size | Number | (Optional) The number of user sessions on each page. The default is 20 and the maximum is 100. To implement pagination, you need to specify a value for both page_no and page_size . |
uids | String | (Optional) The list of user IDs separated by commas (for example, uids=10001,10002,10003 ). You can specify a maximum of 10 user IDs. A user ID may occur twice in the list according to the actual scenario. Therefore, if you specify 10 user IDs in the request, 10 or more user IDs are returned. |
appid | String | App ID of your project. |
exclude_server_user | Boolean | (Optional) Whether to exclude Linux users. true by default, which represents excluding Linux users. |
HTTP request example
Response example
Where:
-
code
: Number. The status code. -
message
: String. The error message. -
requestId
: String. The unique identifier of the HTTP request corresponding to this HTTP response. -
total_size
: Number. The total number of returned user sessions. -
page_no
: Number. The page number. -
page_size
: Number. The number of user sessions on each page. -
call_info
: JSONArray. Information of each user in the call in descending order of the joining time per page. Each user has the following properties: -
sid
: String. The unique ID of the user session. -
cname
: String. The channel name. -
uid
: Number. The user ID. -
network
: String. The network type. -
platform
: String. The platform. -
speaker
: Boolean. Whether or not the user speaks in the call. -
sdk_version
: String. The SDK version. -
device_type
: String. The type of the device used by the user. -
join_ts
: Number. The time when the user joins the call. Unix time (in seconds since 1 January 1970) in UTC. -
leave_ts
: Number. The time when the user leaves the call. Unix time (in seconds since 1 January 1970) in UTC. -
finished
: Boolean. Whether the user is in the call or has left it.
Get quality metrics
Gets the quality metrics of a specified call.
-
Method: GET
-
Endpoint: /beta/analytics/call/metrics
Request parameters
The following query string parameters are required in the URL to specify the call:
Parameter | Type | Description |
---|---|---|
start_ts | Number | The starting time of the call. Unix time (in seconds since 1 January 1970) in UTC. |
end_ts | Number | The ending time of the call. Unix time (in seconds since 1 January 1970) in UTC. |
appid | String | App ID of your project. |
call_id | String | The unique ID of the call. |
sids | String | The list of user session IDs separated by commas, for example, sids=SXXXXXXXXXXXXXXXX1,SXXXXXXXXXXXXXXXX2 . You can specify a maximum of 20 user session IDs. |
HTTP request example
Response example
-
code
: Number. The status code. -
message
: String. The error message. -
requestId
: String. The unique identifier of the HTTP request corresponding to this HTTP response. -
metrics
: JSONArray. Detailed quality metrics of each user session (sid
). Each user session includes the following properties: -
sid
: String. The unique ID of the user session. -
data
: Array. The quality metrics of the user session. -
mid
: Number. The ID of the metric. See Metrics ID for details. -
kvs
: Array. Pairs of the timestamp and the corresponding metric value. -
peer_uid
: Number. The user ID of the remote user. 0 represents that the returned metrics are the local user’s.
Data Insights
With the Data Insights RESTful APIs, you can query the usage and quality metrics within a specified time frame.
API limits
The limits of the Data Insights RESTful APIs depend on the pricing plan you subscribe to.
The Starter, Standard, Premium, and Enterprise pricing plans have the following differences in terms of API limits:
- Endpoint is /beta/insight/usage/by_time:
Starter | Standard | Premium | Enterprise | |
---|---|---|---|---|
Request frequency | N/A | N/A | No more than 3/minute and 40/day | No more than 10/minute and 60/day |
Available data | N/A | N/A | Within the past 14 days | Within the past 30 days |
Query time frame | N/A | N/A | No longer than 3 days | No longer than 7 days |
Data granularity | N/A | N/A | Per day and hour | Per day and hour |
Data delay | N/A | N/A | 12 hours | 6 hours |
- Endpoint is /beta/insight/quality/by_time:
Starter | Standard | Premium | Enterprise | |
---|---|---|---|---|
Request frequency | N/A | N/A | No more than 3/minute and 40/day | No more than 10/minute and 60/day |
Available data | N/A | N/A | Within the past 14 days | Within the past 30 days |
Query time frame | N/A | N/A | No longer than 3 days | No longer than 7 days |
Data granularity | N/A | N/A | Per day, hour, and minute | Per day, hour, and minute |
Data delay | N/A | N/A | 6 hours | 6 hours |
Query usage metrics
This method queries usage metrics such as the number of users or channels.
-
Method: GET
-
Endpoint: /beta/insight/usage/by_time
Request parameters
The following query string parameters are required in the URL:
Parameter | Type | Description |
---|---|---|
|
Number |
The start point (Unix timestamp) of the time frame to query. |
|
Number |
The end point (Unix timestamp) of the time frame to query. |
|
String |
The App ID of your project. |
|
String |
The metrics you want to query. You can set it to one of the following:
|
|
String |
The level of time-related detail in the returned data. You can only set it to |
HTTP request example
The following example queries the total number of users across all channels starting from 8:00 am on July 1, 2021 to 8:00 am on July 3, 2021:
Response example
The response for the previous HTTP request example is as follows:
The response contains the following fields:
-
code
: Number. The status code. -
message
: String. The success or error message. -
data
: JSONArray, an array of JSON objects. Each JSON object contains a Unix timestamp representing 12:00 am (UTC) on each day within the specified time frame and the corresponding value of the specified metrics. In the case of the previous request example, two JSON objects should be returned: one for 12:00 am on July 2, 2021, the other for 12:00 am on July 3, 2021. -
userCount
: Number. Total number of users across all channels. -
ts
: Number. Unix timestamp.
Query quality metrics
This method queries quality metrics such as the audio or video freeze rate.
-
Method: GET
-
Endpoint: /beta/insight/quality/by_time
Request parameters
The following query string parameters are required in the URL:
Parameter | Type | Description |
---|---|---|
|
Number |
The start point (Unix timestamp) of the time frame to query. |
|
Number |
The end point (Unix timestamp) of the time frame to query. |
|
String |
The App ID of your project. |
|
String |
The metrics you want to query. You can set it to one of the following:
|
|
String |
The level of time-related detail in the returned data. You can set it to one of the following:
|
|
String |
The product for which you want to query the metrics. You can set it to:
|
HTTP request example
The following example queries the hourly network delay rate starting from 8:00 am on July 1, 2021 to 8:00 am on July 2, 2021:
Response example
The response for the previous HTTP request example is as follows:
The response contains the following fields:
-
code
: Number. The status code. -
message
: String. The success or error message. -
data
: JSONArray, an array of JSON objects. Each JSON object contains a Unix timestamp representing every hour within the specified time frame and the corresponding value of the specified metrics. In the case of the previous request example, 25 JSON objects should be returned. The first one is for 8:00 am on July 1, 2021, the second for 9:00 am on July 1, 2021, and so on. The last one is for 8:00 am on July 2, 2021. -
networkDelay
: Number. The network delay rate. -
ts
: Number. Unix timestamp.
Real-time Monitoring
With the Real-time Monitoring RESTful APIs, you can query the scale and quality metrics within a specified time frame. The granularity of the returned data is seconds, which can reflect the actual situation in close to real time.
The data is returned in regular 20-second time windows starting from 00:00:00. For example, [00:00:00, 00:00:20] is a time window, while [00:00:10, 00:00:30] is not a time window.
API limits
The limits of the Real-time Monitoring RESTful APIs depend on the pricing plan you subscribe to.
The Starter, Standard, Premium, and Enterprise pricing plans have the following differences in terms of API limits:
Starter | Standard | Premium | Enterprise | |
---|---|---|---|---|
Request frequency | N/A | N/A | No more than 3/minute and 480/day | No more than 10/minute and 1440/day |
Available data | N/A | N/A | Within the past 40 minutes | Within the past 60 minutes |
Query time frame | N/A | N/A | No longer than 40 minutes | No longer than 60 minutes |
Data delay | N/A | N/A | 40 seconds | 20 seconds |
Query real-time scale metrics
This method queries the real-time number of users and channels.
-
Method: GET
-
Endpoint: /beta/realtime/usage/by_time_20sec
Request parameters
The following query string parameters are required in the URL:
Parameter | Type | Description |
---|---|---|
|
Number |
The start point (Unix timestamp) of the time frame to query. The time window that |
|
Number |
The end point (Unix timestamp) of the time frame to query. The time window that |
|
String |
The App ID of your project. |
|
String |
The product for which you want to query the metrics. You can set it to:
|
|
String |
The metric you want to query. You can set it to one of the following options:
|
|
String |
The channel name. If you do not specify this parameter, the metric data of your entire project (rather than a specific channel) is returned. |
HTTP request example
The following example queries the number of users starting from 00:10:10 to 00:11:10 on September 17, 2021:
Response parameters
The response contains the following fields:
Field | Type | Description |
---|---|---|
|
Number |
The status code. |
|
String |
The error message. |
|
JSONArray |
An array consisting of the following fields: The
|
Response example
For the previous HTTP request example, the response includes data of the following time windows:
-
[00:10:00, 00:10:20] on September 17, 2021
-
[00:10:20, 00:10:40] on September 17, 2021
-
[00:10:40, 00:11:00] on September 17, 2021
Query real-time quality metrics
This method queries the real-time values of quality metrics such as the audio or video freeze rate.
-
Method: GET
-
Endpoint: /beta/realtime/quality/by_time_20sec
Request parameters
The following query string parameters are required in the URL:
Parameter | Type | Description |
---|---|---|
|
Number |
The start point (Unix timestamp) of the time frame to query. The time window that |
|
Number |
The end point (Unix timestamp) of the time frame to query. The time window that |
|
String |
The App ID of your project. |
|
String |
The product for which you want to query the metrics. You can set it to one of the following options:
|
|
String |
The metrics you want to query. You can set it to one of the following options:
|
|
String |
The channel name. If you do not specify this parameter, the metric data of your entire project (rather than a specific channel) is returned. |
|
String |
(Optional) The list of user IDs ( The |
HTTP request example
The following example queries the network delay rate from 00:10:10 to 00:11:10 on September 17, 2021:
Example 1: uids
is not specified
Example 2: uids
is specified as 2303692334
and 2963430861
Response parameters
The response contains the following fields:
Field | Type | Description |
---|---|---|
|
Number |
The xref:[status code]. |
|
String |
The error message. |
|
JSONArray |
An array consisting of the following fields: The
(Optional) |
Response example
For the previous HTTP request example, the response includes data of the following time windows:
-
[00:10:00, 00:10:20] on September 17, 2021
-
[00:10:20, 00:10:40] on September 17, 2021
-
[00:10:40, 00:11:00] on September 17, 2021
Example 1: uids
is not specified
Example 2: uids
is specified as 2303692334
and 2963430861
References
Status codes
Code | Description |
---|---|
200 | The request is successful. |
300 | The API limits are exceeded (Call Search only) |
400 | Invalid parameters. |
401 | Unauthorized. |
403 | Wrong authorization information. The request is forbidden. |
404 | Wrong API invoked. |
500 | Unknown error. |
When 300
is returned, you might get the following error messages:
Error message | Description | Examples of error fix |
---|---|---|
qps limit error | The limit on requests per second is exceeded. | If qps limit = 10, ensure that current qps < 10 |
qpd limit error | The limit on requests per day is exceeded. | If qpd limit = 10000, ensure that current qpd < 10000 |
query latency limit error | The limit on data delay is exceeded. | If query latency limit = 10s and current time = 1623316864, ensure that end_ts < 1623316864 - 10 |
query time range limit error | The limit on available calls is exceeded. | If query time range limit = 3d and current time = 1623316864, ensure that start_ts > 1623316864 - 3 * 86400(s) |
query time length limit error | The limit on response content is exceeded. | If query time length limit = 3h, ensure that end_ts -start_ts < 3 * 3600(s) |
you have no auth to access this service, please buy or upgrade your service package | You have no access to this service. | N/A |
Metrics ID
mid | Description | Unit | Example |
---|---|---|---|
20001 | App CPU usage. | % | 27% |
20002 | System CPU usage. | % | 15% |
20003 | The upstream bitrate of the audio. | Kbps | 126 Kbps |
20004 | The downstream bitrate of the audio. | Kbps | 108 Kbps |
20005 | The freeze time in rendering the audio. | ms | 106.67 ms |
20006 | The upstream bitrate of the low-quality video stream. | Kbps | 126 Kbps |
20007 | The capturing frame rate of the video. | fps | 16 fps |
20008 | The upstream frame rate of the high-quality video stream. | fps | 12 fps |
20009 | The downstream bitrate of the video. | Kbps | 309 Kbps |
20010 | The downstream frame rate of the video. | fps | 6 fps |
20011 | The freeze time in rendering the video. | ms | 2000.50 ms |
20013 | Quality of Picture (QP) of the video. The lower the value, the higher the video quality. | —— | —— |
20015 | The upstream packet loss rate of the audio. | % | 1% |
20016 | The end-to-end packet loss rate of the audio. | % | 3% |
20017 | The upstream packet loss rate of the video. | % | 5% |
20018 | The end-to-end packet loss rate of the video. | % | 7% |
20019 | The width of the received video. | —— | 360 |
20020 | The height of the received video. | —— | 640 |
20021 | The task scheduling delay. | ms | 2 ms |
20022 | The round-trip time delay from the client to the local router. | ms | 3 ms |
20023 | The upstream frame rate of the low-quality video stream. | fps | 108 fps |
20024 | The upstream bitrate of the high-quality video stream. | Kbps | 472 Kbps |
20025 | The sampling volume of the sent audio. | dB | 105 dB |
20026 | The playback volume of the received audio. | dB | 98 dB |
20027 | The width of the sent video. | —— | 360 |
20028 | The height of the sent video. | —— | 640 |