Price API(WebSocket)

WebSocketAPI

BW provides users with a simple yet powerful API designed to help users quickly and efficiently integrate BW trading functions into their own applications. If you have any problems during the use, please contact our technical discussion QQ group, we will make the most authoritative answer for you. We have provided a complete demo of the Java and Python versions (GitHub) , please add them.

WebSocket service address

BW WebSocket service connection address:

          
            wss://kline.bw.com/websocket
          
        

Use Instruction

The following APIs can be processed in a WebSocket connection to subscribe to server data by subscribing to the action parameter in the message. The k-line, the handicap, and the transaction record data will first return the full amount of data once, and then will push the new data when there is new data.
Subscription message basic format:

          
            {"dataType":"1_ENTRUST_ADD_EOS_QTUM", "dataSize":1, "action":"ADD"}
            dataType: The requested data type is described in detail in the following sections.
            dataSize: The amount of data requested, determines the amount of the first full amount of data, does not pass or returns 0 to return a piece of data.
            action: The type of action requested, ADD: increase data subscription, DEL: remove data subscription.
          
        

The message format is relatively simple and intuitive. You can use the online websocket tool to test it easily or open the developer mode to view the data on the official website with k-line pages.

1 Price API

Get the latest BW market data

1.1 K line

The maximum size is 500, and the supported time periods are 1M, 5M, 15M, 30M, 1H, 1D.
Example

request
{"dataType":"90_KLINE_1M_BTC_KRW","dataSize":1000,"action":"ADD"} 
First full amount of data response
[["K","90","btc_krw","1530588720","9.182984","9.274772","9.139348","9.219058","66.68","0.39","1.00","1M","false"],
      ["K","90","btc_krw","1530588660","9.323081","9.464753","9.233462","9.245472","137.81","-0.83","1.00","1M","false"]]
Incremental data response
["K","90","btc_krw","1530588660","9.323081","9.464753","9.233462","9.245472","137.81","-0.83","1.00","1M","false"]

request dataType Format is Market id_KLINE_Time Period_Market Seller Currency_Market Seller Currency The full amount of data is a list of incremental data, the field description: [data type, market ID, currency information, time stamp, opening data, highest price, lowest price, closing price, volume, drop, dollar exchange rate, K line Cycle, whether it has been converted]

1.2 Market Depth(Market depth)

There are up to 50 purchases for each sale, and the full amount of data in subsequent versions may be sent multiple times. After receiving the full amount of data, all the exchanges are cleared and replaced.
Example

request
{"dataType":"281_ENTRUST_ADD_BTC_USDT","dataSize":50,"action":"ADD"}
Full amount of data response
[["AE","90","BTC_KRW","1530588744",
      {"asks":[["9.52474412","8.30549744"],["9.52439338","1.27516183"],["9.24510427","7.30032233"]]},
      {"bids":[["9.22777334","0.7185328"],["9.22746464","1.00998182"],["9.22673134","10.67980016"]]}]]  
Incremental data response
["E","90","1530596231","BTC_KRW","ASK","9.31466872","25.17915754"]  

request dataType Format is Market id_ENTRUST_ADD_market seller currency_market seller currency
Full data field description: [data type, market ID, market name, timestamp, asks: (sell) [[price, quantity]], bids (buy) [[price, quantity]]]
Incremental data field description: [data type, market ID, timestamp, market name, type of sale (asks sell bids), price, quantity]
Each incremental data represents a single gear to be data, and an equivalent of 0 indicates that the gear has been completely traded and needs to be removed.

1.3 Transaction Record

Buy up to 50 pieces of full data.
Example

request
{"dataType":"90_TRADE_BTC_KRW","dataSize":20,"action":"ADD"}  
Full amount of data response
[["T","90","1530588744","BTC_KRW","ask","9.21905755","9.51934036"],
      ["T","90","1530588741","BTC_KRW","ask","9.1909928","7.82056220"],
      ["T","90","1530588698","BTC_KRW","ask","9.26087653","3.05215100"]] 
Subsequent incremental data response
["T","90","1530596909","BTC_KRW","ask","9.22561602","15.26344425"]  

request dataType Format is Market id_TRADE_market seller currency_market seller currency
The full amount of data is in the form of a list of incremental data, the field description: [data type, market ID, time stamp, market name, type of sale (ask sell bid buy), price, quantity]

Market quotes include 6-hour closing price

There is no difference between full data and incremental data, only one format.
Example

request
{"dataType":"ALL_TRADE_STATISTIC_24H","dataSize":1,"action":"ADD"}  
response
{"trade_statistic":
      [[99,"9.39","9.82","1","153734.8286","830.3","[[1, 9.39], [2, 9.37], [3, 9.24], [4, 9.39]]","9.27","9.39"],
      [90,"9.5","6652698.301","1.02","169532.11","814.53","[[1, 9.486], [2, 9.658], [3, 9.212], [4, 9.25]]","9.4","9.227"]]}

request dataType Fixed to ALL_TRADE_STATISTIC_24H
Field description:
{"trade_statistic":[[ Market ID, latest transaction price, highest price, lowest price, 24-hour volume, 24-hour price increase, recent 6H closing price list, buy one price, sell one price],....]}。
The latest 6H closing price list data description: [[serial number, closing price], [serial number, closing price], [serial number, closing price]]

1.4 Get all market 24H market data

There is no difference between full data and incremental data, only one format.
Example

request
{"dataType":"ALL_TRADE_STATISTIC_24H","dataSize":1,"action":"ADD"}  
response
{"trade_statistic":
      [[99,"9.39","9.82","1","153734.8286","830.3","[[1, 9.39], [2, 9.37], [3, 9.24], [4, 9.39]]","9.27","9.39","21469873.408"],
      [90,"9.5","6652698.301","1.02","169532.11","814.53","[[1, 9.486], [2, 9.658], [3, 9.212], [4, 9.25]]","9.4","9.227","21469873.408"]]}

request dataType Fixed toALL_TRADE_STATISTIC_24H
Field description:
{"trade_statistic":[[ Market ID, latest transaction price, highest price, lowest price, 24-hour volume, 24-hour price increase, recent 6H closing price list, buy one price, sell one price, 24-hour turnover (unit is buyer's currency)'],....]}。
The latest 6H closing price list data description: [[serial number, closing price], [serial number, closing price], [serial number, closing price]]

1.5 Get individual market 24H market data

There is no difference between full data and incremental data, only one format.
Example

request
{"dataType":"90_TRADE_STATISTIC_24H","dataSize":1,"action":"ADD"}  
response
{"trade_statistic":
      [[90,"9.5","6652698.301","1.02","169532.11","814.53","[[1, 9.486], [2, 9.658], [3, 9.212], [4, 9.25]]","9.4","9.227","21469873.408"]]}

request dataType Format is Markets id_TRADE_STATISTIC
Field description:
The returned data format is consistent with 1.4 for all market 24H market data, except that the list contains only data for a single market.

2 error code

The packet returned in the following is the failure, where the dataType corresponds to the dataType parameter of the subscription data packet.

{
          "msg":"data not exist",
          "code":"5016",
          "dataType":"5_KLINE_1M_BTC_USDT"
      }

Error code list

Error codeDescriptionDescription in English
5016Data does not existdata not exist