Choose a client โ
Choose the REST client for your account and product. Use WebsocketClient for ongoing market and account updates.
- SpotClient: Classic Spot and margin market data, account reads and trading.
- FuturesClient: Classic futures market data, positions and orders.
- BrokerClient: broker and sub-account operations.
- UnifiedAPIClient: Unified Trading Account market data, balances, positions and trading.
- WebsocketClient: public and private subscriptions, connection events and low-level WebSocket API requests.
- WebsocketAPIClient: promise-based Spot, margin, futures and supported UTA order commands over WebSockets.
Combine requests and subscriptions โ
The quickstart and Spot workflow use SpotClient. UTA methods have their own parameters and account requirements; do not assume Classic balance or order methods apply to a Unified Trading Account. For futures, verify contract identifiers and quantity units rather than reusing Spot symbols or amounts.
For subscriptions, the required second argument selects the connection. Classic public Spot uses spotPublicV1; Classic private Spot uses spotPrivateV1. Futures uses futuresPublicV1 or futuresPrivateV1. Pro V2 has separate public keys and the shared privateProV2 connection. Topic names and payloads depend on the connection version.
Keep long-lived clients for each account and region. After a disconnect, recover missed state through REST before relying on cached data.
Send WebSocket API requests โ
Use await and try/catch just as you would with a REST API call. The SDK matches responses to requests and manages the WebSocket connection for you. Requests over a persistent WebSocket can offer lower overhead and latency, depending on the exchange, network and workload.
WebsocketAPIClient provides methods such as submitNewSpotOrder(), modifySpotOrder() and cancelSpotOrder(). It opens and authenticates a dedicated connection when needed. Use private subscriptions separately to follow fills and account changes.