Query Chatroom Information
Retrieve chatroom information, which can return the following data:
-
Total number of chatroom members
-
A list of specified number (up to 20) of chatroom members, including the user ID of each member and the time they joined the chatroom
tip
Rate Limit: A single device can call this once per second, with a maximum of 20 calls per minute per device.
Call the getChatRoomInfo method to retrieve chatroom information.
Interface
RongIMLib.getChatRoomInfo(chatRoomId, options)
#### Parameter Description
| Parameter | Type | Required | Description |
|:--- |:--- |:--- |:--- |
| chatRoomId | string | Yes | Chatroom ID |
| options | object | No | Optional parameters |
- **options Description**
| Parameter | Type | Required | Description |
|:--- |:--- |:--- |:--- |
| count | number | No | Number of chatroom members to retrieve. Valid range: 0-20. Default: 0 |
| order | string | No | Specifies the order in which chatroom members are returned. Default: 0 (no return). Ascending (`1`) returns the earliest joined users. Descending (`2`) returns the latest joined users. |
:::tip
- When either count or order is 0, only the total number of members is returned without the member list. The order parameter specifies the sorting method: 1 for ascending, 2 for descending. Default: 0 (no return).
- A single device can call this once per second, with a maximum of 20 calls per minute per device.
:::
#### Example Code
```js
const chatroomId = "<Chatroom ID>"
const count = 10 // Number of room members to retrieve. Maximum valid value: `20`, minimum: `0`. Default: 0
const order = 1 // Sorting method: `1` for ascending, `2` for descending. Default: 0
RongIMLib.getChatRoomInfo(chatRoomId, {
count: count,
order: order
}).then(res => {
// Successfully retrieved chatroom information
if(res.code === 0){
console.log(res.data)
} else {
console.log(res.code, res.data)
}
})