Query messages
Description
This API allows you to query multiple messages in a specific conversation (group conversation, one-to-one conversation).
Request method and endpoint
-
Request method: POST
-
Request URL:
https://zim-api.zego.im/?Action=QueryMessagesByMsgSeq -
Protocol: HTTPS
-
QPS limit: 20 messages per second
WarningThe frequency limit of this API is 20 messages per second, not 20 requests 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 Common request parameters section of the Accessing Server APIs topic.
| Parameter | Type | Required | Description |
|---|---|---|---|
| FromUserId | String | Yes | The UserID of the user.
|
| ConvId | String | Yes | The conversation ID.
|
| ConvType | Number | Yes | The conversation type:
|
| MsgSeqList | Array of Number | Yes | A list of message sequences to query. The list has an upper limit of 20. Note For adjustments, please contact ZEGOCLOUD technical support.
|
Sample Request
-
Request URL:
https://zim-api.zego.im/?Action=QueryMessagesByMsgSeq &<Common request parameters> -
Request Body:
{ "FromUserId": "user0", "ConvId": "user1", "ConvType": 0, "MsgSeqList": [ 1, 2, 3 ] }
Response Parameters
| Parameter | Type | Description |
|---|---|---|
| Code | Number | Return code. |
| Message | String | Description of the result. |
| RequestId | String | Request ID. |
| MessageList | Array of Object | List of returned messages, details in MessageList Structure. |
MessageList Structure
| Parameter | Type | Description |
|---|---|---|
| Sender | String | Message sender. |
| MsgType | Number | Message type:
|
| SubMsgType | Number | Specific custom type. The value is filled by the user when sending a custom message, and the valid range is [0, 200]. This parameter is meaningful only when MsgType is 200 (custom). |
| MsgBody | String | Message content.
|
| MsgId | Number | Message ID, which can be used to determine the uniqueness of the message. |
| MsgSeq | Number | Message sequence. |
| Payload | String | Message extension field. |
| MsgTime | Number | The time when the server receives the message, in Unix timestamp format, in milliseconds (ms). |
| IsEmpty | Number | Whether it is an empty message:
|
MsgBody JSON String Parsing Result Parameters
Multimedia messages
Basic Parameters
| Parameter | Type | Description |
|---|---|---|
| md5 | String | MD5 value of the file. |
| file_name | String | Name of the file. |
| file_size | String | File size, in bytes (B). |
| download_url | String | Download URL. |
| media_duration | String | Duration of audio/video, in seconds (s). |
Extended Parameters for Image Messages
For image messages, the following additional parameters are provided on top of the basic parameters.
| Parameter | Type | Description |
|---|---|---|
| origin_image_width | Int | Width of the original image, in pixels (px). |
| origin_image_height | Int | Height of the original image, in pixels (px). |
| large_image_download_url | String | URL for downloading the large image. |
| large_image_width | Int | Width of the large image, in pixels (px). |
| large_image_height | Int | Height of the large image, in pixels (px). |
| thumbnail_download_url | String | URL for downloading the thumbnail image. |
| thumbnail_width | Int | Width of the thumbnail, in pixels (px). |
| thumbnail_height | Int | Height of the thumbnail, in pixels (px). |
Extended Parameters for Video Messages
For video messages, the following additional parameters are provided on top of the basic parameters.
| Parameter | Type | Description |
|---|---|---|
| video_first_frame_download_url | String | URL for downloading the first frame image of the video. |
| video_first_frame_width | Int | Width of the video first frame image, in pixels (px). |
| video_first_frame_height | Int | Height of the video first frame image, in pixels (px). |
Multi-Item messages
| Parameter | Type | Description |
|---|---|---|
| multi_msg | Array of Object | Array of items for the multi-item message. |
| └ msg_type | Int | Item type:
|
| └ sub_msg_type | Int | This parameter is returned only when msg_type is 200. |
| └ callback_content | Object | Item content.
|
Revoked messages
| Parameter | Type | Description |
|---|---|---|
| user_id | String | The UserID of the user who initiated the revoke. |
| revoke_time | Number | The revocation timestamp, in milliseconds. |
| msg_type | Number | The original message type. |
| payload | String | The extension field carried during the revocation. |
| msg_status | Number | The corresponding status of the revoked message:
|
Tip Messages
| Parameter | Type | Description |
|---|---|---|
| type | Number | Tips message type:
|
| op_user_info | Object | The user who triggered the Tips message (e.g., the user who created the group, the user who changed the group name). |
| └user_id | String | User ID. |
| └role | Number | User's group role:
|
| └group_member_name | String | User's group member name. |
| └group_member_nickname | String | User's group nickname. |
| target_users | Array of Object | The target users of the tip message operation (e.g., users invited to the group, users kicked out). |
| └user_id | String | User ID. |
| └role | Number | User's group role:
|
| └group_member_name | String | User's group member name. |
| └group_member_nickname | String | User's group nickname. |
| group_data_flag | Number | When type is 30, this parameter indicates the modified group profile item.
|
| group_notice | String | Group announcement. |
| group_name | String | Group name. |
| group_avatar | String | Group avatar. |
| forbid | Object of GroupForbid | When type is 34, this parameter indicates the group-wide mute object. |
| └is_all_forbid | Bool | Whether mute is applied to all members:
|
| └forbid_role_list | Array of Number | Group member roles who are muted. |
| └forbid_expire_time | Number | The timestamp of mute expiration, in milliseconds. |
| forbid_expire_time | Number | When type is 13, this parameter represents the timestamp of the group member's mute expiration, in milliseconds. |
| role | Number | When type is 12, this parameter represents the changed group member role.
|
Sample Response
{
"Code": 0,
"Message": "success",
"RequestId": "343649807833778782",
"MessageList": [
{
"Sender": "userA",
"MsgType": 1,
"MsgBody": "this is a message",
"MsgId": 971503777289036700,
"MsgSeq": 1,
"Payload": "this is a payload",
"MsgTime": 1705895412000,
"IsEmpty": 0
}
]
}Return Codes
| Return Code | Description | Suggested Actions |
|---|---|---|
| 660000001 | Server error. | Please try again or contact ZEGOCLOUD Technical Support. |
| 660000002 | Missing or invalid input parameters. | Please check the input parameters. |
| 660300005 | API call frequency exceeds AppID level limit. | Please try again later or refer to the relevant documentation for frequency limits. |
| 660700008 | Error retrieving user information. | Please check if the UserID is correct. |
| 660700015 | User not registered. | Please register the user first. |

