Skip to main content

You are viewing Agora Docs forBetaproducts and features. Switch to Docs

Query user list

This method gets the list of all users in a specified channel.

Prototype

  • Method: GET
  • Endpoint: https://api.agora.io/dev/v1/channel/user/{appid}/{channelName}

The return list differs based on the channel profile as follows:

  • For the COMMUNICATION profile, this API returns the list of all users in the channel.
  • For the LIVE_BROADCASTING profile, this API returns the list of all hosts and audience members in the channel.
Note
  • Users in a channel must use the same channel profile; otherwise, the query results may be inaccurate.
  • You can synchronize the online channel statistics either by calling this API or by calling the Query user status API. This API requires a lower call frequency and has a higher query efficiency. Therefore, Agora recommends using this API to query online channel statistics.

Request parameters

Path parameters

Pass the following path parameters in the request URL:

ParameterTypeRequired/OptionalDescription
appidStringRequiredThe App ID of the project. You can get it through one of the following methods:
  • Copy from the Agora Console.
  • Call the Get all projects API, and read the value of the vendor_key field in the response body.
  • channelNameStringRequiredThe channel name.
    hosts_onlyStringOptionalIf you fill in this parameter, only the host list in the live broadcast scenario will be returned.

    Request header

    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 RESTful authentication for details.

    Request examples

    Test this request in Postman or use one of the following code examples:

    Sample request:

    curl --request GET \
    --url http://api.sd-rtn.com/dev/v1/channel/user/appid/channelName/hosts_only \
    --header 'Accept: application/json' \
    --header 'Authorization: '

    Response parameters

    For details about possible response status codes, see Response status codes.

    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:

    ParameterTypeDescription
    successBooleanThe state of this request:
  • true: Success.
  • false: Reserved for future use.
  • dataObjectUser information, including the following fields:
    • channel_exist: Boolean. Whether the specified channel exists:
      • true: The channel exists.
      • false: The channel does not exist.
      Note: All other fields are not returned when the value of channel_exist is false.
    • mode: Number. The channel profile:
      • 1:The COMMUNICATION profile.
      • 2: The LIVE_BROADCASTING profile.
    • total: Number. The total number of the users in the channel. This field is returned only when mode is 1.
    • users: Array. User IDs of all users in the channel. This field is returned only when mode is 1.
    • broadcasters:Array. User IDs of all hosts in the channel. This field is returned only when mode is 2.
    • audience: Array. User IDs of the first 10,000 audience members in the channel. This field is returned only when mode is 2 and the hosts_only parameter is not filled in.
    • audience_total: Number. The total number of audience members in the channel. This field is returned only when mode is 2 and the hosts_only parameter is not filled in.

    Response example

    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    }}

    Interactive Live Streaming