Skip to main content
import httpx

# Fetch the top Polymarket markets by 24-hour volume
resp = httpx.get("https://gamma-api.polymarket.com/markets", params={
    "limit": 10,
    "active": True,
    "order": "volume24hr",
    "ascending": False,
})

for market in resp.json():
    yes_price = market["outcomePrices"][0] if market.get("outcomePrices") else "N/A"
    print(f"{market['question']} | YES: {yes_price} | Vol: ${float(market.get('volume24hr', 0)):,.0f}")

What this page covers

  • Architecture — Two separate APIs (Gamma for discovery, CLOB for trading) and when to use each
  • Authentication — HMAC-SHA256 signing for the CLOB API, public access for Gamma
  • py-clob-client SDK — Official Python SDK installation, setup, and usage
  • Core endpoints — Market listing, order books, placing orders, and positions
  • Data model — Condition IDs, token IDs, and how they relate to each other
  • Rate limits and fees — What to expect when building on Polymarket
  • Gaps in the raw API — What Polymarket doesn’t give you and how to fill those gaps

Overview

Polymarket is the largest crypto-native prediction market by trading volume, built on the Polygon blockchain. Markets settle in USDC, outcomes are binary (Yes/No), and prices represent implied probabilities — a Yes price of $0.65 means the market prices the event at 65% likely. Key architectural facts:
  • Order matching — Central Limit Order Book (CLOB), not AMM
  • Market identifiers — condition IDs (hex strings) for events, token IDs for individual outcomes
  • Two separate APIs — Gamma (discovery/metadata, public) and CLOB (trading, authenticated)
If you just need normalized market data across platforms without dealing with two APIs and HMAC signing, see the Rekko Markets API.

Architecture: two APIs

Polymarket splits its API into two completely separate services. Understanding which one to use for what is the first thing that trips up most developers.

Gamma Markets API

Base URL: https://gamma-api.polymarket.com The Gamma API is the read-only discovery layer. Use it to browse markets, get metadata, and check prices.
AspectDetail
AuthenticationNone required
PurposeMarket discovery, metadata, prices, volume
Rate limitsNo published limit (reasonable use expected)
Data freshnessNear real-time

CLOB API

Base URL: https://clob.polymarket.com The CLOB API handles all trading operations. It requires API key authentication with HMAC-SHA256 request signing.
AspectDetail
AuthenticationAPI key + HMAC-SHA256 signature
PurposeOrder placement, cancellation, positions, order book depth
Rate limitsVaries by endpoint
SettlementUSDC on Polygon (chain ID 137)
If you only need to read market data and prices, you can skip CLOB authentication entirely and use the Gamma API.

Choosing the right API

TaskAPIAuth required
List marketsGammaNo
Get current pricesGammaNo
Check market volumeGammaNo
Get order book depthCLOBYes
Place a limit orderCLOBYes
Cancel an orderCLOBYes
View open positionsCLOBYes
Check trade historyCLOBYes

Authentication

Gamma API (no auth)

Public endpoints require no authentication. Just make the request:
curl "https://gamma-api.polymarket.com/markets?limit=5&active=true"

CLOB API (HMAC-SHA256)

Trading endpoints require three headers on every request: your API key, a Unix timestamp, and an HMAC-SHA256 signature over the request details. You generate API credentials from your Polymarket account. The secret is used to sign requests but is never sent over the wire.
TIMESTAMP=$(date +%s)
METHOD="GET"
PATH="/markets"
BODY=""
MESSAGE="${TIMESTAMP}${METHOD}${PATH}${BODY}"
SIGNATURE=$(echo -n "$MESSAGE" | openssl dgst -sha256 -hmac "$POLYMARKET_SECRET" | cut -d' ' -f2)

curl "https://clob.polymarket.com/markets" \
  -H "POLY-API-KEY: $POLYMARKET_API_KEY" \
  -H "POLY-TIMESTAMP: $TIMESTAMP" \
  -H "POLY-SIGNATURE: $SIGNATURE"

py-clob-client SDK

Polymarket publishes an official Python SDK that wraps the CLOB API and handles authentication, order signing, and the Conditional Token Framework (CTF) interactions.

Installation

pip install py-clob-client

Setup

from py_clob_client.client import ClobClient

client = ClobClient(
    host="https://clob.polymarket.com",
    key="YOUR_API_KEY",
    chain_id=137,  # Polygon mainnet
)

Common operations

# List available markets
markets = client.get_markets()

# Get order book for a specific token
book = client.get_order_book(token_id="YOUR_TOKEN_ID")
print(f"Best bid: {book.bids[0].price if book.bids else 'none'}")
print(f"Best ask: {book.asks[0].price if book.asks else 'none'}")

# Place a limit buy order
order = client.create_and_post_order(
    token_id="YOUR_TOKEN_ID",
    price=0.65,      # Price per share in USDC
    size=100,         # Number of shares
    side="BUY",
)
print(f"Order ID: {order['orderID']}")

# Cancel an order
client.cancel(order_id="YOUR_ORDER_ID")

# Get open orders
open_orders = client.get_orders()

# Get positions
positions = client.get_positions()
Trading on Polymarket requires USDC on the Polygon network and CTF (Conditional Token Framework) approval. The SDK handles CTF interactions, but you must have funded your Polygon wallet with USDC first.

Core endpoints

List markets (Gamma API)

Fetch active markets sorted by volume. No authentication required.
curl "https://gamma-api.polymarket.com/markets?limit=10&active=true&order=volume24hr&ascending=false"
Query parameters:
ParameterTypeDescription
limitintegerMax results to return
activebooleanFilter to active markets
orderstringSort field (volume24hr, volume, liquidity, endDate)
ascendingbooleanSort direction
tagstringFilter by category tag

Get a market by slug (Gamma API)

import httpx

slug = "will-bitcoin-hit-100k-2026"
resp = httpx.get(f"https://gamma-api.polymarket.com/markets/{slug}")
market = resp.json()
print(f"{market['question']} — condition: {market['conditionId']}")

Get order book (CLOB API)

Returns the full order book for a token. Requires HMAC authentication.
# See authentication section for $HEADERS
curl "https://clob.polymarket.com/book?token_id=YOUR_TOKEN_ID" \
  -H "POLY-API-KEY: $POLYMARKET_API_KEY" \
  -H "POLY-TIMESTAMP: $TIMESTAMP" \
  -H "POLY-SIGNATURE: $SIGNATURE"
Response structure:
{
  "bids": [
    { "price": "0.65", "size": "500" },
    { "price": "0.64", "size": "1200" }
  ],
  "asks": [
    { "price": "0.66", "size": "300" },
    { "price": "0.67", "size": "800" }
  ]
}

Get positions (CLOB API)

headers = sign_request("GET", "/positions")
resp = httpx.get("https://clob.polymarket.com/positions", headers=headers)
positions = resp.json()

for pos in positions:
    print(f"Token: {pos['asset']['token_id']} | Size: {pos['size']} | Avg: ${pos['avg_price']}")

Market data format

The Gamma API returns market objects with these key fields:
FieldTypeDescription
questionstringThe market question (e.g., “Will Bitcoin exceed $100k in 2026?”)
conditionIdstringHex condition ID — primary identifier for the event
slugstringURL-safe slug for the market page
outcomesstring[]Outcome labels, typically ["Yes", "No"]
outcomePricesstring[]Current prices per outcome (e.g., ["0.65", "0.35"])
volumestringTotal lifetime volume in USDC
volume24hrnumberRolling 24-hour trading volume
liquiditystringAvailable liquidity in the order book
endDatestringISO 8601 resolution date
activebooleanWhether trading is currently open
descriptionstringMarkdown description of the market and resolution criteria
tagsstring[]Category tags (e.g., ["politics", "elections"])
clobTokenIdsstring[]CLOB token IDs for each outcome
Example response:
{
  "question": "Will the Fed cut rates in Q2 2026?",
  "conditionId": "0xabc123...def456",
  "slug": "will-the-fed-cut-rates-q2-2026",
  "outcomes": ["Yes", "No"],
  "outcomePrices": ["0.62", "0.38"],
  "volume": "2450000",
  "volume24hr": 185000,
  "liquidity": "340000",
  "endDate": "2026-06-30T23:59:59Z",
  "active": true,
  "clobTokenIds": ["0x111...aaa", "0x222...bbb"]
}

Condition IDs and token IDs

This is the concept that confuses most developers new to Polymarket. There are two types of identifiers, and they serve different purposes.

Condition ID

The condition ID identifies an event (market). It’s a hex string derived from the market’s oracle and question parameters.
  • One per market
  • Used in the Gamma API to look up metadata
  • Does not appear in trading requests

Token ID

Each market outcome has a token ID. A standard binary market has two token IDs: one for Yes, one for No.
  • Used in the CLOB API for trading and order book queries
  • Tied to ERC-1155 tokens on Polygon
  • Found in the Gamma API clobTokenIds array

How they relate

Market (condition ID: 0xabc...123)
  |
  +-- Yes outcome (token ID: 0x111...aaa)
  |
  +-- No outcome (token ID: 0x222...bbb)
To go from discovery to trading:
  1. Browse markets via the Gamma API (get the conditionId)
  2. Extract the clobTokenIds from the Gamma response
  3. Use the token ID for the outcome you want in CLOB API trading calls
import httpx

# 1. Discover a market
resp = httpx.get("https://gamma-api.polymarket.com/markets", params={
    "limit": 1, "active": True, "order": "volume24hr", "ascending": False,
})
market = resp.json()[0]
condition_id = market["conditionId"]
yes_token_id = market["clobTokenIds"][0]  # Index 0 = Yes outcome
no_token_id = market["clobTokenIds"][1]   # Index 1 = No outcome

print(f"Market: {market['question']}")
print(f"Condition ID: {condition_id}")
print(f"Yes token: {yes_token_id}")
print(f"No token: {no_token_id}")

# 2. Get order book for the Yes outcome
headers = sign_request("GET", "/book")
book = httpx.get("https://clob.polymarket.com/book", headers=headers, params={
    "token_id": yes_token_id,
}).json()

Rate limits and fees

Rate limits

APILimitNotes
Gamma (public reads)No published limitPolymarket expects reasonable usage; aggressive polling may be throttled
CLOB (authenticated)Varies by endpointOrder placement has stricter limits than reads

Fees and settlement

Maker and taker fees are low and vary by market. Polymarket’s fee structure has evolved over time — check their official docs for the latest schedule. All positions settle in USDC on Polygon (chain ID 137). Winning shares pay 1.00,losingsharespay1.00, losing shares pay 0.00. Resolution uses the UMA Optimistic Oracle. Gas costs are minimal (typically < $0.01 per transaction).

What the raw Polymarket API does not provide

The Gamma and CLOB APIs cover market data and trade execution. But if you are building a trading bot or research tool, several things are missing:
GapWhy it matters
Independent probability estimatesYou only see market consensus, not whether the market is mispriced
Cross-platform comparisonNo way to compare Polymarket prices against Kalshi or Robinhood
Position sizing guidanceNo Kelly criterion or bankroll management
Arbitrage detectionNo built-in way to find price divergences across platforms
Causal analysisNo breakdown of why prices move — just the price itself
Resolution intelligenceNo prediction of when or how a market will resolve
Screening and filteringBasic sorting, but no AI-powered market screening for edge
Historical calibrationNo way to know if the market price is systematically biased
These gaps are where a dedicated intelligence layer adds value on top of the raw exchange API.

Adding intelligence to Polymarket data

You can layer AI-powered analysis on top of Polymarket by routing market data through an intelligence API. Here is a complete example that discovers markets on Polymarket, runs an independent analysis, and checks for cross-platform arbitrage.
# List Polymarket markets
curl "https://api.rekko.ai/v1/markets?source=polymarket&limit=5" \
  -H "Authorization: Bearer YOUR_REKKO_API_KEY"

# Trigger analysis
curl -X POST "https://api.rekko.ai/v1/markets/polymarket/0xabc123.../analyze" \
  -H "Authorization: Bearer YOUR_REKKO_API_KEY"

# Get completed analysis (poll status first, then retrieve)
curl "https://api.rekko.ai/v1/markets/polymarket/0xabc123.../analysis" \
  -H "Authorization: Bearer YOUR_REKKO_API_KEY"

# Check for cross-platform arbitrage
curl "https://api.rekko.ai/v1/arbitrage?min_spread=0.02" \
  -H "Authorization: Bearer YOUR_REKKO_API_KEY"

What the intelligence layer adds

CapabilityRaw PolymarketWith Rekko
Market pricesYesYes (normalized across platforms)
Order book depthYes (CLOB API)Not proxied — use CLOB directly
Independent probability estimatesNoYes
Edge detectionNoYes (probability - market_price)
Causal decompositionNoYes (what drives the probability)
Cross-platform arbitrageNoYes (Polymarket vs Kalshi vs Robinhood)
Position sizing (Kelly)NoYes
Resolution intelligenceNoYes (time decay, key dates)
Market screeningBasic sort/filterAI-powered screening for mispricing
Historical calibrationNoYes (track accuracy over time)
You do not need to choose between the Polymarket API and an intelligence API. Use Polymarket’s CLOB directly for trade execution, and an intelligence API for analysis and decision-making.

Common pitfalls

Mixing up condition IDs and token IDs. Condition IDs identify the market. Token IDs identify specific outcomes (Yes/No). Trading endpoints use token IDs, not condition IDs. Forgetting the two-API split. If you call gamma-api.polymarket.com for order book data, you will not find it. Order books live on clob.polymarket.com. Stale outcomePrices from the Gamma API. The Gamma API prices may lag behind the live order book by a few seconds. For latency-sensitive applications, read the order book directly from the CLOB API. USDC and Polygon wallet setup. Before you can trade, you need USDC on the Polygon network (chain ID 137) and must approve the CTF contract. The py-clob-client SDK handles CTF approval, but wallet funding is on you. No sandbox environment. Polymarket does not offer a testnet or paper trading mode. To test order placement, you are working with real funds. Use very small order sizes when developing.

What’s next

Kalshi API guide

The other major prediction market. Different auth model, same concepts.

Build a trading bot

End-to-end tutorial for an automated prediction market trading bot.

API comparison

Side-by-side comparison of Polymarket, Kalshi, and Robinhood APIs.

Cross-platform arbitrage

Find and exploit price differences across platforms.

Rekko API reference

Full endpoint documentation with interactive playground.