Order book

This section describes calls related to order book data, also known as books or passive level 2 data.

JSON structure

Order book related commands return JSON structured like this:

[
  {
    "symbol_id": "BITSTAMP_SPOT_BTC_USD",
    "time_exchange": "2013-09-28T22:40:50.0000000Z",
    "time_coinapi": "2017-03-18T22:42:21.3763342Z",
    "asks": [
      {
        "price": 456.35,
        "size": 123
      },
      {
        "price": 456.36,
        "size": 23
      },
      ... cut ...
    ],
    "bids": [
      {
        "price": 456.10,
        "size": 42
      },
      {
        "price": 456.09,
        "size": 5
      },
      ... cut ...
    ]
  }
]

Output variables

VariableDescription
symbol_idOur symbol identifier, format documented here.
time_exchangeExchange time of order book
time_coinapiCoinAPI time when order book received from exchange
asksBest 20 ask levels in order from best to worst
bidsBest 20 bid levels in order from best to worst
pricePrice of bid/ask
sizeVolume resting on bid/ask level in base amount

Get current order book snapshot for all or a specific symbol.

HTTP Request

  1. GET /v1/orderbooks/current?filter_symbol_id={filter_symbol_id}&limit_levels={limit_levels}
  2. GET /v1/orderbooks/{symbol_id}/current?limit_levels={limit_levels}

URL Parameters

ParameterTypeDescription
filter_symbol_idstring[]Comma or semicolon delimited parts of symbol identifier used to filter response. (required, full list available here)
limit_levelsintMaximum amount of levels from each side of the book to include in response (optional)

Latest data GET

curl https://rest.coinapi.io/v1/orderbooks/BITSTAMP_SPOT_BTC_USD/latest \
  --request GET
  --header "X-CoinAPI-Key: 73034021-THIS-IS-SAMPLE-KEY"

Get latest order book snapshots for a specific symbol, returned in time descending order.

HTTP Request

GET /v1/orderbooks/{symbol_id}/latest?limit={limit}&limit_levels={limit_levels}

URL Parameters

ParameterTypeDescription
symbol_idstringSymbol identifier of requested timeseries (full list available here)
limit_levelsintMaximum amount of levels from each side of the book to include in response (optional)
limitintAmount of items to return (optional, mininum is 1, maximum is 100000, default value is 100, if the parameter is used then every 100 output items are counted as one request)

Historical data GET

curl https://rest.coinapi.io/v1/orderbooks/BITSTAMP_SPOT_BTC_USD/history?time_start=2016-01-01T00:00:00 \
  --request GET
  --header "X-CoinAPI-Key: 73034021-THIS-IS-SAMPLE-KEY"

Get historical order book snapshots for a specific symbol within time range, returned in time ascending order.

HTTP Request

GET /v1/orderbooks/{symbol_id}/history?time_start={time_start}&time_end={time_end}&limit={limit}&limit_levels={limit_levels}

URL Parameters

ParameterTypeDescription
symbol_idstringSymbol identifier for requested timeseries (full list available here)
time_starttimestringStarting time in ISO 8601 (required)
time_endtimestringTimeseries ending time in ISO 8601 (optional, if not supplied then the data is returned to the end or when result elements count reaches the limit)
limit_levelsintMaximum amount of levels from each side of the book to include in response (optional)
limitintAmount of items to return (optional, mininum is 1, maximum is 100000, default value is 100, if the parameter is used then every 100 output items are counted as one request)

Copyright 2022 COINAPI LTD or its affiliates. All rights reserved.
StatusPage: