Introduction
WebSocket API is a convenient tool for obtaining real–time data. You can receive orderbook updates, ongoing orders, kline information and ticker information in real time.
Currently, there are 4 types of subscriptions and 2 requests to the WebSocket API.
Heartbeat
Every once in a while, the server will send a PING
message. The client needs to reply to the PONG
message, otherwise the server will close the connection.
- ping message
- pong message
Subscription Full Depth
To subscribe to these events, you must send the following message:
- $symbol – example: btcusdt
- cb_id – Business ID (not required)
An example of an event that will be sent to you after subscribing to these events:
- The maximum number of returned orders is 30.
Subscription Real Time Trade
To subscribe to these events, you must send the following message:
- $symbol – example: btcusdt
- cb_id – Business ID (not required)
An example of an event that will be sent to you after subscribing to these events:
Subscription Kline Market
To subscribe to these events, you must send the following message:
- $symbol – example: btcusdt
- $interval – 1min / 5min / 15min / 30min / 60min / 1day /1week / 1month
- cb_id – Business ID (not required)
An example of an event that will be sent to you after subscribing to these events:
Subscription Market Tickers
To subscribe to these events, you must send the following message:
- $symbol – example: btcusdt
- cb_id – Business ID (not required)
An example of an event that will be sent to you after subscribing to these events:
Request Kline History Data
To subscribe to these events, you must send the following message:
- $symbol – example: btcusdt
- $interval – 1min / 5min / 15min / 30min / 60min / 1day /1week / 1month
- cb_id – Business ID (not required)
- endIdx – Return pageSize data before endIdx (not required)
- pageSize – page size (not required)
An example of an event that will be sent to you after subscribing to these events:
- data – No more than 300 events
Request Trade History
To subscribe to these events, you must send the following message:
- $symbol – example: btcusdt
- cb_id – Business ID is not required
An example of an event that will be sent to you after subscribing to these events: