Subscribes/Unsubscribes to market futures 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:futures:order:snapshots", { "instrument": "XRPUSDT", "exchange": "binance" } ]
}
Param | Type | Description |
---|---|---|
instrument | string | The asset instrument. (REQUIRED) |
exchange | string | The exchange for which to retrieve asset instruments. (OPTIONAL) |
Response
"result": {
"exchange": "binance",
"instrument": "XRPUSDT",
"timestamp": 1607744820000.0,
"is_bid": true,
"price": 758789,
"size": 1,
"num_order": null,
"rank": null,
"sequence": 769632050479
}
Field | Type | Description |
---|---|---|
exchange | string | The exchange. |
timestamp | number | The 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:futures:order:snapshots'],
id: 1,
}));
});
ws.on('message', data => {
console.log(JSON.stringify(JSON.parse(data), null, 2));
});