> ## Documentation Index
> Fetch the complete documentation index at: https://dexbuilder.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# 消息協議

> 瞭解事件市場 WebSocket 的請求、ACK、推送和訂閱格式。

訊息使用 JSON。請求中的 `t` 與伺服器時間相差不得超過 60 秒，`id` 必須是字串或整數。

## 訂閱

```json theme={null}
{
  "t": 1720000000123,
  "id": "req-1",
  "op": "subscribe",
  "ch": "pred.depth",
  "payload": {"items": [{"token_id": "ge_token-yes", "level": 20}]}
}
```

取消訂閱時使用相同的頻道和 payload，並將 `op` 設為 `unsubscribe`。私有頻道還需要 `auth`；私有頻道支援 `{"all": true}`，公共頻道必須使用 `items`。

## ACK

成功：

```json theme={null}
{"t":1720000000124,"id":"req-1","trace_id":"trace-1","op":"subscribe","ch":"pred.depth","err":null,"result":{"status":"success"}}
```

失敗：

```json theme={null}
{"t":1720000000124,"id":"req-1","trace_id":"trace-1","op":"subscribe","ch":"pred.depth","err":{"code":2,"msg":"invalid depth item"},"result":{"status":"fail"}}
```

## 快照與更新

快取的初始資料使用 `type: "snapshot"`，後續事件使用 `type: "update"`。訊息包含 `ch`、`err: null` 和頻道對應的 `result`。

單次請求最多 100 個訂閱項，單一連線最多 10,000 個訂閱。重新連線後須再次訂閱；私有頻道應透過 REST 介面恢復帳戶目前狀態。


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.