Overview
The Spot WebSocket API uses token-based authentication. To subscribe to private channels (ownTrades, openOrders), first obtain a short-lived token via the REST API, then include it in each subscription message.
Tokens are valid for 15 minutes. Obtain a fresh token before reconnecting or when the current one nears expiry.
Step 1: Obtain a WebSocket token
Call the GetWebSocketsToken REST endpoint using your API key and secret. Authentication uses the same HMAC-SHA512 signing as all other private REST endpoints — see REST Authentication for the full algorithm.- Python
- Go
- Node.js
Step 2: Subscribe to a private channel
Include the token in your WebSocket subscription message:ownTrades and openOrders simultaneously).
Token expiry and refresh
Tokens expire 15 minutes after creation. To maintain uninterrupted access:- Obtain a new token before the current one expires by calling
GetWebSocketsTokenagain - After reconnecting, re-subscribe using the fresh token
Error handling
If you subscribe with an invalid or expired token, the server returns an error in the subscription status message:GetWebSocketsToken to obtain a fresh token, then re-subscribe.