WebSocket API Reference
After successfully establishing a connection with WebSocket API, send data in the following format to the Server to subscribe to the data:
{
"dataType":"$marketId_KLINE_$klineType_$symbol",
"dataSize":"data size for you need"
"action":"ADD"
}
Params | Required | Type | Description | Default | Value range |
---|---|---|---|---|---|
marketId | true | int | The market id corresponding to the symbol | Such as:281... | |
klineType | true | string | K line cycle | 1M, 5M, 15M, 30M, 1H, 1D | |
symbol | true | string | Symbol | Such as:BTC_USDT,...... | |
dataSize | false | int | Data size | 0 < = dataSize < = 500; At 0 or no transmission, only 1 data will be pushed |
Correct subscription
{
"dataType":"281_KLINE_15M_BTC_USDT",
"dataSize":500,
"action":"ADD"
}
Examples of successful return of subscription data::
The full data is a two-dimensional array, and the incremental data is a one-dimensional array
- Full data
[
[
"K", //Data type, K line
"281", //The market id
"btc_usdt", //Symbol
"1569312900",//Timestamp
"9743.7", //Open
"9747.95", //High
"9732.75", //Low
"9735.95", //Close
"26.92", //Volume
"-0.0795", //Change
"30.57", //Dollar currency rate
"15M", //KLine cycle
"false", //Whether to convert data
"262139.72" //Trading volume
],
//more kline data here...
]
- The incremental data
[
"K", //Data type, K line
"281", //The market id
"btc_usdt", //Symbol
"1569312000", //Timestamp
"9754.22", //Open
"9766.21", //High
"9733.52", //Low
"9743.66", //Close
"245.48", //Volume
"-0.1083", //Change
"30.57", //Dollar currency rate
"15M", //KLine cycle
"false", //Whether to convert data
"2392181.46" //Trading volume
],
After successfully establishing a connection with WebSocket API, send data in the following format to the Server to subscribe to the data:
{
"dataType":"$marketId_ENTRUST_ADD_$symbol",
"dataSize":"data size for you need"
"action":"ADD"
}
Params | Required | Type | Description | Default | Value range |
---|---|---|---|---|---|
marketId | true | int | The market id corresponding to the symbol | Such as:281... | |
symbol | true | string | Symbol, the name of the symbol corresponding to marketId | Such as:BTC_USDT,... | |
dataSize | false | int | Data size | 0 < = dataSize < = 500; At 0 or no transmission, only 1 data will be pushed |
Buy and sell each at most 50 pieces, the subsequent version of the full volume data may be issued several times, after receiving the full volume data empty-replace all the disk.
Correct subscription
{
"dataType":"281_ENTRUST_ADD_BTC_USDT",
"action":"ADD",
"dataSize":100
}
Examples of successful return of subscription data:
The full data is a two-dimensional array, and the incremental data is a one-dimensional array
- Full data
[
[
"AE", //Data type, full amount Market Depth
"281", //The market id
"BTC_USDT", //Symbol
"1569313206", //Timestamp
{
"asks": //The selling
[
[
"12658.4",//price
"0.1086" //amount
],
//more asks data here...
]
},
{
"bids": //The buying
[
[
"9734.25",//price
"0.0026" //amount
],
//more bids data here...
]
}
]
]
- The incremental data
[
"E", //Data type,Market Depth
"281", //The market id
"1569313265",//Timestamp
"BTC_USDT", //Symbol
"ASK", //Type, ASK: sell data, BID: buy data
"9832.63", //price
"3.6794" //amount, if the amount is 0, this data has been deleted in depth
]
After successfully establishing a connection with WebSocket API, send data in the following format to the Server to subscribe to the data:
{
"dataType":"$marketId_TRADE_$symbol",
"dataSize":"data size for you need"
"action":"ADD"
}
Params | Required | Type | Description | Default | Value range |
---|---|---|---|---|---|
marketId | true | int | The market id corresponding to the symbol | Such as:281... | |
symbol | true | string | Symbol | Such as:BTC_USDT,... | |
dataSize | false | int | Data size | 0<=dataSize<=50;At 0 or no transmission, only 1 data will be pushed |
Full volume data up to 50
Correct subscription
{
"dataType":"281_TRADE_BTC_USDT",
"action":"ADD",
"dataSize":20
}
Examples of successful return of subscription data:
- Full data
[
[
"T", //Data type, full Trade data
"281", //The market id
"1569313211",//Timestamp
"BTC_USDT", //Symbol
"ask", //Type, ask: Selling order, bid: Buying order
"9735.95", //price
"0.0008" //amount
],
// more Trade Detail data here...
]
- 增量数据
[
"T", //Data type, incremental Trade data
"281", //The market id
"1569313214",//Timestamp
"BTC_USDT", //Symbol
"bid", //Type, ask: Selling order, bid: Buying order
"9739.18", //price
"0.1991" //amount
]
After successfully establishing a connection with WebSocket API, send data in the following format to the Server to subscribe to the data:
{
"dataType":"ALL_TRADE_STATISTIC_24H",
"dataSize":"data size for you need"
"action":"ADD"
}
Params | Required | Type | Description | Default | Value range |
---|---|---|---|---|---|
dataSize | false | int | Data size | 0<=dataSize<=50;At 0 or no transmission, only 1 data will be pushed |
There is no difference between full and incremental data, only one format.
Correct subscription
{
"dataType":"ALL_TRADE_STATISTIC_24H",
"dataSize":1,
"action":"ADD"
}
Examples of successful return of subscription data:
- The response data
{
"trade_statistic":[
[
"4051", //The market id
"0.00619", //Latest price
"0.00685", //High
"0.00584", //Low
"59733830", //24h Volume
"-3.43", //24h Change
"[[1, 0.00619], [2, 0.00597], [3, 0.00596], [4, 0.0062], [5, 0.00619]]",//Last 6 hours closing price list
"0.00591", //take 1 price
"0.0062", //make 1 price
"375332.4314"//24h trading volume, i.e. sum(each transaction price * the transaction volume)
],
......// more ticker data here
]
}
- Last 6 hours closing price list
"[
[1, 0.00619], //[serial number, closing price]
[2, 0.00597],
[3, 0.00596],
[4, 0.0062],
[5, 0.00619]
]"
After successfully establishing a connection with WebSocket API, send data in the following format to the Server to subscribe to the data:
{
"dataType":"4051_TRADE_STATISTIC_24H",
"dataSize":"data size for you need"
"action":"ADD"
}
Params | Required | Type | Description | Default | Value range |
---|---|---|---|---|---|
marketId | true | int | The market id corresponding to the symbol | Such as:281... | |
dataSize | false | int | Data size | 0<=dataSize<=50; At 0 or no transmission, only 1 data will be pushed |
There is no difference between full and incremental data, only one format.
Correct subscription
{
"dataType":"4051_TRADE_STATISTIC_24H",
"dataSize":50,
"action":"ADD"
}
Examples of successful return of subscription data:
- The response data
{
"trade_statistic":[
[
"4051", //The market id
"0.00619", //Lastest
"0.00685", //High
"0.00584", //Low
"59733830", //24h Volume
"-3.43", //24h Change
"[[1, 0.00619], [2, 0.00597], [3, 0.00596], [4, 0.0062], [5, 0.00619]]",// Last 6 hours closing price list
"0.00591", //Take 1 price
"0.0062", //Make 1 price
"375332.4314" //24h trading volume, i.e. sum(each transaction price * the transaction volume)
]
]
}
- Last 6 hours closing price list
"[
[1, 0.00619], //[serial number, closing price]
[2, 0.00597],
[3, 0.00596],
[4, 0.0062],
[5, 0.00619]
]"
{
"dataType":"90_TRADE_STATISTIC_24H",// Subscribe to the dataType
"msg":"data not exist",// The error message
"code":"5016"// Error code
}