Query the message list of group chats
Overview
You can call this operation to paginate and fetch the message list of a specific group chat.
Operation prototype
- Request method: POST
- Request URL:
https://zim-api.zego.im/?Action=QueryGroupMsg
- Protocol: HTTPS
- QPS limit: 20 calls per second.
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.
Parameter | Type | Required | Description |
---|---|---|---|
GroupId | String | Yes | The group ID. |
Limit | Number | No | The number of messages to retrieve at a time, with a value range of (0, 100], defaulting to 10.
|
Next | Number | No | Pagination flag for pulling messages. Fill in 0 for the first time, and then fill in the Next value returned from the previous call. When the returned Next is 0, it means that the message list has been completely retrieved. For example, if there are 250 messages in the current one-on-one chat session and you call this interface to query:
|
WithEmptyMsg | Number | No | Whether the returned result includes retracted messages and messages that have been deleted on the server.
|
Sample request
- Request URL:
https://zim-api.zego.im/?Action=QueryGroupMsg
&<Common request parameters>
- Request message body:
{
"GroupId": "group1",
"Limit": 10,
"Next": 0,
"WithEmptyMsg": 0
}
Response parameters
Code | Number | The return code. |
---|---|---|
Message | String | The description of the request result. |
RequestId | String | The request ID. |
Next | Number | Pagination flag.
Aside from the explanations mentioned above, this field has no association with the list information. Please do not base any other logic on it. |
List | Array of Object | Message list. Return the results in descending order by MsgTime. |
└Sender | String | The ID of the message sender. |
└MsgType | Number | Message type:
|
└SubMsgType | Number | Specific custom type. The value is filled in by the user when sending a custom message, and the value range is [0, 200]. This parameter is only meaningful when MsgType is 200 (custom type). |
└MsgBody | String | Message content.
|
└MsgId | Number | Message ID, which can be used to determine the uniqueness of the message. |
└MsgSeq | Number | The message Seq. |
└Payload | String | Message extension field. |
└MsgTime | Number | Timestamp when the server receives the message, in Unix time format with milliseconds (ms) as the unit. |
└IsEmpty | Number | Whether it is an empty message.
|
MsgBody JSON String Parsing Result Parameters
Multimedia messages
Multi-Item messages
Sample response
{
"Code": 0
"Message": "success",
"RequestId": "343649807833778782",
"Next": 1000,
"List": [
{
"Sender": "user1",
"MsgType": 1,
"MsgBody": "This is a message.",
"MsgId": 971503777289036700,
"MsgSeq": 1,
"Payload": "Payload",
"MsgTime": 1705895412000,
"IsEmpty": 0
}
]
}
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. |
660300005 | The QPS limit specified in AppID is exceeded. | Try again later. |
660500002 | FromUserId is not registered. | Check if FromUserId is correct. |
660600001 | The entered GroupId does not exist. | Please confirm if the entered GroupId is correct. |
660600009 | Failed to retrieve group-related information. | Please confirm if the GroupId is correct. If it is correct, contact ZEGOCLOUD technical support. |