{"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" }}
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
{"ping": 1535975085052}
Response
{"pong": 1535975085052}
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:
{"symbol": "$symbol0, $symbol1","topic": "trade","event": "sub","params": {"binary":false// Whether data returned is in binary format }}
Payload:
{"symbol": "BTCUSDT","topic": "trade","data": [{"v":"426635153180475392",// Version"t":1565594873508,//Timestamp"p":"11369",// Price"q":"0.01",// Quantity"m":false// true = buy, false = sell }, {"v":"426635153373413376","t":1565594873531,"p":"11369","q":"0.0012","m":false }],"f": false// Whether this is the first entry}
Market Tickers Stream
24hr Ticker statistics for a symbol that changed in an array.
{"symbol": "ETHUSDT","topic": "realtimes","data": [{"t":"1565592599015",//time"s":"ETHUSDT",//symbol"c":"212.63",//close"h":"216.96",//high"l":"206.78",//low"o":"210.23",//open"v":"73013.575",//volume"qv":"15726612.498168",//trade amount (in base asset, in this case is USDT) }],"f": false// Whether this is the first entry}
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
{"symbol": "BTCUSDT","topic": "kline","params": {"klineType":"15m"},"data": [{"t":1565595900000,//kline start time"s":"BTCUSDT",// symbol"c":"11436.14",//close"h":"11437",//high"l":"11381.89",//low"o":"11381.89",//open"v":"16.3306"//volume }],"f": true// Whether this is the first entry}
Orderbook Depth Stream
The Depth Streams for symbols.
Here is the book dump instructions:
The book dump frequency:Every 300ms, if book version changed.
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:
["0.00181860","155.92000000"]// price, quantity
If the next payload is:
["0.00181860","12.3"]
This means that this price level"s quantity has changed.
If the next payload is:
["0.00181860","0"]
This means that this price level is not in orderbook anymore.
Payload:
{"symbol": "BTCUSDT","topic": "diffDepth","data": [{"e":0,"t":1565687625534,"v":"115277986_18","b": [ ["11316.78","0.078"], ["11313.16","0.0052"], ["11312.12","0"], ["11309.75","0.0067"], ["11309.58","0"], ["11306.14","0.0073"] ],"a": [ ["11318.96","0.0041"], ["11318.99","0.0017"], ["11319.12","0.0017"], ["11319.22","0.4516"], ["11319.23","0.0934"], ["11319.24","3.0665"] ] }],"f": false//Whether this is the first entry}
Index Data Stream
This stream is for index prices gathered for options and futures.
{"symbol": "HTUSDT","topic": "index","data": [{"symbol":"HTUSDT","index":"5.0941","edp":"5.08799333","formula":"(5.0941[HUOBI])/1" }],"f": true// Whether this is the first entry}