〰️Websocket V1
Websocket API Documentation
Use Websocket V2 documentation for the updated calls. Documentation below is listed for backward compatibility.
General WSS information
The base endpoint is here
Raw streams are accessed at /openapi/quote/ws/v1
topic
realtimes, trade, kline_$interval, depth
event
sub, cancel, cancel_all
interval
1m, 5m, 15m, 30m, 1h, 2h, 6h, 12h, 1d, 1w, 1M
Sample Subscription Data:
{
"symbol" : "$symbol0, $symbol1",
"topic" : "$topic",
"event" : "sub",
// customizable parameter
"params" : {
// kline max limit is 2000, default is 1
"limit" : "$limit",
// Whether data is returned in binary format, default to false
"binary" : "false"
}
}limit
Specify number of entries returned
binary
Whether returned values is in binary format. DEFAULT value is false
Heartbeat
The client need to send a PING message to the server regularly through the Websocket, which then the server replies with PONG. If the client does not send the message every 5 minutes, the server will close the connection.
Request
Response
Trade Streams
The Trade Streams push raw trade information; each trade has a unique buyer and seller.
After successful handshake and connected to server, the server will return the latest 60 trades. After this payload, the following will be real-time trades.
Variable "v" acts as an tradeId. This variable is shared across different symbols; however, each ID is unique. For example, suppose in the last 5 seconds 3 trades happened in ETHSUDT, BTCUSDT, and BHTBTC. Their version (which is "v") will be consecutive: 112, 113, 114.
Subscription message structure:
Payload:
Market Tickers Stream
24hr Ticker statistics for a symbol that changed in an array.
Subscription message structure:
Payload:
Kline/Candlestick Streams
The Kline/Candlestick Stream push updates to the current klines/candlestick every second.
Kline/Candlestick chart intervals:
m -> minutes; h -> hours; d -> days; w -> weeks; M -> months
1m
5m
15m
30m
1h
2h
4h
6h
12h
1d
1w
1M
Subscription message structure:
Payload:
Orderbook Depth Stream
The Depth Streams for symbols.
Here is the book dump instructions:
The book dump frequency:Every 300ms, if book version changed.
The book dump depth:300 for asks and bids each.
The book version change event:
order enters book
order leaves book
order quantity or amount changes
order is finished
Full Depth Stream
Full depth streams all orderbook data, therefore the data frequency is relatively low. If you wish to get higher frequency streams, please see below to subscribe to merged depth. Notice: "mergedDepth" has fewer data.
Payload:
Merged Depth
dumpScale must be specified for this endpoint. It it the precision of the ticker, it cannot be larger than the specified precision. Check precision at brokerInfo (token, options, and contracts).
Sample brokerInfo return:
Diff. Depth Stream
Order book price and quantity depth updates used to locally manage an order book pushed every second.
In the Diff. (difference) depth stream, the quantity doesn"t necessarily mean the corresponding quantity to the price anymore. If the quantity is 0, it means this previous price level is not in the orderbook anymore. If the quantity is > 0, it means the updated quantity for this price level.
Suppose now we have received the first depth data payload:
If the next payload is:
This means that this price level"s quantity has changed.
If the next payload is:
This means that this price level is not in orderbook anymore.
Payload:
Index Data Stream
This stream is for index prices gathered for options and futures.
Subscription message structure:
Payload:
Error handling
Error Codes:
Last updated