Skip to main content

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.
The connection opens when the WebSocket handshake completes.

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:
Expected response:

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:
Expected subscription response:

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:
The params array contains [market_name, last_price]. Parse each lastprice_update event to display real-time prices.

Message Format

Request message

The connection will be closed if invalid JSON is sent.
Types of request messages:
  • 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

Types of response messages:
  • 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:
Subscription:
Update event:

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. See Markets & Trading Pairs for pair notation.

Account Streams

Private channels for account data — balances, orders, deals, positions, and borrows. Requires authorization. See Balances & Transfers for account types.

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.