WebSocket Format
Description: WebSocket format
Copy ├─ op: String (Operation, subscribe unsubscribe)
└─ args: Array (List of subscribed channels)
├─ channel: String
└─ symbol: String
Copy ├─ event: String (subscribe, unsubscribe)
├─ channel: String
├─ symbol: String
├─ code: Number
└─ msg: String
Request:
Copy {
"op": "",
"args": [
{
"channel": "",
"symbol": ""
}
]
}
Response:
Copy {
"event": "",
"channel": "",
"symbol": ""
"code": 0,
"msg": ""
}
WebSocket Connect
Description:
When the user's websocket client connects to the websocket server, the server will send a 'ping' message to it regularly (currently set to 10 seconds).
When the user's websocket client receives this heartbeat message, it should return a 'pong' message.
When the websocket server sends 'ping' messages for three consecutive times but does not receive any 'pong' messages, the server will actively disconnect from this client.
When the websocket client does not receive the 'ping' message from the server for more than 30 seconds, it is considered that it is disconnected from the server and needs to be reconnected.
All Contracts Simplify Tickers Channel
Description: Websocket channel to subscribe simplify ticker of all contracts
Copy ├─ op: String (Operation, subscribe unsubscribe)
└─ args: Array (List of subscribed channels)
└─ channel: String (tickers: All contracts tickers)
Copy ├─ channel: String
└─ data: Array
├─ symbol: String
├─ lastPrice: String
└─ priceChangePercent: String (Percentage of 24-hour price change)
Request:
Copy {
"op": "subscribe",
"args": [
{
"channel": "tickers"
}
]
}
Response:
Copy {
"channel": "tickers"
"data": [
{
"symbol": "ETH-USDC",
"lastPrice": "4.00000200",
"priceChangePercent": "-95.960"
}
]
}
Single Contract Ticker Channel
Description: Websocket channel to subscribe ticker
Copy ├─ op: String (Operation, subscribe unsubscribe)
└─ args: Array
├─ channel: String (ticker: Single Contract Ticker)
└─ symbol: String
Copy ├─ channel: String
├─ symbol: String
└─ data: Object
├─ symbol: String
├─ priceChange: String (24-hour price change)
├─ priceChangePercent: String (Percentage of 24-hour price change)
├─ lastPrice: String (Last trades price)
├─ lastQty: String (Last trades amount)
├─ openPrice: String (Price of the first trades within 24 hours)
├─ highPrice: String (24-hour maximum price)
├─ lowPrice: String (24-hour lowest price)
├─ volume: String (24-hour trades quantity)
├─ quoteVolume: String (24-hour trades amount)
└─ count: Number (24-hour trades count)
Request:
Copy {
"op": "subscribe",
"args": [
{
"channel": "ticker",
"symbol": "ETH-USDC"
}
]
}
Response:
Copy {
"channel": "ticker",
"symbol": "ETH-USDC"
"data": {
"symbol": "ETH-USDC",
"priceChange": "-94.99999800",
"priceChangePercent": "-95.960",
"lastPrice": "4.00000200",
"lastQty": "200.00000000",
"openPrice": "99.00000000",
"highPrice": "100.00000000",
"lowPrice": "0.10000000",
"volume": "8913.30000000",
"quoteVolume": "15.30000000",
"count": 76
}
}
Order Book Channel
Description: Channel to subscribe order book update
Copy ├─ op: String (Operation, subscribe unsubscribe)
└─ args: Array (List of subscribed channels)
├─ channel: String (depth<levels>: levels mean depth levels, Optional 5/10/20; depth5 for 5 depth levels)
└─ symbol: String
Copy ├─ channel: String
├─ symbol: String
├─ action: String (Push data action, incremental data or full snapshot. snapshot: full update: incremental)
└─ data: Object
├─ bids: Array (Buy)
│ ├─ 0: String (price, 1st bit of array)
│ └─ 1: String (quantity, 2nd bit of array)
├─ asks: Array (Sell)
│ ├─ 0: String (price, 1st bit of array)
│ └─ 1: String (quantity, 2nd bit of array)
└─ time: Number
Request:
Copy {
"op": "subscribe",
"args": [
{
"channel": "depth<levels>",
"symbol": "ETH-USDC"
}
]
}
Response:
Copy {
"channel": "depth5",
"symbol": "ETH-USDC"
"action": "snapshot",
"data": {
"bids": [
{
"0": "4.00000000",
"1": "431.00000000"
}
],
"asks": [
{
"0": "4.00000200",
"1": "12.00000000"
}
],
"time": 1569514978020
}
}
Latest Trades Channel
Description: Channel to subscribe latest trades update
Copy ├─ op: String (Operation, subscribe unsubscribe)
└─ args: Array
├─ channel: String (trade:trades)
└─ symbol: String
Copy ├─ channel: String
├─ symbol: String
└─ data: Object
├─ symbol: String
├─ id: String (Trades id)
├─ price: String (Trades price)
├─ qty: String (Trades quantity)
├─ time: Number (Trades time)
├─ side: String
└─ maker: Boolean (if maker)
Request:
Copy {
"op": "subscribe",
"args": [
{
"channel": "trade",
"symbol": "ETH-USDC"
}
]
}
Response:
Copy {
"channel": "trade",
"symbol": "ETH-USDC"
"data": {
"symbol": "ETH-USDC",
"id": "28457",
"price": "4.00000100",
"qty": "12.00000000",
"time": 1499865549590,
"side": "SELL",
"maker": false
}
}
Kline Channel
Description: Channel to subscribe kline update
Copy ├─ op: String (Operation, subscribe unsubscribe)
└─ args: Array
├─ channel: String (channel: kline1m,kline5m,kline15m,kline30m,kline1h,kline4h,kline1d)
└─ symbol: String
Copy ├─ channel: String
├─ symbol: String
└─ data: Object
├─ 0: Number (Start time)
├─ 1: String (Open price)
├─ 2: String (highest price)
├─ 3: String (Lowest price)
├─ 4: String (Close price)
├─ 5: String (Trades quantity)
├─ 6: String (Trades amount)
└─ 7: Number (Trades count)
Request:
Copy {
"op": "subscribe",
"args": [
{
"channel": "kline15m",
"symbol": "ETH-USDC"
}
]
}
Response:
Copy {
"channel": "kline15m",
"symbol": "ETH-USDC"
"data": {
"0": 1499040000000,
"1": "0.01634790",
"2": "0.80000000",
"3": "0.01575800",
"4": "0.01577100",
"5": "148976.11427815",
"6": "2434.19055334",
"7": 308
}
}
Index Tickers Channel
Description: Channel to subscribe index ticker update
Copy ├─ op: String (Operation, subscribe unsubscribe)
└─ args: Array
├─ channel: String (index:Index price)
└─ symbol: String
Copy ├─ channel: String
├─ symbol: String
└─ data: Object
├─ symbol: String
├─ indexPrice: String
└─ time: Number
Request:
Copy {
"op": "subscribe",
"args": [
{
"channel": "index",
"symbol": "ETH-USDC"
}
]
}
Response:
Copy {
"channel": "index",
"symbol": "ETH-USDC"
"data": {
"symbol": "ETH-USDC",
"indexPrice": "28457",
"time": 1499865549590
}
}
Oracle Price Channel
Description: Channel to subscribe oracle price update
Copy ├─ op: String (Operation, subscribe unsubscribe)
└─ args: Array
├─ channel: String (oracle: Oracle price)
└─ symbol: String
Copy ├─ channel: String
├─ symbol: String
└─ data: Object
├─ symbol: String
├─ oraclePrice: String
└─ time: Number (Effective time)
Request:
Copy {
"op": "subscribe",
"args": [
{
"channel": "oracle",
"symbol": "ETH-USDC"
}
]
}
Response:
Copy {
"channel": "oracle",
"symbol": "ETH-USDC"
"data": {
"symbol": "ETH-USDC",
"oraclePrice": "28457",
"time": 1499865549590
}
}
Funding Rate Channel
Description: Channel to subscribe funding rate
Copy ├─ op: String (Operation, subscribe unsubscribe)
└─ args: Array
├─ channel: String (funding:Funding rate)
└─ symbol: String
Copy ├─ channel: String
├─ symbol: String
└─ data: Object
├─ symbol: String
├─ fundingRate: String
└─ time: Number
Request:
Copy {
"op": "subscribe",
"args": [
{
"channel": "funding",
"symbol": "ETH-USDC"
}
]
}
Response:
Copy {
"channel": "funding",
"symbol": "ETH-USDC"
"data": {
"symbol": "ETH-USDC",
"fundingRate": "0.0008",
"time": 1499865549590
}
}