Skip to main content
The @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.
See the SDK Changelog for recent TypeScript releases.

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 with for 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.
The SDK also uses branded types for identifiers, decimal values, timestamps, and EVM addresses so TypeScript can distinguish values that would otherwise all be strings.

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 a SecureClient when your integration needs to trade or access account data. Pass the signer adapter for your wallet library to createSecureClient().
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():
Continue to Wallets and Authentication to configure the account wallet and gasless transactions.

Realtime Subscriptions

The SDK can combine updates from multiple realtime feeds into a single stream of events. Call subscribe() 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.
Narrow 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.