The unified TypeScript SDK gives you a consistent surface across Polymarket discovery, market data, trading, account data, and realtime streams.
The TypeScript SDK is currently in beta. We are keeping it in this beta phase
while we address issues and harden the SDK before transitioning to a more
stable release.
The SDK normalizes data across API seams and uses consistent patterns for pagination and typed error handling across public and authenticated workflows.
Common primitives such as IDs, decimal values, date/time strings, and EVM addresses are represented with explicit SDK types so integrations can avoid treating every value as a plain string.
Use discovery methods to browse events, markets, teams, tags, comments, sports metadata, and search results. The examples below show a few common entry points.
Subscribe through one SDK interface even when events are served by different websocket surfaces. The SDK routes each subscription spec to the right stream and merges the results into one stream.
Create a secure client when you need wallet-scoped reads or trading.By default, createSecureClient uses the signer’s deterministic Deposit Wallet
as the account wallet. The SDK deploys that wallet if needed during client
creation. Pass wallet only when you want to authenticate an existing wallet,
such as an existing Deposit Wallet, Poly Safe, Poly Proxy, or the signer address
itself for EOA trading.The examples below pass wallet to make account selection explicit. Omit
wallet to use the default Deposit Wallet flow.
The SDK is intended to support a variety of wallet libraries. At launch, we support Viem, Privy, and Ethers v5. We will expand support for more libraries based on demand.
Viem
Privy
Ethers v5
1
Install the Packages
Install the SDK and Viem wallet tools.
pnpm add @polymarket/client@beta viem
2
Create the Secure Client
Use the private-key helper, or adapt an existing viem wallet client.
import { createSecureClient } from "@polymarket/client";import { privateKey } from "@polymarket/client/viem";const secureClient = await createSecureClient({ wallet: "YOUR_POLYMARKET_WALLET_ADDRESS", signer: privateKey(process.env.PRIVATE_KEY),});
1
Install the Packages
Install the SDK and Privy Node client.
pnpm add @polymarket/client@beta @privy-io/node
2
Create the Secure Client
Use the Privy Node client with the SDK’s Privy signer adapter.
import { createSecureClient } from "@polymarket/client";import { signerFrom } from "@polymarket/client/privy";import { PrivyClient } from "@privy-io/node";const privy = new PrivyClient({ appId: process.env.PRIVY_APP_ID!, appSecret: process.env.PRIVY_APP_SECRET!,});const secureClient = await createSecureClient({ wallet: "YOUR_POLYMARKET_WALLET_ADDRESS", signer: signerFrom({ privy, walletId: process.env.PRIVY_WALLET_ID!, }),});
1
Install the Packages
Install the SDK and the Ethers v5 package alias used by the adapter.
Before placing orders, make sure the authenticated wallet is deployed and has
the required trading approvals. createSecureClient resolves the signer’s
deterministic Deposit Wallet by default and deploys it if needed.
1
Configure API Key Authorization
Configure API key authorization when the SDK needs to deploy a Deposit Wallet or
submit approval transactions.
Builder API keys are supported for backwards compatibility with builders that
still use them for wallet operations. They are not used for order attribution.
Use builderCode on orders for attribution.
2
Set Up Trading Approvals
Then set up trading approvals.
await secureClient.setupTradingApprovals();
setupTradingApprovals() waits for the setup transaction internally and is
idempotent. If the wallet already has the required approvals, it returns without
submitting a transaction.
Use a secure client to create, sign, and submit orders. Limit orders specify the price and size you want to trade. Market orders execute against resting liquidity immediately.Order placement returns a discriminated response. Check response.ok before reading order details.
Use position lifecycle methods to split collateral into outcome tokens, merge
complete sets back into collateral, or redeem resolved positions. These examples
assume you created a secure client and set up trading approvals as shown above.
Use wallet operation methods for direct token movements from the authenticated
wallet. These examples assume you created a secure client as shown above.
Secure clients expose the API credentials created for the authenticated session. Store them securely if you want to reuse the session later without requiring a new authentication signature while the credentials remain valid.
Point Combos RFQ endpoints at the production domains: combos-rfq-api.polymarket.com (REST) and combos-rfq-gateway-quoter.polymarket.com (quoter WebSocket).
Secure client setup now defaults to the Deposit Wallet flowcreateSecureClient can now derive and use the signer’s deterministic Deposit
Wallet when you omit wallet. If you already know which Polymarket wallet you
want to use, keep passing wallet.
setupTradingApprovals() now waits internallyYou no longer need to wait on the returned handle. Call the method once before
trading; it is safe to call again if approvals are already set.
Gasless setup helpers are deprecatedYou no longer need to call isGaslessReady() or setupGaslessWallet() in the
normal setup path. Create the secure client, then set up trading approvals.