You need to enable JavaScript to run this app.
导航

批量查询消息 GetMessages

最近更新时间2024.04.17 17:35:51

首次发布时间2023.04.24 11:11:46

你可以使用此接口指定消息 ID 对消息进行批量查询。

使用说明

接口行为

你可以调用GetMessages接口,指定你所属的AppId和,会话 ID 和消息 ID,查询指定消息的详细信息。

调用接口

关于调用接口的服务地址、通信协议、字符编码和签名机制,参看调用 OpenAPI

注意事项

QPS 不得超过 100。

请求说明

  • 请求方式:POST
  • 请求地址:https://rtc.volcengineapi.com?Action=GetMessages&Version=2020-12-01

请求参数

下表仅列出该接口特有的请求参数和部分公共参数。更多信息请见公共参数

Query

参数类型是否必选示例值描述
ActionStringGetMessages接口名称。当前 API 的名称为 GetMessages
VersionString2020-12-01接口版本。当前 API 的版本为 2020-12-01

Body

参数类型是否必选示例值描述
AppIdInteger000000应用的唯一标志
ConversationShortIdLong000001会话 ID
MessageIdsArray of Long[10003]消息 ID

返回参数

下表仅列出本接口特有的返回参数。更多信息请参见返回结构

参数类型示例值描述
MessagesArray of MessageBody-消息详细信息

MessageBody

参数类型示例值描述

ConversationType

Integer

1

会话类型

  • 1:单聊。
  • 2:群聊。
ConversationShortIdLong000001会话 ID
MessageIdLong000012消息 ID

MsgType

Integer

10001

消息类型。

  • 10001:文本。
  • 10003:图片。
  • 10004:视频
  • 10005:文件
  • 10006:音频
  • 10012:自定义消息
ContentStringYour_Content消息内容
ExtJSON Map{"key":"value"}消息的扩展字段,key 的数据类型为 String,value 的数据类型为 String。
StatusInteger0消息状态,取值为0,表示消息可见。
CreateTimeLong1669723135771消息创建时间戳,单位为毫秒
SenderLong000010消息发送人 UserId
AppIdInteger000000应用的唯一标志
RefMsgInfoObject of RefMsgInfo-引用消息
IndexInConversationLong1669723135894214消息在会话中的位置
ClientMsgIdString"unique-key"消息客户端Id,如果端上消息发送失败,会进行重试,可通过此字段进行幂等判断

RefMsgInfo

参数类型示例值描述
ReferencedMessageIdLong10005被引用的消息 ID
HintString[图片]消息引用时展示的文本内容

ReferencedMessageType

Integer

10001

被引用的消息类型

  • 10001:文本。
  • 10003:图片。
  • 10004:视频
  • 10005:文件
  • 10006:音频
  • 10012:自定义消息

Status

Integer

0

被引用的消息状态

  • 0:消息可见
  • 1:消息已过期
  • 2:消息(对用户)不可见
  • 3:消息被撤回
  • 4:消息本身可见,后因删除不可见

请求示例

POST https://rtc.volcengineapi.com?Action=GetMessages&Version=2020-12-01

{
    "AppId": 000000,
    "ConversationShortId": 000001,
    "MessageIds": [
        000012,
        000013
    ]
}

返回示例

{
    "ResponseMetadata": {
        "RequestId": "Your_RequestId",
        "Action": "SendMessage",
        "Version": "2020-12-01",
        "Service": "rtc",
        "Region": "cn-north-1"
    },
    "Result": {
        "Messages": [
            {
                "ConversationType": 2,
                "ConversationShortId": 000001,
                "messageId": 000012,
                "MsgType": 10001,
                "Content": "Your_Content",
                "Ext": {
                    "key": "value"
                },
                "Status": 0,
                "CreateTime": 1669723135771,
                "Sender": 000010,
                "AppId": 000000,
                "RefMsgInfo": {
                    "ReferencedMessageId": 000013,
                    "Hint": "[图片]",
                    "ReferencedMessageType": 10001,
                    "Status": 0
                },
                "IndexInConversation": 1669723135894214
            },
            {
                "ConversationType": 2,
                "ConversationShortId": 000001,
                "MessageId": 000014,
                "MsgType": 10001,
                "Content": "222",
                "Ext": {
                    "s:client_message_id": "ae16fb90-2be2-4424-aa6e-3a6e5e53294a"
                },
                "Status": 0,
                "CreateTime": 1669723270194,
                "Sender": 10001,
                "AppId": 000000,
                "RefMsgInfo": {
                    "ReferencedMessageId": 10005,
                    "Hint": "[图片]",
                    "ReferencedMessageType": 10001,
                    "Status": 0
                },
                "IndexInConversation": 1669723270235453
            }
        ]
    }
}

错误码

您可访问公共错误码,获取更多错误码信息。