跳转到主要内容
POST
/
messages
curl -X POST "http://localhost:5001/messages" \
  -H "Content-Type: application/json" \
  -d '{
    "message_ids": [123456789, 123456790, 123456791]
  }'
[
  {
    "message_id": 123456789,
    "message_seq": 1001,
    "client_msg_no": "msg_123",
    "from_uid": "user123",
    "channel_id": "group123",
    "channel_type": 2,
    "timestamp": 1640995200,
    "payload": "SGVsbG8gV29ybGQ="
  },
  {
    "message_id": 123456790,
    "message_seq": 1002,
    "client_msg_no": "msg_124",
    "from_uid": "user456",
    "channel_id": "group123",
    "channel_type": 2,
    "timestamp": 1640995260,
    "payload": "SGkgdGhlcmU="
  }
]

概述

根据消息 ID 列表批量搜索多条消息,适用于需要同时获取多条消息详情的场景。

请求体

message_ids
array
required
消息 ID 列表
message_ids[]
integer
消息 ID
curl -X POST "http://localhost:5001/messages" \
  -H "Content-Type: application/json" \
  -d '{
    "message_ids": [123456789, 123456790, 123456791]
  }'
[
  {
    "message_id": 123456789,
    "message_seq": 1001,
    "client_msg_no": "msg_123",
    "from_uid": "user123",
    "channel_id": "group123",
    "channel_type": 2,
    "timestamp": 1640995200,
    "payload": "SGVsbG8gV29ybGQ="
  },
  {
    "message_id": 123456790,
    "message_seq": 1002,
    "client_msg_no": "msg_124",
    "from_uid": "user456",
    "channel_id": "group123",
    "channel_type": 2,
    "timestamp": 1640995260,
    "payload": "SGkgdGhlcmU="
  }
]

响应字段

响应是一个消息对象数组,每个消息对象包含以下字段:
message_id
integer
required
服务器生成的消息 ID
message_seq
integer
required
消息序列号
client_msg_no
string
required
客户端消息编号
from_uid
string
required
发送者用户 ID
channel_id
string
required
频道 ID
channel_type
integer
required
频道类型
  • 1 - 个人频道
  • 2 - 群组频道
timestamp
integer
required
消息时间戳(Unix 时间戳)
payload
string
required
Base64 编码的消息内容

状态码

状态码说明
200消息搜索成功
400请求参数错误
404部分或全部消息不存在
500服务器内部错误