In this guide
Key takeaway: Polymarket's CLOB (Central Limit Order Book) API enables you to submit orders programmatically, consume live price feeds, and oversee your holdings. Paired with the Gamma API for market intelligence, you can construct an end-to-end automated prediction market trading bot.
Algorithmic trading belongs to everyone, not just institutional traders. The Polymarket API provides developers with complete access to the globe's premier prediction market platform. Whether your goal is to streamline a straightforward rebalancing tactic or engineer an advanced market-making system, this resource walks you through all the essentials.
API Architecture Overview
Polymarket makes available two primary APIs:
- Gamma API (
gamma-api.polymarket.com): Event catalogues, market listings, condition identifiers, and time-series price information. Openly accessible without credentials - CLOB API (
clob.polymarket.com): Order submission, removal, position tracking, and live book snapshots. Demands EIP-712 signed API credentials
Authentication
CLOB API security comprises two stages:
- L1 Authentication (EIP-712): Cryptographically sign a structured message using your Ethereum key to generate API credentials (apiKey, secret, passphrase)
- L2 Authentication (HMAC-SHA256): Sign each request using your derived credentials. The signature encodes the timestamp, HTTP verb, endpoint, and payload
Example credential derivation (JavaScript):
import { ethers } from "ethers";
const wallet = new ethers.Wallet(PRIVATE_KEY);
const domain = { name: "ClobAuthDomain", ... };
const types = { ClobAuth: [{ name: "address", type: "address" }, ...] };
const signature = await wallet.signTypedData(domain, types, value);
// POST to /auth/derive-api-key with the signature
Fetching Market Data
The Gamma API supplies all the foundational information required for your trading system:
// List active events
GET https://gamma-api.polymarket.com/events?active=true&limit=100
// Get specific market details
GET https://gamma-api.polymarket.com/markets/{conditionId}
// Historical price data
GET https://gamma-api.polymarket.com/markets/{conditionId}/prices
Placing Orders
The CLOB API accommodates market orders, limit orders, and diverse time-in-force configurations:
- GTC (Good-Till-Cancelled): Remains active in the order book until executed or withdrawn
- GTD (Good-Till-Date): Automatically terminates at a preset moment
- FOK (Fill-Or-Kill): Requires complete execution or immediate cancellation
- IOC (Immediate-Or-Cancel): Executes available quantity and discards the remainder
WebSocket Streaming
To receive live market information, establish a connection to the CLOB WebSocket channel:
// Subscribe to order book updates
ws.send(JSON.stringify({
type: "subscribe",
channel: "market",
assets_id: TOKEN_ID
}));
Building a Simple Strategy
A straightforward mean-reversion approach could operate as follows:
- Observe price movements across your chosen markets using WebSocket feeds
- Compute a trailing mean across a preceding 24-hour window
- Initiate a purchase when quotations fall 10%+ beneath the computed mean
- Exit the position once quotations recover to the mean level
- Apply Kelly criterion methodology for stake determination
Rate Limits and Best Practices
- CLOB API: 100 requests per 10 seconds per API key
- Always implement exponential backoff when receiving 429 responses
- Favour WebSocket subscriptions for live information rather than repeated polling
- Store your private key in environment configuration, never hardcode it
- Validate strategies with minimal capital before ramping positions
PolyGram members gain entry to these markets via a streamlined dashboard — API coding is entirely optional. Start trading on PolyGram →