market:spot:tickers

Subscribes/Unsubscribes to market ticker data.

Once you're connected to this subscription: wss://ws.amberdata.com/spot, your subscription message must include either a pair/instrument or an exchange field. At least one must be specified — both cannot be empty.

🗒️

Note:

  • Instrument-level wildcards (e.g., "instrument": "ALL") are no longer supported.
  • Exchange-level wildcard subscriptions are only supported for Spot markets.
  • For Futures and Options, you must subscribe using explicit instrument-level subscriptions. See here for more details.

Request

{
  "jsonrpc" : "2.0",
  "id"      : 1,
  "method"  : "subscribe",
  "params"  : [ "market:spot:tickers", { "pair": "btc_usdt", "exchange": "binance" } ]
}
ParamTypeDescription
pairstringThe asset pair.
exchangestringThe exchange for which to retrieve asset pairs.

Response

{
    "jsonrpc": "2.0",
    "method": "subscription",
    "params": {
        "subscription": "ac936208-0c53-4c0a-9bc4-63188a61eb7e",
        "result": {
            "exchange": "binance",
            "pair": "btc_usdt",
            "exchangeTimestamp": 1712238263524,
            "exchangeTimestampNanoseconds": 780195,
            "timestamp": 1712238263524,
            "bid": 67427.98,
            "ask": 67427.99,
            "mid": 67427.985,
            "last": null,
            "sequence": 45375530797,
            "lastVolume": null,
            "bidVolume": 3.25905,
            "askVolume": 2.17779,
            "open24H": null,
            "low24H": null,
            "high24H": null
        }
    }
}
FieldTypeDescription
exchangestringThe exchange.
pairstringThe asset pair.
exchangeTimestampnumberThe exchange provided timestamp at which the trade took place.
exchangeTimestampNanosecondsnumberThe exchange provided nano second part of the exchangeTimestamp (if available from the exchange).
timestampnumberThe timestamp.
bidnumberThe bid of the pair.
asknumberThe ask of the pair.
midnumberThe mid of the pair.
lastnumberThe last of the pair.
sequencenumberThe sequence number (equal to null if it is not provided by the exchange).
lastVolumenumberThe last volume.
bidVolumenumberBest bid volume.
askVolumenumberBest ask volume.
open24HnumberThe 24 hour open.
low24HnumberThe 24 hour low.
high24HnumberThe 24 hour high.

Example

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

ws.on('open', () => {
  ws.send(JSON.stringify({
      jsonrpc: '2.0',
      method: 'subscribe',
      params: ['market:spot:tickers', {'pair': 'btc_usdt', 'exchange': 'binance'}],
      id: 1,
    }));
});

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