polymarket
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChinesePolymarket API
Polymarket API
Polymarket is a decentralized prediction market where users trade on the outcomes of real-world events. It uses a hybrid-decentralized Central Limit Order Book (CLOB) with off-chain matching and on-chain settlement on Polygon.
Check this skill and the official documentation FREQUENTLY. The canonical machine-readable index of all docs lives at:
Always consult to discover every available page before building. It is the single source of truth for endpoint references, SDK docs, WebSocket channels, builder program details, and getting-started guides.
llms.txtPolymarket是一个去中心化预测市场,用户可对现实世界事件的结果进行交易。它采用混合去中心化的中央限价订单簿(CLOB),在链下完成订单匹配,在Polygon上进行链上结算。
请频繁查阅本技能及官方文档。所有文档的标准机器可读索引地址为:
在开发前,请务必通过了解所有可用页面。它是端点参考、SDK文档、WebSocket通道、Builder计划详情及入门指南的唯一权威来源。
llms.txtKey Concepts (Glossary)
核心概念(术语表)
| Term | Definition |
|---|---|
| Event | A collection of related markets grouped under a common topic (e.g., "2024 US Presidential Election"). |
| Market | A single tradeable binary outcome within an event. Each market has Yes and No sides, a condition ID, question ID, and pair of token IDs. |
| Token | Represents a position in a specific outcome (Yes or No). Prices range from 0.00 to 1.00. Winning tokens redeem for $1 USDCe. Also called outcome token. |
| Token ID | The unique identifier for a specific outcome token. Required when placing orders or querying prices. |
| Condition ID | On-chain identifier for a market's resolution condition. Used in CTF operations and as the market identifier in the CLOB. |
| Question ID | Identifier linking a market to its resolution oracle (UMA). |
| Slug | Human-readable URL identifier for a market or event (e.g., |
| CLOB | Central Limit Order Book — Polymarket's off-chain order matching system. Orders are matched here before on-chain settlement. |
| Tick Size | Minimum price increment for a market. Usually |
| Fill | When an order is matched and executed. Orders can be partially or fully filled. |
| Negative Risk (NegRisk) | A multi-outcome event where only one outcome can resolve Yes. Requires |
| CTF | Conditional Token Framework — the on-chain smart contracts that manage outcome tokens. |
| Split | Convert USDCe into a complete set of outcome tokens (one Yes + one No). |
| Merge | Convert a complete set of outcome tokens back into USDCe. |
| Redeem | After resolution, exchange winning tokens for $1 USDCe each. |
| USDCe | Bridged USDC on Polygon — the stablecoin used as collateral on Polymarket. |
| Funder Address | The wallet address that holds funds and tokens for trading. |
| Signature Type | Identifies wallet type: |
Full glossary: https://docs.polymarket.com/quickstart/reference/glossary.md
| 术语 | 定义 |
|---|---|
| Event(事件) | 一组相关市场的集合,归属于同一个主题(例如“2024年美国总统大选”)。 |
| Market(市场) | 事件下的单个可交易二元结果市场。每个市场包含Yes和No两个方向,以及条件ID、问题ID和一对代币ID。 |
| Token(代币) | 代表特定结果(Yes或No)的持仓。价格范围为0.00至1.00。获胜代币可兑换为1 USDCe。也称为结果代币。 |
| Token ID(代币ID) | 特定结果代币的唯一标识符。下达订单或查询价格时必填。 |
| Condition ID(条件ID) | 市场结算条件的链上标识符。用于CTF操作,同时作为CLOB中的市场标识符。 |
| Question ID(问题ID) | 将市场与其结算预言机(UMA)关联的标识符。 |
| Slug | 市场或事件的人类可读URL标识符(例如 |
| CLOB | 中央限价订单簿 — Polymarket的链下订单匹配系统。订单在此匹配后再进行链上结算。 |
| Tick Size(最小价格变动单位) | 市场的最小价格增量。通常为 |
| Fill(成交) | 订单被匹配并执行的过程。订单可部分成交或完全成交。 |
| Negative Risk(NegRisk,负风险) | 多结果事件,其中只有一个结果会结算为Yes。下达订单时需在参数中设置 |
| CTF | 条件代币框架 — 管理结果代币的链上智能合约。 |
| Split(拆分) | 将USDCe转换为一整套结果代币(1个Yes + 1个No)。 |
| Merge(合并) | 将一整套结果代币转换回USDCe。 |
| Redeem(兑换) | 结算完成后,将获胜代币兑换为每个1 USDCe。 |
| USDCe | Polygon上的跨链USDC — Polymarket中用作抵押品的稳定币。 |
| Funder Address(资金方地址) | 持有交易资金和代币的钱包地址。 |
| Signature Type(签名类型) | 标识钱包类型: |
Order Types
订单类型
| Type | Name | Description |
|---|---|---|
| GTC | Good-Til-Cancelled | Remains open until filled or manually cancelled. |
| GTD | Good-Til-Date | Expires at a specified time if not filled. |
| FOK | Fill-Or-Kill | Must be filled entirely and immediately, or cancelled. No partial fills. |
| FAK | Fill-And-Kill | Fills as much as possible immediately, then cancels any remaining unfilled portion. |
| 类型代码 | 名称 | 描述 |
|---|---|---|
| GTC | 取消前有效 | 订单保持有效状态,直到成交或手动取消。 |
| GTD | 指定日期前有效 | 若未成交,在指定时间到期失效。 |
| FOK | 全部成交或取消 | 必须立即完全成交,否则取消订单,不支持部分成交。 |
| FAK | 成交剩余取消 | 立即尽可能多地成交,然后取消未成交的剩余部分。 |
Base URLs
基础URL
| API | Base URL | Description |
|---|---|---|
| CLOB API | | Order management, prices, orderbooks, trading |
| Gamma API | | Market discovery, metadata, events, tags |
| Data API | | User positions, activity, trade history |
| CLOB WebSocket | | Orderbook updates, order status |
| RTDS WebSocket | | Low-latency crypto prices, comments |
Endpoints reference: https://docs.polymarket.com/quickstart/reference/endpoints.md
| API | 基础URL | 描述 |
|---|---|---|
| CLOB API | | 订单管理、价格查询、订单簿、交易相关功能 |
| Gamma API | | 市场发现、元数据、事件、标签相关功能 |
| Data API | | 用户持仓、活动记录、交易历史相关功能 |
| CLOB WebSocket | | 订单簿更新、订单状态推送 |
| RTDS WebSocket | | 低延迟加密货币价格、评论流推送 |
Documentation & References
文档与参考资源
All detailed examples, request/response schemas, and walkthroughs live in the official docs. Always consult these before building:
所有详细示例、请求/响应 schema 及分步指南均在官方文档中。开发前请务必查阅:
Authentication
认证机制
Polymarket uses a two-level authentication system. Public endpoints (market data, prices, orderbooks) require no authentication.
Polymarket采用两级认证体系。公开端点(市场数据、价格、订单簿)无需认证。
L1 Authentication (Private Key)
L1认证(私钥)
L1 uses the wallet's private key to sign an EIP-712 message. It proves ownership of the wallet and is used to create or derive L2 API credentials.
L1 Headers (for direct REST calls):
| Header | Description |
|---|---|
| Polygon signer address |
| EIP-712 signature |
| Current UNIX timestamp |
| Nonce (default 0) |
The is generated by signing an EIP-712 struct with domain (version , chainId ).
POLY_SIGNATUREClobAuthDomain1137TypeScript example:
typescript
import { ClobClient } from "@polymarket/clob-client";
import { Wallet } from "ethers"; // v5.8.0
const HOST = "https://clob.polymarket.com";
const CHAIN_ID = 137; // Polygon mainnet
const signer = new Wallet(process.env.PRIVATE_KEY);
const client = new ClobClient(HOST, CHAIN_ID, signer);
const apiCreds = await client.createOrDeriveApiKey();
// Returns: { apiKey, secret, passphrase }Python example:
python
from py_clob_client.client import ClobClient
import os
client = ClobClient(
host="https://clob.polymarket.com",
chain_id=137,
key=os.getenv("PRIVATE_KEY"),
)
api_creds = client.create_or_derive_api_creds()L1使用钱包私钥签署EIP-712消息,用于证明钱包所有权,同时用于创建或派生L2 API凭证。
L1请求头(直接调用REST接口时):
| 请求头 | 描述 |
|---|---|
| Polygon签名者地址 |
| EIP-712签名 |
| 当前UNIX时间戳 |
| 随机数(默认0) |
POLY_SIGNATUREClobAuthDomain1137TypeScript示例:
typescript
import { ClobClient } from "@polymarket/clob-client";
import { Wallet } from "ethers"; // v5.8.0
const HOST = "https://clob.polymarket.com";
const CHAIN_ID = 137; // Polygon主网
const signer = new Wallet(process.env.PRIVATE_KEY);
const client = new ClobClient(HOST, CHAIN_ID, signer);
const apiCreds = await client.createOrDeriveApiKey();
// 返回结果: { apiKey, secret, passphrase }Python示例:
python
from py_clob_client.client import ClobClient
import os
client = ClobClient(
host="https://clob.polymarket.com",
chain_id=137,
key=os.getenv("PRIVATE_KEY"),
)
api_creds = client.create_or_derive_api_creds()
// 返回结果: { "apiKey": "...", "secret": "...", "passphrase": "..." }Returns: { "apiKey": "...", "secret": "...", "passphrase": "..." }
L2认证(API凭证)
Full L1 auth details: <https://docs.polymarket.com/developers/CLOB/authentication.md>L2使用从L1派生的API凭证(apiKey、secret、passphrase)。请求通过进行HMAC-SHA256签名。
secretL2请求头(直接调用REST接口时):
| 请求头 | 描述 |
|---|---|
| Polygon签名者地址 |
| HMAC-SHA256签名 |
| 当前UNIX时间戳 |
| 用户的API |
| 用户的API |
TypeScript示例(完整L2客户端):
typescript
import { ClobClient } from "@polymarket/clob-client";
import { Wallet } from "ethers"; // v5.8.0
const signer = new Wallet(process.env.PRIVATE_KEY);
const apiCreds = {
apiKey: process.env.API_KEY,
secret: process.env.SECRET,
passphrase: process.env.PASSPHRASE,
};
const client = new ClobClient(
"https://clob.polymarket.com",
137,
signer,
apiCreds,
2, // 签名类型: 0=EOA, 1=POLY_PROXY, 2=GNOSIS_SAFE
process.env.FUNDER_ADDRESS, // 代理钱包地址
);Python示例(完整L2客户端):
python
from py_clob_client.client import ClobClient
from py_clob_client.clob_types import ApiCreds
import os
api_creds = ApiCreds(
api_key=os.getenv("API_KEY"),
api_secret=os.getenv("SECRET"),
api_passphrase=os.getenv("PASSPHRASE"),
)
client = ClobClient(
host="https://clob.polymarket.com",
chain_id=137,
key=os.getenv("PRIVATE_KEY"),
creds=api_creds,
signature_type=2, // 0=EOA, 1=POLY_PROXY, 2=GNOSIS_SAFE
funder=os.getenv("FUNDER_ADDRESS"),
)L2 Authentication (API Credentials)
签名类型
L2 uses the API credentials (apiKey, secret, passphrase) derived from L1. Requests are signed with HMAC-SHA256 using the .
secretL2 Headers (for direct REST calls):
| Header | Description |
|---|---|
| Polygon signer address |
| HMAC-SHA256 signature |
| Current UNIX timestamp |
| User's API |
| User's API |
TypeScript example (full L2 client):
typescript
import { ClobClient } from "@polymarket/clob-client";
import { Wallet } from "ethers"; // v5.8.0
const signer = new Wallet(process.env.PRIVATE_KEY);
const apiCreds = {
apiKey: process.env.API_KEY,
secret: process.env.SECRET,
passphrase: process.env.PASSPHRASE,
};
const client = new ClobClient(
"https://clob.polymarket.com",
137,
signer,
apiCreds,
2, // Signature type: 0=EOA, 1=POLY_PROXY, 2=GNOSIS_SAFE
process.env.FUNDER_ADDRESS, // proxy wallet address
);Python example (full L2 client):
python
from py_clob_client.client import ClobClient
from py_clob_client.clob_types import ApiCreds
import os
api_creds = ApiCreds(
api_key=os.getenv("API_KEY"),
api_secret=os.getenv("SECRET"),
api_passphrase=os.getenv("PASSPHRASE"),
)
client = ClobClient(
host="https://clob.polymarket.com",
chain_id=137,
key=os.getenv("PRIVATE_KEY"),
creds=api_creds,
signature_type=2, # 0=EOA, 1=POLY_PROXY, 2=GNOSIS_SAFE
funder=os.getenv("FUNDER_ADDRESS"),
)| 类型 | 值 | 描述 |
|---|---|---|
| EOA | 0 | 标准以太坊钱包。资金方地址为EOA地址,需要POL支付Gas费。 |
| POLY_PROXY | 1 | Magic Link邮箱/谷歌登录代理钱包。用户需从Polymarket.com导出私钥。 |
| GNOSIS_SAFE | 2 | Gnosis Safe多签代理钱包。是Polymarket.com用户最常用的类型。 |
Signature Types
SDK
| Type | Value | Description |
|---|---|---|
| EOA | 0 | Standard Ethereum wallet. Funder is the EOA address. Needs POL for gas. |
| POLY_PROXY | 1 | Magic Link email/Google login proxy wallet. User must export PK from Polymarket.com. |
| GNOSIS_SAFE | 2 | Gnosis Safe multisig proxy wallet. Most common for Polymarket.com users. |
Full auth guide: https://docs.polymarket.com/developers/CLOB/authentication.md
SDKs
请求限制
Polymarket provides official SDKs. Prefer these for production integrations:
| SDK | Install | Source |
|---|---|---|
| TypeScript | | GitHub |
| Python | | GitHub |
| Rust | | — |
For builders routing orders for users, also install:
| Package | Install | Purpose |
|---|---|---|
| Builder Signing SDK | | Builder order attribution |
Polymarket采用基于Cloudflare的限流机制(请求会被延迟,而非立即拒绝)。核心限制如下:
Rate Limits
通用限制
Polymarket uses Cloudflare-based throttling (requests are delayed, not immediately rejected). Key limits:
| 端点 | 限制 |
|---|---|
| 通用请求限制 | 每10秒15000次请求 |
General
Gamma API限制
| Endpoint | Limit |
|---|---|
| General Rate Limiting | 15,000 requests / 10s |
| 端点 | 限制 |
|---|---|
| Gamma(通用) | 每10秒4000次 |
| 每10秒500次 |
| 每10秒300次 |
| 每10秒900次 |
| 搜索接口 | 每10秒350次 |
| 标签接口 | 每10秒200次 |
| 评论接口 | 每10秒200次 |
Gamma API
CLOB API限制
| Endpoint | Limit |
|---|---|
| Gamma (General) | 4,000 / 10s |
| 500 / 10s |
| 300 / 10s |
| 900 / 10s |
| Search | 350 / 10s |
| Tags | 200 / 10s |
| Comments | 200 / 10s |
| 端点 | 限制 |
|---|---|
| CLOB(通用) | 每10秒9000次 |
| 每10秒1500次 |
| 每10秒1500次 |
| 每10秒1500次 |
| 每10秒500次 |
| 价格历史 | 每10秒1000次 |
CLOB API
CLOB交易接口限制
| Endpoint | Limit |
|---|---|
| CLOB (General) | 9,000 / 10s |
| 1,500 / 10s |
| 1,500 / 10s |
| 1,500 / 10s |
| 500 / 10s |
| Price History | 1,000 / 10s |
| 端点 | 突发限制 | 持续限制 |
|---|---|---|
POST | 每10秒3500次(每秒500次) | 每10分钟36000次(每秒60次) |
DELETE | 每10秒3000次(每秒300次) | 每10分钟30000次(每秒50次) |
POST | 每10秒1000次(每秒100次) | 每10分钟15000次(每秒25次) |
DELETE | 每10秒1000次(每秒100次) | 每10分钟15000次(每秒25次) |
DELETE | 每10秒250次(每秒25次) | 每10分钟6000次(每秒10次) |
CLOB Trading
Data API限制
| Endpoint | Burst Limit | Sustained Limit |
|---|---|---|
POST | 3,500 / 10s (500/s) | 36,000 / 10min (60/s) |
DELETE | 3,000 / 10s (300/s) | 30,000 / 10min (50/s) |
POST | 1,000 / 10s (100/s) | 15,000 / 10min (25/s) |
DELETE | 1,000 / 10s (100/s) | 15,000 / 10min (25/s) |
DELETE | 250 / 10s (25/s) | 6,000 / 10min (10/s) |
| 端点 | 限制 |
|---|---|
| Data API(通用) | 每10秒1000次 |
| 每10秒200次 |
| 每10秒150次 |
| 每10秒150次 |
Data API
REST API端点概述
| Endpoint | Limit |
|---|---|
| Data API (General) | 1,000 / 10s |
| 200 / 10s |
| 150 / 10s |
| 150 / 10s |
Full rate limits: https://docs.polymarket.com/quickstart/introduction/rate-limits.md
以下是按API分类的端点摘要。完整的请求/响应schema请查看链接文档或浏览https://docs.polymarket.com/llms.txt。
REST API Endpoints Overview
Gamma API — 市场发现与元数据
Below is a summary organized by API. For full request/response schemas, see the linked docs or browse https://docs.polymarket.com/llms.txt.
基础地址:
https://gamma-api.polymarket.com| 端点 | 请求方法 | 描述 | 文档 |
|---|---|---|---|
| GET | 列出事件(可按 | 列出事件 |
| GET | 根据ID获取事件详情 | 根据ID获取事件 |
| GET | 根据slug获取事件详情 | 根据slug获取事件 |
| GET | 获取事件标签 | 获取事件标签 |
| GET | 列出市场(可按多种条件过滤) | 列出市场 |
| GET | 根据ID获取市场详情 | 根据ID获取市场 |
| GET | 根据slug获取市场详情 | 根据slug获取市场 |
| GET | 列出标签 | 列出标签 |
| GET | 根据ID获取标签详情 | 根据ID获取标签 |
| GET | 根据slug获取标签详情 | 根据slug获取标签 |
| GET | 列出系列 | 列出系列 |
| GET | 根据ID获取系列详情 | 根据ID获取系列 |
| GET | 获取体育元数据 | 获取体育元数据 |
| GET | 获取有效的体育市场类型 | 获取有效体育市场类型 |
| GET | 列出球队 | 列出球队 |
| GET | 搜索市场、事件和用户资料 | 搜索 |
| GET | 列出评论 | 列出评论 |
| GET | 根据钱包地址获取公开用户资料 | 获取用户资料 |
Gamma API — Market Discovery & Metadata
CLOB API — 定价与订单簿(公开)
Base:
https://gamma-api.polymarket.com| Endpoint | Method | Description | Docs |
|---|---|---|---|
| GET | List events (filter by | List Events |
| GET | Get event by ID | Get Event by ID |
| GET | Get event by slug | Get Event by Slug |
| GET | Get event tags | Get Event Tags |
| GET | List markets (filter by various criteria) | List Markets |
| GET | Get market by ID | Get Market by ID |
| GET | Get market by slug | Get Market by Slug |
| GET | List tags | List Tags |
| GET | Get tag by ID | Get Tag by ID |
| GET | Get tag by slug | Get Tag by Slug |
| GET | List series | List Series |
| GET | Get series by ID | Get Series by ID |
| GET | Get sports metadata | Get Sports Metadata |
| GET | Get valid sports market types | Get Valid Sports Market Types |
| GET | List teams | List Teams |
| GET | Search markets, events, and profiles | Search |
| GET | List comments | List Comments |
| GET | Get public profile by wallet address | Get Profile |
Gamma structure guide: https://docs.polymarket.com/developers/gamma-markets-api/gamma-structure.md
CLOB API — Pricing & Orderbooks (Public)
CLOB API — 交易(需认证)
Base:
https://clob.polymarket.com| Endpoint | Method | Auth | Description | Docs |
|---|---|---|---|---|
| GET | No | Get current price for a token and side | Get Market Price |
| POST | No | Get prices for multiple tokens and sides | Get Multiple Market Prices |
| GET | No | Get midpoint price for a token | Get Midpoint Price |
| GET | No | Get order book for a token | Get Order Book Summary |
| POST | No | Get order books for multiple tokens | Get Multiple Order Books |
| GET | No | Get historical price data for a token | Get Price History |
| GET | No | Get bid-ask spreads for multiple tokens | Get Bid-Ask Spreads |
CLOB API — Trading (Authenticated)
CLOB API — 订单与交易记录(需认证)
Base:
https://clob.polymarket.com| Endpoint | Method | Auth | Description | Docs |
|---|---|---|---|---|
| POST | L2 | Place a single order | Place Single Order |
| DELETE | L2 | Cancel a single order | Cancel Orders |
| POST | L2 | Place multiple orders (batch, up to 15) | Place Multiple Orders |
| DELETE | L2 | Cancel multiple orders | Cancel Orders |
| DELETE | L2 | Cancel all open orders | Cancel Orders |
| DELETE | L2 | Cancel all orders for a specific market | Cancel Orders |
CLOB API — Orders & Trades (Authenticated)
CLOB API — 认证端点
| Endpoint | Method | Auth | Description | Docs |
|---|---|---|---|---|
| GET | L2 | Get a specific order | Get Order |
| GET | L2 | Get active/open orders | Get Active Orders |
| GET | L2 | Get user's trades | Get Trades |
| GET | L2 | Check order reward scoring eligibility | Check Scoring |
| 端点 | 请求方法 | 是否需要认证 | 描述 |
|---|---|---|---|
| POST | L1 | 创建新的API凭证 |
| GET | L1 | 派生已有的API凭证 |
| GET | L2 | 列出API密钥 |
| DELETE | L2 | 删除/吊销API密钥 |
CLOB API — Auth Endpoints
Data API — 持仓与活动记录
| Endpoint | Method | Auth | Description |
|---|---|---|---|
| POST | L1 | Create new API credentials |
| GET | L1 | Derive existing API credentials |
| GET | L2 | List API keys |
| DELETE | L2 | Delete/revoke an API key |
基础地址:
https://data-api.polymarket.com| 端点 | 请求方法 | 描述 | 文档 |
|---|---|---|---|
| GET | 获取用户当前持仓 | 获取当前持仓 |
| GET | 获取用户已平仓持仓 | 获取已平仓持仓 |
| GET | 获取指定市场的持仓 | 获取市场持仓 |
| GET | 获取用户持仓的总价值 | 获取持仓总价值 |
| GET | 获取市场的顶级持仓者 | 获取顶级持仓者 |
| GET | 获取用户或市场的交易记录 | 获取交易记录 |
| GET | 获取用户的链上活动记录 | 获取用户活动记录 |
| GET | 获取交易者排行榜 | 获取排行榜 |
| GET | 获取未平仓合约量 | 获取未平仓合约量 |
| GET | 获取事件的实时交易量 | 获取事件实时交易量 |
Data API — Positions & Activity
跨链桥API — 存款与取款
Base:
https://data-api.polymarket.com| Endpoint | Method | Description | Docs |
|---|---|---|---|
| GET | Get current positions for a user | Get Current Positions |
| GET | Get closed positions for a user | Get Closed Positions |
| GET | Get positions for a market | Get Positions for Market |
| GET | Get total value of a user's positions | Get Total Value |
| GET | Get top holders for markets | Get Top Holders |
| GET | Get trades for a user or markets | Get Trades |
| GET | Get user on-chain activity | Get User Activity |
| GET | Get trader leaderboard rankings | Get Leaderboard |
| GET | Get open interest | Get Open Interest |
| GET | Get live volume for an event | Get Live Volume |
Bridge API — Deposits & Withdrawals
Builder计划端点
| Endpoint | Method | Description | Docs |
|---|---|---|---|
| POST | Create deposit addresses | Create Deposit Addresses |
| POST | Create withdrawal addresses | Create Withdrawal Addresses |
| GET | Get supported chains & tokens | Get Supported Assets |
| GET | Get deposit/withdrawal quote | Get a Quote |
| GET | Get transaction status | Get Transaction Status |
| 端点 | 请求方法 | 描述 | 文档 |
|---|---|---|---|
| GET | 获取Builder总排行榜 | Builder排行榜 |
| GET | 获取Builder每日交易量时间序列数据 | Builder交易量 |
Builder Program Endpoints
费用说明
| Endpoint | Method | Description | Docs |
|---|---|---|---|
| GET | Get aggregated builder leaderboard | Builder Leaderboard |
| GET | Get daily builder volume time-series | Builder Volume |
Builder program: https://docs.polymarket.com/developers/builders/builder-intro.md
当前费用费率(可能会变动):
| 交易量级别 | 挂单手续费(基点) | 吃单手续费(基点) |
|---|---|---|
| >0 USDC | 0 | 0 |
费用计算取决于买入或卖出:
- 卖出结果代币:
feeQuote = baseRate × min(price, 1 - price) × size - 买入结果代币:
feeBase = baseRate × min(price, 1 - price) × (size / price)
Fees
WebSocket API
Current fee schedule (subject to change):
| Volume Level | Maker Fee (bps) | Taker Fee (bps) |
|---|---|---|
| >0 USDC | 0 | 0 |
Fee calculation depends on buying vs. selling:
- Selling outcome tokens:
feeQuote = baseRate × min(price, 1 - price) × size - Buying outcome tokens:
feeBase = baseRate × min(price, 1 - price) × (size / price)
Maker rebates program: https://docs.polymarket.com/developers/market-makers/maker-rebates-program.md
Polymarket提供两个WebSocket服务用于获取实时数据。
WebSocket API
CLOB WebSocket
Polymarket provides two WebSocket services for real-time data.
CLOB WebSocket
市场通道事件
wss://ws-subscriptions-clob.polymarket.com/ws/Two channels are available:
| Channel | Auth Required | Description | Docs |
|---|---|---|---|
| No | Orderbook and price updates (public) | Market Channel |
| Yes | Order status and trade updates | User Channel |
| 事件类型 | 触发条件 | 描述 |
|---|---|---|
| 首次订阅 / 发生交易 | 包含买卖盘的完整订单簿快照 |
| 新订单下达 / 订单取消 | 价格档位的增量变化,包含最优买卖价 |
| 价格>0.96或<0.04 | 最小价格变动单位更新 |
| 订单匹配成交 | 最新成交价、方向和交易量 |
| 最优价格变化 | 最优买价、卖价及价差(需启用 |
| 市场创建 | 新市场详情(需启用 |
| 市场结算 | 结算详情及获胜结果(需启用 |
Market Channel Events
用户通道事件
| Event Type | Trigger | Description |
|---|---|---|
| First subscribe / trade | Full orderbook snapshot with bids and asks |
| New order / cancellation | Incremental price level changes with best bid/ask |
| Price > 0.96 or < 0.04 | Minimum tick size update |
| Trade match | Last trade price, side, and size |
| Best price change | Best bid, ask, and spread (requires |
| Market created | New market details (requires |
| Market resolved | Resolution details with winning outcome (requires |
| 事件类型 | 触发条件 | 描述 |
|---|---|---|
| 订单匹配 / 状态变化 | 交易详情,包含挂单订单、状态( |
| 订单下达 / 更新 / 取消 | 订单详情,包含类型( |
User Channel Events
订阅方式
| Event Type | Trigger | Description |
|---|---|---|
| Order matched / status change | Trade details with maker orders, status ( |
| Order placed / updated / cancelled | Order details with type ( |
连接成功后发送JSON消息:
json
{
"auth": { /* 用户通道需L2认证信息 */ },
"markets": ["0x...conditionId"],
"assets_ids": ["tokenId1", "tokenId2"],
"type": "market",
"custom_feature_enabled": true
}连接后可订阅/取消额外资产:
json
{
"assets_ids": ["tokenId3"],
"markets": [],
"operation": "subscribe",
"custom_feature_enabled": true
}Subscription
RTDS(实时数据流)
Send a JSON message upon connection:
json
{
"auth": { /* L2 auth for user channel */ },
"markets": ["0x...conditionId"],
"assets_ids": ["tokenId1", "tokenId2"],
"type": "market",
"custom_feature_enabled": true
}Subscribe/unsubscribe to additional assets after connecting:
json
{
"assets_ids": ["tokenId3"],
"markets": [],
"operation": "subscribe",
"custom_feature_enabled": true
}Full WebSocket guide: https://docs.polymarket.com/developers/CLOB/websocket/wss-overview.md
WSS Authentication: https://docs.polymarket.com/developers/CLOB/websocket/wss-auth.md
wss://ws-live-data.polymarket.com低延迟流服务,用于获取加密货币价格和评论流,专为做市商优化。
RTDS (Real-Time Data Stream)
体育WebSocket
wss://ws-live-data.polymarket.comLow-latency streaming for crypto prices and comment feeds. Optimized for market makers.
- RTDS Overview: https://docs.polymarket.com/developers/RTDS/RTDS-overview.md
- RTDS Crypto Prices: https://docs.polymarket.com/developers/RTDS/RTDS-crypto-prices.md
- RTDS Comments: https://docs.polymarket.com/developers/RTDS/RTDS-comments.md
Sports WebSocket
数据模型
—
事件 → 市场 → 代币层级结构
Real-time sports results via WebSocket:
- Overview: https://docs.polymarket.com/developers/sports-websocket/overview.md
- Quickstart: https://docs.polymarket.com/developers/sports-websocket/quickstart.md
- Message Format: https://docs.polymarket.com/developers/sports-websocket/message-format.md
Event(例如“2024年大选谁会获胜?”)
├── Market 1(例如“A候选人会获胜吗?”)
│ ├── Token: Yes(token_id: "abc...") price: 0.65
│ └── Token: No (token_id: "def...") price: 0.35
├── Market 2(例如“B候选人会获胜吗?”)
│ ├── Token: Yes(token_id: "ghi...") price: 0.30
│ └── Token: No (token_id: "jkl...") price: 0.70
└── ...- 价格代表隐含概率(0.00–1.00)。Yes和No的价格总和约等于1美元。
- Gamma API返回的对应CLOB交易所需的代币ID。
clobTokenIds - 和
outcomes数组是一一对应的。outcomePrices
Data Model
负风险事件
Event → Market → Token Hierarchy
—
Event (e.g., "Who will win the 2024 election?")
├── Market 1 (e.g., "Will Candidate A win?")
│ ├── Token: Yes (token_id: "abc...") price: 0.65
│ └── Token: No (token_id: "def...") price: 0.35
├── Market 2 (e.g., "Will Candidate B win?")
│ ├── Token: Yes (token_id: "ghi...") price: 0.30
│ └── Token: No (token_id: "jkl...") price: 0.70
└── ...- Prices are implied probabilities (0.00–1.00). Yes + No prices sum to ≈ $1.
- from the Gamma API map to CLOB token IDs needed for trading.
clobTokenIds - and
outcomesarrays are 1:1 mapped.outcomePrices
多结果事件中只有一个结果会结算为Yes,这类事件采用负风险架构。任意市场的NO份额可转换为其他所有市场的YES份额,提升资金使用效率。
- 事件的表示该事件为负风险事件。
negRisk: true - 表示占位符结果可后续明确。
negRiskAugmented: true
Negative Risk Events
常见使用模式
—
获取活跃事件
Multi-outcome events where only one outcome can resolve "Yes" use the negative risk architecture. A NO share in any market can be converted into 1 YES share in all other markets, enabling capital efficiency.
- on the event indicates negative risk.
negRisk: true - means placeholder outcomes can be clarified later.
negRiskAugmented: true
Full NegRisk docs: https://docs.polymarket.com/developers/neg-risk/overview.md
bash
curl -s "https://gamma-api.polymarket.com/events?active=true&closed=false&limit=10" | jq '.[].title'Common Patterns
获取包含市场的事件详情
Fetch Active Events
—
bash
curl -s "https://gamma-api.polymarket.com/events?active=true&closed=false&limit=10" | jq '.[].title'bash
curl -s "https://gamma-api.polymarket.com/events?slug=will-bitcoin-reach-100k-by-2025" | jq '.[0] | {title, markets: [.markets[] | {question, outcomePrices, clobTokenIds}]}'Get Event Details with Markets
获取代币当前价格
bash
curl -s "https://gamma-api.polymarket.com/events?slug=will-bitcoin-reach-100k-by-2025" | jq '.[0] | {title, markets: [.markets[] | {question, outcomePrices, clobTokenIds}]}'bash
curl -s "https://clob.polymarket.com/price?token_id=YOUR_TOKEN_ID&side=buy"Get Current Price for a Token
返回结果: { "price": "0.65" }
bash
curl -s "https://clob.polymarket.com/price?token_id=YOUR_TOKEN_ID&side=buy"undefinedReturns: { "price": "0.65" }
获取订单簿深度
undefinedbash
curl -s "https://clob.polymarket.com/book?token_id=YOUR_TOKEN_ID" | jq '{bids: .bids[:3], asks: .asks[:3]}'Get Orderbook Depth
获取中间价
bash
curl -s "https://clob.polymarket.com/book?token_id=YOUR_TOKEN_ID" | jq '{bids: .bids[:3], asks: .asks[:3]}'bash
curl -s "https://clob.polymarket.com/midpoint?token_id=YOUR_TOKEN_ID"Get Midpoint Price
返回结果: { "mid": "0.655" }
bash
curl -s "https://clob.polymarket.com/midpoint?token_id=YOUR_TOKEN_ID"undefinedReturns: { "mid": "0.655" }
搜索市场
undefinedbash
curl -s "https://gamma-api.polymarket.com/search?query=bitcoin&limit=5" | jq '.markets[] | {question, slug}'Search for Markets
发现体育市场
bash
curl -s "https://gamma-api.polymarket.com/search?query=bitcoin&limit=5" | jq '.markets[] | {question, slug}'bash
undefinedDiscover Sports Markets
获取所有支持的体育联赛
bash
undefinedcurl -s "https://gamma-api.polymarket.com/sports" | jq '.'
Get all supported sports leagues
获取NBA事件
curl -s "https://gamma-api.polymarket.com/sports" | jq '.'
curl -s "https://gamma-api.polymarket.com/events?series_id=10345&active=true&closed=false" | jq '.[].title'
undefinedGet NBA events
获取用户持仓(Data API)
curl -s "https://gamma-api.polymarket.com/events?series_id=10345&active=true&closed=false" | jq '.[].title'
undefinedbash
curl -s "https://data-api.polymarket.com/positions?user=0xYOUR_ADDRESS" | jq '.'Get User Positions (Data API)
下达订单(TypeScript)
bash
curl -s "https://data-api.polymarket.com/positions?user=0xYOUR_ADDRESS" | jq '.'typescript
import { ClobClient, Side, OrderType } from "@polymarket/clob-client";
import { Wallet } from "ethers";
const client = new ClobClient(
"https://clob.polymarket.com", 137, signer, apiCreds, 2, funderAddress
);
const market = await client.getMarket("CONDITION_ID");
const response = await client.createAndPostOrder(
{ tokenID: "TOKEN_ID", price: 0.50, size: 10, side: Side.BUY },
{ tickSize: market.tickSize, negRisk: market.negRisk },
OrderType.GTC
);
console.log("Order ID:", response.orderID);Place an Order (TypeScript)
下达订单(Python)
typescript
import { ClobClient, Side, OrderType } from "@polymarket/clob-client";
import { Wallet } from "ethers";
const client = new ClobClient(
"https://clob.polymarket.com", 137, signer, apiCreds, 2, funderAddress
);
const market = await client.getMarket("CONDITION_ID");
const response = await client.createAndPostOrder(
{ tokenID: "TOKEN_ID", price: 0.50, size: 10, side: Side.BUY },
{ tickSize: market.tickSize, negRisk: market.negRisk },
OrderType.GTC
);
console.log("Order ID:", response.orderID);python
from py_clob_client.client import ClobClient
from py_clob_client.clob_types import OrderArgs, OrderType
from py_clob_client.order_builder.constants import BUY
market = client.get_market("CONDITION_ID")
response = client.create_and_post_order(
OrderArgs(token_id="TOKEN_ID", price=0.50, size=10, side=BUY),
options={"tick_size": market["tickSize"], "neg_risk": market["negRisk"]},
order_type=OrderType.GTC,
)
print("Order ID:", response["orderID"])Place an Order (Python)
CTF操作(拆分/合并/兑换)
python
from py_clob_client.client import ClobClient
from py_clob_client.clob_types import OrderArgs, OrderType
from py_clob_client.order_builder.constants import BUY
market = client.get_market("CONDITION_ID")
response = client.create_and_post_order(
OrderArgs(token_id="TOKEN_ID", price=0.50, size=10, side=BUY),
options={"tick_size": market["tickSize"], "neg_risk": market["negRisk"]},
order_type=OrderType.GTC,
)
print("Order ID:", response["orderID"])条件代币框架(CTF)支持USDCe与结果代币之间的转换:
| 操作 | 描述 | 使用场景 |
|---|---|---|
| 拆分 | USDCe → 1个Yes代币 + 1个No代币 | 做市商创建库存 |
| 合并 | 1个Yes代币 + 1个No代币 → USDCe | 平仓,收回抵押品 |
| 兑换 | 获胜代币 → 1 USDCe | 市场结算完成后 |
- 拆分: https://docs.polymarket.com/developers/CTF/split.md
- 合并: https://docs.polymarket.com/developers/CTF/merge.md
- 兑换: https://docs.polymarket.com/developers/CTF/redeem.md
- 部署及地址: https://docs.polymarket.com/developers/CTF/deployment-resources.md
CTF Operations (Split / Merge / Redeem)
Builder计划
The Conditional Token Framework enables conversion between USDCe and outcome tokens:
| Operation | Description | When to Use |
|---|---|---|
| Split | USDCe → 1 Yes token + 1 No token | Create inventory for market making |
| Merge | 1 Yes token + 1 No token → USDCe | Exit positions, reclaim collateral |
| Redeem | Winning token → $1 USDCe | After market resolution |
- Split: https://docs.polymarket.com/developers/CTF/split.md
- Merge: https://docs.polymarket.com/developers/CTF/merge.md
- Redeem: https://docs.polymarket.com/developers/CTF/redeem.md
- Deployment & addresses: https://docs.polymarket.com/developers/CTF/deployment-resources.md
Builder是将Polymarket集成到自有应用中的第三方开发者。该计划提供无权限集成、分级请求限制、奖励及盈利机会。
Builder凭证与用户凭证是相互独立的。你可以使用Builder凭证对订单进行标记/归因,但每个用户仍需自己的L2凭证才能交易。
Builder Program
做市商相关
Builders are third-party developers who integrate Polymarket into their apps. The program offers permissionless integration with tiered rate limits, rewards, and revenue opportunities.
| Resource | URL |
|---|---|
| Builder Introduction | https://docs.polymarket.com/developers/builders/builder-intro.md |
| Builder Profile & Keys | https://docs.polymarket.com/developers/builders/builder-profile.md |
| Builder Tiers | https://docs.polymarket.com/developers/builders/builder-tiers.md |
| Order Attribution | https://docs.polymarket.com/developers/builders/order-attribution.md |
| Builder Methods | https://docs.polymarket.com/developers/CLOB/clients/methods-builder.md |
| Relayer Client (gasless txns) | https://docs.polymarket.com/developers/builders/relayer-client.md |
| Examples (Next.js) | https://docs.polymarket.com/developers/builders/examples.md |
Builder credentials are separate from user credentials. You use builder credentials to tag/attribute orders, but each user still needs their own L2 credentials to trade.
Market Making
使用技巧
- 始终先查看:https://docs.polymarket.com/llms.txt包含所有端点和指南。
llms.txt - 切勿硬编码私钥 — 使用环境变量或安全密钥存储。
- 价格代表概率(0.00–1.00)。获胜代币可兑换为1 USDCe。
- 查询事件时使用,仅获取可交易的活跃市场。
active=true&closed=false - 代币ID来自Gamma API — 从Gamma API获取事件/市场,然后使用进行CLOB查询和交易。
clobTokenIds - 正确设置— 多结果事件采用负风险。检查事件的
negRisk字段,并在创建订单时传入该参数。negRisk - 使用SDK而非手动签名 — L1/L2签名逻辑复杂(EIP-712 + HMAC-SHA256)。TypeScript和Python客户端已处理好这些逻辑。
- 必须设置授权额度 — 下达订单前,资金方地址必须为Exchange合约设置USDCe授权额度(买入时)或条件代币授权额度(卖出时)。
- 结合REST与WebSocket使用 — 使用REST获取初始状态,使用WebSocket获取实时增量更新。
- 遵守请求限制 — 被限流时实现退避机制。使用批量端点(,
/books)减少请求次数。/prices - 签名类型很重要 — 独立钱包使用类型(EOA),大多数Polymarket.com用户使用类型
0(Gnosis Safe)。签名类型错误会导致认证失败。2 - 代理钱包的资金方≠签名者 — 资金方地址是代理钱包地址(可在polymarket.com/settings查看),而非私钥对应的EOA地址。
- 存在地域限制 — 交易前请查看https://docs.polymarket.com/developers/CLOB/geoblock.md。
- 订单有效性会被持续监控 — 余额、授权额度和链上取消操作会被实时检查。滥用会导致被列入黑名单。
Usage Tips
错误处理
- Always check first: https://docs.polymarket.com/llms.txt has every endpoint and guide.
llms.txt - Never hardcode private keys — use environment variables or secure key storage.
- Prices are probabilities (0.00–1.00). Winning tokens redeem at $1 USDCe.
- Use when querying events to get only live, tradable markets.
active=true&closed=false - Token IDs come from Gamma — fetch events/markets from Gamma API, then use for CLOB queries and trading.
clobTokenIds - Set correctly — multi-outcome events use negative risk. Check the event's
negRiskfield and pass it when creating orders.negRisk - Use the SDK instead of signing manually — L1/L2 signing is complex (EIP-712 + HMAC-SHA256). The TypeScript and Python clients handle this.
- Allowances must be set — before placing orders, the funder address must have USDCe allowance set for the Exchange contract (buying) or conditional token allowance (selling).
- Combine REST + WebSocket — use REST for initial state and WebSocket for real-time deltas.
- Respect rate limits — implement backoff when throttled. Use batch endpoints (,
/books) to reduce request count./prices - Signature type matters — type (EOA) for standalone wallets, type
0(Gnosis Safe) for most Polymarket.com accounts. Incorrect type will cause auth failures.2 - Funder ≠ Signer for proxy wallets — the funder is the proxy wallet address (visible at polymarket.com/settings), not the private key's EOA address.
- Geographic restrictions apply — check https://docs.polymarket.com/developers/CLOB/geoblock.md before trading.
- Order validity is continuously monitored — balances, allowances, and on-chain cancellations are checked in real time. Abuse leads to blacklisting.
采用标准HTTP错误码。API会返回包含描述性信息的JSON错误体。
- 请求被限流:请求会被延迟/排队,而非立即拒绝。请实现退避机制。
- 认证错误:验证私钥、签名类型、资金方地址和API凭证是否匹配。
- 余额不足:检查资金方地址是否有足够的USDCe或条件代币,包括未成交订单的占用额度。
- 订单被拒绝:最大订单量 = (按市场计算)。
余额 - sum(未成交订单量 - 已成交量) - 地域限制:受限地区无法进行交易。
Error Handling
市场结算
Standard HTTP error codes apply. The API returns JSON error bodies with descriptive messages.
- Throttled requests (rate limited): Requests are delayed/queued, not immediately rejected. Implement backoff.
- Authentication errors: Verify private key, signature type, funder address, and API credentials match.
- Insufficient balance: Check funder address has enough USDCe or conditional tokens, including existing open order commitments.
- Order rejected: Max order size = per market.
balance - sum(openOrderSize - fillAmount) - Geographic restriction: Trading blocked from restricted regions.
市场由UMA乐观预言机进行结算,这是一个基于智能合约的乐观预言机。结算结果可通过UMA协议提出异议。
- 结算概述: https://docs.polymarket.com/developers/resolution/UMA.md
- 市场如何结算: https://docs.polymarket.com/polymarket-learn/markets/how-are-markets-resolved.md
- 如何对结算结果提出异议: https://docs.polymarket.com/polymarket-learn/markets/dispute.md
Resolution
链上资源
Markets are resolved by the UMA Optimistic Oracle, a smart-contract-based optimistic oracle. Resolution can be disputed via the UMA protocol.
- Resolution overview: https://docs.polymarket.com/developers/resolution/UMA.md
- How markets are resolved: https://docs.polymarket.com/polymarket-learn/markets/how-are-markets-resolved.md
- How markets are disputed: https://docs.polymarket.com/polymarket-learn/markets/dispute.md
| 资源 | URL |
|---|---|
| Exchange合约源码 | GitHub |
| Exchange合约文档 | GitHub |
| 安全审计报告(Chainsecurity) | 审计PDF |
| 负风险适配器 | Polygonscan |
| Subgraph概述 | https://docs.polymarket.com/developers/subgraph/overview.md |
| 区块链数据资源 | https://docs.polymarket.com/developers/builders/blockchain-data-resources.md |
| Polygon上的USDC | |
On-Chain Resources
更新日志
| Resource | URL |
|---|---|
| Exchange contract source | GitHub |
| Exchange contract docs | GitHub |
| Security audit (Chainsecurity) | Audit PDF |
| Negative Risk Adapter | Polygonscan |
| Subgraph overview | https://docs.polymarket.com/developers/subgraph/overview.md |
| Blockchain data resources | https://docs.polymarket.com/developers/builders/blockchain-data-resources.md |
| USDC on Polygon | |
请关注Polymarket更新日志,了解CLOB、API、UI及移动应用的更新内容。
Changelog
—
Monitor the Polymarket Changelog for updates to the CLOB, API, UI, and mobile applications.
—