Skip to main content

Query Chatroom Information

Retrieve chatroom information, which includes the following data:

  • Total number of chatroom members
  • A list of a 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 API once per second, with a maximum of 20 calls per minute per device.

You can use the getChatRoomInfo method under RongChatRoomClient or RongIMClient:

String chatroomId = "Chatroom Target ID";
int defMemberCount = 10;

RongChatRoomClient.getInstance().getChatRoomInfo(chatroomId, defMemberCount, ChatRoomMemberOrder.RC_CHAT_ROOM_MEMBER_ASC, new IRongCoreCallback.ResultCallback<ChatRoomInfo>() {

@Override
public void onSuccess(ChatRoomInfo chatRoomInfo) {
// Get ChatRoomInfo properties

String chatRoomId = chatRoomInfo.getChatRoomId();
int totalMemberCount = chatRoomInfo.getTotalMemberCount();

// Get ChatRoomMemberInfo properties
List<ChatRoomMemberInfo> memberInfoList = chatRoomInfo.getMemberInfo();
if (memberInfoList != null) {
for (ChatRoomMemberInfo memberInfo : memberInfoList) {
String MemberId = memberInfo.getUserId();
long JoinTime = memberInfo.getJoinTime();
}
}
}

@Override
public void onError(IRongCoreEnum.CoreErrorCode e) {
// Handle error
}
});
ParameterTypeDescription
chatRoomIdStringChatroom ID
defMemberCountintNumber of chatroom members to retrieve. Range: 0-20. Due to the potentially large number of chatroom members, the maximum number of members that can be retrieved is 20 to balance efficiency and user experience. If count is 0, the returned chatroom information will only include the total number of members, not the specific member list.
orderChatRoomMemberOrderThe order in which chatroom members are returned. RC_CHAT_ROOM_MEMBER_ASC (ascending order) retrieves members starting from the earliest join time, returning the list of members who joined first. RC_CHAT_ROOM_MEMBER_DESC (descending order) retrieves members starting from the latest join time, returning the list of members who joined last.
callbackResultCallback<ChatRoomInfo>Callback interface. On success, it returns ChatRoomInfo, which contains the list of chatroom members retrieved according to the specified parameters. The list elements are chatroom member objects ChatRoomMemberInfo, which include the user ID (userId) and the join time (joinTime) in Unix timestamp format, in milliseconds. The members in the list are ordered from oldest to newest based on their join time.