跳转到主要内容
Polymarket Real-Time Data Socket (RTDS) 是一个基于 WebSocket 的流式服务,提供评论加密货币价格的实时更新。

TypeScript client

官方 RTDS TypeScript 客户端 (real-time-data-client)。

端点

wss://ws-live-data.polymarket.com
某些用户特定的流可能需要使用你的钱包地址进行 gamma_auth 身份验证。

订阅

发送 JSON 消息来订阅数据流:
{
  "action": "subscribe",
  "subscriptions": [
    {
      "topic": "topic_name",
      "type": "message_type",
      "filters": "optional_filter_string",
      "gamma_auth": {
        "address": "wallet_address"
      }
    }
  ]
}
要取消订阅,发送相同结构的消息,将 "action" 改为 "unsubscribe" 你可以在不断开连接的情况下添加、删除和修改订阅。每 5 秒发送一次 PING 消息以维持连接。
仅支持下文记录的订阅类型。

消息结构

所有消息都遵循以下结构:
{
  "topic": "string",
  "type": "string",
  "timestamp": "number",
  "payload": "object"
}
字段类型描述
topicstring订阅主题(例如 crypto_pricescomments)
typestring消息类型/事件(例如 updatereaction_created)
timestampnumber消息发送时的 Unix 时间戳(毫秒)
payloadobject特定于事件的数据对象

加密货币价格

来自两个来源的实时加密货币价格数据:BinanceChainlink。无需身份验证。

Binance 来源

订阅所有交易对:
{
  "action": "subscribe",
  "subscriptions": [
    {
      "topic": "crypto_prices",
      "type": "update"
    }
  ]
}
使用逗号分隔的过滤器订阅特定交易对:
{
  "action": "subscribe",
  "subscriptions": [
    {
      "topic": "crypto_prices",
      "type": "update",
      "filters": "solusdt,btcusdt,ethusdt"
    }
  ]
}
交易对使用小写连接格式(例如 solusdtbtcusdt)。 Solana 价格更新:
{
  "topic": "crypto_prices",
  "type": "update",
  "timestamp": 1753314064237,
  "payload": {
    "symbol": "solusdt",
    "timestamp": 1753314064213,
    "value": 189.55
  }
}
Bitcoin 价格更新:
{
  "topic": "crypto_prices",
  "type": "update",
  "timestamp": 1753314088421,
  "payload": {
    "symbol": "btcusdt",
    "timestamp": 1753314088395,
    "value": 67234.50
  }
}
正在交易 15 分钟加密货币市场? 获取由 Chainlink 赞助的 Chainlink API 密钥,并获得入门支持。填写此表单
订阅所有交易对:
{
  "action": "subscribe",
  "subscriptions": [
    {
      "topic": "crypto_prices_chainlink",
      "type": "*",
      "filters": ""
    }
  ]
}
使用 JSON 过滤器订阅特定交易对:
{
  "action": "subscribe",
  "subscriptions": [
    {
      "topic": "crypto_prices_chainlink",
      "type": "*",
      "filters": "{\"symbol\":\"eth/usd\"}"
    }
  ]
}
交易对使用斜杠分隔格式(例如 eth/usdbtc/usd)。 Ethereum 价格更新:
{
  "topic": "crypto_prices_chainlink",
  "type": "update",
  "timestamp": 1753314064237,
  "payload": {
    "symbol": "eth/usd",
    "timestamp": 1753314064213,
    "value": 3456.78
  }
}
Bitcoin 价格更新:
{
  "topic": "crypto_prices_chainlink",
  "type": "update",
  "timestamp": 1753314088421,
  "payload": {
    "symbol": "btc/usd",
    "timestamp": 1753314088395,
    "value": 67234.50
  }
}

价格 Payload 字段

字段类型描述
symbolstring交易对符号。Binance: 小写连接(例如 solusdtbtcusdt)。Chainlink: 斜杠分隔(例如 eth/usdbtc/usd)
timestampnumber价格记录时间,Unix 毫秒时间戳
valuenumber计价货币中的当前价格值

支持的交易对

Binance 来源 — 小写连接格式:
  • btcusdt — Bitcoin 对 USDT
  • ethusdt — Ethereum 对 USDT
  • solusdt — Solana 对 USDT
  • xrpusdt — XRP 对 USDT
Chainlink 来源 — 斜杠分隔格式:
  • btc/usd — Bitcoin 对 USD
  • eth/usd — Ethereum 对 USD
  • sol/usd — Solana 对 USD
  • xrp/usd — XRP 对 USD

评论

Polymarket 平台上的实时评论事件,包括新评论、回复、反应和删除。某些用户特定数据可能需要 Gamma 身份验证。

订阅

{
  "action": "subscribe",
  "subscriptions": [
    {
      "topic": "comments",
      "type": "comment_created"
    }
  ]
}

消息类型

类型描述
comment_created用户创建新评论或回复
comment_removed评论被移除或删除
reaction_created用户对评论添加反应
reaction_removed反应从评论中移除

comment_created

当用户发布新评论或回复现有评论时触发。
{
  "topic": "comments",
  "type": "comment_created",
  "timestamp": 1753454975808,
  "payload": {
    "body": "That's a good point about the definition.",
    "createdAt": "2025-07-25T14:49:35.801298Z",
    "id": "1763355",
    "parentCommentID": "1763325",
    "parentEntityID": 18396,
    "parentEntityType": "Event",
    "profile": {
      "baseAddress": "0xce533188d53a16ed580fd5121dedf166d3482677",
      "displayUsernamePublic": true,
      "name": "salted.caramel",
      "proxyWallet": "0x4ca749dcfa93c87e5ee23e2d21ff4422c7a4c1ee",
      "pseudonym": "Adored-Disparity"
    },
    "reactionCount": 0,
    "replyAddress": "0x0bda5d16f76cd1d3485bcc7a44bc6fa7db004cdd",
    "reportCount": 0,
    "userAddress": "0xce533188d53a16ed580fd5121dedf166d3482677"
  }
}
对上述评论的回复 — 注意 parentCommentID 引用了父评论:
{
  "topic": "comments",
  "type": "comment_created",
  "timestamp": 1753454985123,
  "payload": {
    "body": "I agree, the resolution criteria should be clearer.",
    "createdAt": "2025-07-25T14:49:45.120000Z",
    "id": "1763356",
    "parentCommentID": "1763355",
    "parentEntityID": 18396,
    "parentEntityType": "Event",
    "profile": {
      "baseAddress": "0x1234567890abcdef1234567890abcdef12345678",
      "displayUsernamePublic": true,
      "name": "trader",
      "proxyWallet": "0x9876543210fedcba9876543210fedcba98765432",
      "pseudonym": "Bright-Analysis"
    },
    "reactionCount": 0,
    "replyAddress": "0x0bda5d16f76cd1d3485bcc7a44bc6fa7db004cdd",
    "reportCount": 0,
    "userAddress": "0x1234567890abcdef1234567890abcdef12345678"
  }
}

评论 Payload 字段

字段类型描述
bodystring评论的文本内容
createdAtstring评论创建时的 ISO 8601 时间戳
idstring此评论的唯一标识符
parentCommentIDstring如果这是回复,则为父评论的 ID(顶级评论为 null)
parentEntityIDnumber父实体(事件、市场等)的 ID
parentEntityTypestring父实体的类型(EventMarket)
profileobject评论作者的个人资料信息
reactionCountnumber此评论当前的反应数量
replyAddressstring用于回复的 Polygon 地址(可能与 userAddress 不同)
reportCountnumber此评论当前的举报数量
userAddressstring评论作者的 Polygon 地址

Profile 对象字段

字段类型描述
baseAddressstring用户资料地址
displayUsernamePublicboolean用户名是否公开显示
namestring用户的显示名称
proxyWalletstring用于交易的代理钱包地址
pseudonymstring为用户生成的假名

评论层级结构

评论支持嵌套分层:
  • 顶级评论: parentCommentID 为 null 或为空
  • 回复评论: parentCommentID 包含父评论的 ID
  • 所有评论都与 parentEntityIDparentEntityType(EventMarket)关联

故障排除

每 5 秒发送一次 PING 消息以保持连接活跃。连接错误将触发自动重连尝试。
验证你的订阅消息是否为有效的 JSON,并包含正确的 actiontopictype 字段。无效的订阅消息可能导致连接关闭。
如果订阅用户特定的流,请确保你的 gamma_auth 对象包含有效的钱包 address。身份验证失败将阻止订阅受保护的主题。