Price
Derivatives price endpoint
What is this endpoint for?
This endpoint shows the mark price, index price, and price (last traded price) of a derivative.
Endpoint
https://eu.market-api.kaiko.io/v2/data/derivatives.v2/price
Parameters
Fields
Request examples
curl --compressed -H 'Accept: application/json' -H 'X-Api-Key: <client-api-key>' \
'https://eu.market-api.kaiko.io/v2/data/derivatives.v2/price?exchange=okex&instrument_class=perpetual-future&instrument=btc-usdt&page_size=2'
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/derivatives.v2/price"
# Start of mandatory parameter configuration
mandatory_params = {
"exchange": "okex",
"instrument_class": "perpetual-future",
"instrument": "btc-usdt", # Corrected typo: "instrument" instead of "intrument"
}
# End of mandatory parameter configuration
# Start of optional parameter configuration
optional_params = {
"interval": "1h",
}
# 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)
# Pagination for next pages
all_data = []
next_url = f"{api_base_endpoint}?{url_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)}")
Response example
{
"query": {
"exchange": "okex",
"instrument_class": "perpetual-future",
"instrument": "btc-usdt",
"interval": "1m",
"page_size": 2,
"sort": "desc",
"data_version": "v2",
"commodity": "derivatives",
"request_time": "2022-04-28T12:36:34.981Z"
},
"time": "2022-04-28T12:36:37.166Z",
"timestamp": 1651149397166,
"data": [
{
"timestamp": 1651149360000,
"index_price": null,
"mark_price": "39707.8",
"price": "39709.7"
},
{
"timestamp": 1651149300000,
"index_price": "39713.3",
"mark_price": "39745.9",
"price": "39767"
}
],
/*---*/
"access": {
"access_range": {
"start_timestamp": 1646006400000,
"end_timestamp": null
},
"data_range": {
"start_timestamp": null,
"end_timestamp": null
}
}
}
Last updated