Connection
WebSocket endpoint:wss://api.whitebit.com/ws
The API is based on JSON RPC over the WebSocket protocol.
The API returns time in Unix-time format.
Quickstart
Prerequisites
- A WebSocket client (browser, Node.js, Python, or similar)
No API key is required for public channels.
Step 1: Establish a connection
Open a WebSocket connection to the endpoint.Step 2: Keep the connection alive
The server closes the connection after 60 seconds of inactivity. Send a ping message every 50 seconds to keep the connection alive. Add the following to the connection established in Step 1:Step 3: Subscribe to last price updates
Subscribe to the Last Price channel to receive real-time price updates for one or more markets. Send the subscription message using the connection from Step 1:Step 4: Receive update events
After a successful subscription, the server sends update events every second. Each event contains the market name and the latest price. Example update event:params array contains [market_name, last_price]. Parse each lastprice_update event to display real-time prices.
Message Format
Request message
| Field | Type | Description |
|---|---|---|
id | Integer | Unique identifier to match the response to the request |
method | String | Name of the method to call |
params | Array | Parameters for the method |
- Query — one-time requests (
ping,candles_request,balanceSpot_request, etc.) - Subscription — streaming updates (
candles_subscribe,lastprice_subscribe,balanceSpot_subscribe, etc.). Repeating a subscription cancels the previous one for the same data type.
Response message
| Field | Type | Description |
|---|---|---|
id | Integer | ID of the original request |
result | Object / null | null on failure; see channel docs for success payloads |
error | Object / null | null on success; error object on failure |
- Query result — direct response to a query request
- Subscription status — success or failure of a subscription request
- Update events — pushed by the server when subscribed data changes
Examples
Query — ping/pong:For connection limits, request limits, and error codes, see WebSocket Rate Limits & Error Codes. Private channels require authorization. See WebSocket Authentication for the full setup flow.
Channels
Market Streams
Public channels for market data — kline, last price, trades, depth, book ticker, and more.
Account Streams
Private channels for account data — balances, orders, deals, positions, and borrows. Requires authorization.
Connection best practices
Reuse a single WebSocket connection for multiple subscriptions instead of opening a new connection per channel. See WebSocket Rate Limits & Error Codes for connection and request limits, timeout behavior, and reconnection guidance.Related resources
- WebSocket Authentication — Authorization flow for private Account Stream channels
- WebSocket Rate Limits & Error Codes — Connection limits, request limits, and error codes
- API Reference Overview — Base URL, quickstart, and endpoint groups
- Market Streams — All public channels (kline, trades, depth, book ticker)
- Account Streams — Private channels for balances, orders, and positions