SDK Examples
Both SDKs build and validate session grants before anything is signed, and manage one JWT and one WebSocket per account the session covers.
Session support ships in @paradex/sdk 0.10.0 and paradex-py 0.10.0, and is experimental. Earlier versions sign a passkey SessionMint the server no longer accepts. Method names and options may change before they are marked stable.
Read the Paradex chain id from the starknet_chain_id field of GET /v1/system/config for the environment you use.
Open a session and trade
TypeScript
Python
paradex.js runs in the browser. SessionConnector generates the session key in the page, keeps it encrypted at rest under a WebCrypto key that cannot be exported, asks the wallet for one signature and registers the grant with POST /v2/sessions. SessionAccounts then signs in for each account and routes requests by account.
Open a new account with the first grant
A wallet with no Paradex account can open one with its first grant, as described in Create a Session. Name the address the server derives for the wallet, list no subaccounts, and pass any referral or marketing codes. They are sent with the grant but not signed.
TypeScript
Python
Refusals, including the onboarding ones, come back as a SessionApiError with a typed code in TypeScript, and as an exception naming the code in Python.
Handle the end of a session
Both SDKs follow the rule described in Check a session’s status: when a sign in or a request is refused for authentication, they call GET /v2/sessions/{grant_id}/status once. If the session is revoked, expired or unknown, every account is dropped together, JWTs are cleared and sockets are closed. Any other answer is treated as transient. A 403 from a missing scope never drops the session.
TypeScript
Python
Revoke the session
Revoking from the SDK calls DELETE /v2/sessions/{grant_id} with the session’s own JWT, then drops every account.
Both SDKs send cancel_orders=true by default, which also cancels the session’s resting orders, TWAPs, untriggered stops and the open RFQs it created, on every account. Once revoked, the session key can no longer cancel them itself. To sign out and leave the orders working, as the Paradex app does, pass { cancelOrders: false } in TypeScript or cancel_orders=False in Python. A session whose grant approves a builder still cancels its TWAPs and untriggered stops.
The session is dropped only once the server confirms the revoke, or answers 404 because it no longer has the grant. If the session key itself is refused, the status check above decides: a revoked, expired or unknown grant drops the session, and the call raises the drop error (SessionGrantError in TypeScript, SessionDroppedError in Python). Any other error is raised and the session stays live. After a 5xx the grant may already be revoked with its orders still working: a retry then drops the session, and only the owner’s DELETE /v2/sessions/{grant_id}?cancel_orders=true cancels them.
TypeScript
Python
To revoke every session on the account at once, call DELETE /v2/sessions with a JWT from the account’s own key.
Typed data only
Both SDKs also expose the typed data on its own, for apps that sign with their own tooling or open sessions with a passkey.
TypeScript
Python
The default limits in both SDKs are the only form the server accepts today: every amount "none" and markets ["*"].