Replication data
Identify the underlying trades used to calculate each rate publication
Last updated
Was this helpful?
Was this helpful?
curl --compressed \
-H 'Accept: application/json' \
-H 'X-Api-Key: <client-api-key>' \
'https://us.market-api.kaiko.io/v1/data/index_replication.v1/rates?sequence_id=csibfhkth8ejovmc3fcg'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 = "/v1/data/index_replication.v1/rates"
# Start of mandatory parameter configuration
mandatory_params = {
"sequence_id": "csibfhkth8ejovmc3fcg",
}
# End of mandatory parameter configuration
# Start of optional parameter configuration
optional_params = {
"sort": "asc",
}
# End of optional parameter configuration
conn = http.client.HTTPSConnection(api_host)
headers = {
"X-Api-Key": api_key,
"Accept": "application/json"
}
all_params = {**mandatory_params, **optional_params}
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}?{url_params}"
# Pagination for next pages
all_data = []
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_data.extend(data.get("data", []))
print(f"Fetched {len(data.get('data', []))} datapoints. Total: {len(all_data)}")
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_data)}"){
"time": "2024-11-01T11:18:09.931Z",
"timestamp": 1730459889931,
"data": [
{
"index_code": "KK_BRR_BTCUSD",
"index_type": "SIC_REAL_TIME",
"sequence_id": "csibfhkth8ejovmc3fcg",
"underlying_data": [
"https://us.market-api.kaiko.io/v3/data/trades.v1/exchanges/cbse/spot/btc-usd/trades?start_time=2024-11-01T11:12:55Z&end_time=2024-11-01T11:13:10Z&index_inserted_at=2024-11-01T11:13:09.839473378Z&sort=asc",
"https://us.market-api.kaiko.io/v3/data/trades.v1/exchanges/gmni/spot/btc-usd/trades?start_time=2024-11-01T11:12:55Z&end_time=2024-11-01T11:13:10Z&index_inserted_at=2024-11-01T11:13:09.839473378Z&sort=asc",
"https://us.market-api.kaiko.io/v3/data/trades.v1/exchanges/krkn/spot/btc-usd/trades?start_time=2024-11-01T11:12:55Z&end_time=2024-11-01T11:13:10Z&index_inserted_at=2024-11-01T11:13:09.839473378Z&sort=asc",
"https://us.market-api.kaiko.io/v3/data/trades.v1/exchanges/lmax/spot/btc-usd/trades?start_time=2024-11-01T11:12:55Z&end_time=2024-11-01T11:13:10Z&index_inserted_at=2024-11-01T11:13:09.839473378Z&sort=asc",
"https://us.market-api.kaiko.io/v3/data/trades.v1/exchanges/stmp/spot/btc-usd/trades?start_time=2024-11-01T11:12:55Z&end_time=2024-11-01T11:13:10Z&index_inserted_at=2024-11-01T11:13:09.839473378Z&sort=asc"
]
}
],
"result": "success",
"continuation_token": "",
"next_url": "",
"access": {
"access_range": {
"start_timestamp": 1454284800000,
"end_timestamp": null
},
"data_range": {
"start_timestamp": null,
"end_timestamp": null
}
}
}