Robust Pair Prices
What is this endpoint for?
This endpoint returns a robust price calculation for a specific pair by aggregating prices from our Trade Data. Read the methodology to learn about the calculation process.
If a null value is returned, it means there are not enough trades to calculate a direct price. In this case, use Cross Prices instead.
Endpoint
https://<eu|us>.market-api.kaiko.io/v2/data/trades.v1/robust_pair_price/{base_asset}/{quote_asset}
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/trades.v1/robust_pair_price/btc/eth?interval=1m&extrapolate_missing_values=true&start_time=2023-05-03T00:01:00.000Z&end_time=2023-05-04T00:00:00.000Z'
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/trades.v1/robust_pair_price/{base_asset}/{quote_asset}"
# Start of mandatory parameter configuration
base_asset = "btc"
quote_asset = "eth"
interval = "1m"
# End of mandatory parameter configuration
# Start of optional parameter configuration
optional_params = {
"extrapolate_missing_values": "true",
"start_time": "2023-05-03T00:01:00.000Z",
"end_time": "2023-05-03T01:00:00.000Z",
}
# End of optional parameter configuration
conn = http.client.HTTPSConnection(api_host)
headers = {
"X-Api-Key": api_key,
"Accept": "application/json"
}
all_params = {
**optional_params,
"interval": interval
}
url_params = []
for param, value in all_params.items():
url_params.append(f"{param}={value}")
url_params = '&'.join(url_params)
endpoint_with_params = f"{api_base_endpoint.format(base_asset=base_asset, quote_asset=quote_asset)}?{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)}")
Information from this endpoint can be accessed through Google BigQuery. To get started, read our guide.
Response example
{
"query": {
"start_time": "2023-05-03T23:50:00Z",
"end_time": "2023-05-04T00:00:00Z",
"base_asset": "btc",
"quote_asset": "eth",
"interval": "1m",
"sort": "desc",
"sources": false,
"page_size": 10,
"include_exchanges": [],
"exclude_exchanges": [],
"request_time": "2024-07-11T07:39:11.34695219Z",
"data_version": "v1",
"commodity": "trades",
"extrapolate_missing_values": true,
"instruments": [
"bbsp:spot:eth-btc",
"bfly:spot:eth-btc",
"bfnx:spot:eth-btc",
"bgon:spot:eth-btc",
"binc:spot:eth-btc",
"bnus:spot:eth-btc",
"bull:spot:eth-btc",
"cbse:spot:eth-btc",
"cnex:spot:eth-btc",
"kcon:spot:eth-btc",
"krkn:spot:eth-btc",
"lmax:spot:eth-btc",
"okex:spot:eth-btc",
"stmp:spot:eth-btc",
"yobt:spot:eth-btc"
]
},
"time": "2024-07-11T07:39:11.430101692Z",
"timestamp": 1720683551,
"data": [
{
"timestamp": 1683158340000,
"price": "15.236109727862226",
"volume": "10.661977267122458",
"count": 263,
"extrapolate_missing_values": false
},
{
"timestamp": 1683158280000,
"price": "15.226897227981592",
"volume": "26.42011153624422",
"count": 184,
"extrapolate_missing_values": false
},
/*...*/
],
"result": "success",
"continuation_token": "V7Dxo9XotwyC1qQtT6Dkaq3fhY8jFqzmgjwkALFWdZQ4JHWoUQFrDaTw8Zc4yCY4Cf863uPBY4phumdqcjoL4imnx5amnLJCZP3rr7dDBw2EC33kpYtsRPsmx1sVW2tfp5pUh72fP9gYrhHzzQpGAz5PKFFwiTuHT921xT1ajG8EV9aRibXxs69PLGwnfH6WD5iw4SAc58c7ZF8PafYgb34APyYC1",
"next_url": "https://us.market-api.kaiko.io/v2/data/trades.v1/robust_pair_price/btc/eth?continuation_token=V7Dxo9XotwyC1qQtT6Dkaq3fhY8jFqzmgjwkALFWdZQ4JHWoUQFrDaTw8Zc4yCY4Cf863uPBY4phumdqcjoL4imnx5amnLJCZP3rr7dDBw2EC33kpYtsRPsmx1sVW2tfp5pUh72fP9gYrhHzzQpGAz5PKFFwiTuHT921xT1ajG8EV9aRibXxs69PLGwnfH6WD5iw4SAc58c7ZF8PafYgb34APyYC1",
"access": {
"access_range": {
"start_timestamp": 1262995200000,
"end_timestamp": 2186006399000
},
"data_range": {
"start_timestamp": null,
"end_timestamp": null
}
}
}
Last updated