WebSocket Public Information Streams

WebSocket Format

  • Path: /public

  • Method: WebSocket

  • Description: WebSocket format

  • Parameters:

├─ op: String  (Operation, subscribe unsubscribe)
└─ args: Array (List of subscribed channels)
   ├─ channel: String
   └─ symbol: String
  • Response:

├─ event: String  (subscribe, unsubscribe)
├─ channel: String
├─ symbol: String
├─ code: Number
└─ msg: String
  • Example:

Request:

{
  "op": "",
  "args": [
    {
      "channel": "",
      "symbol": ""
    }
  ]
}

Response:

{
  "event": "",
  "channel": "",
  "symbol": ""
  "code": 0,
  "msg": ""
}

WebSocket Connect

  • Path: /public

  • Method: WebSocket

  • 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.

  • Parameters:

└─ ping
  • Response:

└─ pong

All Contracts Simplify Tickers Channel

  • Path: /public

  • Method: WebSocket

  • Description: Websocket channel to subscribe simplify ticker of all contracts

  • Parameters:

├─ op: String  (Operation, subscribe unsubscribe)
└─ args: Array (List of subscribed channels)
   └─ channel: String  (tickers: All contracts tickers)
  • Response:

├─ channel: String
└─ data: Array
   ├─ symbol: String
   ├─ lastPrice: String
   └─ priceChangePercent: String  (Percentage of 24-hour price change)
  • Example:

Request:

{
  "op": "subscribe",
  "args": [
    {
      "channel": "tickers"
    }
  ]
}

Response:

{
  "channel": "tickers"
  "data": [
    {
      "symbol": "ETH-USDC",
      "lastPrice": "4.00000200",
      "priceChangePercent": "-95.960"
    }
  ]
}

Single Contract Ticker Channel

  • Path: /public

  • Method: WebSocket

  • Description: Websocket channel to subscribe ticker

  • Parameters:

├─ op: String  (Operation, subscribe unsubscribe)
└─ args: Array
   ├─ channel: String  (ticker: Single Contract Ticker)
   └─ symbol: String
  • Response:

├─ 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)
  • Example:

Request:

{
  "op": "subscribe",
  "args": [
    {
      "channel": "ticker",
      "symbol": "ETH-USDC"
    }
  ]
}

Response:

{
  "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

  • Path: /public

  • Method: WebSocket

  • Description: Channel to subscribe order book update

  • Parameters:

├─ 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
  • Response:

├─ 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
  • Example:

Request:

{
  "op": "subscribe",
  "args": [
    {
      "channel": "depth<levels>",
      "symbol": "ETH-USDC"
    }
  ]
}

Response:

{
  "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

  • Path: /public

  • Method: WebSocket

  • Description: Channel to subscribe latest trades update

  • Parameters:

├─ op: String  (Operation, subscribe unsubscribe)
└─ args: Array
    ├─ channel: String (trade:trades) 
    └─ symbol: String
  • Response:

├─ 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)
  • Example:

Request:

{
  "op": "subscribe",
  "args": [
    {
      "channel": "trade",
      "symbol": "ETH-USDC"
    }
  ]
}

Response:

{
  "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

  • Path: /public

  • Method: WebSocket

  • Description: Channel to subscribe kline update

  • Parameters:

├─ op: String  (Operation, subscribe unsubscribe)
└─ args: Array
   ├─ channel: String  (channel: kline1m,kline5m,kline15m,kline30m,kline1h,kline4h,kline1d)
   └─ symbol: String
  • Response:

├─ 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)
  • Example:

Request:

{
  "op": "subscribe",
  "args": [
    {
      "channel": "kline15m",
      "symbol": "ETH-USDC"
    }
  ]
}

Response:

{
  "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

  • Path: /public

  • Method: WebSocket

  • Description: Channel to subscribe index ticker update

  • Parameters:

├─ op: String  (Operation, subscribe unsubscribe)
└─ args: Array
    ├─ channel: String (index:Index price) 
    └─ symbol: String
  • Response:

├─ channel: String
├─ symbol: String
└─ data: Object
   ├─ symbol: String
   ├─ indexPrice: String
   └─ time: Number
  • Example:

Request:

{
  "op": "subscribe",
  "args": [
    {
      "channel": "index",
      "symbol": "ETH-USDC"
    }
  ]
}

Response:

{
  "channel": "index",
  "symbol": "ETH-USDC"
  "data": {
    "symbol": "ETH-USDC",
    "indexPrice": "28457",
    "time": 1499865549590
  }
}

Oracle Price Channel

  • Path: /public

  • Method: WebSocket

  • Description: Channel to subscribe oracle price update

  • Parameters:

├─ op: String  (Operation, subscribe unsubscribe)
└─ args: Array
   ├─ channel: String  (oracle: Oracle price)
   └─ symbol: String
  • Response:

├─ channel: String
├─ symbol: String
└─ data: Object
   ├─ symbol: String
   ├─ oraclePrice: String
   └─ time: Number  (Effective time)
  • Example:

Request:

{
  "op": "subscribe",
  "args": [
    {
      "channel": "oracle",
      "symbol": "ETH-USDC"
    }
  ]
}

Response:

{
  "channel": "oracle",
  "symbol": "ETH-USDC"
  "data": {
    "symbol": "ETH-USDC",
    "oraclePrice": "28457",
    "time": 1499865549590
  }
}

Funding Rate Channel

  • Path: /public

  • Method: WebSocket

  • Description: Channel to subscribe funding rate

  • Parameters:

├─ op: String  (Operation, subscribe unsubscribe)
└─ args: Array
    ├─ channel: String (funding:Funding rate) 
    └─ symbol: String
  • Response:

├─ channel: String
├─ symbol: String
└─ data: Object
   ├─ symbol: String
   ├─ fundingRate: String
   └─ time: Number
  • Example:

Request:

{
  "op": "subscribe",
  "args": [
    {
      "channel": "funding",
      "symbol": "ETH-USDC"
    }
  ]
}

Response:

{
  "channel": "funding",
  "symbol": "ETH-USDC"
  "data": {
    "symbol": "ETH-USDC",
    "fundingRate": "0.0008",
    "time": 1499865549590
  }
}

Last updated