polymarket-client package is the official Python SDK for building
Polymarket integrations.
GitHub
View the Python SDK source.
PyPI Package
Install
polymarket-client from PyPI.Quickstart
1
Install the SDK
Install the SDK with your preferred package manager.
2
Create a Public Client
Create an
AsyncPublicClient to access publicly available Polymarket data.3
Fetch Active Markets
Fetch a page of active markets to discover trading opportunities.
Async and Sync Interfaces
Public clients access public data. Secure clients add trading and account access. Both client types are available in async and sync forms.
Async clients fit services, bots, and applications that already run an event
loop. Sync clients are convenient for scripts and notebooks.
Some features, including realtime subscriptions, are async-only because they
rely on long-lived streams.
Pagination
SDK list methods use a consistent paginator interface. Iterate over the paginator to retrieve every page, or fetch one page at a time when you need to control pacing.page.next_cursor is an opaque SDK cursor. Store it as-is if you want to resume
a scan later, and omit it when starting from the first page.
Types
SDK methods return typed models, and their public types are exported frompolymarket.
decimal.Decimal, while dates and timestamps
use Python’s datetime types.
Error Handling
All SDK exceptions inherit fromPolymarketError. Catch specific exceptions
when your application can respond to them, then catch the base exception as a
fallback.
Secure Client
Create anAsyncSecureClient or SecureClient when your integration needs to
trade or access account data. The Python SDK creates the signer from a local
private key.
Realtime Subscriptions
The Python SDK can combine updates from multiple realtime feeds into a single stream of events.Realtime subscriptions are available only through
AsyncPublicClient and
AsyncSecureClient. PublicClient and SecureClient do not implement
subscribe().subscribe() with one or more subscription specs. Both AsyncPublicClient
and AsyncSecureClient support public streams, while AsyncSecureClient also
provides private streams for the connected account.
event.topic before handling a specific event shape. The examples show
a few streams; see Real-Time Data,
Real-Time Order Updates, and
Perps Realtime Updates for feed-specific options.
DataFrames and Jupyter
Convert pages and paginators directly to a pandas DataFrame, Polars DataFrame, or Apache Arrow Table. Install thepandas, polars, or arrow package extra for the format you use;
the quant extra installs all three.
limit=None to retrieve
every item.
Common SDK objects also render as compact cards in
Jupyter notebooks. Return an object as
the last expression in a cell to display it.
Next Steps
Read Market Data
Discover markets and work with prices, order books, and historical data.
Subscribe to Real-Time Updates
Stream market and account updates as they happen.
Place Your First Order
Set up an account and complete your first authenticated trade.