Sign Up Assets {{loginUser.loginName}}
{{showLang}}
  • Exchange
  • Fiat
  • Savings
  • Bonus Center
  • Rebate
  • Seed
  • Listing Application
  • {{showLang}}
  • {{loginUser.loginName}}
  • Sign In
  • Sign Up
Dear ZBG users, you have not opened contract trading account, please open first.
Not now Open
用户API-WebSocket接口

WebSocketAPI

ZBG provides users with a simple and powerful API, designed to help users quickly and efficiently integrate ZBG trading capabilities into their own applications.If you have any questions, please contact us for technical discussion at QQ group:829230107, We will provide you the most authoritative answer

CCXT Example: https://github.com/zbgapi/ccxt/

Java Example: https://github.com/zbg-user-api-demo/user_api_demo_java.git

Python Example: https://github.com/zbg-user-api-demo/user_api_demo_py.git

WebSocket Service Address

ZBG WebSocket服务连接地址: {{url}}

Instructions

All API below can be processed on one WebSocket connection. You can subscribe server data by subscribing the action parameter in message. The servers of K line, handicap and trading record will return the full data once at first, and push the data proactively whenever there is new data.
Basic format of subscribing message:

{"dataType":"336_ENTRUST_ADD_ZT_USDT", "dataSize":1, "action":"ADD"}
dataType: data type requested, details are in chapters below.
dataSize: data size requested, determine the size of first full data, return a data when no param or 0.
action: action type requested,ADD: add data subscription,DEL: delete data subscription.  

Since the format is simple and intuitive, you can make a test via online WebSocket tool or check the data by entering developer mode on the page with K line before developing.

1Quotation API

Receive the latest ZBG market data

1.1K-Line

Maximum size is 500; support the period of 1M, 5M, 15M, 30M, 1H, 1D
Example

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

The format of request dataType is Market id_KLINE_ time period _ market seller's currency _ market seller's currency Full amount data is a list of incremental data. Field description: [data type, market ID, currency information, time stamp, opening data, highest price, lowest price, closing price, volume, fluctuation, dollar exchange rate, K-line period, whether converted]

1.2Handicap (Depth of Market)

Maximum bid size or ask size is 50, full data may be sent multiple times in follow-up versions; handicap will be empty and replaced on receipt of full data.
Example

request
{"dataType":"336_ENTRUST_ADD_ZT_USDT","dataSize":50,"action":"ADD"}
Full data response
[["AE","336","ZT_USDT","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","336","1530596231","ZT_USDT","ASK","9.31466872","25.17915754"]  

The format of request dataType is Market id_ENTRUST_ADD_ market seller's currency _ market seller's currency
Field description of the full amount data: [data type, market ID, currency information, time stamp, asks:[[price, amount]], bids:[[price, amount]]
Incremental data field description: [data type, market ID, timestamp, type of sale (asks bids), price, amount]
Each incremental data is a single file position data, equivalent to 0 indicates that the position has been fully traded and need to be removed.

1.3 Trading Record

Maximum full data amount to buy is 1000.
Example

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

The format of request dataType is Market id_TRADE_ market seller's currency _ market seller's currency
Full volume data is a list form of incremental data, field description: [data type, market ID, currency information, timestamp, type of sale (asks/bids), price, amount]

1.4All markets 24H data

There is only one format with no distinction between full and incremental data
Example

request
{"dataType":"ALL_TRADE_STATISTIC_24H","dataSize":1,"action":"ADD"}  
response
{"trade_statistic":
[[336,"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"],
[336,"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 Price, Highest Price, Lowest Price, 24H volume, 24H change, last 6H closing price list, buy price, sell price, 24 hours transaction amount (in buyer's currency)],....]}.
Last 6H close price list data description: [[ordinal, closing price], [ordinal, closing price], [ordinal, closing price]]

1.5 obtain 24H market data of a single market

There is only one format with no distinction between full and incremental data
Example

request
{"dataType":"336_TRADE_STATISTIC_24H","dataSize":1,"action":"ADD"}  
response
{"trade_statistic":
[[336,"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 to marketId_TRADE_STATISTIC
Field description:
The data format returned is consistent with 1.4 to obtain all the 24H market quotation data, except that the list only contains the data of a single market.

1.6用户委托变更

首次推送最多50条
Example

request
{"dataType":"336_RECORD_ADD_7eOUtLBFXTU_ZT_USDT","dataSize":50,"action":"ADD"}
Full data response
[["AR","366","7eOUtLBFXTU","1564390839",[["E6561532111948357632",1,2,"1.6","10","10","16","1.6","1564391162"],["E6561530917704179712",1,1,"0.3","10","0","0","","1564391101"],["E6561530755883737088",1,1,"0.3016","10","0","0","","1564391084"]]]]

 
Incremental data response
["R","366","7eOUtLBFXTU","1564391224","E6561532371596746752",1,0,"0.8","20","0","0","","1564391224"] 

The format of request dataType is 市场id_RECORD_ADD_市场卖方货币_市场买方货币
全量数据字段说明:[数据类型, 市场ID, 用户ID, 时间戳, [委托单号, 买卖类型, 状态, 价格, 委托量, 完成量, 完成金额, 均价, 创建时间戳]]
增量数据字段说明:[数据类型, 市场ID, 用户ID, 时间戳, 委托单号, 买卖类型, 状态, 价格, 委托量, 完成量, 完成金额, 均价, 创建时间戳]

Field description:
Trading type: 0: Sell 1: Buy
status:0 起始 1 Cancel 2 交易成功 3 交易一部分 其他失败

2Error Code

Failure returns the following message, where the dataType corresponds to the dataType parameter of the subscription dataType

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

Error code list :

Error Code Description English Description
5016 Data not exist data not exist