Full Aggregation
Read more about how the aggregation period works: Order Book Aggregations
What is this endpoint for?
This endpoint returns the following metrics, averaged for the requested period.
Bid volume
Ask volume
Bid-ask spread
Price Slippage
Read more about how the aggregation period works here: Order Book Aggregations.
We are unable to collect the full 10% snapshot from all exchanges we cover. Thus, for some exchanges, 'Market Depth' does not accurately portray the exchange's order book volume.
Endpoint
https://us.market-api.kaiko.io/v2/data/order_book_snapshots.v1/exchanges/{exchange}/{instrument_class}/{instrument}/ob_aggregations/full
Parameters
Fields
Request examples
curl --compressed -H 'Accept: application/json' -H 'X-Api-Key: <client-api-key>' \
'https://us.market-api.kaiko.io/v2/data/order_book_snapshots.v1/exchanges/krkn/spot/btc-usd/ob_aggregations/full?page_size=10&slippage=100000&interval=1h&start_time=2019-12-04T00:00:00Z&end_time=2019-12-06T00:00:00Z'
import http.client
import json
# Enter your Kaiko API Key
api_key = "KAIKO_API_KEY"
api_host = "us.market-api.kaiko.io"
api_base_endpoint = "/v2/data/order_book_snapshots.v1/exchanges/{exchange}/{instrument_class}/{instrument}/ob_aggregations/full"
# Start of mandatory parameter configuration
exchange = "krkn"
instrument_class = "spot"
instrument = "btc-usd"
# End of mandatory parameter configuration
# Start of optional parameter configuration
optional_params = {
"start_time": "2024-09-26T00:00:00Z",
"end_time": "2024-09-26T10:00:00Z",
"slippage_ref": "best",
"slippage": "1000000",
"interval": "1h",
}
# End of optional parameter configuration
conn = http.client.HTTPSConnection(api_host)
headers = {
"X-Api-Key": api_key,
"Accept": "application/json"
}
api_endpoint = api_base_endpoint.format(exchange=exchange, instrument_class=instrument_class, instrument=instrument)
url_params = []
for param, value in optional_params.items():
url_params.append(f"{param}={value}")
url_params = '&'.join(url_params)
# Initial request
endpoint_with_params = f"{api_endpoint}?{url_params}"
# Pagination for next pages
all_trades = []
next_url = endpoint_with_params
while next_url:
conn.request("GET", next_url, headers=headers)
response = conn.getresponse()
data = json.loads(response.read().decode("utf-8"))
all_trades.extend(data.get("data", []))
print(f"Fetched {len(data.get('data', []))} datapoints. Total: {len(all_trades)}")
next_url = data.get("next_url", "").replace("https://us.market-api.kaiko.io", "")
if not next_url:
break
conn.close()
print(f" datapoints fetched: {(all_trades)}")
Response example
{
"query": {
"page_size": 10,
"exchange": "krkn",
"instrument_class": "spot",
"instrument": "btc-usd",
"interval": "1h",
"slippage": 100000,
"slippage_ref": "mid_price",
"sort": "desc",
"aggregation": "full",
"data_version": "v1",
"commodity": "order_book_snapshots",
"request_time": "2020-05-26T14:46:00.561Z"
},
"time": "2020-05-26T14:46:03.776Z",
"timestamp": 1590504363776,
"data": [
{
"poll_timestamp": 1590501600000,
"ask_slippage": "0.00032766083806437735",
"bid_slippage": "0.0002206511273162024",
"bid_volume0_1": "31.751239130434783",
"bid_volume0_2": "87.33763043478261",
"bid_volume0_3": "139.32403260869566",
"bid_volume0_4": "177.62314130434783",
"bid_volume0_5": "206.71984782608695",
"bid_volume0_6": "251.4888043478261",
"bid_volume0_7": "287.1503043478261",
"bid_volume0_8": "317.3515869565217",
"bid_volume0_9": "335.79671739130436",
"bid_volume1": "352.03117391304346",
"bid_volume1_5": "419.0988260869565",
"bid_volume2": "470.6285",
"bid_volume4": "859.7884347826086",
"bid_volume6": "1134.0595760869564",
"bid_volume8": "1134.4657173913045",
"bid_volume10": "1134.4657173913045",
"ask_volume0_1": "21.558043478260867",
"ask_volume0_2": "37.20532608695652",
"ask_volume0_3": "78.02648913043478",
"ask_volume0_4": "143.83753260869565",
"ask_volume0_5": "192.98572826086954",
"ask_volume0_6": "235.31961956521738",
"ask_volume0_7": "280.5659565217391",
"ask_volume0_8": "309.4857717391304",
"ask_volume0_9": "327.8923152173913",
"ask_volume1": "341.79707608695657",
"ask_volume1_5": "411.3568043478261",
"ask_volume2": "475.6048586956521",
"ask_volume4": "885.1007826086956",
"ask_volume6": "1263.1216413043478",
"ask_volume8": "1364.2838369565218",
"ask_volume10": "1364.2838369565218",
"mid_price": "8830.427717391303",
"spread": "1.175"
}
/* ... */
],
"result": "success",
"access": {
"access_range": {
"start_timestamp": null,
"end_timestamp": null
},
"data_range": {
"start_timestamp": null,
"end_timestamp": null
}
}
}
Last updated