1. 同步
ShangCloud
  • ShangCloud简介
  • 立项一周年庆祝
  • v3
    • V3设计理念
    • 扩展使用教程
    • 数据导出
    • 云变量
      • 用户变量操作 (读/写/删)
    • 云函数
      • 整体概述
      • 使用指南
      • 调用主节点云函数
    • 社区作品ID获取教程
      • 40code
      • ZeroCat (Moonrend)
      • CCW(共创世界)
      • AstraEditor & 02engine & Bilup
    • OAuth
      • 设备授权登录
      • 获取或刷新 AccessToken
    • MMO联机
      • 说明
      • TCP/UDP协议联机
      • 创建房间
      • 加入已有房间
      • 设置房间配置
      • 设置房间额外数据(键值对)
      • 获取房间所有额外数据
      • 删除房间额外数据中的指定键
      • 强制踢出房间内指定用户
      • 查询指定房间的当前人数
    • 即时通讯
      • 会话
        • 获取会话列表
        • 获取会话详情
        • 获取当前会话成员
      • 消息
        • 获取历史消息
        • 发送文本消息或回复
        • 获取历史消息(兼容路径)
        • 回复指定消息
        • 编辑文本消息
        • 仅为自己删除消息
        • 撤回消息
      • 已读状态
        • 获取自己的已读状态
        • 推进自己的已读位置
        • 获取自己的已读状态(兼容路径)
        • 推进自己的已读位置(兼容路径)
      • 同步
        • 增量同步会话和消息变化
          POST
    • 娱乐功能
      • 随机图
    • 扩展API
      • QQ消息推送
      • 群推送接口
      • IP查询
    • Q&A
      • 40code作品绑定教程
      • ZeroCat作品绑定教程
      • 时间同步
      • 未绑定作品
      • AstraEditor & 02engine & Bilup
    • 健康监控
      • 平台存活状态
      • MMO 系统状态
      • 平台统计数据
  • v2
    • v2
    • 账号操作
      • 登陆
      • 获取用户信息
      • 绑定40code账户
    • 数据库部分
      • 新建数据库
      • 删除数据库
      • 读取数据库
      • 写入数据库
      • 获取数据库列表
      • 重置数据库
    • 状态获取
      • 服务器总占用
  • v1
    • v1
    • 账号操作
      • 管理员
        • 创建新用户
        • 删除用户
        • 设置管理员
        • 获取用户列表
        • 封禁用户
        • 解封用户
      • 普通用户
        • 登录
        • 更改密码
      • 游客
        • 获取用户状态
        • 注册
    • API部分
      • 获取时间戳
      • 获取版本号
      • 邮件验证码
      • 发送HTTP请求
    • 数据库部分
      • 新建数据库
      • 删除数据库
      • 读取数据库
      • 写入数据库
      • 更改数据库权限
      • 获取数据库列表
    • MySQL接口
    • 服务器状态
      • 获取CPU占用
      • 获取总内存
      • 获取使用中内存
      • 获取指定硬盘总容量
      • 获取指定硬盘使用容量
      • 获取内存占用率
      • 获取指定硬盘占用率
      • 设置风扇转速
      • 设置风扇为手动模式
      • 服务器总状态
  • MMO
    • 接入文档
    • 加入MMO房间
    • 创建MMO房间
  • 所有操作
    GET
  • 数据模型
    • Schemas
      • AccessTokenInvalid
      • SuccessResponse
      • BadResponse
      • NoPowerResponse
      • NotFoundResponse
      • ServerErrorResponse
    • 极验数据
    • RoomResult
    • VariableResponse
    • StatusResponse
    • ErrorResponse
    • InvokeSuccess
    • Error
    • MmoStatsResponse
    • UserSummary
    • SuccessStatusResponse
    • PlatformStatsResponse
    • ConversationMember
    • AppTitle
    • Attachment
    • ReplyReference
    • Message
    • Conversation
    • ConversationSummary
    • ChangedConversation
    • CursorPair
    • MessageCursorMap
    • PairCursorMap
    • SendMessageRequest
    • ReplyMessageRequest
    • EditMessageRequest
    • UpdateReadStateRequest
    • SyncRequest
    • ConversationListData
    • MemberListData
    • HistoryData
    • ReadStateData
    • DeleteMessageData
    • RecallMessageData
    • SyncData
    • ConversationListResponse
    • ConversationResponse
    • MemberListResponse
    • HistoryResponse
    • ReadStateResponse
    • MessageResponse
    • DeleteMessageResponse
    • RecallMessageResponse
    • SyncResponse
    • SuccessEnvelope
  1. 同步

增量同步会话和消息变化

POST
/sync
最后修改时间:2026-08-05 02:10:17
首次同步传 since: 0,游标映射可省略或传空对象。后续请求应完整回传上次
响应中的 since、message_cursors、message_change_cursors 和
message_delete_cursors。如果 messages_has_more 为 true,应立即使用响应
游标继续同步。客户端应按资源 ID 幂等应用结果,并始终以服务器返回的游标为准。

请求参数

Authorization
OAuth 2.0
Authorization Code
在 Header 添加参数
Authorization
,其值为在 Bearer 之后拼接 Token
示例:
Authorization: Bearer ********************
Authorize URL: https://api.yearnstudio.cn/oauth/authorize
Token URL: https://api.yearnstudio.cn/oauth/token
Scopes:
im:read-读取可见会话、成员、历史、已读状态并增量同步
or
Body 参数application/json必填

示例
{
    "since": 0,
    "client_id": "string",
    "active_cid": "string",
    "message_cursors": {
        "property1": 0,
        "property2": 0
    },
    "message_change_cursors": {
        "property1": [],
        "property2": []
    },
    "message_delete_cursors": {
        "property1": [],
        "property2": []
    }
}

请求示例代码

Shell
JavaScript
Java
Swift
Go
PHP
Python
HTTP
C
C#
Objective-C
Ruby
OCaml
Dart
R
请求示例请求示例
Shell
JavaScript
Java
Swift
curl --location 'https://api.yearnstudio.cn/sync' \
--header 'Content-Type: application/json' \
--data '{
    "since": 0,
    "client_id": "string",
    "active_cid": "string",
    "message_cursors": {
        "property1": 0,
        "property2": 0
    },
    "message_change_cursors": {
        "property1": [],
        "property2": []
    },
    "message_delete_cursors": {
        "property1": [],
        "property2": []
    }
}'

返回响应

🟢200
application/json
增量同步结果和下一次请求所需的检查点。
Bodyapplication/json

示例
{
    "code": 200,
    "msg": "ok",
    "data": {
        "since": 0,
        "changed": [
            {
                "id": "string",
                "type": "1:1",
                "name": "string",
                "avatar": "string",
                "announcement": "string",
                "announcement_updated_at": 0,
                "announcement_editor": {
                    "uid": 0,
                    "nickname": "string",
                    "avatar": "string"
                },
                "join_policy": "invite_only",
                "invite_confirmation": true,
                "all_muted": true,
                "owner_uid": 0,
                "created_at": 0,
                "updated_at": 0,
                "pinned_at": 0,
                "pinned": true,
                "last_read_id": 0,
                "peer": {
                    "uid": 0,
                    "nickname": "string",
                    "avatar": "string"
                },
                "my_role": "string",
                "my_muted_until": 0,
                "notifications_muted": true,
                "is_system": true,
                "kind": "string",
                "read_only": true,
                "can_send": true,
                "member_count": 0,
                "online_uids": [
                    0
                ],
                "all_read_id": 0,
                "members": [
                    {
                        "uid": 0,
                        "role": "owner",
                        "muted_until": 0,
                        "info": {
                            "uid": 0,
                            "nickname": "string",
                            "avatar": "string"
                        }
                    }
                ],
                "last_message": {
                    "id": 0,
                    "conversation_id": "string",
                    "sender": {
                        "uid": 0,
                        "nickname": "string",
                        "avatar": "string"
                    },
                    "is_official": true,
                    "content": "string",
                    "msg_type": "string",
                    "mention_uids": [
                        0
                    ],
                    "mention_all": true,
                    "reply": {
                        "message_id": 0,
                        "sender": {
                            "uid": 0,
                            "nickname": "string",
                            "avatar": "string"
                        },
                        "content": "string"
                    },
                    "status": "normal",
                    "recalled_by": {
                        "uid": 0,
                        "nickname": "string",
                        "avatar": "string"
                    },
                    "created_at": 0,
                    "edited_at": 0,
                    "edit_version": 0,
                    "client_message_id": "string",
                    "title": {
                        "app_id": "string",
                        "app_name": "string"
                    },
                    "attachments": [
                        {
                            "id": "string",
                            "filename": "string",
                            "mime_type": "string",
                            "size": 0,
                            "is_image": true,
                            "download_url": "string",
                            "preview_url": "string"
                        }
                    ]
                },
                "unread": 0,
                "mentioned": true,
                "new_messages": [
                    {
                        "id": 0,
                        "conversation_id": "string",
                        "sender": {
                            "uid": 0,
                            "nickname": "string",
                            "avatar": "string"
                        },
                        "is_official": true,
                        "content": "string",
                        "msg_type": "string",
                        "mention_uids": [
                            0
                        ],
                        "mention_all": true,
                        "reply": {
                            "message_id": 0,
                            "sender": {
                                "uid": 0,
                                "nickname": "string",
                                "avatar": "string"
                            },
                            "content": "string"
                        },
                        "status": "normal",
                        "recalled_by": {
                            "uid": 0,
                            "nickname": "string",
                            "avatar": "string"
                        },
                        "created_at": 0,
                        "edited_at": 0,
                        "edit_version": 0,
                        "client_message_id": "string",
                        "title": {
                            "app_id": "string",
                            "app_name": "string"
                        },
                        "attachments": [
                            {
                                "id": "string",
                                "filename": "string",
                                "mime_type": "string",
                                "size": 0,
                                "is_image": true,
                                "download_url": "string",
                                "preview_url": "string"
                            }
                        ]
                    }
                ],
                "deleted_message_ids": [
                    0
                ],
                "message_delete_cursor": [],
                "message_cursor": 0,
                "messages_has_more": true
            }
        ],
        "presence": {
            "property1": [
                0
            ],
            "property2": [
                0
            ]
        },
        "conversation_ids": [
            "string"
        ],
        "message_cursors": {
            "property1": 0,
            "property2": 0
        },
        "message_change_cursors": {
            "property1": [],
            "property2": []
        },
        "message_delete_cursors": {
            "property1": [],
            "property2": []
        },
        "messages_has_more": true,
        "conversation_messages_has_more": {
            "property1": true,
            "property2": true
        }
    }
}
🟠400BadRequest
🟠401Unauthorized
🟠403ReadForbidden
🟠429RateLimited
🔴500InternalError
🔴503ServiceUnavailable
修改于 2026-08-05 02:10:17
上一页
推进自己的已读位置(兼容路径)
下一页
随机图
Built with