@polymarket/client NPM package is the official TypeScript SDK for building Polymarket integrations.
With this SDK client you can fetch market data, subscribe to real-time data,
submit orders, redeem positions and many other actions.
GitHub
View the TypeScript SDK source.
NPM Package
Install
@polymarket/client@latest.Quickstart
1
Install the SDK
Install the SDK with your preferred package manager.
2
Create a Public Client
Create a
PublicClient to access publicly available Polymarket data.3
Fetch Active Markets
Fetch a page of active markets to discover trading opportunities.
Pagination
SDK list methods use a consistent paginator interface. Iterate withfor await
to retrieve every page, or fetch one page at a time when you need to control
pacing.
page.nextCursor 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 responses, and their public types are exported from@polymarket/client.
Error Handling
Each SDK action exposes a matching error guard. Use it to handle documented errors for that action and rethrow anything unexpected.Wallet Integrations
Create aSecureClient when your integration needs to trade or access account
data. Pass the signer adapter for your wallet library to
createSecureClient().
- Viem
- Privy
- Ethers v5
Install the Viem adapter alongside the SDK.Create the signer directly from a private key:If your application already has a Viem
WalletClient instance, adapt it with
signerFrom():Realtime Subscriptions
The SDK can combine updates from multiple realtime feeds into a single stream of events. Callsubscribe() with one or more subscription specs. Public streams are
available on both PublicClient and SecureClient. A SecureClient 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.
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.