Skip to main content

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.

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.
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


Authentication

Gamma API (no auth)

Public endpoints require no authentication. Just make the request:

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.

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

Setup

Common operations

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.
Query parameters:

Get a market by slug (Gamma API)

Get order book (CLOB API)

Returns the full order book for a token. Requires HMAC authentication.
Response structure:

Get positions (CLOB API)


Market data format

The Gamma API returns market objects with these key fields: Example response:

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

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

Rate limits and fees

Rate limits

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: 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.

What the intelligence layer adds

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.