Python client for the Polymarket Central Limit Order Book (CLOB).
Documentation
Installation
# install from PyPI (Python 3.9>)
pip install py-clob-client
Usage
The examples below are short and copy‑pasteable.
What you need:
Python 3.9+
Private key that owns funds on Polymarket
Optional: a proxy/funder address if you use an email or smart‑contract wallet
Tip: store secrets in environment variables (e.g., with .env)
Quickstart (read‑only)
from py_clob_client.client import ClobClient
client = ClobClient("https://clob.polymarket.com") # Level 0 (no auth)
ok = client.get_ok()
time = client.get_server_time()
print(ok, time)
Start trading (EOA)
Note: If using MetaMask or hardware wallet, you must first set token allowances. See Token Allowances section below.
from py_clob_client.client import ClobClient
HOST = "https://clob.polymarket.com"
CHAIN_ID = 137
PRIVATE_KEY = "<your-private-key>"
FUNDER = "<your-funder-address>"
client = ClobClient(
HOST, # The CLOB API endpoint
key=PRIVATE_KEY, # Your wallet's private key
chain_id=CHAIN_ID, # Polygon chain ID (137)
signature_type=1, # 1 for email/Magic wallet signatures
funder=FUNDER # Address that holds your funds
)
client.set_api_creds(client.create_or_derive_api_creds())
Start trading (proxy wallet)
For email/Magic or browser wallet proxies, you need to specify two additional parameters:
Funder Address
The funder address is the actual address that holds your funds on Polymarket. When using proxy wallets (email wallets like Magic or browser extension wallets), the signing key differs from the address holding the funds. The funder address ensures orders are properly attributed to your funded account.
Signature Types
The signature_type parameter tells the system how to verify your signatures:
signature_type=0 (default): Standard EOA (Externally Owned Account) signatures - includes MetaMask, hardware wallets, and any wallet where you control the private key directly
Note: EOA/MetaMask users must set token allowances before trading. See Token Allowances section below.
from py_clob_client.client import ClobClient
HOST = "https://clob.polymarket.com"
CHAIN_ID = 137
PRIVATE_KEY = "<your-private-key>"
FUNDER = "<your-funder-address>"
client = ClobClient(
HOST, # The CLOB API endpoint
key=PRIVATE_KEY, # Your wallet's private key
chain_id=CHAIN_ID, # Polygon chain ID (137)
signature_type=1, # 1 for email/Magic wallet signatures
funder=FUNDER # Address that holds your funds
)
client.set_api_creds(client.create_or_derive_api_creds())
last = client.get_last_trade_price("<token-id>")
trades = client.get_trades()
print(last, len(trades))
Important: Token Allowances for MetaMask/EOA Users
Do I need to set allowances?
Using email/Magic wallet? No action needed - allowances are set automatically.
Using MetaMask or hardware wallet? You need to set allowances before trading.
What are allowances?
Think of allowances as permissions. Before Polymarket can move your funds to execute trades, you need to give the exchange contracts permission to access your USDC and conditional tokens.
Quick Setup
You need to approve two types of tokens:
USDC (for deposits and trading)
Conditional Tokens (the outcome tokens you trade)
Each needs approval for the exchange contracts to work properly.
Setting Allowances
Here's a simple breakdown of what needs to be approved: