Skip to main content
The Polymarket CLOB Client is a TypeScript SDK that provides a comprehensive interface for interacting with Polymarket’s Central Limit Order Book (CLOB). It enables developers to build automated trading strategies, market-making bots, and custom trading applications on top of Polymarket’s prediction markets.

What is the CLOB client?

The CLOB (Central Limit Order Book) Client is the primary interface for programmatic trading on Polymarket. It provides:
  • Order management: Create, post, cancel, and query orders on prediction markets
  • Market data access: Fetch real-time orderbooks, prices, trades, and market information
  • Account management: Manage API keys, check balances, and track trading activity
  • Cryptographic signing: Handle EIP-712 signatures for secure order authentication
  • RFQ (Request for Quote): Access to the RFQ system for large-size trades
The client abstracts away the complexity of interacting with the CLOB API, handling authentication, request signing, and data formatting automatically.

Key features

Type-safe API

Fully typed TypeScript SDK with comprehensive interfaces and type definitions for all API operations

Flexible authentication

Support for multiple wallet types including ethers.js Wallet, viem WalletClient, and Magic email login

Order building

Built-in order builder that handles price rounding, tick sizes, and creates properly formatted signed orders

Market & limit orders

Support for both market orders (FOK/FAK) and limit orders (GTC/GTD) with automatic price calculation

Real-time data

Access to live orderbooks, market prices, trade history, and market events

Error handling

Configurable error handling with both error objects and thrown exceptions

Why use the CLOB client?

Automated trading strategies

Build sophisticated trading bots that can:
  • Monitor multiple markets simultaneously
  • Execute trades based on custom algorithms
  • Implement market-making strategies with tight spreads
  • React to market events in real-time

Market making

Provide liquidity to Polymarket’s prediction markets:
  • Maintain two-sided quotes across multiple markets
  • Automatically adjust prices based on market conditions
  • Earn trading fees and liquidity rewards
  • Manage inventory and risk programmatically

Data analysis

Access comprehensive market data for research and analysis:
  • Historical price and volume data
  • Order book depth and liquidity metrics
  • Trade history and market statistics
  • User trading activity and rewards

Custom applications

Integrate Polymarket trading into your own applications:
  • Build custom trading interfaces
  • Create portfolio management tools
  • Develop risk management systems
  • Integrate with other DeFi protocols

How it works

The CLOB Client uses a two-level authentication system:
1

Level 1 (L1) Authentication

Uses EIP-712 signatures from your Ethereum wallet to prove ownership of an address. Required for creating API keys and signing orders.
2

Level 2 (L2) Authentication

Uses HMAC signatures with API key credentials for all authenticated requests. Provides faster authentication without requiring wallet signatures for each request.

Order flow

  1. Create order: Build an order with the desired parameters (token, price, size, side)
  2. Sign order: The client cryptographically signs the order using your wallet
  3. Post order: Submit the signed order to the CLOB API
  4. Matching: The order is matched against existing orders in the orderbook
  5. Settlement: Matched trades are settled on the Polygon blockchain
All orders are signed off-chain but settled on-chain, combining the speed of centralized orderbooks with the security of decentralized settlement.

Supported chains

The CLOB Client supports:
  • Polygon Mainnet (Chain ID: 137) - Production environment
  • Polygon Amoy Testnet (Chain ID: 80002) - Testing environment

Architecture

The client is built with a modular architecture:
ClobClient
├── OrderBuilder: Constructs and signs orders
├── RfqClient: Handles Request-for-Quote operations
├── HTTP methods: GET, POST, PUT, DELETE with auto-retry
└── Authentication: L1 (EIP-712) and L2 (HMAC) signing

Next steps

Quickstart

Get started with a complete example from installation to placing your first order

Installation

Detailed installation instructions and environment setup

API Reference

Complete API documentation for all client methods

Examples

Code examples for common use cases and trading patterns

Build docs developers (and LLMs) love