[!WARNING] This repository has been archived and is no longer maintained.
The client is no longer functional and should not be used for new or existing integrations.
Please migrate to our new unified SDK: https://github.com/Polymarket/py-sdk
Python client for the Polymarket Central Limit Order Book (CLOB).
# install from PyPI (Python 3.9>)
pip install py-clob-client
The examples below are short and copy‑pasteable.
.env)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)
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())
For email/Magic or browser wallet proxies, you need to specify two additional parameters:
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.
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 directlysignature_type=1: Email/Magic wallet signatures (delegated signing)signature_type=2: Browser wallet proxy signatures (when using a proxy contract, not direct wallet connections)from py_clob_client.client import ClobClient
HOST = "https://clob.polymarket.com"
CHAIN_ID = 137
PRIVATE_KEY = "<your-private-key>"
PROXY_FUNDER = "<your-proxy-or-smart-wallet-address>" # Address that holds your funds
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=PROXY_FUNDER # Address that holds your funds
)
client.set_api_creds(client.create_or_derive_api_creds())
from py_clob_client.client import ClobClient
from py_clob_client.clob_types import BookParams
client = ClobClient("https://clob.polymarket.com") # read-only
token_id = "<token-id>" # Get a token ID: https://docs.polymarket.com/developers/gamma-markets-api/get-markets
mid = client.get_midpoint(token_id)
price = client.get_price(token_id, side="BUY")
book = client.get_order_book(token_id)
books = client.get_order_books([BookParams(token_id=token_id)])
print(mid, price, book.market, len(books))
Note: EOA/MetaMask users must set token allowances before trading. See Token Allowances section below.
from py_clob_client.client import ClobClient
from py_clob_client.clob_types import MarketOrderArgs, OrderType
from py_clob_client.order_builder.constants import BUY
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())
mo = MarketOrderArgs(token_id="<token-id>", amount=25.0, side=BUY, order_type=OrderType.FOK) # Get a token ID: https://docs.polymarket.com/developers/gamma-markets-api/get-markets
signed = client.create_market_order(mo)
resp = client.post_order(signed, OrderType.FOK)
print(resp)
Note: EOA/MetaMask users must set token allowances before trading. See Token Allowances section below.
from py_clob_client.client import ClobClient
from py_clob_client.clob_types import OrderArgs, OrderType
from py_clob_client.order_builder.constants import BUY
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())
order = OrderArgs(token_id="<token-id>", price=0.01, size=5.0, side=BUY) # Get a token ID: https://docs.polymarket.com/developers/gamma-markets-api/get-markets
signed = client.create_order(order)
resp = client.post_order(signed, OrderType.GTC)
print(resp)
Note: EOA/MetaMask users must set token allowances before trading. See Token Allowances section below.
from py_clob_client.client import ClobClient
from py_clob_client.clob_types import OpenOrderParams
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())
open_orders = client.get_orders(OpenOrderParams())
order_id = open_orders[0]["id"] if open_orders else None
if order_id:
client.cancel(order_id)
client.cancel_all()
from py_clob_client.client import ClobClient
client = ClobClient("https://clob.polymarket.com")
markets = client.get_simplified_markets()
print(markets["data"][:1])
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))
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.
You need to approve two types of tokens:
Each needs approval for the exchange contracts to work properly.
Here's a simple breakdown of what needs to be approved:
For USDC (your trading currency):
0x2791Bca1f2de4661ED88A30C99A7a9449Aa841740x4bFb41d5B3570DeFd03C39a9A4D8dE6Bd8B8982E (Main exchange)0xC5d563A36AE78145C45a50134d48A1215220f80a (Neg risk markets)0xd91E80cF2E7be2e162c6513ceD06f1dD0dA35296 (Neg risk adapter)For Conditional Tokens (your outcome tokens):
0x4D97DCd97eC945f40cF65F87097ACe5EA0476045See this Python example for setting allowances programmatically.
Pro tip: You only need to set these once per wallet. After that, you can trade freely.
See /example for more.
Overall
Maintained
Code review
PyPI
Latest release
Releases this year
1,184 followers · starred Jan 2026
113 followers · starred Mar 2025
267 followers · starred Mar 2026
98 followers · starred Dec 2025
[!WARNING] This repository has been archived and is no longer maintained.
The client is no longer functional and should not be used for new or existing integrations.
Please migrate to our new unified SDK: https://github.com/Polymarket/py-sdk
Python client for the Polymarket Central Limit Order Book (CLOB).
# install from PyPI (Python 3.9>)
pip install py-clob-client
The examples below are short and copy‑pasteable.
.env)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)
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())
For email/Magic or browser wallet proxies, you need to specify two additional parameters:
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.
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 directlysignature_type=1: Email/Magic wallet signatures (delegated signing)signature_type=2: Browser wallet proxy signatures (when using a proxy contract, not direct wallet connections)from py_clob_client.client import ClobClient
HOST = "https://clob.polymarket.com"
CHAIN_ID = 137
PRIVATE_KEY = "<your-private-key>"
PROXY_FUNDER = "<your-proxy-or-smart-wallet-address>" # Address that holds your funds
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=PROXY_FUNDER # Address that holds your funds
)
client.set_api_creds(client.create_or_derive_api_creds())
from py_clob_client.client import ClobClient
from py_clob_client.clob_types import BookParams
client = ClobClient("https://clob.polymarket.com") # read-only
token_id = "<token-id>" # Get a token ID: https://docs.polymarket.com/developers/gamma-markets-api/get-markets
mid = client.get_midpoint(token_id)
price = client.get_price(token_id, side="BUY")
book = client.get_order_book(token_id)
books = client.get_order_books([BookParams(token_id=token_id)])
print(mid, price, book.market, len(books))
Note: EOA/MetaMask users must set token allowances before trading. See Token Allowances section below.
from py_clob_client.client import ClobClient
from py_clob_client.clob_types import MarketOrderArgs, OrderType
from py_clob_client.order_builder.constants import BUY
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())
mo = MarketOrderArgs(token_id="<token-id>", amount=25.0, side=BUY, order_type=OrderType.FOK) # Get a token ID: https://docs.polymarket.com/developers/gamma-markets-api/get-markets
signed = client.create_market_order(mo)
resp = client.post_order(signed, OrderType.FOK)
print(resp)
Note: EOA/MetaMask users must set token allowances before trading. See Token Allowances section below.
from py_clob_client.client import ClobClient
from py_clob_client.clob_types import OrderArgs, OrderType
from py_clob_client.order_builder.constants import BUY
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())
order = OrderArgs(token_id="<token-id>", price=0.01, size=5.0, side=BUY) # Get a token ID: https://docs.polymarket.com/developers/gamma-markets-api/get-markets
signed = client.create_order(order)
resp = client.post_order(signed, OrderType.GTC)
print(resp)
Note: EOA/MetaMask users must set token allowances before trading. See Token Allowances section below.
from py_clob_client.client import ClobClient
from py_clob_client.clob_types import OpenOrderParams
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())
open_orders = client.get_orders(OpenOrderParams())
order_id = open_orders[0]["id"] if open_orders else None
if order_id:
client.cancel(order_id)
client.cancel_all()
from py_clob_client.client import ClobClient
client = ClobClient("https://clob.polymarket.com")
markets = client.get_simplified_markets()
print(markets["data"][:1])
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))
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.
You need to approve two types of tokens:
Each needs approval for the exchange contracts to work properly.
Here's a simple breakdown of what needs to be approved:
For USDC (your trading currency):
0x2791Bca1f2de4661ED88A30C99A7a9449Aa841740x4bFb41d5B3570DeFd03C39a9A4D8dE6Bd8B8982E (Main exchange)0xC5d563A36AE78145C45a50134d48A1215220f80a (Neg risk markets)0xd91E80cF2E7be2e162c6513ceD06f1dD0dA35296 (Neg risk adapter)For Conditional Tokens (your outcome tokens):
0x4D97DCd97eC945f40cF65F87097ACe5EA0476045See this Python example for setting allowances programmatically.
Pro tip: You only need to set these once per wallet. After that, you can trade freely.
See /example for more.
Overall
Maintained
Code review
PyPI
Latest release
Releases this year
1,184 followers · starred Jan 2026
113 followers · starred Mar 2025
267 followers · starred Mar 2026
98 followers · starred Dec 2025