The Polymarket CLOB API provides programmatic access to Polymarket’s central limit order book, enabling automated trading strategies on prediction markets. It allows developers to create, manage, and cancel orders programmatically while streaming real-time market data through WebSocket connections.
TL;DR
- The Polymarket CLOB API provides direct access to the order book for sophisticated trading automation
- Authentication requires EIP-712 wallet signing and careful security practices
- The official @polymarket/clob-client library handles most complexity
- Liquidity varies significantly across markets requiring adaptive strategies
- Automation provides scalability, not guaranteed profits
- Primary costs are gas fees and capital risk, not API access fees
Key takeaways
- The Polymarket CLOB API provides direct programmatic access to prediction market trading
- Security requires dedicated wallets and proper EIP-712 signature implementation
- Real-time data streaming via WebSocket is essential for serious trading operations
- Bankroll management must adapt to varying liquidity across different markets
- Automation amplifies strategic edges but doesn’t create them inherently
What Is the Polymarket CLOB API?
A Central Limit Order Book (CLOB) is a system that matches buy and sell orders based on price and time priority—the foundation of most traditional and crypto exchanges. The Polymarket CLOB API provides programmatic access to this engine for their prediction markets.
Think of it this way: the Polymarket website is a user-friendly interface built on top of this API. By using the API directly, you bypass the UI and interact with the core trading system. You can submit limit orders, cancel existing orders, pull real-time market data, and check account balances and positions.
This is not a read-only or simplified data API. It’s a full trading interface where your code acts as a trader.
Why It Matters for Operators in 2026
In 2026, prediction markets have matured beyond novelty. They are venues for trading probabilistic outcomes on politics, finance, technology, and sports. With maturity comes professionalization.
The human speed ceiling is gone. Manually refreshing a page to scalp price movements is a losing game. The API allows millisecond reactions, simultaneous monitoring of dozens of markets, and execution of complex conditional logic.
Systematic edge is the only sustainable edge. Emotional trading on geopolitical events is a recipe for ruin. The API forces you to define your strategy in code: entry points, exit points, position size. This allows for backtesting and rigorous performance review.
The infrastructure has stabilized. As of 2026, the @polymarket/clob-client library and associated documentation have matured. Early adapter pain points—frequent breaking changes, sparse examples—have largely been resolved.
Core Mechanics: How the API Works
The API follows a standard HTTP/WebSocket model with a critical twist: every state-changing request must be cryptographically signed by your Ethereum wallet.
Connection and authentication require signing EIP-712 structured data messages. This proves wallet ownership without exposing private keys to the server. Your API key and signature are sent with each request.
The API supports essential order types for precise control: Good Till Cancel (GTC), Good Till Date (GTD), Fill or Kill (FOK), and Fill and Kill (FAK). Each serves specific strategic purposes in prediction markets.
| Order Type | Acronym | Best Use Case |
|---|---|---|
| Good Till Cancel | GTC | Resting orders for target prices expected to hit eventually |
| Good Till Date | GTD | Betting on outcomes before specific deadlines |
| Fill or Kill | FOK | Immediate all-or-nothing execution needs |
| Fill and Kill | FAK | Quick entry/exit when exact size isn’t critical |
Market data flows through HTTP APIs for snapshots and WebSocket endpoints for real-time streaming. When markets resolve, positions in YES or NO tokens automatically settle to $1 or $0.
Setup: Authentication and Wallet Security
This is the most critical phase. Mistakes here can lead to drained wallets.
Start with a dedicated wallet. Never use your main wallet with significant assets. Create a new, separate Ethereum wallet specifically for API trading. Fund it only with the USDC you’re willing to risk on Polymarket.
Acquire your API key through the Polymarket website while connected with your dedicated trading wallet. You’ll receive a public API key and a secret passphrase. The secret is used for L2 authentication but is not your private key.
Understanding EIP-712 signing is essential. The @polymarket/clob-client library handles this, but you must understand the process. When creating an order, the library builds a structured data object containing market ID, price, size, and other parameters. It then uses your wallet’s private key to sign this data according to the EIP-712 standard.
Critical security checklist: Never hardcode private keys or use insecure storage. Use hardware security modules or cloud key management services for production. For development, use environment variables with strict permissions excluded from version control.
Creating and Managing Orders: A Practical Walkthrough
Start by installing the required packages:
npm install @polymarket/clob-client ethers
Here’s a basic script to post a GTC limit order:
import { ClobClient, Side, OrderType } from '@polymarket/clob-client';
import { Wallet } from 'ethers';
// Configuration from environment variables
const RPC_URL = process.env.RPC_URL;
const PRIVATE_KEY = process.env.TRADING_WALLET_PRIVATE_KEY;
const API_KEY = process.env.POLYMARKET_API_KEY;
// Initialize client
const wallet = new Wallet(PRIVATE_KEY);
const clobClient = new ClobClient(
'https://clob.polymarket.com',
'polygon',
{ signer: wallet, apiKey: API_KEY }
);
// Define order parameters
const marketId = '0x...'; // Market contract address
const order = {
tokenID: marketId,
price: 0.65,
side: Side.BUY,
size: 100,
feeRateBps: 0,
orderType: OrderType.GTC,
nonce: Date.now()
};
// Post the order
async function postOrder() {
try {
const signedOrder = await clobClient.createOrder(order);
const response = await clobClient.postOrder(signedOrder);
console.log('Order Posted Successfully:', response);
} catch (error) {
console.error('Failed to post order:', error);
}
}
postOrder();
Key implementation notes: Use clobClient.getMarkets() to find market IDs. Cancel orders using the order ID from post responses. Implement robust error handling and retry logic for network issues.
Streaming Market Data via WebSocket
Polling HTTP APIs is inefficient and rate-limited. Serious trading requires WebSocket feeds for real-time data.
import WebSocket from 'ws';
const WS_URL = 'wss://clob.polymarket.com/ws';
const ws = new WebSocket(WS_URL);
ws.on('open', () => {
const subscribeMsg = {
type: 'subscribe',
channel: 'l2_book',
id: 'YOUR_MARKET_ID_HERE'
};
ws.send(JSON.stringify(subscribeMsg));
});
ws.on('message', (data) => {
const message = JSON.parse(data.toString());
if (message.channel === 'l2_book') {
const bestBid = message.payload.bids[0];
const bestAsk = message.payload.asks[0];
const spread = bestAsk[0] - bestBid[0];
console.log(`Spread: ${spread.toFixed(4)}`);
}
});
Use case: A simple market maker bot can subscribe to l2_book, calculate mid-price, place buy orders below and sell orders above mid-price, earning the spread while managing inventory risk.
Polymarket API vs. Alternatives: A Clear Comparison
| Platform | Interface | Primary Use Case | Liquidity Depth | Technical Overhead |
|---|---|---|---|---|
| Polymarket CLOB API | Direct CLOB Access | Sophisticated automation | High on major events | High |
| Polymarket UI/Website | Graphical Interface | Manual trading | Same as API | None |
| Manifold Markets API | Simplified REST API | Custom UIs, basic automation | Generally lower | Low to Medium |
| Augur v2 | Decentralized Protocol | Censorship-resistant markets | Fragmented, often low | Very High |
| Betfair Exchange API | Traditional Sportsbook CLOB | Sports betting automation | Extremely high for sports | High |
Choose Polymarket’s API if your edge is in speed and algorithmic execution on crypto-native, event-driven markets. It’s the most direct path to professional trading on these instruments.
Essential Tools and Your Implementation Path
Development requires Node.js environment with TypeScript strongly recommended. The library has good type definitions that catch errors at compile time.
Polymarket doesn’t offer a public testnet. Your best options are dry-run logging or paper trading with microscopic amounts to validate your stack without material risk.
For backtesting, build your own historical data pipeline by recording WebSocket feeds continuously. This data is invaluable for strategy development.
Production deployment requires a low-cost Linux VPS close to Polymarket’s servers (likely AWS us-east-1) to reduce latency. Use process management tools like pm2 or systemd to keep scripts running. Implement comprehensive logging and monitoring for API errors, WebSocket disconnections, and wallet balance changes.
Monetization: Turning API Access into a P&L
Automation doesn’t create profit by itself. It amplifies your strategic edge. Concrete approaches include statistical arbitrage, liquidity provision, and news-based trading.
Statistical arbitrage identifies correlated markets. If Trump to win election is at 0.60 and Republican to win election is at 0.58, a 0.02 spread exists. Your bot can simultaneously buy the undervalued contract and sell the overvalued one, locking in the spread regardless of outcome.
Liquidity provision places bids and offers around current prices to earn spreads. Earnings are the difference between buy and sell prices multiplied by volume. Risk: sharp market moves leaving large losing positions requiring stop-loss systems.
News sniping monitors news feeds for keywords related to active markets. Upon triggers, bots immediately place FOK orders to get in before market adjustments. This is high-risk and latency-competitive.
Bankroll sizing rule: Never risk more than 1-2% of total dedicated trading capital on a single market position. Prediction markets can gap dramatically—position sizes must be survivable.
Risks, Pitfalls, and Security Non-Negotiables
Technical risks include smart contract risk (interacting with Polymarket’s audited but potentially buggy contracts), gas price volatility burning through funds during network congestion, API reliability issues with WebSocket disconnections, and logic bugs causing immediate losses.
Market risks include illiquidity preventing fair price exits, resolution disputes or delays locking funds, and regulatory uncertainty affecting access or withdrawals.
The number one pitfall: Overestimating your edge and undersizing your bankroll. Most new operators deploy with too much capital and are wiped out by the first real-world scenario their model didn’t capture.
Myths vs. Facts About Prediction Market Automation
Myth: A perfectly coded market-making bot is free money from the spread.
Fact: It’s picking up pennies in front of a steamroller. You earn small spreads but take large asymmetric risk if markets trend.
Myth: Backtesting guarantees future performance.
Fact: Backtesting shows how strategies would have performed historically. It doesn’t account for future structural changes or unique events.
Myth: The API gives you an unfair advantage over regular users.
Fact: It gives you parity with other automated traders. Advantage comes from strategy, execution speed, and risk management.
Myth: You need high-frequency trading setups to compete.
Fact: For most Polymarket events, sub-second latency is fine. Focus on robust logic over nanosecond optimizations.
FAQ: Answering the Real Operator Questions
Q: What are the actual rate limits?
A: Public endpoints have limits (e.g., 120 requests per minute). Authenticated endpoints are more permissive but can throttle under heavy load. Use WebSockets for data and implement efficient request patterns.
Q: Can I run multiple bots from one wallet/API key?
A: Technically yes, but risk nonce collisions. Implement centralized nonce management or use separate wallets for each bot.
Q: How do I handle USDC deposits for my bot?
A: Your bot’s wallet needs USDC on Polygon. Bridge from Ethereum or buy directly. Start with manual lump-sum funding; automating deposits adds complexity.
Q: Is there a fee for using the API?
A: No direct fee. Pay Polygon gas for transactions and Polymarket’s built-in trading fee (1-2%) automatically deducted from fills.
Q: My order isn’t filling. What should I check?
A: Check price realism against live order book, sufficient USDC balance, correct tokenID for YES/NO, and market expiration/resolution status.
Actionable Next Steps: Your First Script in 30 Minutes
- Create new directory:
mkdir poly-bot && cd poly-bot - Initialize project:
npm init -y - Install packages:
npm install @polymarket/clob-client ethers dotenv - Create .env file with PRIVATE_KEY, RPC_URL, and API_KEY (add to .gitignore)
- Copy order posting example from earlier section
- Replace marketId with real ID from small active market
- Set aggressive price for high fill probability and size to 1 ($0.50 risk)
- Run:
node index.jsand check Polymarket UI
You’ve executed your first automated trade. Now build toward a system that manages risk, reacts to markets, and runs unsupervised.
Glossary of Key Terms
CLOB (Central Limit Order Book): A record of buy and sell limit orders organized by price and time for trade matching.
EIP-712: Ethereum standard for signing structured, human-readable data used for Polymarket authentication.
Market ID / Token ID: Unique smart contract address representing specific outcomes on Polymarket.
GTC/GTD/FOK/FAK: Order duration and execution types (Good Till Cancel, Good Till Date, Fill or Kill, Fill and Kill).
Mid-Price: Theoretical price between best bid and ask: (bestBid + bestAsk) / 2.
Spread: Difference between best ask and bid representing immediate trading cost.
Notional Value: Total position value: Size * Price.
Liquidity: Order book depth with large orders close to mid-price being liquid.
Paper Trading: Running systems with real data but minimal capital for validation.