• 简体中文
  • 同步 API

    GET /sync

    GET /_matrix/client/v3/sync?since=s72595_0_0&timeout=30000&full_state=false

    客户端接收事件的主要端点。支持长轮询。

    查询参数

    参数类型默认值说明
    filterJSON/字符串过滤器对象或已保存的过滤器 ID
    sincestring增量同步的流令牌
    timeoutint0长轮询超时时间(毫秒,最大 30000)
    full_stateboolfalse不论 since 如何,包含所有状态

    响应

    {
      "next_batch": "s72595_0_1",
      "rooms": {
        "join": {
          "!room:localhost": {
            "timeline": {
              "events": [...],
              "limited": false,
              "prev_batch": "t123"
            },
            "state": { "events": [...] },
            "ephemeral": { "events": [
              { "type": "m.typing", "content": {"user_ids": ["@bob:localhost"]} }
            ]},
            "account_data": { "events": [...] },
            "unread_notifications": {
              "notification_count": 5,
              "highlight_count": 1
            }
          }
        },
        "invite": {},
        "leave": {}
      },
      "presence": { "events": [...] },
      "device_lists": {
        "changed": ["@bob:localhost"],
        "left": ["@charlie:localhost"]
      },
      "device_one_time_keys_count": {
        "signed_curve25519": 50
      }
    }

    POST /filter

    POST /_matrix/client/v3/filter

    保存过滤器以供重用:

    {
      "room": {
        "rooms": ["!room:localhost"],
        "state": { "types": ["m.room.member", "m.room.name"] },
        "timeline": { "limit": 100 },
        "ephemeral": { "types": ["m.typing", "m.receipt"] }
      }
    }

    GET /messages

    GET /_matrix/client/v3/rooms/{roomId}/messages?from=t123&dir=b&limit=50

    在房间时间线中向前/向后分页。

    参数说明
    from起始令牌
    dirb(向后/更新)或 f(向前/更旧)
    limit最大事件数(默认 50,最大 100)
    filter事件类型的 JSON 过滤器

    GET /context

    GET /_matrix/client/v3/rooms/{roomId}/context/{eventId}?limit=50

    返回特定事件周围的事件(用于线程/回复上下文)。

    输入状态

    PUT /_matrix/client/v3/rooms/{roomId}/typing/{userId}
    {
      "typing": true,
      "timeout": 30000
    }

    已读标记

    POST /_matrix/client/v3/rooms/{roomId}/read_markers
    {
      "m.fully_read": "$latest_event",
      "m.read": "$read_event",
      "m.read.private": "$private_read_event"
    }

    回执

    POST /_matrix/client/v3/rooms/{roomId}/receipt/{receiptType}/{eventId}

    发送已读回执(m.read)或私密已读回执(m.read.private)。

    通知

    GET /_matrix/client/v3/notifications?from=t123&limit=50

    返回待处理的通知,支持高亮过滤。