|
|
|
|
|
|
|
|
|
|
|
|
Loading prices...

Polymarket API Guide

A developer-focused guide to the Polymarket CLOB API. Learn how to fetch market data, read orderbooks, place orders programmatically, and build custom trading applications.

API Overview

Polymarket's trading infrastructure is powered by the CLOB (Central Limit Order Book) API. This is the same API that Polyblock and other third-party tools use to interact with Polymarket's markets.

  • REST APIFor fetching market data, orderbook snapshots, user positions, and placing orders.
  • WebSocket APIFor real-time streaming of price updates, orderbook changes, and trade events.
  • Gamma APIPolymarket's market metadata API for fetching market details, categories, and resolution info.
Info
The CLOB API is publicly documented but requires authentication for trading operations. Read-only market data endpoints are generally accessible without auth.

Authentication

To place orders via the API, you need to authenticate with your Polymarket account:

  1. 1
    Generate API credentials

    Create an API key through Polymarket's interface or derive credentials from your wallet signature.

  2. 2
    Sign requests

    Trading requests must be signed with your private key. This proves you own the wallet.

  3. 3
    Include headers

    Add your API key and signature to request headers for authenticated endpoints.

Warning
Never expose your private key or API credentials in client-side code. Always make authenticated requests from a secure backend server.

Market Data Endpoints

Key endpoints for fetching market information:

  • GET /marketsList all available markets with metadata, current prices, and volume.
  • GET /markets/{id}Get detailed information about a specific market including resolution criteria.
  • GET /pricesFetch current YES/NO prices for one or more markets.
  • GET /tradesGet recent trade history for a market — timestamps, prices, sizes.

Market Data Fields

  • condition_idUnique identifier for the market condition.
  • token_idThe token IDs for YES and NO shares (needed for placing orders).
  • outcome_pricesCurrent best bid/ask prices for each outcome.
  • volumeTotal trading volume in USDC.

Orderbook Data

The orderbook shows all pending buy and sell orders:

  • GET /bookFull orderbook snapshot with all bids and asks at every price level.
  • Bid sideAll buy orders sorted by price (highest first). Represents demand.
  • Ask sideAll sell orders sorted by price (lowest first). Represents supply.
  • DepthCumulative volume at each price level — shows where large orders are stacked.
Pro Tip
For real-time orderbook updates, use the WebSocket API instead of polling the REST endpoint. WebSocket gives you instant updates on every order change.

Placing Orders

To place orders programmatically, you need to:

  1. 1
    Build the order object

    Specify token_id, side (BUY/SELL), price, size, and order type (LIMIT/MARKET).

  2. 2
    Sign the order

    Use your private key to sign the order according to Polymarket's EIP-712 signature scheme.

  3. 3
    Submit via POST /order

    Send the signed order to the CLOB API. You'll receive an order ID and status.

  4. 4
    Monitor order status

    Check if the order was filled, partially filled, or is still pending via GET /orders.

Info
Order signing is the most complex part of the API integration. You need to implement EIP-712 typed data signing with the correct domain separator and order struct hash.

WebSocket Streaming

The WebSocket API provides real-time data streams:

  • Price channelReal-time price updates for subscribed markets.
  • Book channelOrderbook changes — new orders, cancellations, and fills.
  • Trade channelEvery trade execution as it happens.
  • User channelYour personal order updates, fills, and position changes (authenticated).

Connection

Connect to the WebSocket endpoint and subscribe to specific channels and markets. Messages are delivered as JSON with event type, market ID, and payload data.

Rate Limits

  • REST APIRate-limited per IP and per API key. Typical limits are 10-100 requests per second depending on the endpoint.
  • WebSocketConnection limits per API key. Subscribe to markets individually to manage bandwidth.
  • Order placementStricter rate limits on order submission to prevent spam. Typically 5-10 orders per second.
Warning
Exceeding rate limits will result in temporary IP bans. Implement proper rate limiting and exponential backoff in your code.

The Polyblock Alternative: No Code Required

Building a custom trading bot with the Polymarket API requires significant engineering effort — authentication, order signing, WebSocket management, error handling, and infrastructure.

Polyblock's Playground gives you the same result without writing a single line of code. Describe your strategy in plain English, and the AI builds, deploys, and runs it on Polyblock's infrastructure.

Custom API Bot

Days to weeks of development. Requires Python/JS skills, API knowledge, server infrastructure, and ongoing maintenance.

Polyblock Playground

5 minutes to deploy. Describe strategy in English. AI handles the technical setup. Runs 24/7 on Polyblock servers.

Pro Tip
Even experienced developers often prefer the Playground for rapid prototyping. Build and test ideas in minutes, then implement custom API solutions only for highly specialised needs.

Skip the API — use Playground instead

Don't want to write code? Polyblock's Playground lets you build automated strategies by chatting with AI. Same power, zero coding.