Query whether a user is in a room
Overview
You can call this operation to query whether a user is in a specified room. By default, you can batch query up to 10 users. If you need a higher limit, contact ZEGOCLOUD technical support.
Request method and endpoint
- Request method: GET
- Request URL:
https://zim-api.zego.im/?Action=QueryRoomMembers - Protocol: HTTPS
- QPS limit: 5 calls per second, applicable to group chats only.
Request parameters
The following table describes only the operation-specific request parameters and some common request parameters. For the complete list of common request parameters, see the Common request parameters section of the Accessing Server APIs topic.
| Parameter | Type | Required | Description |
|---|---|---|---|
| UserId[] | Array of String | Yes | The list of user IDs to be queried. By default, up to 10 user IDs can be queried at a time. Example: UserId[]=a&UserId[]=b&UserId[]=c&UserId[]=d |
| RoomId | String | Yes | The room ID. |
The UserId parameter cannot exceed 32 bytes in length, and the RoomID parameter cannot exceed 128 bytes in length. Both parameters can contain only digits, letters, and the following characters: '!', '#', '$', '%', '&', '(', ')', '+', '-', ':', ';', '<', '=', '.', '>', '?', '@', '[', ']', '^', '_', ' ', ', ', '|', '~'.
Sample request
https://zim-api.zego.im/?Action=QueryRoomMembers
&UserId[]=a&UserId[]=b&UserId[]=c&UserId[]=d&RoomId=roomid
&<Common request parameters>Response parameters
| Parameter | Type | Description |
|---|---|---|
| Code | Number | The return code. |
| Message | String | The description of the request result. |
| RequestId | String | The request ID. |
| UserList | Array of Object | The query result, that is, the list of users in the specified room. |
| └user_id | String | The ID of the user in the specified room. |
| └user_name | String | The name of the user in the specified room. |
| └avatar | String | The user's avatar information, can be null. |
| └extra | String | Extended information, can be null. |
| ErrorList | Array of Object | The list of users not in the specified room.
|
| └UserId | String | The ID of the user not in the specified room. |
| └SubCode | Number | The return code that indicates the reason for not being in the specified room. |
Sample response
{
"Code": 0,
"Message": "success",
"RequestId": "343649807833778782",
"UserList": [
{
"user_id": "a",
"user_name": "UserNamea",
"avatar": "https://www.xxx.com/avatarA.png",
"extra": "Extraa"
},
{
"user_id": "b",
"user_name": "UserNameb",
"avatar": "https://www.xxx.com/avatarB.png",
"extra": "Extrab"
}
],
"ErrorList": [
{
"UserId": "c",
"SubCode": 660300012
},
{
"UserId": "d",
"SubCode": 660200001
}
]
}Return codes
The following table describes only the return codes related to the business logic of the operation. For the complete list of return codes, see Return codes.
| Return Code | Description | Solution |
|---|---|---|
| 660000002 | Invalid parameter. | Check the input parameter. |
| 660000011 | Too many users are included in the list. | Check the number of users. |
| 660200001 | The user ID is not registered. | Check whether the user ID exists or whether the user has logged out of the ZIM service. |
| 660300006 | The QPS limit is exceeded. | Try again later. |
| 660300012 | The user is not in the room. | No handling is required. |

