In addition to the Voice/Video SDK integrated into the app client, Agora provides RESTful APIs for channel management, with which you can manage users in the channel and query channel statistics at the app server.
This page provides detailed help for the Agora Channel Management RESTful APIs.
This section provides basic information about the Agora Channel Management RESTful APIs.
All requests are sent to the domain name: api.agora.io
.
The Content-Type
field in all HTTP request headers is application/json
. All requests and responses are in JSON format. All request URLs and request bodies are case-sensitive.
The Agora Channel Management RESTful APIs only support HTTPS. Before sending HTTP requests, you must generate a Base64-encoded credential with the Customer ID and Customer Secret provided by Agora, and pass the credential to the Authorization
field in the HTTP request header. See HTTP authentication.
For each Agora account (not each App ID), the call frequency of each online channel statistics query API is no more than 20 queries per second, and the call frequency of each other API is no more than 10 queries per second. If you are frequency limited when calling the APIs, please see How can I avoid being frequency limited when calling Agora Server RESTful APIs to optimize API call frequency.
Creates a rule of banning specified user privileges.
The user privileges (privileges
) that can be banned include the following:
join_channel
: Joining a channel.
publish_audio
: Publishing audio.
publish_video
: Publishing video.
The banning rule works based on the following three fields: cname
, uid
, and ip
.
When you set privileges
as join_channel
, the rule works as follows:
If you set ip
, but not cname
or uid
, then all users with this ip
cannot join any channel in the app.
Using ip
as a filter field may incorrectly block users who should not be blocked, for example, in a scenario where multiple users share an IP address.
If you set cname
, but not uid
or ip
, then no one can join the channel specified by the cname
field.
Using cname
as a filter field directly blocks the channel with the cname
.
If you set uid
, but not cname
or ip
, then the user with the user ID cannot join any channel in the app.
If you set cname
and uid
, but not ip
, then the user with the user ID cannot join the channel specified by the cname
field.
When you set privileges
as publish_audio
or publish_video
, the rule works as follows:
If you set ip
, but not cname
or uid
, then the users with this ip
cannot publish audio or video in any channel of the app.
If you set cname
, but not uid
or ip
, then no one can publish audio or video in the channel specified bythe cname
field.
If you set uid
, but not cname
or ip
, then the user with the user ID cannot publish audio or video inany channel of the app.
If you set cname
and uid
, but not ip
, then the user with the user ID cannot publish audio or video inthe channel specified by the cname
field.
A user who is kicked out of a channel (that is when you set privileges
as join_channel
) receives one of the following callbacks based on their platform:
onConnectionStateChanged
callback reports CONNECTION_CHANGED_BANNED_BY_SERVER(3)
.connectionChangedToState
callback reports AgoraConnectionChangedBannedByServer(3)
.Client.on("client-banned")
callback.Client.on("connection-state-change")
callback.onConnectionStateChanged
callback reports CONNECTION_CHANGED_BANNED_BY_SERVER(3)
.AgoraRtcEngine.on("connectionStateChanged")
callback reports 3
.OnConnectionStateChangedHandler
callback reports CONNECTION_CHANGED_BANNED_BY_SERVER(3)
.ConnectionStateChanged
callback reports BannedByServer(3)
.ConnectionStateChanged
callback reports BannedByServer(3)
.onConnectionStateChanged
callback reports CONNECTION_CHANGED_BANNED_BY_SERVER(3)
.POST
https://api.agora.io/dev/v1/kicking-rule
Request body parameters
Pass in the following parameters in the request body:
Parameter | Data type | Required/Optional | Description |
---|---|---|---|
appid |
String | Required | The App ID of the project. You can get it through one of the following methods:vendor_key field in the response body. |
cname |
String | Optional | The channel name. |
uid |
Number | Optional | The user ID. Do not set it as 0 . |
ip |
String | Optional | The IP address of the user. Do not set it as 0 . |
time |
Number | Required | The time duration (in minutes) to ban the user. The value range is [1,1440]. Note 0 and 1 , Agora automatically sets the value to 1 .1440 , Agora automatically sets the value to 1440 .0 , the banning rule does not take effect. The server sets all users that conform to the rule offline, and users can log in again to rejoin the channel.time or time_in_seconds . If you set both parameters, the time_in_seconds parameter takes effect; if you set neither of these parameters, the Agora server automatically sets the banning time duration to 60 minutes, that is, 3600 seconds. |
time_in_seconds |
Number | Required | The time duration (in seconds) to ban the user. The value range is [10,86430]. Note 0 and 10 , Agora automatically sets the value to 10 .86430 , Agora automatically sets the value to 86430 .0 , the banning rule does not take effect. The server sets all users that conform to the rule offline, and users can log in again to rejoin the channel.time or time_in_seconds . If you set both parameters, the time_in_seconds parameter takes effect; if you set neither of these parameters, the Agora server automatically sets the banning time duration to 60 minutes, that is, 3600 seconds. |
privileges |
Array | Required | The user privileges you want to block. You can choose the following values: join_channel : String. Bans a user from joining a channel or kicks a user out of a channel.publish_audio : String. Bans a user from publishing audio. You can pass in both publish_audio and publish_video to ban a user from publishing audio and video.publish_video : Bans a user from publishing video. You can pass in both publish_audio and publish_video to ban a user from publishing audio and video. |
Request body
{
"appid": "4855xxxxxxxxxxxxxxxxxxxxxxxxeae2",
"cname": "channel1",
"uid": 589517928,
"ip": "",
"time": 60,
"privileges": [
"join_channel"
]
}
For details about possible response status codes, see the Response status codes table.
If the status code is not 200
, the request fails. See the message
field in the response body for the reason for this failure.
If the status code is 200
, the request succeeds, and the response body includes the following parameters:
Parameter | Type | Description |
---|---|---|
status |
String | The status of this request. success means the request succeeds. |
id |
Number | The rule ID. If you want to update or delete the rule, you need the rule ID to specify the rule. |
The following is a response example for a successful request:
{
"status": "success",
"id": 1953
}
Gets the list of all banning rules.
GET
https://api.agora.io/dev/v1/kicking-rule
Query parameters
Pass the following query parameters in the request URL:
Parameter | Type | Required/Optional | Description |
---|---|---|---|
appid |
String | Required | The App ID of the project. You can get it through one of the following methods:vendor_key field in the response body. |
For details about possible response status codes, see the Response status codes table.
If the status code is not 200
, the request fails. See the message
field in the response body for the reason for this failure.
If the status code is 200
, the request succeeds, and the response body includes the following parameters:
Parameter | Type | Description |
---|---|---|
status |
String | The status of this request. success means the request succeeds. |
rules |
Array | The list of banning rules. This array consists of multiple objects. Each object contains the information on one banning rule and includes the following fields:
|
createAt |
String | The UTC time when this rule is created. |
updateAt |
String | The UTC time when this rule is updated. |
The following is a response example for a successful request:
{
"status": "success",
"rules": [
{
"id": 1953,
"appid": "4855xxxxxxxxxxxxxxxxxxxxxxxxeae2",
"uid": 589517928,
"opid": 1406,
"cname": "11",
"ip": "192.168.0.1",
"ts": "2018-01-09T07:23:06.000Z",
"privileges": [
"join_channel"
],
"createAt": "2018-01-09T06:23:06.000Z",
"updateAt": "2018-01-09T14:23:06.000Z"
}
]
}
Updates the expiration time of a specified banning rule.
PUT
https://api.agora.io/dev/v1/kicking-rule
Request body parameters
Pass in the following parameters in the request body:
Parameter | Type | Required/Optional | Description |
---|---|---|---|
appid |
String | Required | The App ID of the project. You can get it through one of the following methods:vendor_key field in the response body. |
id |
Number | Required | The ID of the rule that you want to update. |
time |
Number | Required | The time duration (in minutes) to ban the user. The value range is [1,1440]. Note 0 and 1 , Agora automatically sets the value to 1 .1440 , Agora automatically sets the value to 1440 .0 , the banning rule does not take effect. The server sets all users that conform to the rule offline, and users can log in again to rejoin the channel.time or time_in_seconds . If you set both parameters, the time_in_seconds parameter takes effect; if you set neither of these parameters, the Agora server automatically sets the banning time duration to 60 minutes, that is, 3600 seconds. |
time_in_seconds |
Number | Required | The time duration (in seconds) to ban the user. The value range is [10,86430]. Note 0 and 10 , Agora automatically sets the value to 10 .86430 , Agora automatically sets the value to 86430 .0 , the banning rule does not take effect. The server sets all users that conform to the rule offline, and users can log in again to rejoin the channel.time or time_in_seconds . If you set both parameters, the time_in_seconds parameter takes effect; if you set neither of these parameters, the Agora server automatically sets the banning time duration to 60 minutes, that is, 3600 seconds. |
Request body
{
"appid": "4855xxxxxxxxxxxxxxxxxxxxxxxxeae2",
"id": 1953,
"time": 60
}
For details about possible response status codes, see the Response status codes table.
If the status code is not 200
, the request fails. See the message
field in the response body for the reason for this failure.
If the status code is 200
, the request succeeds, and the response body includes the following parameters:
Parameter | Type | Description |
---|---|---|
status |
String | The status of this request. success means the request succeeds. |
result |
Object | The result of the update:id : String. The rule ID.ts : String. The UTC time when the rule expires. |
The following is a response example for a successful request:
{
"status": "success",
"result": {
"id": 1953,
"ts": "2018-01-09T08:45:54.545Z"
}
}
Deletes a specified banning rule.
DELETE
https://api.agora.io/dev/v1/kicking-rule
Request body parameters
The following parameters are required in the request body:
Parameter | Type | Required/Optional | Description |
---|---|---|---|
appid |
String | Required | The App ID of the project. You can get it through one of the following methods:vendor_key field in the response body. |
id |
Number | Required | The ID of the rule that you want to delete. |
Request body
{
"appid": "4855xxxxxxxxxxxxxxxxxxxxxxxxeae2",
"id": 1953
}
For details about possible response status codes, see the Response status codes table.
If the status code is not 200
, the request fails. See the message
field in the response body for the reason for this failure.
If the status code is 200
, the request succeeds, and the response body includes the following parameters:
Parameter | Type | Description |
---|---|---|
status |
String | The status of this request. success means the request succeeds. |
id |
String | The ID of the rule that you want to delete. |
The following is a response example for a successful request:
{
"status": "success",
"id": 1953
}
Gets the status of a specified user.
This method checks if a specified user is in a specified channel, and if yes, the role of this user in the channel.
GET
https://api.agora.io/dev/v1/channel/user/property/{appid}/{uid}/{channelName}
Path parameters
Pass the following path parameters in the request URL:
Parameter | Type | Required/Optional | Description |
---|---|---|---|
appid |
String | Required | The App ID of the project. You can get it through one of the following methods:vendor_key field in the response body. |
uid |
Number | Required | The user ID. Note: This parameter does not support string user accounts. Ensure that you use the integer user ID. |
channelName |
String | Required | The channel name. |
Request URL
https://api.agora.io/dev/v1/channel/user/property/12sfegxxxxxxxxxxxx365/2845863044/test
For details about possible response status codes, see the Response status codes table.
If the status code is not 200
, the request fails. See the message
field in the response body for the reason for this failure.
If the status code is 200
, the request succeeds, and the response body includes the following parameters:
Parameter | Type | Description |
---|---|---|
success |
Boolean | The state of this request:true : Success. false : Reserved for future use. |
data |
Object | User statistics, including the following fields:
|
The following is a response example for a successful request:
{
"success": true,
"data": {
"join": 1640330382,
"uid": 2845863044,
"in_channel": true,
"platform": 7,
"role": 2
}
}
Gets the list of all users in a specified channel.
The return list differs with the channel profile as follows:
COMMUNICATION
profile, this API returns the list of all users in the channel.LIVE_BROADCASTING
profile, this API returns the list of all hosts and audience members in the channel.GET
https://api.agora.io/dev/v1/channel/user/{appid}/{channelName}
Path parameters
Pass the following path parameters in the request URL:
Parameter | Type | Required/Optional | Description |
---|---|---|---|
appid |
String | Required | The App ID of the project. You can get it through one of the following methods:vendor_key field in the response body. |
channelName |
String | Required | The channel name. |
For details about possible response status codes, see the Response status codes table.
If the status code is not 200
, the request fails. See the message
field in the response body for the reason for this failure.
If the status code is 200
, the request succeeds, and the response body includes the following parameters:
Parameter | Type | Description |
---|---|---|
success |
Boolean | The state of this request:true : Success.false : Reserved for future use. |
data |
Object | User information, including the following fields:
|
The following is a response example for a successful request:
In COMMUNICATION
profile
{
"success": true,
"data": {
"channel_exist": true,
"mode": 1,
"total": 1,
"users": [
906218805
]
}
}
In LIVE_BROADCASTING
profile
{
"success": true,
"data": {
"channel_exist": true,
"mode": 2,
"broadcasters": [
2206227541,
2845863044
],
"audience": [
906219905
],
"audience_total": 1
}
}
Gets the list of all channels under a specified project.
This API gets the channel list by page. In the request URL, you can specify the page number and the number of channels shown on the page. A successful request returns the channel list of the specified page according to the set page_size
.
GET
https://api.agora.io/dev/v1/channel/{appid}
Path parameters
Pass the following path parameters in the request URL:
Parameter | Type | Required/Optional | Description |
---|---|---|---|
appid |
String | Required | The App ID of the project. You can get it through one of the following methods:vendor_key field in the response body. |
Query parameters
Pass the following query parameters in the request URL:
Parameter | Type | Required/Optional | Description |
---|---|---|---|
page_no |
Number | Optional | The page number that you want to query. The default value is 0, that is, the first page. Note: The value of page_no cannot exceed (the total number of channels/the value of page_size - 1); otherwise, the specified page does not contain any channel. |
page_size |
Number | Optional | The number of channels on a page. The value range is [1,500], and the default value is 100. |
For details about possible response status codes, see the Response status codes table.
If the status code is not 200
, the request fails. See the message
field in the response body for the reason for this failure.
If the status code is 200
, the request succeeds, and the response body includes the following parameters:
Parameter | Type | Description |
---|---|---|
success |
Boolean | The state of this request: true : Success. false : Reserved for future use. |
data |
Object | Channel statistics, including the following fields:
|
The following is a response example for a successful request:
{
"success": true,
"data": {
"channels": [
{
"channel_name": "lkj144",
"user_count": 3
}
],
"total_size": 1
}
}
Response status code | Description |
---|---|
200 | The operation is successful. |
400 | Bad request. |
401 | Unauthorized (incorrect App ID/Customer Certificate). |
403 | Forbidden. |
404 | The requested resource could not be found. |
415 | Unsupported media type. Make sure that you set Content-Type in Headers as application/json . |
429 | Too many requests. |
500 | Internal error of the Agora RESTful API service. |