Subscribes/Unsubscribes to market futures Order Book Snapshots data.
Once you're connected to this subscription: wss://ws.amberdata.com/futures, you must provide either the instrument or exchange - one needs to be specified, both cannot be empty.
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
{
"jsonrpc": "2.0",
"method": "subscription",
"params": {
"subscription": "8e1f5873-5023-4989-8573-2e91a6e4112c",
"result": [
{
"exchange": "binance",
"instrument": "BTCUSDT",
"timestamp": 0,
"exchangeTimestamp": 1711570980336,
"isBid": false,
"data": [
[
69135.8,
0.07,
null
],
[
69136.4,
0.029,
null
]
],
"sequence": 4292893574687,
"currentFunding": null
}
]
}
}
Field | Type | Description |
---|---|---|
exchange | string | The exchange name. |
instrument | string | The instrument name. |
timestamp | number | The time at which the order book snapshot took place. |
exchangeTimestamp | number | The timestamp at which the event was recorded by the exchange. |
isBid | boolean | A boolean indicator of whether the orders in the snapshot are buy (bid) orders. |
data[0][0] | number | The price level of the order. |
data[0][1] | number | The quantity of the asset available at the specified price level. |
data[0][2] | number | The number of individual orders that are aggregated at the specified price level. |
sequence | number | A unique identifier for the order book state. |
currentFunding | number | The current funding rate for perpetual futures contracts. |
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));
});