Polymarket API
Polymarket exchange mechanics, on-chain Polygon CTF, Gamma/CLOB/Data APIs, EIP-712...
Install
npx skills add agiprolabs/claude-trading-skills --skill polymarket-api -g -a claude-code -y- Repository
- agiprolabs/claude-trading-skills507
- Category
- Engineering
- Updated
- 2mo ago
- License
- MIT
- Context cost
- Mediumabout 1,536 tokens
- Runs scripts
- No, instructions only
What it does
Polymarket exchange mechanics, on-chain Polygon CTF, Gamma/CLOB/Data APIs, EIP-712 auth, identifier model, WebSocket, settlement, and geo/KYC constraint
Polymarket API
Polymarket is a prediction market on Polygon mainnet. Every market is a pair of YES/NO ERC-1155 tokens issued by the Conditional Token Framework (CTF), collateralized 1:1 in USDC. Off-chain CLOB matching, on-chain settlement, zero taker fees. Prices are in [0.00, 1.00] USDC; YES + NO ≈ 1.0 per market.
Before you write any API code, read the live docs first.
- Docs: https://docs.polymarket.com
- Official Python SDK: https://github.com/Polymarket/py-clob-client
Polymarket endpoints and auth flows have changed without notice. Prefer the official
py-clob-clientSDK over hand-rolled HTTP; it handles EIP-712 derivation, API credential management, and order signing. Only hand-roll when the SDK doesn't expose what you need.
Identifier model
You will juggle four distinct IDs, get them confused and queries silently return wrong data.
| ID | What it is |
|---|---|
condition_id | On-chain hex ID of the market (the CTF condition) |
clob_token_ids | The YES/NO pair of ERC-1155 token IDs, a two-element list |
token_id | A single outcome token, what you pass to order-book and WebSocket queries |
event_id | Parent grouping (e.g. all brackets for "NYC high today") |
Quick Start
1. Read markets, Gamma API (no auth required)
import httpx
# CRITICAL: default sort is OLDEST-first, always override or you silently get closed markets
events = httpx.get("https://gamma-api.polymarket.com/events", params={
"tag_id": 103040, # category tag (e.g. weather)
"order": "endDate",
"ascending": "false", # must be string "false", not bool
"closed": "false",
}).json()
