-
Notifications
You must be signed in to change notification settings - Fork 3
WebSocket API Subscribe instructions
bw-exchange edited this page Oct 16, 2019
·
3 revisions
WebSocket protocol is a new network protocol based on TCP. It realizes the full duplex communication between the client and the server on a single TCP connection, and the server actively sends information to the client, reducing the unnecessary overhead such as frequent authentication. It has two biggest advantage :
- Header data requested by both parties is very small, only about 2 Bytes
- The server no longer passively receives the client's request and then returns the data, but actively pushes the new data to the client.The advantages brought by the above WebSocket protocol make it very suitable for the real-time interface of digital currency quotation and trading
- Mainland Chinese users: wss://kline.bw.io/websocket
- Non-mainland Chinese users: wss://kline.bw.com/websocket
- Data that supports subscriptions: KLine, Market Depth, Trade, Ticker.
- Push mechanism is the first full amount of data, after which new data is pushed incrementally.
{
"dataType":"281_ENTRUST_ADD_BTC_USDT",
"dataSize":50,
"action":"ADD"
}
- dataType: the dataType of a subscription, as explained in the following syntax
- dataSize: number of data bars subscribed, which determines the number of bars of the first full amount of data. If no data is transmitted or 0, one data is returned
- action: action type of subscription, ADD: Add data subscription, DEL: remove data subscription
The variable parameter is preceded by a $. Such as $marketId
Subscribed datas | dataType | action | Description |
---|---|---|---|
Kline | $marketId_KLINE_$klineType_$symbol | ADD/DEL | According to the cycle, subscribe to the K line data of the symbol |
Market Depth | $marketId_ENTRUST_ADD_$symbol | ADD/DEL | Based on the symbol, subscribe to the depth data of the trading pair |
Trade Detail | $marketId_TRADE_$symbol | ADD/DEL | Based on the symbol, subscribe to the bargain data of the symbol |
Market Tickers | ALL_TRADE_STATISTIC_24H | ADD/DEL | Subscribe to the 24-hour Ticker data for all symbols |
Market Tickers-single-market | $marketId_TRADE_STATISTIC_24H | ADD/DEL | Subscribe to a single symbol of 24-hour Ticker data based on the market id |
- $marketId: marketId, which can be obtained from API: getWebById
- $klineType: K line period, optional value: 1M, 5M, 15M, 30M, 1H, 1D.
- $symbol:symbol, the name of the symbol corresponding to marketId, such as BTC_USDT...
- Technology discussion group: telegram (please specify uid and programming language when adding groups), we will try our best to help you answer questions.
- Subscribe instructions
- API Reference
- Error code
- Code sample: Java Python Nodejs