Price Slippage
You can also get Price Slippage from the Full Aggregationendpoint.
What is this endpoint for?
This endpoint returns the average price slippage for the requested period. Read more about how the aggregation period works here: Order Book Aggregations.
Endpoint
https://us.market-api.kaiko.io/v2/data/order_book_snapshots.v1/exchanges/{exchange}/{instrument_class}/{instrument}/ob_aggregations/slippage
Parameters
Fields
Request examples
'https://us.market-api.kaiko.io/v2/data/order_book_snapshots.v1/exchanges/krkn/spot/btc-usd/ob_aggregations/slippage?page_size=10&slippage=100000&interval=1h'
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/slippage"
# 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": "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)}")
message = "hello world"
puts message
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": "slippage",
"data_version": "v1",
"commodity": "order_book_snapshots",
"request_time": "2020-05-26T15:07:06.840Z"
},
"time": "2020-05-26T15:07:07.260Z",
"timestamp": 1590505627260,
"data": [
{
"poll_timestamp": 1590505200000,
"ask_slippage": "0.00012513598764468878",
"bid_slippage": "0.0003678539692963374"
},
{
"poll_timestamp": 1590501600000,
"ask_slippage": "0.00030969034268815156",
"bid_slippage": "0.00024353107110561094"
},
/* ... */
],
"result": "success",
"access": {
"access_range": {
"start_timestamp": null,
"end_timestamp": null
},
"data_range": {
"start_timestamp": null,
"end_timestamp": null
}
}
}
Last updated