market:spot:reference-quote:1s

Subscribes to reference quotes.

The calculation takes into account mid prices from every exchange, with a maximum lookback of 1 minute, meaning if a pair for an exchange has not been updated in the most recent 60 seconds, it is dropped and not used in the calculation of the current price.

The reference quote is calculated as the average of mid prices across all exchanges which support this pair.

Mid is defined as (bid + ask) / 2 (best bid and best ask).

This feed returns point-in-time data, meaning it returns real-time data, and is not retroactively changed after the fact due to some reconciliation phase or some delayed data for example.

Make sure you're connected.

Request

Default feed:

{"jsonrpc":"2.0","id":1,"method":"subscribe","params":["market:spot:reference-quote:1s",{"pair":"btc_usdt"}]}

Choose the exchanges participating in the price calculation:

{"jsonrpc":"2.0","id":1,"method":"subscribe","params":["market:spot:reference-quote:1s",{"pair":"btc_usdt", "sources":"binance,huobi"}]}

Param

Type

Description

pair

string

The asset pair for which to retrieve the price feed.

sources

array

Inclusion list - only exchanges in this list will be included in the calculation of the price

includeSources

boolean

If true, the exchanges which participated in the calculation (ie the sources) are included in the response

Response

{
  "result": {
    "timestamp" : 1652979512953,
    "pair": "btc_usdt",
    "price": 30124.69504984455,
    "sources": ["kraken","poloniex","bitfinex","gdax","bitstamp","zb","huobi","bybit","ftx","okex","binance"]
  }
}

Field

Type

Description

pair

string

The pair.

price

number

The quote price of the asset pair.

timestamp

number

The time at which the price change took place.

sources

array

List of exchanges which participated in the calculation of this price point.

Example

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

ws.on('open', () => {
  ws.send(JSON.stringify({
      jsonrpc: '2.0',
      method: 'subscribe',
      params: ["market:spot:reference-quote:1s", { "pair": "btc_usdt"}],
      id: 1,
    }));
});

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