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 to this subscription: wss://ws.web3api.io/quotes.

📘

Specifying Select Exchanges

Use the sources parameter to include only specific exchanges in the calculation.

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"}]}
ParamTypeDescription
pairstringThe asset pair for which to retrieve the price feed.
sourcesarrayInclusion list - only exchanges in this list will be included in the calculation of the price
includeSourcesbooleanIf true, the exchanges which participated in the calculation (ie the sources) are included in the response

Response

{
	"jsonrpc": "2.0",
	"method": "subscription",
	"params": {
		"subscription": "m6owfs2f4u9ng065b774kubvnrmao4u9d66qnw7ua7250rae6wnytzzn99rkubkc",
		"result": {
			"timestamp": 1683947691964,
			"timestampNanoseconds": 255127,
			"pair": "btc_usdt",
			"price": 26778.02681818182,
			"sources": [
				"mexc",
				"gemini",
				"poloniex",
				"bitfinex",
				"zb",
				"bitstamp",
				"huobi",
				"binanceus",
				"bybit",
				"okex",
				"binance"
			]
		}
	}
}
FieldTypeDescription
pairstringThe pair.
pricenumberThe quote price of the asset pair.
timestampnumberThe time at which the price change took place.
timestampNanosecondsnumberThe nanosecond portion of the timestamp
sourcesarrayList 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));
});