logo
In-app Chat
Powered Byspreading
On this page

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.

Operation prototype

  • 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 Public request parameters section of the Accessing Server APIs topic.

ParameterTypeRequiredDescription
UserId[]Array of StringYes

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

RoomIdStringYesThe room ID.
Note

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

Untitled
https://zim-api.zego.im/?Action=QueryRoomMembers
&UserId[]=a&UserId[]=b&UserId[]=c&UserId[]=d&RoomId=roomid
&<Common request parameters>
1
Copied!

Response parameters

ParameterTypeDescription
CodeNumberThe return code.
MessageStringThe description of the request result.
RequestIdStringThe request ID.
UserListObjectThe query result, that is, the list of users in the specified room.
└UserIdStringThe IDs of users in the specified room.
└UserNameStringThe names of users in the specified room.
ErrorUserObject

The list of users not in the specified room.

  • If Code is 0:

    • If ErrorUser is empty, all users are in the specified room.
    • If ErrorUser is not empty, some users are not in the specified room. For more information, see SubCode.
  • If Code is not 0:

    • If ErrorUser is empty, one or more parameters are invalid, the QPS limit is exceeded, or a system error occurs.
    • If ErrorUser is not empty, all users are not in the specified room.
└UserIdStringThe IDs of users not in the specified room.
└SubCodeNumberThe return code that indicates the reason for not being in the specified room.

Sample response

Untitled
{
    "Code": 0,
    "Message": "success",
    "RequestId": "343649807833778782",
    "UserList": [
        {
            "UserId": "a",
            "UserName": "UserNamea"
        },
        {
            "UserId": "b",
            "UserName": "UserNameb"
        }
    ],
     "ErrorUser": [
        {
            "UserId": "c",
            "SubCode": 660300012
        },
        {
            "UserId": "d",
            "SubCode": 660200001
        }
    ]
}
1
Copied!

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 CodeDescriptionSolution
660000002Invalid parameter.Check the input parameter.
660000011Too many users are included in the list.Check the number of users.
660200001The user ID is not registered.Check whether the user ID exists or whether the user has logged out of the ZIM service.
660300006The QPS limit is exceeded.Try again later.
660300012The user is not in the room.No handling is required.

Previous

Remove user from the room

Next

Create a group