VWAP
You can also get OHLCV Candlesticks from the Trade Count, OHLCV Candlesticks & VWAP endpoint.
What is this endpoint for?
This endpoint retrieves aggregated VWAP (volume-weighted average price) history for an instrument on an exchange.
Endpoint
https://<eu|us>.market-api.kaiko.io/v2/data/{commodity}.{data_version}/exchanges/{exchange}/{instrument_class}/{instrument}/aggregations/vwap
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/exchanges/cbse/spot/btc-usd/aggregations/vwap'
import http.client
import json
# Enter your Kaiko API Key
api_key = "KAIK0_API_KEY"
api_host = "us.market-api.kaiko.io"
api_base_endpoint = "/v2/data/trades.v1/exchanges/{exchange}/{instrument_class}/{instrument}/aggregations/vwap"
# Start of mandatory parameter configuration
exchange = "cbse"
instrument_class = "spot"
instrument = "btc-usd"
# End of mandatory parameter configuration
# Start of optional parameter configuration
optional_params = {
"interval": "1d",
"sort": "desc",
}
# 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": 100,
"exchange": "cbse",
"instrument_class": "spot",
"instrument": "btc-usd",
"interval": "1d",
"sort": "desc",
"aggregation": "vwap",
"data_version": "v1",
"commodity": "trades",
"request_time": "2020-11-12T16:52:36.988Z"
},
"time": "2020-11-12T16:52:37.114Z",
"timestamp": 1605199957114,
"data": [
{
"timestamp": 1605139200000,
"price": "15879.385939106618"
},
{
"timestamp": 1605052800000,
"price": "15664.643871798791"
},
/* ... */
],
"result": "success",
"continuation_token": "55qoNvASfrVdCIjrF8Ygw6TVJ4yamzUyeL9QXAmvWZZur3iaKoPcVBW1V4unNJi2zMjojbsYr9Pgt9XFCUpnAiuBiECm8X4cedvYc9t2WxHXnHKjgAp2wRAeV8ZPUSj8WNgpWTCBVymGaQZPj3oMDZwVeCPyuTLFdVPfTXVjZA94BtHeBmghoPv92JtWxN3yRvCkrw79hJBu",
"next_url": "https://<eu|us>.market-api.kaiko.io/v2/data/trades.v1/exchanges/cbse/spot/btc-usd/aggregations/vwap?continuation_token=55qoNvASfrVdCIjrF8Ygw6TVJ4yamzUyeL9QXAmvWZZur3iaKoPcVBW1V4unNJi2zMjojbsYr9Pgt9XFCUpnAiuBiECm8X4cedvYc9t2WxHXnHKjgAp2wRAeV8ZPUSj8WNgpWTCBVymGaQZPj3oMDZwVeCPyuTLFdVPfTXVjZA94BtHeBmghoPv92JtWxN3yRvCkrw79hJBu",
"access": {
"access_range": {
"start_timestamp": 1546300800000,
"end_timestamp": 1577836800000
},
"data_range": {
"start_timestamp": 1417391000000,
"end_timestamp": 1577836800000
}
}
}
Last updated