All posts
API ReferencePolymarket APICLOBGamma API

The Polymarket API, Mapped: Gamma vs CLOB vs Data API

Newcomers lose a day to the same problem: Polymarket does not have an API, it has four of them, and the endpoint you want is rarely on the one you tried first. This is the complete map.

10 min read

The first thing to understand about the Polymarket API is that there is no such thing. There are four REST APIs and four WebSocket streams, each serving a distinct part of an integration, each on its own hostname, with its own rate limits and its own auth requirements.

Almost every "the Polymarket API doesn't have X" question turns out to be "X is on a different host". Here is the whole surface in one place.

The four REST APIs

APIBase URLWhat it is forAuth
Gammagamma-api.polymarket.comDiscover events and markets; metadataNone
CLOBclob.polymarket.comPrices, order books, placing and managing ordersNone to read, L1/L2 to trade
Datadata-api.polymarket.comPositions, activity, market participationNone
Relayerrelayer-v2.polymarket.comSubmit wallet transactions without holding POL for gasSigned

Gamma API — discovery and metadata

Gamma is where you start. It answers what exists: events, the markets inside them, tags, search, and the metadata you need to work with anything else — critically, the token IDs that every CLOB endpoint requires.

  • /events — list events, with keyset pagination available
  • /markets — list markets; also by id, by slug, by token
  • /public-search — search across events and markets
  • /tags, /comments — taxonomy and discussion
  • Open interest, live volume, top holders

CLOB API — prices, books and orders

The order book itself, and the only place you can trade. Reading is public; trading needs credentials.

GroupEndpointsAuth
Order book/book, /books, /midpoint, /midpoints, /spread, /spreadsPublic
Pricing/price, /prices, /prices-history, last trade price, /tick-size, fee ratePublic
OrdersPOST /order, POST /orders, DELETE /order, /orders, /cancel-all, /cancel-market-ordersL2 + wallet signature
Ledger/trades, /data/orders, /data/trades, /notificationsL2
Auth/auth/api-key, /auth/api-keys, /auth/derive-api-keyL1
Accountbalance allowance (get / update)L2

Data API — positions and activity

Portfolio-shaped questions: /positions, /closed-positions, /trades, plus the user PNL API. Note that this is the tightest of the three main APIs — a general limit of 1,000 req / 10s, with /positions and /closed-positions at just 150 req / 10s each. It is designed for dashboards, not for polling loops.

The four WebSocket streams

If you are polling /book on a timer, stop — this is what the streams are for. Polling is the single most common way to burn a rate limit budget for no benefit.

StreamURLCarries
CLOB Marketwss://ws-subscriptions-clob.polymarket.com/ws/marketPublic order book, price and market lifecycle updates
CLOB Userwss://ws-subscriptions-clob.polymarket.com/ws/userAuthenticated order and trade updates for your account
RTDSwss://ws-live-data.polymarket.comPublic reference prices, comments, trade activity
Sportswss://sports-api.polymarket.com/wsLive game status and scores

The User channel is the one people miss. If your bot polls /data/orders to find out whether its order filled, you are paying rate limit budget for information the User channel would have pushed to you the moment it happened — and with lower latency.

Authentication: L1 and L2

Public market data needs no credentials at all — you can hit Gamma, the CLOB read endpoints and the Data API with a bare curl. Trading needs two layers, and understanding which is which resolves most auth errors.

LayerHow it worksPurpose
L1The wallet signs an EIP-712 messageProve wallet control; create or derive API credentials
L2Requests signed with API credentials using HMAC-SHA256Authenticate private CLOB requests

Order placement uses both: L2 authenticates the request, and a wallet signature authorises the order. The L1 typed data is a ClobAuth payload on chainId: 137 (Polygon), with your signer address, a Unix timestamp in seconds, a nonce (use 0 unless you are managing multiple credential sets), and the fixed message string.

Getting an API key

  1. Sign the ClobAuth EIP-712 payload with your Polygon private key.
  2. Call POST /auth/api-key with the L1 headers to create credentials. You get back a key, a secret and a passphrase — all three are required for L2.
  3. On subsequent runs, call GET /auth/derive-api-key to retrieve the existing credentials instead of creating new ones.

SDKs

Polymarket maintains unified TypeScript and Python SDKs that wrap all of the above with a typed interface and handle pagination, error shapes and wallet setup. If you are starting fresh in either language, use them — hand-rolling EIP-712 signing and HMAC request signing is a genuinely error-prone way to spend a weekend.

Go direct to REST when your runtime is not covered by an SDK, when you need exact control over signing, headers, retries or transport, or when you need an endpoint the SDK has not exposed yet. Note that these are the unified SDKs — if you are on an older client, there is a documented migration path, and older clients are where a lot of stale-credential bugs come from.

What does the Polymarket API cost?

Nothing. There is no paid tier, no API pricing page and no subscription — Polymarket's APIs are free to use, with access governed by rate limits rather than billing. Public market data does not even require a key.

The only thing that scales with money is the per-signer trading limits, which are tiered by your maker wallet's 30-day volume — from Standard at 40 order tokens/sec up to Elite at 600 — but that is a throughput allocation, not a fee.

The one thing none of these APIs will give you

Having mapped the whole surface, the useful thing to know is what is not on it: historical order book depth.

Every endpoint above serves current state. /book returns the book now. /prices-history gives you a price series, not the depth behind it — so it cannot tell you what your fill would have been. And when a market resolves it disappears from the public feeds, taking its history with it. There is no plan, key or rate limit tier that changes this.

QuestionAnswerable via Polymarket API?
What is the book right now?Yes — /book
What was the price yesterday?Partly — /prices-history, mid only
What was the depth at 14:03:17 yesterday?No
What would my 500-share order have filled at?No
Show me a market that resolved last weekNo — gone from public feeds

That gap is why backtesting a Polymarket strategy needs a separate data source that recorded the book while markets were running. PolyTest does exactly that for crypto Up/Down markets — 90M+ point-in-time snapshots with 8 levels of depth per side, sub-second timestamps, and resolved markets kept rather than dropped. One header, clean JSON, and a free tier:

curl -H "X-API-Key: $POLYTEST_KEY" \
  "https://api.polytest.io/api/v1/markets?coin=btc&market_type=5m&limit=20"

Full endpoint reference in the PolyTest docs, or start free — no card required.

Frequently asked questions

What are the Polymarket API endpoints?
Polymarket runs four REST APIs: Gamma (gamma-api.polymarket.com) for events, markets and metadata; CLOB (clob.polymarket.com) for prices, order books and trading; Data API (data-api.polymarket.com) for positions and activity; and Relayer (relayer-v2.polymarket.com) for gasless transactions. There are also four WebSocket streams covering the public market channel, the authenticated user channel, real-time data, and sports.
Is the Polymarket API free?
Yes. There is no paid tier, subscription or API pricing page — access is governed by rate limits rather than billing, and public market data requires no API key at all. The only thing that scales is the per-signer trading throughput tier, which is based on your wallet's 30-day trading volume, not on payment.
How do I get a Polymarket API key?
Sign the ClobAuth EIP-712 typed-data payload with your Polygon private key, then call POST /auth/api-key with the L1 headers to create credentials. You receive a key, secret and passphrase — all three are needed for L2 request signing. On later runs use GET /auth/derive-api-key to retrieve the existing credentials rather than creating new ones. Public market data needs no key.
What is the difference between the Gamma API and the CLOB API?
Gamma is for discovery: what events and markets exist, their metadata, and the token IDs other endpoints need. CLOB is for the order book: current prices, book depth, and placing or cancelling orders. If you need to find a market, use Gamma; if you need to price or trade one, use CLOB.
Does Polymarket have a Python SDK?
Yes. Polymarket maintains unified TypeScript and Python SDKs that cover all four REST APIs with a typed interface and handle pagination, error shapes and wallet setup. There is a documented migration path from older clients. Going direct to REST makes sense when your runtime is unsupported, you need exact control over signing and retries, or you need an endpoint the SDK has not exposed yet.
Can I get historical order book depth from the Polymarket API?
No. Every Polymarket endpoint serves current state. The /prices-history endpoint returns a mid-price series without the depth behind it, so it cannot tell you what a given order size would have filled at, and resolved markets disappear from public feeds entirely. Backtesting requires point-in-time snapshots recorded while markets were live, such as PolyTest's 90M+ snapshot archive of crypto Up/Down markets.

Get the historical data Polymarket does not keep

PolyTest records Polymarket crypto Up/Down markets as they run — 90M+ snapshots with 8 levels of order book depth, sub-second timestamps, and resolved markets preserved. Free tier, no card.

Keep reading