Skip to content

会话消息 API

获取对话列表

http
GET /api/conversations?limit=20&offset=0

参数:

参数类型默认值说明
limitnumber20每页数量
offsetnumber0偏移量

响应:

json
{
  "conversations": [
    {
      "accountId": "账号ID",
      "chatId": "会话ID",
      "userId": "对方用户ID",
      "nickname": "对方昵称",
      "avatar": "头像",
      "lastMessage": "最后一条消息",
      "lastTime": 1703520000000,
      "unreadCount": 0
    }
  ],
  "total": 100,
  "limit": 20,
  "offset": 0
}

获取对话详情

http
GET /api/conversations/:accountId/:chatId?limit=50&beforeId=xxx

参数:

参数类型默认值说明
limitnumber50消息数量
beforeIdnumber-加载此 ID 之前的消息

响应:

json
{
  "accountId": "账号ID",
  "chatId": "会话ID",
  "messages": [
    {
      "id": 1,
      "content": "消息内容",
      "fromMe": false,
      "timestamp": 1703520000000
    }
  ]
}

标记已读

http
POST /api/conversations/:accountId/:chatId/read

发送消息

http
POST /api/messages/send

请求体:

json
{
  "accountId": "账号ID",
  "chatId": "会话ID",
  "toUserId": "接收者ID",
  "text": "消息内容"
}

获取用户头像

http
GET /api/conversations/user/:userId/avatar?accountId=xxx

Released under the GPL-3.0 License.