polymarket

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Polymarket Comprehensive Skill

Polymarket 综合技能指南

Complete assistance with Polymarket development - covering the full platform (API, trading, market data) and the real-time data streaming client (WebSocket subscriptions for live market activity).
为Polymarket开发提供全方位支持——涵盖整个平台(API、交易、市场数据)以及实时数据流客户端(用于市场实时活动的WebSocket订阅)。

When to Use This Skill

何时使用本技能

This skill should be triggered when:
Platform & API:
  • Working with Polymarket prediction markets
  • Using Polymarket API for market data
  • Implementing trading strategies
  • Building applications with Polymarket services
  • Learning Polymarket best practices
Real-Time Data Streaming:
  • Connecting to Polymarket's WebSocket service
  • Building prediction market monitoring tools
  • Processing live trades, orders, and market updates
  • Monitoring market comments and social reactions
  • Tracking RFQ (Request for Quote) activity
  • Integrating crypto price feeds
本技能适用于以下场景:
平台与API:
  • 开发Polymarket预测市场相关功能
  • 使用Polymarket API获取市场数据
  • 实现交易策略
  • 基于Polymarket服务构建应用
  • 学习Polymarket最佳实践
实时数据流:
  • 连接Polymarket的WebSocket服务
  • 构建预测市场监控工具
  • 处理实时交易、订单和市场更新
  • 监控市场评论和社交互动
  • 跟踪RFQ(询价)活动
  • 集成加密货币价格数据源

Quick Reference

快速参考

Real-Time Data Client Setup

实时数据客户端设置

Installation:
bash
npm install @polymarket/real-time-data-client
Basic Usage:
typescript
import { RealTimeDataClient } from "@polymarket/real-time-data-client";

const onMessage = (message: Message): void => {
    console.log(message.topic, message.type, message.payload);
};

const onConnect = (client: RealTimeDataClient): void => {
    client.subscribe({
        subscriptions: [{
            topic: "activity",
            type: "trades"
        }]
    });
};

new RealTimeDataClient({ onMessage, onConnect }).connect();
安装:
bash
npm install @polymarket/real-time-data-client
基础用法:
typescript
import { RealTimeDataClient } from "@polymarket/real-time-data-client";

const onMessage = (message: Message): void => {
    console.log(message.topic, message.type, message.payload);
};

const onConnect = (client: RealTimeDataClient): void => {
    client.subscribe({
        subscriptions: [{
            topic: "activity",
            type: "trades"
        }]
    });
};

new RealTimeDataClient({ onMessage, onConnect }).connect();

Supported WebSocket Topics

支持的WebSocket主题

1. Activity (
activity
)
  • trades
    - Completed trades
  • orders_matched
    - Order matching events
  • Filters:
    {"event_slug":"string"}
    OR
    {"market_slug":"string"}
2. Comments (
comments
)
  • comment_created
    ,
    comment_removed
  • reaction_created
    ,
    reaction_removed
  • Filters:
    {"parentEntityID":number,"parentEntityType":"Event"}
3. RFQ (
rfq
)
  • Request/Quote lifecycle events
  • No filters, no auth required
4. Crypto Prices (
crypto_prices
,
crypto_prices_chainlink
)
  • update
    - Real-time price feeds
  • Filters:
    {"symbol":"BTC"}
    (optional)
5. CLOB User (
clob_user
)
⚠️ Requires Auth
  • order
    - User's order updates
  • trade
    - User's trade executions
6. CLOB Market (
clob_market
)
  • price_change
    - Price movements
  • agg_orderbook
    - Aggregated order book
  • last_trade_price
    - Latest prices
  • market_created
    ,
    market_resolved
1. 活动(
activity
  • trades
    - 已完成的交易
  • orders_matched
    - 订单匹配事件
  • 过滤器:
    {"event_slug":"string"}
    {"market_slug":"string"}
2. 评论(
comments
  • comment_created
    ,
    comment_removed
  • reaction_created
    ,
    reaction_removed
  • 过滤器:
    {"parentEntityID":number,"parentEntityType":"Event"}
3. RFQ(询价)
  • 询价全生命周期事件
  • 无需过滤器和认证
4. 加密货币价格(
crypto_prices
,
crypto_prices_chainlink
  • update
    - 实时价格数据
  • 过滤器:
    {"symbol":"BTC"}
    (可选)
5. CLOB 用户(
clob_user
⚠️ 需要认证
  • order
    - 用户订单更新
  • trade
    - 用户交易执行记录
6. CLOB 市场(
clob_market
  • price_change
    - 价格变动
  • agg_orderbook
    - 聚合订单簿
  • last_trade_price
    - 最新成交价
  • market_created
    ,
    market_resolved

Authentication for User Data

用户数据认证

typescript
client.subscribe({
    subscriptions: [{
        topic: "clob_user",
        type: "*",
        clob_auth: {
            key: "your-api-key",
            secret: "your-api-secret",
            passphrase: "your-passphrase"
        }
    }]
});
typescript
client.subscribe({
    subscriptions: [{
        topic: "clob_user",
        type: "*",
        clob_auth: {
            key: "your-api-key",
            secret: "your-api-secret",
            passphrase: "your-passphrase"
        }
    }]
});

Common Use Cases

常见使用场景

Monitor Specific Market:
typescript
client.subscribe({
    subscriptions: [{
        topic: "activity",
        type: "trades",
        filters: `{"market_slug":"btc-above-100k-2024"}`
    }]
});
Track Multiple Markets:
typescript
client.subscribe({
    subscriptions: [{
        topic: "clob_market",
        type: "price_change",
        filters: `["100","101","102"]`
    }]
});
Monitor Event Comments:
typescript
client.subscribe({
    subscriptions: [{
        topic: "comments",
        type: "*",
        filters: `{"parentEntityID":12345,"parentEntityType":"Event"}`
    }]
});
监控特定市场:
typescript
client.subscribe({
    subscriptions: [{
        topic: "activity",
        type: "trades",
        filters: `{"market_slug":"btc-above-100k-2024"}`
    }]
});
跟踪多个市场:
typescript
client.subscribe({
    subscriptions: [{
        topic: "clob_market",
        type: "price_change",
        filters: `["100","101","102"]`
    }]
});
监控活动评论:
typescript
client.subscribe({
    subscriptions: [{
        topic: "comments",
        type: "*",
        filters: `{"parentEntityID":12345,"parentEntityType":"Event"}`
    }]
});

Reference Files

参考文档

This skill includes comprehensive documentation in
references/
:
Platform Documentation:
  • api.md - Polymarket API documentation
  • getting_started.md - Getting started guide
  • guides.md - Development guides
  • learn.md - Learning resources
  • trading.md - Trading documentation
  • other.md - Additional resources
Real-Time Client:
  • README.md - WebSocket client API and examples
  • llms.md - LLM integration guide
  • llms-full.md - Complete LLM documentation
Use
view
to read specific reference files for detailed information.
本技能在
references/
目录下包含完整文档:
平台文档:
  • api.md - Polymarket API 文档
  • getting_started.md - 入门指南
  • guides.md - 开发指南
  • learn.md - 学习资源
  • trading.md - 交易相关文档
  • other.md - 其他资源
实时客户端:
  • README.md - WebSocket 客户端API及示例
  • llms.md - LLM集成指南
  • llms-full.md - 完整LLM文档
使用
view
命令查看特定参考文件以获取详细信息。

Key Features

核心功能

Platform Capabilities: ✅ Prediction market creation and resolution ✅ Trading API (REST & WebSocket) ✅ Market data queries ✅ User portfolio management ✅ Event and market discovery
Real-Time Streaming: ✅ WebSocket-based persistent connections ✅ Topic-based subscriptions ✅ Dynamic subscription management ✅ Filter support for targeted data ✅ User authentication for private data ✅ TypeScript with full type safety ✅ Initial data dumps on connection
平台能力: ✅ 预测市场的创建与结算 ✅ 交易API(REST & WebSocket) ✅ 市场数据查询 ✅ 用户投资组合管理 ✅ 活动与市场发现
实时数据流: ✅ 基于WebSocket的持久连接 ✅ 基于主题的订阅 ✅ 动态订阅管理 ✅ 支持过滤器以获取目标数据 ✅ 用户认证以访问私有数据 ✅ 带完整类型安全的TypeScript支持 ✅ 连接时的初始数据导出

Best Practices

最佳实践

WebSocket Connection Management

WebSocket连接管理

  • Use
    onConnect
    callback for subscriptions
  • Implement reconnection logic for production
  • Clean up with
    disconnect()
    when done
  • Handle authentication errors gracefully
  • 使用
    onConnect
    回调进行订阅
  • 为生产环境实现重连逻辑
  • 使用完毕后调用
    disconnect()
    清理连接
  • 优雅处理认证错误

Subscription Strategy

订阅策略

  • Use wildcards (
    "*"
    ) sparingly
  • Apply filters to reduce data volume
  • Unsubscribe from unused streams
  • Process messages asynchronously
  • 谨慎使用通配符(
    "*"
  • 应用过滤器以减少数据量
  • 取消订阅不再使用的数据流
  • 异步处理消息

Performance

性能优化

  • Consider batching high-frequency data
  • Use filters to minimize client processing
  • Validate message payloads before use
  • 考虑对高频数据进行批量处理
  • 使用过滤器减少客户端处理压力
  • 使用前验证消息负载

Requirements

环境要求

  • Node.js: 14+ recommended
  • TypeScript: Optional but recommended
  • Package Manager: npm or yarn
  • Node.js: 推荐14+版本
  • TypeScript: 可选但推荐使用
  • 包管理器: npm 或 yarn

Resources

资源

Official Links

官方链接

Working with This Skill

如何使用本技能

For Beginners: Start with
getting_started.md
for foundational concepts.
For API Integration: Use
api.md
and
trading.md
for REST API details.
For Real-Time Data: Use
README.md
for WebSocket client implementation.
For LLM Integration: Use
llms.md
and
llms-full.md
for AI/ML use cases.
面向初学者:
getting_started.md
开始学习基础概念。
面向API集成开发者: 使用
api.md
trading.md
获取REST API详细信息。
面向实时数据开发者: 使用
README.md
实现WebSocket客户端。
面向LLM集成开发者: 使用
llms.md
llms-full.md
获取AI/ML相关用例。

Notes

注意事项

  • Real-Time Client is TypeScript/JavaScript (not Python)
  • Some WebSocket topics require authentication
  • Use filters to manage message volume effectively
  • All timestamps are Unix timestamps
  • Market IDs are strings (e.g., "100", "101")
  • Platform documentation covers both REST API and WebSocket usage

This comprehensive skill combines Polymarket platform expertise with real-time data streaming capabilities!
  • 实时客户端基于TypeScript/JavaScript(不支持Python)
  • 部分WebSocket主题需要认证
  • 有效使用过滤器管理消息量
  • 所有时间戳均为Unix时间戳
  • 市场ID为字符串(例如:"100", "101")
  • 平台文档同时涵盖REST API和WebSocket使用方法

本综合技能结合了Polymarket平台能力与实时数据流功能!