OHLCV

Request

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

Response

{
    "jsonrpc": "2.0",
    "method": "subscription",
    "params": {
        "subscription": "bff1a804-1cd6-48c7-ac7f-9e7242a3cdf3",
        "result": {
            "exchange": "gdax",
            "pair": "btc_usd",
            "timestamp": 1711570440000,
            "open": 68892.28,
            "high": 68925.5,
            "low": 68878.72,
            "close": 68904.59,
            "volume": 6.97651585
        }
    }
}
FieldTypeDescription
exchangestringThe exchange name.
pairstringThe instrument name.
timestampnumberThe timestamp associated with this record in UTC.
opennumberThe price at which the first trade occurred during the specified period.
highnumberThe highest price at which a trade took place during the period.
lownumberThe lowest price at which a trade occurred during the period.
closenumberThe price at which the last trade occurred during the specified period.
volumenumberThe total quantity traded during the period.

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:ohlcv', {'pair': 'btc_usd', 'exchange': 'gdax'}],
      id: 1,
    }));
});

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

Order Book Events

Request

All exchanges:
{"jsonrpc":"2.0","id":1,"method":"subscribe","params":["market:spot:order:events",{"pair":"btc_usd"}]}
Specific exchange:
{"jsonrpc":"2.0","id":1,"method":"subscribe","params":["market:spot:order:events",{"pair":"btc_usd","exchange":"gdax"}]}
ParamTypeDescription
pair*stringThe asset pair.
exchangestringThe exchange for which to retrieve asset pairs.
*required Note: Subscription response will include a field metadata which includes the names of the columns in the order in which they appeared in the event notification response.

Response

{
    "jsonrpc": "2.0",
    "method": "subscription",
    "params": {
        "subscription": "0f46d7af-3c49-4f2d-8e20-711efb9dc49a",
        "result": [
            [
                "gdax",
                "btc_usd",
                1711570660806,
                782000,
                68894.26,
                0.01136045,
                false,
                480582155806700
            ]
        ]
    }
}
FieldTypeDescription
exchangestringThe exchange name.
pairstringThe pair name.
timestampnumberThe time at which the order book event took place.
timestampNanosecondsnumberThe nano second part of the timestampMilliseconds, where applicable.
pricenumberThe quote price of the asset pair.
volumenumberThe number of assets traded in a specific asset pair within a given period of time.
isBidboolIndicates if it is a bid or ask order: true for a bid and false for an ask.
sequencenumberA unique identifier for the order book event.

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:order:events",  {"pair": "btc_usd", "exchange": "gdax"}],
      id: 1,
    }));
});

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

Order Book Snapshots

Request

All exchanges:
{"jsonrpc":"2.0","id":1,"method":"subscribe","params":["market:spot:order:snapshots",{"pair":"btc_usd"}]}
Specific exchange:
{"jsonrpc":"2.0","id":1,"method":"subscribe","params":["market:spot:order:snapshots",{"pair":"btc_usd","exchange":"gdax"}]}
ParamTypeDescription
pair*stringThe asset pair.
exchangestringThe exchange for which to retrieve asset pairs.
*required Note: Subscription response will include a field metadata which includes the names of the columns in the order in which they appeared in the event notification response.

Response

{
  "jsonrpc": "2.0",
  "method": "subscription",
  "params": {
      "subscription": "b6491c56-3660-47f3-896c-0890a551d42c",
      "result": [
          {
              "exchange": "gdax",
              "instrument": "btc_usd",
              "timestamp": 1711570680000,
              "exchangeTimestamp": 1711570680436,
              "isBid": false,
              "data": [
                  [
                      68886.37,
                      0.02257637,
                      1
                  ],
                  [
                      68886.85,
                      0.01000001,
                      1
                  ],
                  [
                      68887.58,
                      0.04482475,
                      1
                  ]
              ],
              "sequence": 76615491457
          }
      ]
  }
}
FieldTypeDescription
exchangestringThe exchange name.
instrumentstringThe pair name.
timestampnumberThe time at which the order book snapshot took place.
exchangeTimestampnumberThe timestamp from the exchange.
isBidboolIndicates if it is a bid or ask order: true for a bid and false for an ask.
data.pricenumberThe quote price of the asset pair.
data.volumenumberThe number of assets traded in a specific asset pair within a given period of time.
data.numOrdersnumberThe number of orders aggregated at this price level.
sequencestringA unique identifier associated with this snapshot.

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:order:snapshots",  {"pair": "btc_usd", "exchange": "gdax"}],
      id: 1,
    }));
});

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

Price Updates

Request

All pairs:
{"jsonrpc":"2.0","id":1,"method":"subscribe","params":["market:spot:prices:updates"]}

Specific pair or pair & exchange:
{"jsonrpc":"2.0","id":1,"method":"subscribe","params":["market:spot:prices:updates",{"pair":"btc_usdt"}]}

ParamTypeDescription
pairstringThe asset pair by which to filter.

Response

{
    "jsonrpc": "2.0",
    "method": "subscription",
    "params": {
        "result": {
            "delistedPair": false,
            "delta": "-4.8437252449679828865397170717",
            "isNewPair": false,
            "pair": "btc_usdt",
            "previousPrice": "67289.46636745258833937719",
            "previousTimestamp": 1712237940000,
            "price": "67284.6226422076203564906502829283",
            "timestamp": 1712238000000,
            "unchangedPrice": false
        },
        "subscription": "a931528473328abe28708cbe90f4183bff898dd213fe0ef7c2e7747b71b5d615"
    }
}
FieldTypeDescription
delistedPairbooltrue if pair has been delisted. false otherwise.
deltaThe dollar value change in price since last update.
isNewPairbooltrue if pair is new. false otherwise.
pairstringThe pair.
previousPriceThe price at time of last update.
previousTimestampThe time of the last update.
pricenumberThe quote price of the asset pair.
timestampnumberThe time at which the price change took place.
unchangedPricebooltrue if price hasn’t changed since last update. false otherwise.

Example

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

ws.on('open', () => {
  ws.send(JSON.stringify({
      jsonrpc: '2.0',
      method: 'subscribe',
      params: ["market:spot:prices:updates",{ "pair": "ltc_usdt"}],
      id: 1,
    }));
});

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

Prices

Request

All pairs:
{"jsonrpc":"2.0","id":1,"method":"subscribe","params":["market:spot:prices"]}
Specific pair or pair & exchange:
{"jsonrpc":"2.0","id":1,"method":"subscribe","params":["market:spot:prices",{ "pair": "ltc_usdt"}]}
ParamTypeDescription
pairstringThe asset pair by which to filter.

Response

{
    "jsonrpc": "2.0",
    "method": "subscription",
    "params": {
        "result": {
            "pair": "akt_eur",
            "price": "3.93400000000000000000",
            "timestamp": 1712237820000
        },
        "subscription": "ed372faab21477c26eeedec5980c1e2a318ff2c58d0e0926dde94b6afa7e8e27"
    }
}
FieldTypeDescription
pairstringThe pair.
pricenumberThe quote price of the asset pair.
timestampnumberThe time at which the price change took place.

Example

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

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

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

Tickers

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

JSON
{
    "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));
});

Trades

Request

{"jsonrpc":"2.0","id":1,"method":"subscribe","params":["market:spot:trades",{"pair":"btc_usd","exchange":"gdax"}]}
ParamTypeDescription
pairstringThe asset pair.
exchangestringThe exchange for which to retrieve asset pairs.
Note: Subscription response will include a field metadata which includes the names of the columns in the order in which they appeared in the event notification response.

Response

{
    "jsonrpc": "2.0",
    "method": "subscription",
    "params": {
        "subscription": "6ad60ce3-0738-452e-a6e9-6ce73b61e90d",
        "result": [
            [
                "gdax",
                "btc_usd",
                1712238290888,
                589000,
                "626365469",
                67431.41,
                0.10287182,
                false
            ]
        ]
    }
}
FieldTypeDescription
exchangestringThe exchange.
pairstringThe normalized pair name.
timestampnumberThe time at which the trade took place.
timestampNanosecondsnumberThe nano second part of the timestampMilliseconds, where applicable.
tradeIdstringThe unique id given by an exchange.
pricenumberThe quote price of the asset pair.
volumenumberThe number of assets traded in a specific asset pair within a given period of time.
isBuyboolIndicates if it is a buy or sell trade: true for a buy trade and false for a sell.

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:trades",  {"pair": "btc_usd", "exchange": "gdax"}],
      id: 1,
    }));
});

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