Set Up Perps Access
- TypeScript
- Python
- API
Create a Secure Client
Create a
SecureClient for the Polymarket wallet that owns the Perps account,
using the signer that controls it.This example uses Viem for wallet signing. See the TypeScript tooling
guide for other wallet library
integrations.
Session Lifecycle
Open an authenticated session to start trading, read private Perps account data, and receive private real-time updates.- TypeScript
- Python
- API
Listen for Session Events
After opening a Perps session, iterate over it to receive private real-time
updates.This example handles a few common session events.
order and fill are the
core trading updates, while portfolio provides periodic account-level snapshots
for margin, equity, positions, and withdrawable balance.See Reconcile Trade State for how to use
these events to keep local trading state in sync.Resume a Session
Resume a session when stored credentials are still valid and a Perps workflow needs to continue in a new runtime context.- TypeScript
- Python
- API
Read where Pass stored credentials back to
session.credentials after opening a session and store the object in secure
credential storage.PerpsCredentials is:openPerpsSession() while they are still valid.
The SDK validates them and resumes the session.