market:swaps:order:snapshots

Subscribes/Unsubscribes to market swaps Order Book Snapshots data.

Make sure you're connected to this subscription: wss://ws.web3api.io.

Request

{
  "jsonrpc" : "2.0",
  "id"      : 1,
  "method"  : "subscribe",
  "params"  : [ "market:swaps:order:snapshots", { "instrument": "BTC-USDT", "exchange": "huobi" } ]
}
ParamTypeDescription
instrumentstringThe asset instrument. (REQUIRED)
exchangestringThe exchange for which to retrieve asset instruments. (OPTIONAL)

Response

"result": {
  "exchange": "huobi",
  "instrument": "BTC-USDT",
  "timestamp": 1607744820000.0,
  "is_bid": true,
  "price": 758789,
  "size": 1,
  "num_order": null,
  "rank": null
}
FieldTypeDescription
exchangestringThe exchange.
timestampnumberThe time at which the order book snapshot took place.

Example

const WebSocket = require('ws');
const ws = new WebSocket('wss://ws.web3api.io/', {headers: {x-api-key:'<api_key>'}});

ws.on('open', () => {
  ws.send(JSON.stringify({
      jsonrpc: '2.0',
      method: 'subscribe',
      params: ['market:swaps:order:snapshots'],
      id: 1,
    }));
});

ws.on('message', data => {
  console.log(JSON.stringify(JSON.parse(data), null, 2));
});