QueryGroupMsg
https://zim-api.zego.im/
By calling this API, you can pull the message list of a group conversation in pages.
Request
Query Parameters
Possible values: [QueryGroupMsg]
API prototype parameter
https://zim-api.zego.im/?Action=QueryGroupMsg
💡Public parameter. Application ID, assigned by ZEGOCLOUD. Get it from the ZEGOCLOUD Admin Console.
💡Public parameter. A 16-character hexadecimal random string (hex encoding of 8-byte random number). Refer to Signature example for how to generate.
💡Public parameter. Current Unix timestamp, in seconds. Refer to Signature example for how to generate, with a maximum error of 10 minutes.
Possible values: [2.0]
Default value: 2.0
💡Public parameter. Signature version number.
💡Public parameter. Signature, used to verify the legitimacy of the request. Refer to Signing the requests for how to generate an API request signature.
- application/json
Body
required
- When the value is ≤ 0, it is corrected to 10.
- When the value is > 100, it is corrected to 100.
- First call: Set Limit to 100, Next to 0, to query messages 1-100; the Next value in the returned result is num1.
- Second call: Set Limit to 100, Next to num1, to query messages 101-200; the Next value in the returned result is num2.
- Third call: Set Limit to 100, Next to num2, to query messages 201-250; the query is complete, and the Next value in the returned result is 0.
- 0: Default value, not included.
- 1: Included.
Possible values: <= 32 characters
Group ID.
Possible values: >= 1 and <= 100
Default value: 10
Number of messages to retrieve at a time, value range is (0, 100], default is 10.
Pagination flag. Fill in 0 for the first time, and then fill in the Next value returned last time. When the returned Next is 0, it means the message list has been fully retrieved.
For example, if the current group conversation has 250 messages, when calling this API to query:
Possible values: [0, 1]
Default value: 0
Whether the returned result includes recalled messages and messages deleted on the server.
Responses
- 200
- application/json
- Schema
- Example (from schema)
Schema
- Non-zero: Indicates there are still messages not returned. You need to set this field to the request parameter Next to pull more messages.
- Zero: Indicates the complete message list has been returned.
- Array[
- 1: Text.
- 10: Combined.
- 11: Image.
- 12: File.
- 13: Audio.
- 14: Video.
- 200: Custom.
- When MsgType is 1 (text type) or 200 (custom type), MsgBody is the message content passed in when sending the message, and developers can directly read the message content.
- When MsgType is one of the following types, MsgBody is a JSON string. Please use URLDecode to decode this JSON string and obtain the data of each field in the message according to the corresponding structure:
- When MsgType is 11, 12, 13, 14 (multimedia message), please refer to the multimedia message parameter description of the MsgBody JSON string parsing result.
- When MsgType is 10 (combined message), please refer to the combined message parameter description of the MsgBody JSON string parsing result.
- multimedia messaging
- multi-item messages
- Array[
- 1: Text.
- 11: Image.
- 12: File.
- 13: Audio.
- 14: Video.
- 200: Custom message type.
- Only when msg_type is 1 or 200, you can directly read the message content in this parameter.
- When Item is 11, 12, 13, or 14, please refer to the multimedia message structure in this document to understand the data of each field in the message.
- ]
- 0: Not empty.
- 1: Message has been deleted or expired.
- 2: Message has been recalled.
- ]
Return code.
The following only lists the return codes related to the API business logic. For the complete return codes, please refer to Return codes.
| Return code | Description | Suggested Solution |
|---|---|---|
| 660000002 | Input parameter error. | Please check the input parameters. |
| 660300005 | The API call frequency exceeds the AppID-level limit. | Please try again later. |
| 660500002 | FromUserId is not registered. | Please check if FromUserId is correct. |
| 660600001 | The entered GroupId does not exist. | Please confirm if GroupId is correct. |
| 660600009 | Failed to get group-related information. | Please confirm if GroupId is correct; otherwise contact ZEGOCLOUD Technical Support. |
Description of the request result.
Request ID.
Pagination flag.
Note
Apart from the above description, this field has no association with the list information. Please do not base any other logic on this.
List object[]
Message sender ID.
Message type:
Specific custom type. The value is filled in by the user when sending a custom message, with a value range of [0,200]. This parameter is only meaningful when MsgType is 200 (custom type).
MsgBody object
Message content.
MD5 value of the file.
File name.
File size in bytes (B).
Download URL.
Audio/video duration in seconds (s).
🏞️If it is an image message, this property is included. Width of the original image in pixels (px).
🏞️If it is an image message, this property is included. Height of the original image in pixels (px).
🏞️If it is an image message, this property is included. Large image download URL.
🏞️If it is an image message, this property is included. Width of the large image in pixels (px).
🏞️If it is an image message, this property is included. Height of the large image in pixels (px).
🏞️If it is an image message, this property is included. Thumbnail download URL.
🏞️If it is an image message, this property is included. Width of the thumbnail in pixels (px).
🏞️If it is an image message, this property is included. Height of the thumbnail in pixels (px).
🎬If it is a video message, this property is included. Download URL of the video first frame image.
🎬If it is a video message, this property is included. Width of the video first frame image in pixels (px).
🎬If it is a video message, this property is included. Height of the video first frame image in pixels (px).
multi_msg object[]required
Item type:
This parameter is returned only when msg_type is 200. Indicates the specific custom type, with a value range of [0,200].
Item content.
Message ID, which can be used to determine the uniqueness of the message.
Message Seq.
Message extension field.
Time when the server received the message, Unix timestamp in milliseconds (ms).
Whether it is an empty message.
{
"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
}
]
}{
"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
}
]
}