websocket URL :
wss://wsapi.bitz.plus/
Data Compression
In order to improve data transmission efficiency, Bit-Z The WebSocket API stopped returning uncompressed data at 17:00 (UTC+8) on October 08, 2019, and only returned GZIP compressed data. Bit-Z API users should upgrade as soon as possible: add the dataType=1 parameter when subscribing, and decompress the data locally after receiving it.Please refer to documentation and demo for decompression
heartbeat and persistent connection strategy
a) Client sends string ping
every
5 secondsto server, then Server returns
pong` to maintain persistent connection in this heartbeat.
b) Server
detects every 10 seconds
: if haven't received ping
from Client within 60 seconds
, it will initiate to terminate the connection.
c) Server
detects network connection between Server and Client every 5 seconds
, Server will delete this subscription if network is down, and Client won't receive new messages anymore, at this time Client needs to resend subscription
request, the previous subscription requests will be invalid.
d) Server will detect the network connection status when sending new messages
to Client, if network is down, Server will deal with it in the same way as mentioned above.
Send request command format:
Sendjson
"action":"Topic.sub","data":{"symbol":"bz_usdt","type":"market,depth,order,kline","resolution":"60min","_CDID":"100002","dataType": "1"},"msg_id":1562156656532}
Show after analysis:
{
"action": "Topic.sub",
"data": {
"symbol": "bz_usdt",
"type": "market,depth,order,kline",
"resolution": "60min",
"_CDID": "100002",
"dataType": "1"
},
"msg_id": 1562156656532
}
Command details:
action
:
- Subscription request:
Topic.sub
Subscribe、Topic.unsub
Unsubscribe;Single selection
data
:
a. symbol
- Trading pair, e.g.:
btc_usdt
、eth_btc
;Single selectionb. type
- Subscribe type Optional value: market overview
market
、depthdepth
、Contract noteorder
、k-linekline
; multi-choice, separated by commac. resolution (Non-required transmit)
- Transmit required with subscribe type k-line :
1min
、5min
、15min
、30min
、60min
、4hour
、1day
、5day
、1week
、1mon
; Single selectiond. _CDID
- Site information bit-z web code:
100002
e.dataType
- 0: Deprecated
- 1: Required, gzip compressed binary format data, need user client decompression
msg_id
:
current millisecond time stamp
message received on client:
a. market
Market overview:
{
"msgId": 0, # message id
"params": [], # parameter
"data": { # data
"btc_usdt": { #trading pair
"s": "btc_usdt", #trading pair
"q": "748289393.19", #24h turnover
"v": "68457.02", #24h volume
"tp": "6.58", #today's price change
"p24": "11.74", #24h price change
"o": "10138.95", #Opening price
"h": "11500.00", #24h maximum price
"l": "9728.61", #24h minimum price
"n": "11330.00", #current price
"nP": 4, #Digital place of volume
"pP": 2, #Digital place of price
"cny": "77978.74", #RMB Valuation
"usd": "11330.00", #USD Valuation
"krw": "13235981.30", #KRW Valuation
"jpy": "1220905.17" #JPY Valuation
},
...... #All other trading pair information
},
"action": "Pushdata.market", #Subscribe type
"time": 1562159048028, #Message time
"source": "sub-api" #Message source
}
b. order
order informtion:
{
"msgId": 0, #message id
"params": { # parameter
"symbol": "bz_usdt" #trading pair
},
"action": "Pushdata.order", #Subscribe type
"data": [ #data
{
"id": 1216814315, #id
"t": "21:04:10", #time
"T": 1562159050, #time stamp
"p": "0.1599", #price
"n": "2185.0000", #Quantity
"s": "sell" #Direction sell;buy
}
],
"time": 1562159051901, #Message time
"source": "sub-api" #Message source
}
c. depth
Depth information:
{
"msgId": 0, #message id
"params": { # parameter
"symbol": "bz_usdt" #trading pair
},
"action": "Pushdata.depth", #Subscribe type
"data": { #data
"asks": [ # Entrusted direction: asks: sell, bids: buy
[
"0.1586", #price
"616.4175", #Quantity
"97.7638" #Total amount
]
]
},
"time": 1562159910917, #Message time
"source": "sub-api" #Message source
}
d. kline
k-line information:
{
"msgId": 0, #message id
"params": { # parameter
"symbol": "bz_usdt", #trading pair
"resolution": "60min" #k line type
},
"action": "Pushdata.kline", #Subscribe type
"data": { #data
"bars": [ # K-line chart
{
"time": "1562155200000", #millisecond time stamp
"open": "0.1609", #Opening price
"high": "0.1635", #Maximum price
"low": "0.1575", #Minimum price
"close": "0.1603", #Closing price
"volume": "1288739.3374", #Trading volume
"datetime": "2019-07-03 20:00:00" #k-line time stamp
}
],
"resolution": "60min", #k line type
"symbol": "bz_usdt", # K-line trading pair
"from": "1562155200000", #Start time
"to": "1562151600000", #End time
"size": 1 #K-line total
},
"time": 1562156715923, #Message time
"source": "sub-api" #Message source
}
Error:
-101001
Subscription type parameter error-101002
Fail to get subscribed symbol of trading pair.-101003
k-line scale resolution error