# About the Developer Hub

### Welcome to the Kaiko Developer Hub.&#x20;

This hub is your go-to place for everything Kaiko. It's broken down into 3 core sections:&#x20;

#### Knowledge hub

Your go-to place for information on Kaiko products, coverage, updates, and inspiration on how you can leverage our solutions. We'll be working on bringing more content over the coming months, so keep checking back.

[#knowledge-hub](#knowledge-hub "mention")

#### Kaiko Data

Everything you need to start consuming Kaiko data across all our delivery channels:

* [Kaiko Stream](/stream)
* [Rest API](/rest-api)
* [Cloud Delivery](/cloud-delivery)
* [On-chain](/on-chain#welcome-to-the-kaiko-csv-documentation)

#### Kaiko Indices

Everything you need to get started with Kaiko Indices.

[Kaiko Indices](/kaiko-indices)

## Stay in the know

If you'd like to be alerted when we make changes to our products, sign-up to our mailing list [here](https://www.kaiko.com/product-updates).


# About Kaiko

An introduction to Kaiko and our products.

## What is Kaiko?

Kaiko is the global independent leader in digital assets market data, analytics, indices, and monitoring for institutional investors, financial services firms, and regulators.<br>

Kaiko provides the foundational data infrastructure bridging traditional finance and on-chain capital markets through regulatory-compliant and auditable data. For over 10 years, we've delivered the trusted, transparent, and actionable financial data that institutions need to navigate both centralized and decentralized crypto markets.

## Our solutions

We provide data solutions across four main pillars:

#### Data Feeds

Market data feeds for front and mid-office operations, business intelligence, and risk management.

#### Analytics

Proprietary data analytics solutions for risk analysis, fair value pricing for marking, and derivatives listings.

#### Monitoring

Market-level and blockchain solutions for surveillance, AML/CFT compliance, and research.

#### Kaiko Indices

Kaiko Indices offers institutional-grade benchmarks and indices, setting the standard for reliability and transparency in the digital asset market. As a regulated Benchmark Administrator under the EU BMR framework and compliant with IOSCO principles, we empower exchanges, asset managers, and financial institutions with trusted data solutions that support robust settlement and risk management practices.

## Tour the data

Depending on the solution, you can consume our data by Rest API, streaming service, or via cloud service providers. Have a look at our [data dictionary](broken://pages/3Zrdo3hDdfLzjXIzcFtT) to see which solution are available by which channel, as well as specific information on the data's granularity, historical availability.&#x20;


# Tour the Knowledge Hub

{% @supademo/embed demoId="cm1ta527x12rbspgcnmvyjfd5" url="<https://app.supademo.com/demo/cm1ta527x12rbspgcnmvyjfd5>" %}


# Kaiko Examples

Learn more about what you can do with Kaiko data and how to make successful system requests in our use-case micro-guides. &#x20;

*These are just a few examples of how Kaiko data can help you achieve your strategic goals. If you need help with a use case not currently featured, please reach out to our Support Team.*&#x20;


# Capture alpha before major events impact the market

Being able to react quickly to major hacks or market events before most others can help market participants execute trades and orders more effectively.

Take the Bybit hack as an example: a security breach occurred, but the market was slow to react. It wasn’t until hours later, when Bybit’s CEO made an official announcement, that a full market response took place. However, some participants spotted the early signs and acted before the news became public. Their trading activity left a visible footprint in trading data, creating a window of opportunity for others to recognize these early warning signs and react accordingly to capture the alpha. By doing so, they position themselves ahead of the broader market, rather than reacting after the widespread panic set in.

To secure the best trading conditions, market participants must monitor data in real-time and act quickly. Reacting early reduces the impact of their trades, helping them stay ahead before market depth deteriorates and a large-scale sell-off takes hold.

By leveraging [Kaiko Level 1 Data](https://www.kaiko.com/products/data-feeds/l1-l2-data) via Kaiko Stream, participants gain access to real-time, tick-level trade data the moment transactions occur. This allows them to identify unusual market movements—such as an unexplained sell-off followed by a sharp recovery—and react swiftly to minimize losses and seize opportunities before the broader market.

### Subscribe to tick-level trades

To subscribe to real-time trade data for a specific asset, configure your connection to Kaiko Stream as below. In this example, we'll monitor ETH spot trades on all exchanges covered by Kaiko. This data will show every single trade involving ETH. To subscribe to just one venue, see example 2.

{% tabs %}
{% tab title="Example 1 - All exchanges" %}

```python
from __future__ import print_function
import logging
import os

import grpc
from google.protobuf.json_format import MessageToJson
from google.protobuf import duration_pb2

from kaikosdk import sdk_pb2_grpc
from kaikosdk.core import instrument_criteria_pb2, assets_pb2
from kaikosdk.stream.aggregates_ohlcv_v1 import request_pb2 as pb_ohlcv
from kaikosdk.stream.aggregates_vwap_v1 import request_pb2 as pb_vwap
from kaikosdk.stream.market_update_v1 import request_pb2 as pb_market_update
from kaikosdk.stream.market_update_v1 import commodity_pb2 as pb_commodity
from kaikosdk.stream.trades_v1 import request_pb2 as pb_trades

def market_update_request(channel: grpc.Channel):
    try:
        with channel:
            stub = sdk_pb2_grpc.StreamMarketUpdateServiceV1Stub(channel)
            responses = stub.Subscribe(pb_market_update.StreamMarketUpdateRequestV1(
                  # start of parameter configuration # 
                instrument_criteria = instrument_criteria_pb2.InstrumentCriteria(
                    exchange = "*",
                    instrument_class = "spot",
                    code = "eth-*"
                ),
                  # end of parameter configuration # 
                commodities=[pb_commodity.SMUC_TRADE]
            ))
            for response in responses:
                print("Received message %s" % (MessageToJson(response, including_default_value_fields = True)))
                # print("Received message %s" % list(map(lambda o: o.string_value, response.data.values)))
    except grpc.RpcError as e:
        print(e.details(), e.code())
        
def run():
    credentials = grpc.ssl_channel_credentials(root_certificates=None)
    call_credentials = grpc.access_token_call_credentials(os.environ['KAIKO_API_KEY'])
    composite_credentials = grpc.composite_channel_credentials(credentials, call_credentials)
    channel = grpc.secure_channel('gateway-v0-grpc.kaiko.ovh', composite_credentials)

    market_update_request(channel)

if __name__ == '__main__':
    logging.basicConfig()
    run()
```

{% endtab %}

{% tab title="Example 2 - A specific venue" %}

```python
from __future__ import print_function
import logging
import os

import grpc
from google.protobuf.json_format import MessageToJson
from google.protobuf import duration_pb2

from kaikosdk import sdk_pb2_grpc
from kaikosdk.core import instrument_criteria_pb2, assets_pb2
from kaikosdk.stream.aggregates_ohlcv_v1 import request_pb2 as pb_ohlcv
from kaikosdk.stream.aggregates_vwap_v1 import request_pb2 as pb_vwap
from kaikosdk.stream.market_update_v1 import request_pb2 as pb_market_update
from kaikosdk.stream.market_update_v1 import commodity_pb2 as pb_commodity
from kaikosdk.stream.trades_v1 import request_pb2 as pb_trades

def market_update_request(channel: grpc.Channel):
    try:
        with channel:
            stub = sdk_pb2_grpc.StreamMarketUpdateServiceV1Stub(channel)
            responses = stub.Subscribe(pb_market_update.StreamMarketUpdateRequestV1(
                  # start of parameter configuration # 
                instrument_criteria = instrument_criteria_pb2.InstrumentCriteria(
                    exchange = "binc",
                    instrument_class = "spot",
                    code = "eth-*"
                ),
                  # end of parameter configuration # 
                commodities=[pb_commodity.SMUC_TRADE]
            ))
            for response in responses:
                print("Received message %s" % (MessageToJson(response, including_default_value_fields = True)))
                # print("Received message %s" % list(map(lambda o: o.string_value, response.data.values)))
    except grpc.RpcError as e:
        print(e.details(), e.code())
        
def run():
    credentials = grpc.ssl_channel_credentials(root_certificates=None)
    call_credentials = grpc.access_token_call_credentials(os.environ['KAIKO_API_KEY'])
    composite_credentials = grpc.composite_channel_credentials(credentials, call_credentials)
    channel = grpc.secure_channel('gateway-v0-grpc.kaiko.ovh', composite_credentials)

    market_update_request(channel)

if __name__ == '__main__':
    logging.basicConfig()
    run()
```

{% endtab %}
{% endtabs %}

Once configured, your received messages will look like this, containing the trade amount, the price at which it was executed, if the trade was a sell or a buy of the asset, and the exchange involved.&#x20;

```json
Received message {
  "commodity": "SMUC_TRADE",
  "amount": 0.1846,
  "class": "spot",
  "code": "eth-usdc",
  "exchange": "binc",
  "sequenceId": "cuuuc51nce0cg8o1ltk0",
  "id": "80983213",
  "price": 2400.87,
  "tsExchange": {
    "value": "2025-02-25T15:47:32.016Z"
  },
  "tsCollection": {
    "value": "2025-02-25T15:47:32.171124934Z"
  },
  "tsEvent": "2025-02-25T15:47:32.340833187Z",
  "updateType": "TRADE_BUY",
  "additionalProperties": {}
}
```


# Trace stolen funds across a blockchain

Tracing blockchain transactions and wallets is critical in the aftermath of a hack, enabling investigators to follow stolen funds, uncover illicit activity, and improve transparency. [Kaiko Blockchain Monitoring](https://www.kaiko.com/products/monitoring/blockchain-monitoring) provides direct, UI-free access to on-chain data, ensuring full control over data extraction and analysis. Unlike proprietary interfaces that can be restrictive, this approach allows for flexible, scalable investigations tailored to evolving threats.

This guide demonstrates how to:

* Trace fund movements across Ethereum wallets
* Aggregate and analyze on-chain flows
* Conduct scalable investigations without the constraints of a predefined UI

### Request information on a single address or transaction

To see the balances and transactions for a single Ethereum wallet, use this request example.&#x20;

{% tabs %}
{% tab title="cURL" %}
{% code overflow="wrap" %}

```url
curl --compressed -H "Accept: application/json" -H "X-Api-Key: <client-api-key>" \
  "https://eu.market-api.kaiko.io/v2/data/wallet.v1/audit?blockchain=ethereum"
```

{% endcode %}
{% endtab %}

{% tab title="Python" %}

```python
import pandas as pd 
import requests
from tqdm import tqdm
from concurrent.futures import ThreadPoolExecutor
import time

list_wallets = ['0xf977814e90da44bfa03b6295a0616a897441acec','0xbe0eb53f46cd790cd13851d5eff43d12404d33e8']
start_time = '2025-02-27T00:00:00.000Z'
blockchain = 'ethereum'

# Headers for the API request
headers_dict = {
    'Accept': 'application/json',
    'X-Api-Key': 'YOUR_API_KEY'
}

# API URL for fetching Kaiko product Blockchain Monitoring
URL = 'https://us.market-api.kaiko.io/v2/data/wallet.v1/audit'

def get_data(url, headers, params=None, retries=5, delay=1):
    for attempt in range(retries):
        try:
            response = requests.get(url, headers=headers, params=params)
            response.raise_for_status()  # Raise an exception for HTTP errors
            return response.json()
        except requests.exceptions.RequestException as e:
            print(f"Attempt {attempt + 1} failed: {e}")
            if attempt < retries - 1:
                time.sleep(delay)
            else:
                raise

def get_all_events_for_address(address, start_time, blockchain):
    data = pd.DataFrame()
    
    params_dict = {
        'blockchain': blockchain,
        'user_address': address.lower(),
        'start_time': start_time
    }

    res = get_data(URL, headers_dict, params_dict)
    try:
        data = pd.concat([data, pd.DataFrame(res['data'])], ignore_index=True)
    except Exception as e:
        print(e)

    while 'next_url' in res.keys():
        if res['next_url'] == None:
            break
        try:
            res = get_data(res['next_url'], headers_dict)
            data = pd.concat([data, pd.DataFrame(res['data'])], ignore_index=True)
        except KeyboardInterrupt:
            print("Exit")
            break
        except Exception as e:
            print(e)
            continue

    return data


def get_all_events_for_addresses(addresses, start_time):
    with ThreadPoolExecutor(max_workers=20) as executor:
        results = list(tqdm(executor.map(lambda addr: get_all_events_for_address(addr, start_time, blockchain), addresses), total=len(addresses)))
    return pd.concat(results, ignore_index=True)

data = get_all_events_for_addresses(addresses=list_wallets, start_time=start_time, blockchain=blockchain)

```

{% endtab %}
{% endtabs %}

### Trace funds through several paths

To automatically trace the destination of funds, it's wise to use a custom Python script that:

* Queries multiple wallets in a batch request
* Automatically requests information on subesquent "hops" or flows
* Consolidates into a final list of destinations addresses

This script dynamically traces fund flows across multiple paths, quickly generating a csv with all  wallets associated with the hack up to 4 hops. You can re-run the script any time to get an instantly up-to-date picture of the stolen funds and any new associated wallets. You can also add extra steps to trace across as many hops as required.

{% tabs %}
{% tab title="Python" %}
{% code fullWidth="true" %}

````python
import pandas as pd
import requests
from tqdm import tqdm
from concurrent.futures import ThreadPoolExecutor
import time

# Headers for the API request
KAIKO_HEADERS_DICT = {
    'Accept': 'application/json',
    'X-Api-Key': 'YOUR_API_KEY'
}

def get_data(url, headers, params=None, retries=10, delay=2):
    """
    Fetches data from the given URL with retry logic.

    Parameters:
    url (str): The URL to fetch data from.
    headers (dict): The headers for the request.
    params (dict): The parameters for the request.
    retries (int): The number of retry attempts.
    delay (int): The delay between retry attempts in seconds.

    Returns:
    dict: The JSON response from the API.
    """
    for attempt in range(retries):
        try:
            response = requests.get(url, headers=headers, params=params)
            response.raise_for_status()  # Raise an exception for HTTP errors
            return response.json()
        except requests.exceptions.RequestException:
            if attempt < retries - 1:
                time.sleep(delay)
            else:
                print('max retries exceeded')
                raise


def get_all_events_for_address(address, start_time='2024-01-01T00:00:00.000Z'):
    """
    Fetches all events for a given address starting from a specified time.
    
    Parameters:
    address (str): The user address to fetch events for.
    start_time (str): The start time for fetching events in ISO 8601 format.
    
    Returns:
    pd.DataFrame: A DataFrame containing all events for the given address.
    """
    URL = 'https://us.market-api.kaiko.io/v2/data/wallet.v1/audit'  
    data = pd.DataFrame()
    params_dict = {
        'blockchain': 'ethereum',
        'user_address': address.lower(),
        'start_time': start_time,
        'page_size':400
    }
    res = get_data(URL, KAIKO_HEADERS_DICT, params_dict)
    try:
        data = pd.concat([data, pd.DataFrame(res['data'])], ignore_index=True)
    except Exception as e:
        print(e)
    count = 0
    while 'next_url' in res.keys():
        count+=1
        if res['next_url'] == None:
            break
        try:
            res = get_data(res['next_url'], KAIKO_HEADERS_DICT)
            data = pd.concat([data, pd.DataFrame(res['data'])], ignore_index=True)
            if (count > 100):
                print(address, count)
                break
        except KeyboardInterrupt:
            print("Exit")
            break
        except Exception as e:
            print(e)
            continue
    return data


def get_all_events_for_addresses(addresses, start_time='2024-01-01T00:00:00.000Z'):
    """
    Fetches all events for multiple addresses starting from a specified time using multithreading.
    
    Parameters:
    addresses (list): A list of user addresses to fetch events for.
    start_time (str): The start time for fetching events in ISO 8601 format.
    
    Returns:
    pd.DataFrame: A DataFrame containing all events for the given addresses.
    """
    with ThreadPoolExecutor(max_workers=20) as executor:
        results = list(tqdm(executor.map(lambda addr: get_all_events_for_address(addr, start_time), addresses), total=len(addresses)))
    return pd.concat(results, ignore_index=True)


def get_all_events_for_addresses_with_time(addresses_and_time):
    """
    Fetches all events for multiple addresses with different start times using multithreading.
    
    Parameters:
    addresses_and_time (list of tuples): A list of tuples where each tuple contains an address and a start time.
    example:
        addresses_and_time = [["0x47666fab8bd0ac7003bce3f5c3585383f09486e2", '2025-01-01T04:00:00.000Z'],
        ["0xaf620e6d32b1c67f3396ef5d2f7d7642dc2e6ce9", '2021-02-21T01:00:00.000Z']]
    
    Returns:
    pd.DataFrame: A DataFrame containing all events for the given addresses and start times.
    """
    with ThreadPoolExecutor(max_workers=20) as executor:
        results = list(tqdm(executor.map(lambda addr: get_all_events_for_address(addr[0], addr[1]), addresses_and_time), total=len(addresses_and_time)))
    return pd.concat(results, ignore_index=True)

def get_all_pools():
    URL = 'https://reference-data-api.kaiko.io/v1/pools'
    data = pd.DataFrame()
    params_dict = {
        'blockchain': 'ethereum'}
    res = get_data(URL, KAIKO_HEADERS_DICT, params_dict)
    try:
        data = pd.concat([data, pd.DataFrame(res['data'])], ignore_index=True)
    except Exception as e:
        print(e)
    return data['address'].tolist()

def get_receiver_addresses_filtered_with_time(events, filter_out):
    """
    Filters and returns a list of receiver addresses with their earliest transaction timestamps,
    excluding specified addresses and keeping only those with a total amount_usd > 100.

    Parameters:
    events (pd.DataFrame): DataFrame containing transaction events.
    filter_out (set): A set of addresses to be excluded from the results.

    Returns:
    list: A list of tuples where each tuple contains a receiver address and its earliest transaction timestamp.
    """
    outgoing_events = events[events["direction"] == "out"]
    amount_sums = outgoing_events.groupby('receiver_address')['amount_usd'].sum()
    valid_addresses = amount_sums[amount_sums > 10].index
    receiver_addresses_list_with_time = outgoing_events[outgoing_events['receiver_address'].isin(valid_addresses)][["receiver_address", "timestamp"]]
    receiver_addresses_list_with_time['timestamp'] = pd.to_datetime(receiver_addresses_list_with_time['timestamp'], unit='ns').dt.strftime('%Y-%m-%dT%H:%M:%S.%fZ')
    receiver_addresses_list_with_time = receiver_addresses_list_with_time.groupby('receiver_address')['timestamp'].min().reset_index().values.tolist()
    receiver_addresses_list_with_time = [addr for addr in receiver_addresses_list_with_time if addr[0] not in filter_out]
    return receiver_addresses_list_with_time

# ----------------------------

# Addresses to be removed from the results
addresses_to_remove = [
    "0x0000000000000000000000000000000000000000", # null address
    '', # empty address
    "0x47666fab8bd0ac7003bce3f5c3585383f09486e2", # exploiter
    "0xf89d7b9c864f589bbf53a82105107622b35eaa40", # bybit hot wallet
    "0x1f9090aae28b8a3dceadf281b0f12828e676c326", # block builder
    "0x95222290dd7278aa3ddd389cc1e1d165cc4bafe5", # block builder
    "0x4838b106fce9647bdf1e7877bf73ce8b0bad5f97", # block builder
    "0x388c818ca8b9251b393131c08a736a67ccb19297", # Lido execution builder
    "0x7e2a2fa2a064f693f0a55c5639476d913ff12d05", # mev block builder
    "0x6be457e04092b28865e0cba84e3b2cfa0f871e67", # mev block builder
    "0x3bee5122e2a2fbe11287aafb0cb918e22abb5436", # mev block builder
    "0xdadb0d80178819f2319190d340ce9a924f783711", # block builder
    "0xe688b84b23f322a994a53dbf8e15fa82cdb71127", # block fee recipient
    "0xd11d7d2cb0aff72a61df37fd016ee1bd9f180633", # mev block builder
    "0x4675c7e5baafbffbca748158becba61ef3b0a263", # mev block builder
    "0x7adc0e867ebc337e2d20c44db181c067fa08637b", # block builder
    "0x98ed2d46a27afeead62a5ea39d022a33ea4d25c1", # ?
    "0x00000000219ab540356cbb839cbe05303d7705fa", # Beacon chain deposit contract
    "0x0000000000bbf5c5fd284e657f01bd000933c96d", # Paraswap delta v2
    "0x6a000f20005980200259b80c5102003040001068", # Paraswap augustus v6.2
    "0x3fc91a3afd70395cd496c647d5a6cc9d4b2b7fad", # Uniswap universal router
    "0x1231deb6f5749ef6ce6943a275a1d3e7486f4eae", # li.fi diamond (router)
    "0x74de5d4fcbf63e00296fd95d33236b9794016631", # metamask swap
    "0x7d0ccaa3fac1e5a943c5168b6ced828691b46b36", # OKX DEX router
    "0x9008d19f58aabd9ed0d60971565aa8510560ab41", # Cow protocol settlement
    "0xd37bbe5744d730a1d98d8dc97c42f0ca46ad7146", # THORCHAIN router
]

# Get all pools on Ethereum in Kaiko's reference data (to be filtered out because they're not receivers from the exploiter)
all_pools = get_all_pools()
addresses_to_remove = addresses_to_remove + all_pools

# Level 1: Get all events from the exploiter
exploiter_address = "0x47666fab8bd0ac7003bce3f5c3585383f09486e2"
hack_time = '2025-02-21T14:00:00.000Z'
exploiter_events = get_all_events_for_address(exploiter_address, start_time=hack_time)

# Level 2: Get all events for all addresses that received funds from the exploiter
receiver_addresses_list_with_time = get_receiver_addresses_filtered_with_time(exploiter_events, addresses_to_remove)
receiver_addresses_2_events = get_all_events_for_addresses_with_time(receiver_addresses_list_with_time)

# Level 3: Get all events for all addresses that received funds from addresses that received funds from the exploiter
receiver_addresses_3_list_with_time = get_receiver_addresses_filtered_with_time(receiver_addresses_2_events, addresses_to_remove)
receiver_addresses_3_events = get_all_events_for_addresses_with_time(receiver_addresses_3_list_with_time)

# Level 4: Get all events for all addresses that received funds from addresses that received funds from the addresses that received funds from the exploiter
receiver_addresses_4_list_with_time = get_receiver_addresses_filtered_with_time(receiver_addresses_3_events, addresses_to_remove)
receiver_addresses_4_events = get_all_events_for_addresses_with_time(receiver_addresses_4_list_with_time)

# ----------------------------

# Concat all events dataframe and specify each "level" it is.
df1 = exploiter_events.copy()
df2 = receiver_addresses_2_events.copy()
df3 = receiver_addresses_3_events.copy()
df4 = receiver_addresses_4_events.copy()

# Add the 'Layer' column
df1["level"] = "Level 1"
df2["level"] = "Level 2"
df3["level"] = "Level 3"
df4["level"] = "Level 4"

# Concatenate the DataFrames
all_transfers = pd.concat([df1, df2, df3, df4], ignore_index=True)
all_transfers.to_csv("all_exploiters_and_receivers_transfers.csv", index=False)

list_addresses = all_transfers[all_transfers["direction"] == "out"].groupby(['user_address', 'level'])['amount_usd'].sum()
list_addresses.to_csv("list_addresses.csv", index=True)
```
````

{% endcode %}
{% endtab %}

{% tab title="CSV Output Example" %}

<table><thead><tr><th valign="top">User_address</th><th valign="top">Level</th><th valign="top">Amount_usd</th></tr></thead><tbody><tr><td valign="top">0x000010036c0190e009a000d0fc3541100a07380a</td><td valign="top">Level 4</td><td valign="top">165439929.37011100</td></tr><tr><td valign="top">0x000949aef11d7b124a3c333e737af450fc70682a</td><td valign="top">Level 4</td><td valign="top">528853.1734133920</td></tr><tr><td valign="top">0x0014462b38e67e6c1f5e0385fbbd298abf182722</td><td valign="top">Level 4</td><td valign="top">686812.705417298</td></tr><tr><td valign="top">0x001c0cf0aba3614e650d591ef222ccb0f8e3a0ee</td><td valign="top">Level 4</td><td valign="top">90055.16267862360</td></tr><tr><td valign="top">0x00214cb533e66d062f420125b99fc60b6b3069a0</td><td valign="top">Level 3</td><td valign="top">239743.47125701400</td></tr><tr><td valign="top">0x00214cb533e66d062f420125b99fc60b6b3069a0</td><td valign="top">Level 4</td><td valign="top">239743.47125701400</td></tr><tr><td valign="top">0x0026b786684690772d87a448f9ff909669c83649</td><td valign="top">Level 4</td><td valign="top">152745.4588658880</td></tr><tr><td valign="top">0x002b8edf90443fca65241075709db049187b9603</td><td valign="top">Level 4</td><td valign="top">327137.64441197500</td></tr><tr><td valign="top">0x002fd753417a7348fdd84b4be390e399515fc488</td><td valign="top">Level 4</td><td valign="top">264196.3332642850</td></tr></tbody></table>
{% endtab %}
{% endtabs %}


# Track asset volume on exchanges

Track the volume of any asset trading on a centralized or decentralized exchange. Quickly identify the top trending tokens and spot instances where volumes differ from market expectations.

<figure><img src="https://lh7-eu.googleusercontent.com/docsz/AD_4nXeTQxA6bWEaRwMQ0FQvH9LWiG8C7okZ_doNqu1auGg4UnfxrJ7QhtOcO1PaZ67O07IjHRFvw9FWibHCi9xJuuGI62TlXgO-vkg-02uX0cpa8s55mWgmXZ58UWi_RxMuMwsV3H1mqbmQEo0wtcqKOi6keN88?key=yKeDMZ63ctoLut6nyqnEtA" alt=""><figcaption><p>In the example above, we can see that smaller tokens like SLERF, ENA, and BONE have recorded very large volumes, on some days, significantly higher than that of eth.<br><br></p></figcaption></figure>

### <mark style="color:blue;">How to build the request</mark>

With the Market Metrics [**Exchange** **endpoint**](/rest-api/monitoring/kaiko-market-explorer/exchanges#what-is-this-endpoint-for), you can use the following parameters to source the specific information you're looking for:&#x20;

| Paramater   | Value                    |
| ----------- | ------------------------ |
| exchange    | huob                     |
| start\_time | 2024-04-01T00:00:00.000Z |
| end\_time   | 2024-04-11T00:00:00.000Z |
| interval    | 1d                       |
| page\_size  | 100                      |
| sort        | asc                      |

Here's an example of an HTTP string request using the values above:

<https://us.market-api.kaiko.io/v2/data/analytics.v2/exchange_metrics?exchange=huob&start_time=2024-04-01T00:00:00.000Z&end_time=2024-04-11T00:00:00.000Z&interval=1d&page_size=100&sort=asc>

When you receive your response, search for the following fields to find the data you need:

* timestamp&#x20;
* asset\_code
* total\_volume\_usd

####


# Compare market depth between exchanges

Market depth is a measure of how well a market can handle large orders without impacting asset prices. A "deep" market has enough volume on both sides - bids (buy orders) and asks (sell orders) - to handle large orders while keeping prices stable. Market depth varies between exchanges and over time, so traders often monitor it across different platforms to determine the best market on which to trade.&#x20;

<figure><img src="/files/y4ExdOeknE7YImSYOGzh" alt=""><figcaption><p>This chart shows the 1% market depth for all trading pairs with BTC as the base asset. It shows the USD value of all bids <code>(bid_volume_1)</code> and asks (<code>ask_volume_1</code>) within 1% of the mid-price.</p></figcaption></figure>

### <mark style="color:blue;">How to build the request</mark>

Use [Market Metrics](/rest-api/monitoring/kaiko-market-explorer/assets) (assets) with the following parameters to replicate this chart.

| Paramater   | Value                    |
| ----------- | ------------------------ |
| asset       | btc                      |
| start\_time | 2022-11-05T00:00:00.000Z |
| end\_time   | 2022-11-28T00:00:00.000Z |
| interval    | 1d                       |
| sources     | true                     |

Here's an example of a cURL string request using the values above:

{% code overflow="wrap" %}

```url
curl -X GET "https://us.market-api.kaiko.io/v2/data/analytics.v2/asset_metrics?asset=btc&start_time=2022-11-05T00:00:00.000Z&end_time=2022-11-28T00:00:00.000Z&interval=1d&sources=true" -H "accept: application/json" -H "X-Api-Key: YOUR_API_KEY"
```

{% endcode %}

When you receive your response, search for the following fields to find the data you need:

* `timestamp`&#x20;
* `buy_market_depths`:
  * exchange
  * volume\_usds: {bid\_volume\_0\_1}
* `sell_market_depth`s:&#x20;
  * exchange&#x20;
  * volume\_usds: {ask\_volume\_0\_1}


# Identify high-potential assets before they're listed on CEXs

Track the most popular assets on leading DEXs such as Uniswap to uncover high-potential early stage tokens not yet listed on centralized exchanges.&#x20;

<figure><img src="https://lh7-eu.googleusercontent.com/docsz/AD_4nXd9cmVOGtEI15hLdTHF7X861X1Krk7Zi9JlrfLvZZXWdo23OzWiGgQtX__NKpW58-eNpPyR9MpTI5-4YYp4qaHKJZdW54bU7mVyB8LDO-agNGr_Ssj13fxL21QTlBLtCSpDmEN4FhYyN3CwfEuWOznpWXI?key=yKeDMZ63ctoLut6nyqnEtA" alt=""><figcaption><p>See how assets exclusively available on DEXs like USDE (Ethena's stablecoin) and WSTETH (a liquid staking token), have impressive trading volumes, even surpassing popular assets like LINK.</p></figcaption></figure>

### <mark style="color:blue;">How to build the request</mark>

With the Market Metrics [**Exchange** **endpoint**](/rest-api/monitoring/kaiko-market-explorer/exchanges#what-is-this-endpoint-for), you can use the following parameters to source the specific information you're looking for:&#x20;

| Paramater   | Value                    |
| ----------- | ------------------------ |
| exchange    | usp3                     |
| start\_time | 2024-04-05T00:00:00.000Z |
| end\_time   | 2024-04-13T00:00:00.000Z |
| interval    | 1d                       |
| page\_size  | 100                      |
| sort        | asc                      |

Here's an example of an HTTP string request using the values above:

<https://us.market-api.kaiko.io/v2/data/analytics.v2/exchange\\_metrics?exchange=usp3\\&start\\_time=2024-04-05T00:00:00.000Z\\&end\\_time=2024-04-13T00:00:00.000Z\\&interval=1d\\&page\\_size=100\\&sort=asc&#x20>;

When you receive your response, search for the following fields to find the data you need:

* timestamp&#x20;
* asset\_code
* asset\_total\_volume\_usd

####


# Generate a liquidity-based asset ranking

Identify an asset's liquidity, put it into a ranking and then compare it with the market cap to evaluate its true value. Go beyond simple market capitalization to generate more accurate token value estimates.&#x20;

<figure><img src="https://lh7-eu.googleusercontent.com/docsz/AD_4nXd-soZkMfBr55ZxN9u1l7ekBpqu9L-5wbfcAI7SaiCMEdIZQx0rOEK6VYhX_DYJ1xbaehVcI69o8DYkN2wnEEKD1HMmwDfuaO4RYtr-rg5zcgjpIM04aPJW2n7MmVVBGhYrZb4j1Z4oVqdaF1xcSngWENg?key=yKeDMZ63ctoLut6nyqnEtA" alt=""><figcaption></figcaption></figure>

The graph above shows the market depth for FFT, and highlights how there was a significant drop in liquidity - even though it was in the top 20 for market cap - prior to its collapse.&#x20;

### <mark style="color:blue;">How to build the request</mark>

With the Market Metrics **Asset endpoint,** you can use the following parameters to source the specific information you're looking for:

| Paramater   | Value                    |
| ----------- | ------------------------ |
| asset       | FTT                      |
| start\_time | 2022-11-05T00:00:00.000Z |
| end\_time   | 2022-11-28T00:00:00.000Z |
| interval    | 1d                       |
| sources     | true                     |

You can find specific asset codes from our [instruments explorer](https://instruments.kaiko.com/#/instruments) or [reference data](https://docs.kaiko.com/#assets).

*NOTE: To calculate the gap between market depth, you'll need access to market cap data.*&#x20;

Here's an example of an HTTP string request using the values above:

<https://us.market-api.kaiko.io/v2/data/analytics.v2/asset\\_metrics?start\\_time=2022-11-05T00:00:00.000Z\\&end\\_time=2022-11-28T00:00:00.000Z\\&asset=fft\\&interval=1d><br>

When you receive your response, search for the following fields to find the data you need:

* timestamp
* buy\_market\_depths
* sell\_market\_depths

<br>


# Analyze supply distribution to determine asset-risk

Identify the number of addresses that hold at least 1% of the asset's total supply to effectively measure its popularity and the strength of its price discovery process.&#x20;

<mark style="color:blue;">How to build the request</mark>

With the Market Metrics **Asset endpoint,** you can use the following parameters to source the specific information you're looking for:

| Paramater   | Value                    |
| ----------- | ------------------------ |
| asset       | crv                      |
| start\_time | 2023-01-01T00:00:00.000Z |
| end\_time   | 2023-01-04T00:00:00.000Z |
| interval    | 1d                       |

You can find specific asset codes from our [instruments explorer](https://instruments.kaiko.com/#/instruments) or [reference data](https://docs.kaiko.com/#assets).

Here's an example of an HTTP string request using the values above:

<https://us.market-api.kaiko.io/v2/data/analytics.v2/asset_metrics?start_time=2023-01-01T00:00:00.000Z&end_time=2023-01-04T00:00:00.000Z&asset=crv>

When you receive your response, search for the following fields to find the data you need:

* main\_holders
* number\_of\_holders
* total\_supply

For a more in-depth analysis of all wallets holding a particular asset, you can utilize [Kaiko Wallet Data](https://www.kaiko.com/products/market-data-defi-protocols/wallet-data).


# Identify wash trading and volume quality

Evaluate an asset's volume-to-liquidity ratio. If the USD volume substantially exceeds the depth of the order books (a high volume-to-depth ratio), it suggests that the genuine market demand isn't accurately represented by the current trading volume, hinting at possible wash trading.

<figure><img src="https://lh7-eu.googleusercontent.com/docsz/AD_4nXeJdFwMMCK50roqhpGx0rzDsqa0VQVgpVsd5y_MKPrC0tYD6qkFqrJO4qAIQh1rkA0iWFCTO3QBKnx9qk-neFtf4HiZ6jrtYtcl64kY7ahG4WOm3r4f2qk3M_GSc7v-qk85k180WQxqFpI106yAWaUnpaqn?key=yKeDMZ63ctoLut6nyqnEtA" alt=""><figcaption></figcaption></figure>

The liquidity-volume-ratio is significantly higher on Bitforex.

### <mark style="color:blue;">How to build the request</mark>

With the Market Metrics **Asset endpoint,** you can use the following parameters to source the specific information you're looking for:

| Paramater   | Value                    |
| ----------- | ------------------------ |
| asset       | ltc                      |
| start\_time | 2023-12-28T00:00:00.000  |
| end\_time   | 2024-01-28T00:00:00.000Z |
| interval    | 1d                       |
| sources     | true                     |

You can find specific asset codes from our [instruments explorer](https://instruments.kaiko.com/#/instruments) or [reference data](https://docs.kaiko.com/#assets).

Here's an example of an HTTP string request using the values above:

<https://us.market-api.kaiko.io/v2/data/analytics.v2/asset_metrics?start_time=2023-12-28T00:00:00.000Z&end_time=2024-01-28T00:00:00.000Z&asset=ltc&sources=true&interval=1d>

When you receive your response, search for the following fields to find the data you need:

* total\_off\_chain\_volume\_usd
* buy\_market\_depths - bid\_volume\_1
* sell\_market\_depths - ask\_volume\_1


# Gauge market sentiment with Implied Volatility

Evaluate the market outlook for various dates using our [Derivatives Risk Indicators](/rest-api/analytics/derivatives-risk-indicators) solution. IV provides one figure that accounts for options contracts with various strikes and expiries, enabling a more accurate view of the overall market sentiment. For example, if an IV curve is steep to the left, this suggests the prevailing market sentiment sees prices falling.

<figure><img src="/files/bYDLXOPJmaqGmJFHmJ52" alt=""><figcaption><p>Here we see an IV smile across all expiries which means there is a high probability of price moves in either direction. There is a slight skew to the left on the shortest expiry (orange), suggesting higher demand on the short side.</p></figcaption></figure>

### How to build the request

With the Implied Volatility [smile](/rest-api/analytics/derivatives-risk-indicators/implied-volatility-calculation-smile) endpoin&#x74;**,** you can use the following parameters. This example calculates just one expiry, but you can also run a script locally to request and combine expiries like the chart above. Contact our operations team for support with this.

| Paramater   | Value                    |
| ----------- | ------------------------ |
| base        | btc                      |
| quote       | usd                      |
| exchange    | drbt                     |
| value\_time | 2024-09-25T10:20:09.224Z |
| expiry      | 2024-06-28T00:00:00.000Z |
| deltas      | 0.05                     |

You can find specific asset codes from our [instruments explorer](https://instruments.kaiko.com/#/instruments) or [reference data](https://docs.kaiko.com/#assets).

### Example request

Here's an example of an HTTP string request using the values above.&#x20;

{% code overflow="wrap" %}

```url
https://us.market-api.kaiko.io/v2/data/analytics.v2/implied_volatility_smile?base=btc&quote=usd&value_time=2024-09-09T14:00:00.000Z&expiry=2024-10-25T00:00:00.000Z&exchanges=drbt&strikes=30000,40000,50000,60000,70000,80000,90000,100000
```

{% endcode %}

When you receive your response, search for the following fields to find the data you need:

* `implied_volatilities_strike`
* `implied_volatilities_implied_volatility`


# Compare price slippage between exchanges

Price slippage measures how liquid a market is by measuring the gap between the expected and actual price of a marker order. When markets drop and there are large sell-offs, slippage often increases and it becomes harder to buy or sell at your desired price. This varies by exchange, trading pair, and time of day. Using Kaiko's data, we can measure potential BTC slippage across exchanges for different trade sizes. This provides valuable insight for market traders looking to minimize losses.

<figure><img src="/files/q1U0pGNWxK7u4R6yliLq" alt=""><figcaption><p>The chart abode shows how price slippage increased on Itbit between 5th, and 7th August for BTC-USD, suggesting liquidity troubles.</p></figcaption></figure>

### <mark style="color:blue;">How to build the request</mark>

Use [Order Book Snapshots](/rest-api/cefi-spot-market-data/order-book-aggregations/price-slippage-aggregation) (slippage) with the following parameters to replicate this chart.

| Paramater          | Value                                                                                                                                    |
| ------------------ | ---------------------------------------------------------------------------------------------------------------------------------------- |
| `exchange`         | <p><code>cbse</code><br><br>... and then <br><br><code>stmp</code><br><code>itbi</code><br><code>krkn</code></p><p><code>okcn</code></p> |
| `instrument_class` | spot                                                                                                                                     |
| `intrument`        | btc-usd                                                                                                                                  |

Here's an example of a cURL string request using the values above:

{% code overflow="wrap" %}

```url
curl -X GET "https://us.market-api.kaiko.io/v2/data/order_book_snapshots.v1/exchanges/cbse/spot/btc-usd/ob_aggregations/slippage?slippage=100000&interval=1h" -H "accept: application/json" -H "X-Api-Key: YOUR_API_KEY"
```

{% endcode %}

When you receive your response, search for the following fields to find the data you need:

* `timestamp`&#x20;
* `ask_slippage`
* `bid_slippage`

{% hint style="warning" %}
Order Book Snapshots are available through the API with a 1-month rolling window. While this means you can't recreate the example shown above, the instant live data meets most trading and analysis needs.
{% endhint %}


# 2026


# March 2026

2026-03-06

### Mapping Update

* **Transfer Coin** has been remapped from `tx` to `trnx`
* **TX** is now mapped to `tx`&#x20;

2026-03-09

### Mapping Update

* **BSB** has been remapped from `bsb` to `bsba`
* **Block Street** is now mapped to `bsb`&#x20;


# April 2026

2026-04-17

### Mapping Update

* **StablR USD** has been remapped from `usdir` to `usdr`
* `usdr` is now mapped to **StablR USD** (previously Tangible's Real USD)
* `usdir` has been deprecated and removed
* All StablR USDR instruments across Kraken, BigONE, WhiteBIT, MEXC, CoinEx, Bitmart, Curve, Uniswap V3 and Uniswap V4 are now tracked under `usdr`

2026-04-29

### Mapping Update

* Instruments previously mapped to **Midnight Evergreen** have been updated to reflect the correct asset, **Midnight**
* Instrument code `midnight` has been updated to `night` for applicable instruments following a mapping review
* A number of instruments have been remapped from code `robor` to code `robof`, with the corresponding asset updated to **Fabric Protocol**


# August 2026

2026-08-03

### IV Surface Endpoint Update

* optimization of the source code of the IV surface, to improve the performance
* addition of a few greeks : `vega` and `theta`


# 2025


# September 2025

2025-09-26

### Mapping Update

We've identified some mapping discrepancies around instruments with the asset code NEIRO. This appears to originate from different exchanges using this same code to refer to at least 3 distinct assets.&#x20;

The mapping in our reference data will be updated as outlined below:&#x20;

`NEIROCTO` : First NEIRO on ETH\
`1NEIRO` : NEIRO ETH \
`NEIRO` : NEIRO

2025-09-23

### Mapping Update

* Instruments listed below are update to use the base asset code `ONOMY`
  * CoinEx spot `nom-btc` becomes `onomy-btc`         &#x20;
  * Bitfinex spot `nom-usd` becomes `onomy-usd` & `nom-usdt` becomes         &#x20;
  * KuCoin spot `nom-usdt`
  * MEXC spot `nom-usdt`


# July 2025

2025-07-14

### Mapping Update

* Instruments listed below are update to use asset code 'PUMPFUN'
  * Bybit Spot `bbsp`  & Bitget Spot `bgsp`: Instrument code 'pumpfun-usdt' will refer to Pump.fun for all ongoing data


# June 2025

**2025-06-16**

### Mapping Update

* Asset code "HOME" is now assigned to Defi.app. OtterHome has been re-assigned to use code "OTTERHOME"

## Expanded DEX & L\&B coverage now live!

We’ve significantly expanded our decentralized exchange (DEX) and liquidity & borrowing (L\&B) coverage across several Kaiko products. You can now access data for the following platforms:

* **Raydium:** AMM, CLLM
* **Meteora:** CLLM, DLLM
* **Orca:** CLLM
* **Camelot**
* **Arbitrum**
* **Pancakeswap**
* **Morpho**

This enhanced coverage reflects out ongoing commitment to offer the latest and most comprehensive DeFi data.\
\
**Check out the full coverage details here:**

<a href="/pages/Ln4QYOqE9Axr1EI2wDK3" class="button primary">Decentralized spot exchanges</a>\
\ <a href="/pages/1jad4w84PMmIgoI9G0n9" class="button primary">Lending and borrowing protocols</a>

If you'd like to add any of these platforms to your Kaiko subscription, contact your Account Manager, or email <support@kaiko.com>.


# May 2025

**2025-05-08**

### Mapping Update

* Asset code "MYX" is now assigned to MYX Finance. MYX Network has been re-assigned to use code "MYXN"

**2025-05-15**

### Mapping Update

* Instruments for ebtc.finance (0x661c70333aa1850ccdbae82776bb436a0fcfeefb) have been updated to use Asset Code "EBTCF"

**2025-05-16**

### Mapping Update

* Asset code "A" is now assigned to Vaulta. Instruments referring to Alpha Token have been remapped to use the asset code "ALPHAT".
* Asset code "BOLD" is now assigned to the V2 Liquity BOLD Token (0x6440f144b7e50d6a8439336510312d2f54beb01d). Instruments referring to the Legacy Token (0xb01dd87b29d187f3e3a4bf6cdaebfb97f3d9ab98) have been remapped to use the asset code "BOLDV1".


# April 2025

**2025-04-14**

### Mapping Update

* Bybit Link perpetual future listed under code "LINK-USDT" has been corrected to "LINK-USDC"


# March 2025

### Kaiko Blockchain Monitoring - Solana Support

Kaiko Blockchain Monitoring now supports Solana. Solana has emerged as a crucial platform for stablecoin growth and DeFi app development, and this enhancement reflects our commitment to supporting the networks most valuable to our clients. Kaiko Blockchain Monitoring provides real-time insights across all supported blockchains, with full historical coverage back to each chain’s inception. You can learn more about Kaiko Blockchain Monitoring [here](https://www.kaiko.com/products/monitoring/blockchain-monitoring).<br>


# February 2025

**2025-02-27**

### Mapping Update

* All Clover Finance instruments listed under the base asset code of "CLOVER" will be remapped to use the code "CLV". Please use "CLV" to access any clover finance instruments.

**2025-02-12**

### Mapping Update

* The asset code "LAYER" has been assigned to Solayer. Unilayer, has been re-assigned to use the asset code "UNILAYER".

**2025-02-21**

### Mapping Update

* The asset code "AIC" has been assigned to AI Companions. ASCSIGN INC has been re-assigned to use the asset code "ASCSIGN".


# 2024


# November 2024

### Mapping Update

* The asset code "HYPE" has been assigned to Hyperliquid. Supreme Finance has been re-assigned to use the asset code "HYPE2"&#x20;

### Blockchain Monitoring Now Available via REST API&#x20;

We're excited to announce that our Blockchain Monitoring solution is now accessible through REST API. Wallet Data allows you to:

* Access complete transaction histories across all supported blockchains&#x20;
* View real-time wallet balances
* Track historical balance changes for the source of wealth checks
* Query detailed transaction data

Whether you need to monitor a single wallet or multiple addresses, our API delivers the data in a standardized format for seamless integration into your applications. Get started by exploring the documentation below.

{% content-ref url="/spaces/ltAbhvgBfrAWlpUnC7ys/pages/EE0x9lpbmW6d5W9MaUOf" %}
[Kaiko Blockchain Monitoring](/rest-api/monitoring/kaiko-blockchain-monitoring)
{% endcontent-ref %}

### New Reference APIs

We've launched two new reference APIs to help you quickly find our coverage:

#### <mark style="color:blue;">**Reference Rates**</mark>

This endpoint retrieves a complete list of our published Reference Rates. Our rules-based and independent rates aim to increase pricing transparency by providing a reliable and accurate benchmark.&#x20;

{% content-ref url="/spaces/bvJkzmxJbcDMceEJsq2K/pages/LuRvxugUCfB4M5cHse52" %}
[Broken mention](broken://spaces/bvJkzmxJbcDMceEJsq2K/pages/LuRvxugUCfB4M5cHse52)
{% endcontent-ref %}

#### <mark style="color:blue;">Protocols</mark>

This endpoint retrieves a complete list of the defi protocols supported by Kaiko data. This can help you identify which exchanges are defi when working with our Market Data.

{% content-ref url="/spaces/bvJkzmxJbcDMceEJsq2K/pages/o98OiL8Ilf2jUFb8SXv5" %}
[Broken mention](broken://spaces/bvJkzmxJbcDMceEJsq2K/pages/o98OiL8Ilf2jUFb8SXv5)
{% endcontent-ref %}

### Meet Kaiko On-Chain Delivery

{% embed url="<https://25446524.fs1.hubspotusercontent-eu1.net/hubfs/25446524/Videos%20and%20GIFs/On%20chain%20demo%20video%20gif%20.gif>" %}

As demand for complex data in smart contracts increases, we’re really pleased to introduce our new on-chain delivery channel. The new capability brings our trusted market data directly to the blockchain for the first time, providing reliable digital asset insights to power any on-chain contract.

To demonstrate its power, we’ve deployed Kaiko Cross Prices on-chain with free hourly price updates.&#x20;

Read our [user guide](/on-chain/kaiko-data/kaiko-reference-rates/data-on-ramp/arbitrum) to try it for yourself.


# September 2024

### Python code examples&#x20;

We've added Python code examples to all our Rest API documentation pages. This forms part of our ongoing mission to improve your user experience with Kaiko documentation. To see an example, head to any Rest API page and select the "Python" tab in the "Request Examples" section.&#x20;

<figure><img src="/files/FSSmNvn2tDQi0FR28N8p" alt=""><figcaption></figcaption></figure>

### Derivatives Risk Indicators Enhancements

We've made significant improvements to Kaiko [Derivatives Risk Indicators](https://www.kaiko.com/products/analytics/derivatives-risk-indicators). Users can now configure their IV using one of three calculation methods:

* Deltas
* Strikes
* Forward log moneyness

We've also made several enhancements, allowing finer granularity in your computations.

Kaiko Derivatives Risk Indicators helps you manage risk in the options market with confidence, calculating the potential volatility of any crypto asset with user-provided criteria. It's made specifically for crypto, backed by our trusted market data. [Contact us](https://www.kaiko.com/products/analytics/implied-volatility#form) if you'd like to learn more about it.

### New stream documentation

We've brought our stream documentation into our new Developer Hub. Take a look [here](https://docs.kaiko.com/stream/) -  you'll see we've added specific code examples for each Kaiko data solution and significantly improved discoverability. As always, we welcome your feedback, so please let our operations team know if you have any thoughts.&#x20;

<figure><img src="/files/rmE6zGXM4TSWPIX3DP1W" alt=""><figcaption></figcaption></figure>

As a reminder, Kaiko Stream is the fastest and easiest way to consume Kaiko Data. Once connected to a stream, you'll get constant updates, providing true real-time data. \
\
**Key benefits:**

✔ Real-time updates delivered instantly with no need to call an API each time&#x20;

✔ Data on multiple exchanges or instruments simultaneously in one stream

&#x20;✔ gRPC technology for the best data delivery and uptime&#x20;

✔ Customizable calculations, frequencies, and channels&#x20;


# July 2024

Our Latest Updates

## <mark style="color:blue;">**Kaiko data through BigQuery is now available in real-time**</mark>

**2024-07-19**

We’ve made improvements to how you integrate our data by enabling real-time access to BigQuery, so you can now access our insights when and where you need them most.&#x20;

This means you can conduct ongoing real-time analysis directly in the BigQuery platform, eliminating the need for support from your development team in making individual API calls. BigQuery also brings the power of data visualization to Kaiko data.&#x20;

This update applies to:

* [Broken mention](broken://pages/AEjJY7U9tT11wEe5AM3L#tick-level-trades)
* [Broken mention](broken://pages/nizjhhLUsb5gA9tRaGPf#cross-prices)
* [Broken mention](broken://pages/AEjJY7U9tT11wEe5AM3L#derivatives-metrics)

You can learn more about how to receive Kaiko data through BigQuery [here](https://docs.kaiko.com/explore-our-data/our-delivery-methods/third-party-data-services/bigquery) or check out the full range of products available through BigQuery in our data dictionary.


# June 2024

**2024-06-27**

* Corrected instrument mapping for the following Perpetual-Futures on Bybit V2. These were originally assigned the quote asset *USDT* in error:
  * WIF-USDC
  * WLD-USDC
  * TON-USDC

**2024-06-24**

* Updated documentation for implied volatilities smile and surface.


# March 2024

**2024-03-15**

* Added documentation for trades v3.
* Added blockchain parameter for instruments reference data.


# Previous updates

**2023-12-12**

Mapping update: Changes implemented for the following Instruments due to Ronin And Romanian Fiat Currencies having an identical ticker.

* Romanian Leu: *ron* → *ronle* .
  * *ron* is now referring to Ronin.

**2023-12-11**

* Added CEX and DEX Coverage sections.

**2023-12-04**

* Exchange Metrics - Retrieve off-chain and on-chain metrics that help performing exchange analysis.

**2023-11-23**

* Added documentation for Lending and Borrowing Rates & Liquidity CSV.
* Renamed product DEX Liquidity Events into Mints and Burns.
* Renamed product DEX Liquidity Snapshots into Token Reserves.

**2023-11-16**

* Added documentation for Wallet Data CSV files on Bitcoin.

**2023-11-13**

Mapping update: Changes implemented for the following Instruments due to Merit Circle Migration from MC to BEAN Ticker.

* BEAM: *beam* → *beamprivacy* . Name Changed from BEAM to BEAM (Privacy).
  * *beam* is now referring to BEAM (Merit Circle).

**2023-11-10**

Mapping updates:

* Asset *FLOKIINU* has been deprecated as it was a duplicate of existing *FLOKI*. All instruments are now referencing the asset code *FLOKI*
* *MBOX-USD* (MOBOX) instruments on KuCoin & MEXC which were previously mapped as fiat *USD* (United States Dollar) have been corrected to *USDT* (Tether). The new instrument code for these is *MBOX-USDT*
* Binance *LUNA-BUSD* & *LUNA2-BUSD* perpetual future contract codes are now mapped separately. No ongoing data is present for *LUNA-BUSD*

**2023-10-26** - Data Quality Update. We identified and resolved an issue that caused duplication in our MEXC trades data. As of 2023-10-26, all new MEXC trades data will be free from such duplication. Please note that due to MEXC's unique data structure, we are unable to retroactively correct the impacted historical data. We recommend users to consider this when using any MEXC trade data prior to 2023-10-26.

**2023-10-26**

* Added 'live' parameter for all on-chain products.

**2023-09-22**

* Added documentation for Wallet Data CSV files on Ethereum.
* Added field and parameter blockchain for Liquidity Events and Liquidity Snapshots.
* Added documentation for Blockchain Reference Data.

**2023-09-18**

Reference Data behavior Update - The "trade\_end\_timestamp" field will only be populated after 7 consecutive days of inactivity. Previously, this field would be populated after 1 day of inactivity.

**2023-07-26**

Mapping update: Change implemented to the code used for DMarket. Code changed to accomodate the actively trading Dream Machine Token.

* DMarket: *DMT* → *DMK*
* Dream Machine Token: *-* → *DMT*

**2023-06-08**

Mapping update: Changes implemented for BitMEX Perpetual Futures contracts. Instrument codes are no longer using "base\_asset" - "quote\_asset" convention for API codes. To differentiate between different Perpetual Future contract types, these should now be queried using the codes assigned by BitMEX

E.g. BTC-USD → XBTUSD

* Added documentation for Robust Pair Price and Cross Price v2.

**2023-06-06**

* Added the Australian Exchange, Independent Reserve's case of [`taker_side_sell`](https://docs.kaiko.com/#quot-taker_side_sell-quot-explained) and pulled off the Google Doc page of order book data while updating the contents

**2023-05-31**

* Added documentation for CSV files of the following products: Order Book Snapshots, Derivatives Metrics, OHLCV candles, VWAP, Count-OHLCV-VWAP

**2023-05-17**

Mapping update: Changes implemented for the following Instruments

* Toncoin: *toncoin* → *ton*
* *OKX: LUNA/BTC* → *OKX: LUNA2/BTC*

**2023-05-03**

* Added documentation for Top of Book CSV files

**2023-04-24**

* Added documentation for Lending & Borrowing Rates and Liquidity

**2023-04-11**

Mapping update: Changes implemented for the following Instruments

* METIS Dao:
  * *Gemini: MTS/USD* → *Gemini: METIS/USD*
  * *Huobi: MTS/USDT* → *Huobi: METIS/USDT*

**2023-04-06**

Mapping update: Changes implemented for the following Instruments

* Polytrade: *OKEX TRADE/USDT* → *OKEX POLYTRADE/USDT*
* METIS Dao:
  * *OKEX MTS/USDT* → *OKEX METIS/USDT*
  * *COINBASE MTS/USDT* → *COINBASE METIS/USDT*
* GoMining Token: *BITTREX GMT/USDT* → *BITTREX GOMININGTOKEN/USDT*

**2023-04-05**

* Implied Volatility Surface - Retrieve calibrated and interpolated implied volatilities from options market prices

**2023-04-04**

* Updated the list of Tick-Level Order Book CSV files.
  * Upbit
  * Huobi Derivatives Market
  * Crypto Facilities
  * Bithumb
  * Binance US

**2023-03-30**

* Asset Metrics - Retrieve off-chain and on-chain metrics that help performing asset analysis.

**2023-03-29**

Mapping update: Changes implemented for the following Assets

* Republic Protcol: *REPUP* → *REN*
* Everest: *ID* → *EVERID*
  * *ID* is now mapped to Space ID
* PrimeDAO: *PRIME* → *PRIMEDAO*
  * *PRIME* is now mapped to Prime Echelon
* Lition: *LIT* → *LITION*
  * *LIT* is now mapped to Litentry
* *AXL* is now mapped to Axelar

**2023-03-27**

Mapping update: Changes implemented for the following Assets

* Facebook : *FB* → *FACEBOOK*
  * *FB* is now mapped to Fenerbahce
* Orbitcoin : *ORB* → *ORBITCOIN*
  * *ORB* is now mapped to Orbcity

**2023-03-23**

Mapping update: Changes implemented for the following Assets

* Arbit : *ARB* → *ARBIT*
  * *ARB* is now mapped to Arbitrum
* SoloCoin : *SOLO* → *SOLOC*
  * *SOLO* is now mapped to Sologenic

**2023-02-21**

Mapping update: Changes implemented for the following Assets

* OHM : *OHM* → *OHMV1*
  * *OHM* is now mapped to OHM V2

**2023-02-06**

* OKX can now be included in Implied Volatility computations

**2023-02-02**

* Cross Price - Extrapolation can be set to avoid missing values for low liquidity pairs

**2023-01-26**

* Derivative Metrics (Price) - `end_time` became exclusive
* Derivative Metrics (Risk) - `vega` added to the REST API responses

**2023-01-16**

* Binance Options have been added to Derivative Metrics, Trade, and Order Book data

**2023-01-12**

* CSV Files - Tick By Tick Order Book added to the doc

**2022-06-03**

Mapping update: Changes implemented for the following Assets

* Polkadot : *PDOT* → *DOT*
* Uniswap : *UNISWAP* → *UNI*
* FTX Token : *FTXT* → *FTT*
* LEO Token : *LEOT* → *LEO*
* MCDEX : *MCDEX* → *MCB*
* Mercurial : *MERC* → *MER*
* Oxygen : *OXYG* → *OXY*
* Merit Circle : *MRC* → *MC*
* Mines of Dalarnia : *DARA* → *DAR*
* Cybermiles : *CYMI* → *CMT*
* FairGame : *FAIRGAME* → *FAIR*
* Origin Sport : *ORSP* → *ORS*

**2022-05-18**

Mapping Update: FTXUSD deprecation

* All USD quoted spot instruments trading on FTX (International) are mapped to have fiat USD (United States Dollar) as 'quote\_asset'

**2022-04-29**

* Derivatives API update: Derivatives API endpoint split into 3 endpoints, which are reference, risk, and price

**2022-02-17**

Mapping update

* Bittrex *SUSHI/BTC* corrected from *BTC/SUSHI*

**2022-02-15**

Mapping update

* Pax Dollar (asset) updated to use code *USDP* & USDP stablecoin: Unit Protocol (asset) updated to use code *UUSDP*

**2022-01-06**

Mapping update

* SubGame (asset) code updated to use code *SGBM* & Songbird (asset) updated to use code *SGB*

**2021-12-28**

Mapping update

* BitDAO (asset) code updated to use code *BIT*

**2021-12-24**

* Quote Asset correction for FTX perpetual-future instruments

**2021-12-20**

* Cross Price (Spot Exchange Rate) endpoint updated to support non-fiat currencies as 'quote\_asset'

**2021-12-10**

Mapping update

* Stox (asset) code changed from *STX* to *STOX* & Blockstack (asset) code changed from *BSTX* to *STX*<br>

**2021-12-08**

Mapping update

* Quote Asset correction for Bitfinex Tether quoted instruments

<br>


# Data dictionary

A comprehensive breakdown of Kaiko's data and endpoints

***

<table data-full-width="true"><thead><tr><th width="265.3046875">Data</th><th width="227.5703125">Included with (Subscriptions)</th><th>Delivery channels</th></tr></thead><tbody><tr><td>All bids and asks<br><sub>(full order book)</sub></td><td>Level 1 &#x26; Level 2 Data<br><sub>[Level 2 Tick-Level Tier]</sub></td><td><p><strong>Stream</strong></p><ul><li>Live data</li><li>Tick-level granularity</li><li>72 hours of history on replay</li><li>Available for <a href="https://open-2v.gitbook.com/url/preview/site_mOwZN/~/revisions/VfuoK4elR8GzyzKvgWjR/coverage/cefi-spot-markets">CeFi spot</a> and <a href="https://docs.kaiko.com/coverage/cefi-derivative-markets">CeFi Derivative</a> markets</li></ul><p></p><p><a href="/spaces/v5MrdvtFK4Vl0U5hpSQz/pages/FtcwWLsHo36rNGklc3UZ" class="button secondary">See docs</a></p><hr><p><strong>AWS, Azure, Google Cloud Platform (GCP)</strong></p><ul><li>New CSV once a day</li><li>Tick-level granularity</li><li>History since August 2023</li><li>Available for <a href="/pages/zihBYMUoiG1rqRYUNvzM">CeFi spot</a> markets</li></ul><p><br><a href="/spaces/195pnvvX8d8tAqU43UQY/pages/ul5ZWlVnXeVYPyCKQSpN" class="button secondary">See docs</a></p></td></tr><tr><td>All trades<br><sub>(tick-level trades)</sub></td><td>Level 1 &#x26; Level 2 Data<br><sub>[Level 1 Tick-Level Tier]</sub><br><sub>[Level 2 Aggregations Tier]</sub><br><sub>[Level 2 Tick-Level Tier]</sub></td><td><p><strong>Stream</strong></p><ul><li>Live data</li><li>Tick-level granularity</li><li>72 hours of history on replay</li><li>Available for <a href="https://open-2v.gitbook.com/url/preview/site_mOwZN/~/revisions/VfuoK4elR8GzyzKvgWjR/coverage/cefi-spot-markets">CeFi spot</a>, <a href="https://docs.kaiko.com/coverage/cefi-derivative-markets">CeFi Derivative</a>, and <a href="https://docs.kaiko.com/coverage/defi-spot-markets">DeFi spot</a> markets</li></ul><p></p><p><a href="/spaces/v5MrdvtFK4Vl0U5hpSQz/pages/RkAQHrR4skdo0dPR22cy" class="button secondary">See docs</a></p><hr><p><strong>REST API</strong></p><ul><li>Tick-level granularity</li><li>History since 2010</li><li>Available for <a href="https://open-2v.gitbook.com/url/preview/site_mOwZN/~/revisions/VfuoK4elR8GzyzKvgWjR/coverage/cefi-spot-markets">CeFi spot</a>, <a href="https://docs.kaiko.com/coverage/cefi-derivative-markets">CeFi Derivative</a>, and <a href="https://docs.kaiko.com/coverage/defi-spot-markets">DeFi spot</a> markets</li></ul><p></p><p><a href="/spaces/ltAbhvgBfrAWlpUnC7ys/pages/LFJOM8zk2daINpgVQz8S" class="button secondary">See docs</a></p><hr><p><strong>AWS, Azure, Google Cloud Platform (GCP)</strong></p><ul><li>New CSV once a day</li><li>Tick-level granularity</li><li>History since 2010</li><li>Available for <a href="https://open-2v.gitbook.com/url/preview/site_mOwZN/~/revisions/VfuoK4elR8GzyzKvgWjR/coverage/cefi-spot-markets">CeFi spot</a> markets</li></ul><p></p><p><a href="https://docs.kaiko.com/cloud-delivery/data-feeds/level-1-tick-level/all-trades" class="button secondary">See docs</a></p><hr><p><strong>Snowflake, BigQuery</strong></p><ul><li>Available as a once-a-day refresh or in near real-time</li><li>Tick-level granularity</li><li>History since 2010</li><li>Available for CeFi spot markets</li></ul><p><br><a href="https://docs.kaiko.com/cloud-delivery/data-feeds/level-1-tick-level/all-trades" class="button secondary">See docs</a></p></td></tr><tr><td>Asset-level metrics </td><td>Market Explorer<br><sub>[Assets &#x26; Exchanges]</sub><br><sub>[Full Coverage]</sub></td><td><p><strong>REST API</strong></p><ul><li>1-hour to 1-day granularity</li><li>DEXs: History since genesis</li><li>CEXs: History since 2010</li><li>Available for <a href="https://open-2v.gitbook.com/url/preview/site_mOwZN/~/revisions/VfuoK4elR8GzyzKvgWjR/coverage/cefi-spot-markets">CeFi spot</a> and <a href="https://docs.kaiko.com/coverage/defi-spot-markets">DeFi spot</a> markets<br><a href="https://docs.kaiko.com/rest-api/monitoring-solutions/kaiko-market-explorer/assets" class="button secondary">See docs</a></li></ul></td></tr><tr><td>Balances and transactions - Ethereum<br><br>Balances and transactions - Solana<br><br>Bitcoin transactions<br><br>Bitcoin wallet balances</td><td>Blockchain Monitoring</td><td><p><strong>REST API</strong></p><ul><li>Live data</li><li>Event-level granularity (sub transaction)</li><li>History since genesis</li><li><a href="https://docs.kaiko.com/coverage/kaiko-blockchain-monitoring">Coverage</a></li></ul><p></p><p><a href="/spaces/ltAbhvgBfrAWlpUnC7ys/pages/EE0x9lpbmW6d5W9MaUOf" class="button secondary">See docs</a></p><hr><p><strong>AWS, Azure, Google Cloud Platform (GCP)</strong></p><ul><li>Event-level granularity (sub transaction)</li><li>History since genesis</li><li>New CSV once-a-day</li><li><a href="https://docs.kaiko.com/coverage/kaiko-blockchain-monitoring">Coverage</a></li></ul><p></p><p><a href="/spaces/195pnvvX8d8tAqU43UQY/pages/9RBxoyRagba8JYdH6D3u" class="button secondary">See docs</a></p><hr><p><strong>BigQuery</strong></p><ul><li>Event-level granularity (sub transaction)</li><li>History since genesis</li><li>Live with a ~15-minute delay to account for potential block reorganizations and ensure data accuracy</li><li><a href="https://docs.kaiko.com/coverage/kaiko-blockchain-monitoring">Coverage</a></li></ul><p><br><a href="/spaces/195pnvvX8d8tAqU43UQY/pages/9RBxoyRagba8JYdH6D3u" class="button secondary">See docs</a></p></td></tr><tr><td>Best bids and asks<br><sub>(top-of-book)</sub></td><td>Level 1 &#x26; Level 2 Data<br><sub>[Level 1 Tick-Level Tier]</sub><br><sub>[Level 2 Aggregations Tier]</sub><br><sub>[Level 2 Tick-Level Tier]</sub></td><td><p><strong>Stream</strong></p><ul><li>Live data</li><li>Tick-level granularity</li><li>72 hours of history on replay</li><li>Available for <a href="https://open-2v.gitbook.com/url/preview/site_mOwZN/~/revisions/VfuoK4elR8GzyzKvgWjR/coverage/cefi-spot-markets">CeFi spot</a> markets</li></ul><p></p><p><a href="/spaces/v5MrdvtFK4Vl0U5hpSQz/pages/wRIHfYVakXfmIRyavLNJ" class="button secondary">See docs</a></p><hr><p><strong>AWS, Azure, Google Cloud Platform (GCP)</strong></p><ul><li>New CSV once a day</li><li>Tick-level granularity</li><li>History since December 2022</li><li>Available for <a href="https://open-2v.gitbook.com/url/preview/site_mOwZN/~/revisions/VfuoK4elR8GzyzKvgWjR/coverage/cefi-spot-markets">CeFi spot</a> markets</li></ul><p><br><a href="/spaces/195pnvvX8d8tAqU43UQY/pages/iUVgvAKi25DBBhipd0ln" class="button secondary">See docs</a></p></td></tr><tr><td>Bid-ask-spread</td><td>Level 1 &#x26; Level 2 Data<br><sub>[Level 2 Aggregations Tier]</sub><br><sub>[Level 2 Tick-Level Tier]</sub></td><td><p><strong>REST API</strong></p><ul><li>Bid-ask spread calculated from a comparison of several raw order book snapshots over time</li><li>1-month rolling history</li><li>Available for <a href="https://open-2v.gitbook.com/url/preview/site_mOwZN/~/revisions/VfuoK4elR8GzyzKvgWjR/coverage/cefi-spot-markets">CeFi spot</a> markets</li></ul><p><br><a href="/spaces/ltAbhvgBfrAWlpUnC7ys/pages/phdC9r0itsJ5t3HfRAJR" class="button secondary">See docs</a></p><hr><p><strong>AWS, Azure, Google Cloud Platform (GCP)</strong></p><ul><li>Includes the raw order book snapshot data on which bid-ask-spread is calculated</li><li>New CSV once a day containing at least one snapshot per minute</li><li>History since 2015 (varies per exchange)</li><li>Available for <a href="https://open-2v.gitbook.com/url/preview/site_mOwZN/~/revisions/VfuoK4elR8GzyzKvgWjR/coverage/cefi-spot-markets">CeFi spot</a> &#x26; <a href="https://docs.kaiko.com/coverage/cefi-derivative-markets">CeFi Derivative</a> markets</li></ul><p><br><a href="/spaces/195pnvvX8d8tAqU43UQY/pages/BSBYTbmoPmwyIDb4YGaY" class="button secondary">See docs</a></p></td></tr><tr><td>Borrows, repayments, liquidations, and withdrawals<br><sub>(for lending protocols)</sub></td><td>Level 1 &#x26; Level 2 Data<br><sub>[Level 1 Tick-Level Tier]</sub><br><sub>[Level 2 Tick-Level Tier]</sub></td><td><p><strong>REST API</strong></p><ul><li>Live data</li><li>Tick-level granularity</li><li>History since genesis</li><li>Available for <a href="https://docs.kaiko.com/coverage/defi-lending-and-borrowing-protocols">DeFi L&#x26;B</a> protocols</li></ul><p></p><p><a href="/spaces/ltAbhvgBfrAWlpUnC7ys/pages/jQ7DXMzjhpDcTd0rFUFt" class="button secondary">See docs</a></p><p></p><hr><p><strong>AWS, Azure, Google Cloud Platform (GCP)</strong></p><ul><li>New CSV once a day</li><li>Tick-level granularity</li><li>History since genesis</li><li>Available for <a href="https://docs.kaiko.com/coverage/defi-lending-and-borrowing-protocols">DeFi L&#x26;B</a> protocols<br><br><a href="/spaces/195pnvvX8d8tAqU43UQY/pages/Z6RfuZUU4Y4JRAxzOp1c" class="button secondary">See docs</a></li></ul></td></tr><tr><td>Custom portfolio valuation</td><td>Portfolio &#x26; Risk Management</td><td><p><strong>REST API</strong></p><ul><li>DEX historical data since genesis</li><li>CEX historical data since 2010</li><li>End-of-day and intraday pricing</li><li>Available for <a href="https://open-2v.gitbook.com/url/preview/site_mOwZN/~/revisions/VfuoK4elR8GzyzKvgWjR/coverage/cefi-spot-markets">CeFi spot</a> and <a href="https://docs.kaiko.com/coverage/defi-spot-markets">DeFi spot</a> markets</li></ul><p><br><a href="/spaces/ltAbhvgBfrAWlpUnC7ys/pages/0HHQ2crfk7ZUu3RRcJVu" class="button secondary">See docs</a></p></td></tr><tr><td>Derivatives contract details</td><td>Derivatives Risk Indicators<br>[Basic Tier]<br><sub>[Advanced Tier]</sub></td><td><p><strong>Stream</strong></p><ul><li>Live data</li><li>1s, 1h, 4h, 1d granularities</li><li>Coverage for <a href="https://docs.kaiko.com/coverage/cefi-derivative-markets">CeFi Derivative</a> markets</li></ul><p><br><a href="/spaces/v5MrdvtFK4Vl0U5hpSQz/pages/retMejoB7QDrtyud8ktN" class="button secondary">See docs</a></p><p></p><hr><p><strong>REST API</strong></p><ul><li>Historical data since July 2020</li><li>1s, 1h, 4h, 1d granularities</li><li>Coverage for <a href="https://docs.kaiko.com/coverage/cefi-derivative-markets">CeFi Derivative</a> markets</li></ul><p><br><a href="/spaces/ltAbhvgBfrAWlpUnC7ys/pages/9DWiPvKIRAK7dcGeiJbm" class="button secondary">See docs</a></p><hr><p><strong>AWS, Azure, Google Cloud Platform (GCP)</strong></p><ul><li>Historical data since July 2020</li><li>1s, 1h, 4h, 1d granularities</li><li>Coverage for <a href="https://docs.kaiko.com/coverage/cefi-derivative-markets">CeFi Derivative</a> markets</li></ul><p><br><a href="/spaces/195pnvvX8d8tAqU43UQY/pages/DDZG3EiCdDwg8sOTnZcV" class="button secondary">See docs</a></p></td></tr><tr><td>Derivative liquidation events</td><td>Level 1 &#x26; Level 2 Data<br><sub>[Level 1 Tick-Level Tier] [Add-on]</sub><br><sub>[Level 2 Aggregations Tier] [Add-on]</sub><br><sub>[Level 2 Tick-Level Tier] [Add-on]</sub></td><td><p><strong>REST API</strong></p><ul><li>Live data</li><li>Tick-level granularity</li><li>History since Jan 8th 2025</li><li>Coverage for <a href="https://docs.kaiko.com/coverage/cefi-derivative-markets">CeFi Derivative</a> markets</li></ul><p><br><a href="/spaces/ltAbhvgBfrAWlpUnC7ys/pages/5Z6jmyEYAy5JearSJfD7" class="button secondary">See docs</a></p></td></tr><tr><td>Implied volatility calculation - surface</td><td>Derivatives Risk Indicators<br><sub>[Advanced Tier]</sub></td><td><p><strong>REST API</strong></p><ul><li>Historical data since April 2021</li><li>1m granularity</li><li>Coverage for <a href="https://docs.kaiko.com/coverage/cefi-derivative-markets">CeFi Derivative</a> markets</li></ul><p><br><a href="/spaces/ltAbhvgBfrAWlpUnC7ys/pages/CknrxYXdp9Yf16fSETBq" class="button secondary">See docs</a></p></td></tr><tr><td>Token-level liquidation volumes</td><td>Derivatives Risk Indicators<br><sub>[Advanced Tier]</sub></td><td><p><strong>REST API</strong></p><ul><li>Historical data since Jan 8th 2025</li><li>1h granularity</li><li>Coverage for <a href="https://docs.kaiko.com/coverage/cefi-derivative-markets">CeFi Derivative</a> markets</li></ul><p><br><a href="/spaces/ltAbhvgBfrAWlpUnC7ys/pages/JH6t56qX2rF2Cs621FoB" class="button secondary">See docs</a></p></td></tr><tr><td>Supply &#x26; market cap<br><br>Supply &#x26; market cap - aggregation<br><br>Supply &#x26; market cap - per blockchain<br><br>Supply &#x26; market cap - ranking<br><br></td><td>Market Explorer<br><sub>[Supply &#x26; Market Cap Tier]</sub><br><sub>[Full Coverage Tier]</sub></td><td><p><strong>REST API</strong></p><ul><li>Since mid-September 2025 or from the date of deployment for any new assets</li><li>5-minute increments granularity for raw data</li><li>5-minute to 30-day intervals, aggregated from raw data</li><li><a href="/pages/XaGxYhKUTCFTzMZXBSLZ">Coverage</a></li></ul><p><br><a href="/spaces/ltAbhvgBfrAWlpUnC7ys/pages/b6hdgY8eIuAnqk3uH4Ot" class="button secondary">See docs</a></p></td></tr><tr><td>Implied volatility calculation - smile</td><td>Derivatives Risk Indicators<br><sub>[Advanced Tier]</sub></td><td><p><strong>REST API</strong></p><ul><li>Historical data since April 2021</li><li>1m granularity</li><li>Coverage for <a href="https://docs.kaiko.com/coverage/cefi-derivative-markets">CeFi Derivative</a> markets</li></ul><p><br><a href="/spaces/ltAbhvgBfrAWlpUnC7ys/pages/cxeQMdvWCeCJQRode5Jn" class="button secondary">See docs</a></p></td></tr><tr><td>Expected shortfall calculation</td><td>Portfolio &#x26; Risk Management</td><td><p><strong>REST API</strong></p><ul><li>DEX historical data since genesis</li><li>CEX historical data since 2010</li><li>Intraday updates of daily ES</li><li>Available for <a href="https://open-2v.gitbook.com/url/preview/site_mOwZN/~/revisions/VfuoK4elR8GzyzKvgWjR/coverage/cefi-spot-markets">CeFi spot</a> and <a href="https://docs.kaiko.com/coverage/defi-spot-markets">DeFi spot</a> markets</li></ul><p><br><a href="https://docs.kaiko.com/rest-api/analytics-solutions/kaiko-portfolio-and-risk-management/expected-shortfall-calculation" class="button secondary">See docs</a></p></td></tr><tr><td>Exchange-level-metrics</td><td>Market Explorer<br><sub>[Assets &#x26; Exchanges]</sub><br><sub>[Full Coverage]</sub></td><td><p><strong>REST API</strong></p><ul><li>1-hour to 1-day granularity</li><li>DEXs: History since genesis</li><li>CEXs: History since 2010</li><li>Available for <a href="https://open-2v.gitbook.com/url/preview/site_mOwZN/~/revisions/VfuoK4elR8GzyzKvgWjR/coverage/cefi-spot-markets">CeFi spot</a> and <a href="https://docs.kaiko.com/coverage/defi-spot-markets">DeFi spot</a> markets<br><a href="https://docs.kaiko.com/rest-api/monitoring-solutions/kaiko-market-explorer/exchanges" class="button secondary">See docs</a></li></ul></td></tr><tr><td>Direct Price</td><td>Kaiko Fair Market Value<br><sub>[Established Assets Tier]</sub><br><sub>[Full Coverage Tier]</sub></td><td><p><strong>Stream</strong></p><ul><li>Live data</li><li>Publication windows of 1s, 5s, 10s, 15s, 30s, and 1m</li><li>Computation windows of 1s, 5s, 10s, 15s, 30s, 1m, 5m</li><li>Available for <a href="https://open-2v.gitbook.com/url/preview/site_mOwZN/~/revisions/VfuoK4elR8GzyzKvgWjR/coverage/cefi-spot-markets">CeFi spot</a> and <a href="https://docs.kaiko.com/coverage/defi-spot-markets">DeFi spot</a> markets</li></ul><p><br><a href="/spaces/v5MrdvtFK4Vl0U5hpSQz/pages/0mZ3UnEdlQhFL13NIQN1" class="button secondary">See docs</a></p><hr><p><strong>REST API</strong></p><ul><li>Time periods between 1s and 1d</li><li>History since 2010 for CeFi spot markets</li><li>History since genesis for DeFi spot markets</li><li>Available for <a href="https://open-2v.gitbook.com/url/preview/site_mOwZN/~/revisions/VfuoK4elR8GzyzKvgWjR/coverage/cefi-spot-markets">CeFi spot</a> and <a href="https://docs.kaiko.com/coverage/defi-spot-markets">DeFi spot</a> markets</li></ul><p><br><a href="/spaces/ltAbhvgBfrAWlpUnC7ys/pages/3sWvmFeSgMsaXLbw4Ff2" class="button secondary">See docs</a></p></td></tr><tr><td>Principal Market Price</td><td>Kaiko Fair Market Value<br><sub>[Established Assets Tier]</sub><br><sub>[Full Coverage Tier]</sub></td><td><p><strong>REST API</strong></p><ul><li>Single point in time granularity only</li><li>History since July 2025</li><li>Coverage for the top 20 from the <a href="https://www.kaiko.com/indices/exchange-ranking">Kaiko Exchange Ranking</a>, filtered by those offering USD spot pairs</li></ul><p><br><a href="/spaces/ltAbhvgBfrAWlpUnC7ys/pages/9niEK5LusBbbXJ27IHEt" class="button secondary">See docs</a></p></td></tr><tr><td>Stablecoin metrics</td><td>Kaiko Market Explorer <br><sub>[Assets and Exchanges Tier]</sub></td><td><p></p><p><strong>REST API</strong></p><ul><li>1d granularity </li><li>All History </li><li>Live</li></ul><p><br><br><a href="https://docs.kaiko.com/rest-api/monitoring-solutions/kaiko-market-explorer/stablecoins" class="button secondary">See docs</a></p></td></tr><tr><td>State Price</td><td>Kaiko Fair Market Value<br><sub>[Emerging Assets Tier]</sub><br><sub>[Full Coverage Tier]</sub></td><td><p><strong>Stream</strong></p><ul><li>Live data</li><li>1s granularity (non-configurable)</li><li>No historic data</li></ul><p><br><a href="/spaces/v5MrdvtFK4Vl0U5hpSQz/pages/0vDcJUKj1MVoyMxyj0pz" class="button secondary">See docs</a></p><hr><p><strong>REST API</strong></p><ul><li>24 hours of historical data</li><li>1-second granularity (non-configurable)</li></ul><p><br><a href="/spaces/ltAbhvgBfrAWlpUnC7ys/pages/puyoJ9B2zkumSxS3373J" class="button secondary">See docs</a></p></td></tr><tr><td>Synthetic Price</td><td>Kaiko Fair Market Value<br><sub>[Established Assets Tier]</sub><br><sub>[Full Coverage Tier]</sub></td><td><p><strong>Stream</strong></p><ul><li>Live data</li><li>Publication windows of 1s, 5s, 10s, 15s, 30s, and 1m</li><li>Computation windows of 1s, 5s, 10s, 15s, 30s, 1m, 5m</li><li>Available for <a href="https://open-2v.gitbook.com/url/preview/site_mOwZN/~/revisions/VfuoK4elR8GzyzKvgWjR/coverage/cefi-spot-markets">CeFi spot</a> and <a href="https://docs.kaiko.com/coverage/defi-spot-markets">DeFi spot</a> markets</li></ul><p><br><a href="/spaces/v5MrdvtFK4Vl0U5hpSQz/pages/d4KWcFdyu0Qeud5M2fMl" class="button secondary">See docs</a></p><hr><p><strong>REST API</strong></p><ul><li>Time periods between 1s and 1d</li><li>History since 2010 for CeFi spot markets</li><li>History since genesis for DeFi spot markets</li><li>Available for <a href="https://open-2v.gitbook.com/url/preview/site_mOwZN/~/revisions/VfuoK4elR8GzyzKvgWjR/coverage/cefi-spot-markets">CeFi spot</a> and <a href="https://docs.kaiko.com/coverage/defi-spot-markets">DeFi spot</a> markets</li></ul><p><br><a href="/spaces/ltAbhvgBfrAWlpUnC7ys/pages/5CRtt3tkQ117paXlY3K3" class="button secondary">See docs</a></p></td></tr><tr><td>Interest rates, borrowed and deposited amounts<br>(for lending protocols)</td><td>Level 1 &#x26; Level 2 Data<br><sub>[Level 2 Aggregations Tier]</sub><br><sub>[Level 2 Tick-Level Tier]</sub></td><td><p><strong>REST API</strong></p><ul><li>Block-by-block granularity</li><li>History since genesis</li><li>Available for <a href="https://docs.kaiko.com/coverage/defi-lending-and-borrowing-protocols">DeFi L&#x26;B</a> protocols</li></ul><p><br><a href="https://docs.kaiko.com/rest-api/data-feeds/level-1-and-level-2-data/level-2-aggregations/interest-rates-borrowed-and-deposited-amounts" class="button secondary">See docs</a></p></td></tr><tr><td>Market depth</td><td>Level 1 &#x26; Level 2 Data<br><sub>[Level 2 Aggregations Tier]</sub><br><sub>[Level 2 Tick-Level Tier]</sub></td><td><p><strong>REST API</strong></p><ul><li>Market depth calculated from at least one order book snapshot per minute</li><li>Also available as an aggregation of several calculations over time</li><li>1-month rolling history</li><li>Available for <a href="https://open-2v.gitbook.com/url/preview/site_mOwZN/~/revisions/VfuoK4elR8GzyzKvgWjR/coverage/cefi-spot-markets">CeFi spot</a> markets</li></ul><p><br><a href="/spaces/ltAbhvgBfrAWlpUnC7ys/pages/3szN7U4gF6eoieu1ThCt" class="button secondary">See docs</a></p><hr><p><strong>AWS, Azure, Google Cloud Platform (GCP)</strong></p><ul><li>Includes the raw order book snapshot data on which market depth is calculated</li><li>New CSV once a day, containing at least one snapshot per minute</li><li>History since 2015 (varies per exchange</li><li>Available for <a href="https://open-2v.gitbook.com/url/preview/site_mOwZN/~/revisions/VfuoK4elR8GzyzKvgWjR/coverage/cefi-spot-markets">CeFi spot</a> &#x26; <a href="https://docs.kaiko.com/coverage/cefi-derivative-markets">CeFi Derivative</a> markets</li></ul><p><br><a href="/spaces/ltAbhvgBfrAWlpUnC7ys/pages/3szN7U4gF6eoieu1ThCt" class="button secondary">See docs</a></p></td></tr><tr><td>Mints and burns</td><td>Level 1 &#x26; Level 2 Data<br><sub>[Level 2 Tick-Level Tier]</sub></td><td><p><strong>REST API</strong></p><ul><li>Live data</li><li>Tick-level granularity</li><li>History since genesis</li><li>Available for <a href="https://docs.kaiko.com/coverage/defi-spot-markets">DeFi spot</a> markets</li></ul><p><br><a href="/spaces/ltAbhvgBfrAWlpUnC7ys/pages/pS60EG2AQomtHPALM2yh" class="button secondary">See docs</a></p><hr><p><strong>AWS, Azure, Google Cloud Platform (GCP)</strong></p><ul><li>New CSV once a day</li><li>Tick-level granularity</li><li>History since genesis</li><li>Available for <a href="https://docs.kaiko.com/coverage/defi-spot-markets">DeFi spot</a> markets</li></ul><p><br><a href="/spaces/195pnvvX8d8tAqU43UQY/pages/RJFkeK160wPJVTgkvGEY" class="button secondary">See docs</a></p></td></tr><tr><td>Oanda FX conversion</td><td>Add-on to Kaiko Fair Market Value</td><td><p><strong>REST API</strong></p><ul><li>Granularities between 1m and 1d</li><li>Historical data since July 22, backfill on request</li><li>Coverage for more than 70 assets</li></ul><p><br><a href="/spaces/ltAbhvgBfrAWlpUnC7ys/pages/tpb6TTldiAo7hU5ujIEc" class="button secondary">See docs</a></p></td></tr><tr><td>OHLCV</td><td>Level 1 &#x26; Level 2 Data<br><sub>[Level 1 Aggregations Tier]</sub><br><sub>[Level 1 Tick-Level Tier]</sub><br><sub>[Level 2 Aggregations Tier]</sub><br><sub>[Level 2 Tick-Level Tier]</sub></td><td><p><strong>Stream</strong></p><ul><li>Live data</li><li>1-second granularity</li><li>72 hours of history on replay</li><li>Available for <a href="https://open-2v.gitbook.com/url/preview/site_mOwZN/~/revisions/VfuoK4elR8GzyzKvgWjR/coverage/cefi-spot-markets">CeFi spot</a>, <a href="https://docs.kaiko.com/coverage/cefi-derivative-markets">CeFi Derivative</a>, and <a href="https://docs.kaiko.com/coverage/defi-spot-markets">DeFi spot</a> markets</li></ul><p><br><a href="/spaces/v5MrdvtFK4Vl0U5hpSQz/pages/Bp6BRBuO5Twllpz764Hb" class="button secondary">See docs</a></p><hr><p><strong>REST API</strong></p><ul><li>1-second to 1-day granularity</li><li>History since 2010</li><li>Available for <a href="https://open-2v.gitbook.com/url/preview/site_mOwZN/~/revisions/VfuoK4elR8GzyzKvgWjR/coverage/cefi-spot-markets">CeFi spot</a>, <a href="https://docs.kaiko.com/coverage/cefi-derivative-markets">CeFi Derivative</a>, and <a href="https://docs.kaiko.com/coverage/defi-spot-markets">DeFi spot</a> markets</li></ul><p><br><a href="/spaces/ltAbhvgBfrAWlpUnC7ys/pages/X8tPneA9qD8yu0zRfVrn" class="button secondary">See docs</a></p><hr><p><strong>AWS, Azure, Google Cloud Platform (GCP)</strong></p><ul><li>Available as a once-a-day refresh or in near real-time</li><li>1-second to 1-day granularity</li><li>History since 2010</li><li>Available for <a href="https://open-2v.gitbook.com/url/preview/site_mOwZN/~/revisions/VfuoK4elR8GzyzKvgWjR/coverage/cefi-spot-markets">CeFi spot</a> markets</li></ul><p><br><a href="/spaces/195pnvvX8d8tAqU43UQY/pages/rE3lPkaDbJhzkjzc7MDE" class="button secondary">See docs</a></p></td></tr><tr><td>Price slippage</td><td>Level 1 &#x26; Level 2 Data<br><sub>[Level 2 Aggregations Tier]</sub><br><sub>[Level 2 Tick-Level Tier]</sub></td><td><p><strong>REST API</strong></p><ul><li>Price slippage calculated from at least one order book snapshot per minute</li><li>Also available as an aggregation of several calculations over time</li><li>1-month rolling history</li><li>Available for <a href="https://open-2v.gitbook.com/url/preview/site_mOwZN/~/revisions/VfuoK4elR8GzyzKvgWjR/coverage/cefi-spot-markets">CeFi spot</a> markets</li></ul><p><br><a href="/spaces/ltAbhvgBfrAWlpUnC7ys/pages/q7D4sOs6UjOgi8mXHB4x" class="button secondary">See docs</a></p><hr><p><strong>AWS, Azure, Google Cloud Platform (GCP)</strong></p><ul><li>Includes the raw order book snapshot data on which price slippage is calculated</li><li>New CSV once a day containing at least one snapshot per minute<br>• History since 2015 (varies per exchange)<br>• Available for <a href="https://open-2v.gitbook.com/url/preview/site_mOwZN/~/revisions/VfuoK4elR8GzyzKvgWjR/coverage/cefi-spot-markets">CeFi spot</a> &#x26; <a href="https://docs.kaiko.com/coverage/cefi-derivative-markets">CeFi Derivative</a> markets</li></ul><p><br><a href="/spaces/195pnvvX8d8tAqU43UQY/pages/BSBYTbmoPmwyIDb4YGaY" class="button secondary">See docs</a></p><p></p></td></tr><tr><td>Asset codes<br></td><td>Reference Data<br><sub>[Basic Tier]</sub></td><td><p><strong>REST API</strong></p><p></p><p><br><a href="/spaces/ltAbhvgBfrAWlpUnC7ys/pages/ZtAjUBxYgG6MyaYQBPuS" class="button secondary">See docs</a></p></td></tr><tr><td>Staking rates</td><td>Market Explorer <br><sub>[Supply &#x26; Market Cap Tier]</sub><br><sub>[Full Coverage Tier]</sub></td><td><p><strong>REST API</strong> </p><ul><li>Granularity 1d</li><li>Limited history</li><li>Coverage for ETH and SOL. More can be added on customer request. <br><br><a href="https://docs.kaiko.com/rest-api/monitoring-solutions/kaiko-market-explorer/staking-rates" class="button secondary">See docs</a></li></ul></td></tr><tr><td>Tokens in a liquidity pool<br>(for decentralized exchanges)</td><td>Level 1 &#x26; Level 2 Data<br><sub>[Level 2 Tick-Level Tier]</sub></td><td><p><strong>REST API</strong></p><ul><li>Block-by-block granularity</li><li>History since genesis</li><li>Available for <a href="https://docs.kaiko.com/coverage/defi-spot-markets">DeFi spot</a> markets</li></ul><p><br><a href="/spaces/ltAbhvgBfrAWlpUnC7ys/pages/I65vpqvRiMJPWr9y0Zhn" class="button secondary">See docs</a></p></td></tr><tr><td>Total Value Locked</td><td>Market Explorer<br><sub>[Total Value Locked Tier]</sub><br><sub>[Full Coverage Tier]</sub></td><td><p><strong>REST API</strong></p><ul><li>Historical data since inception</li><li>1-day granularity</li><li><a href="/pages/frQq6S7U3KYI8jimGAuw">Coverage</a></li></ul><p><br><a href="/spaces/ltAbhvgBfrAWlpUnC7ys/pages/IFU8flHu1FIitxH1ftXR" class="button secondary">See docs</a></p></td></tr><tr><td>Trade count</td><td>Level 1 &#x26; Level 2 Data<br><sub>[Level 1 Aggregations Tier]</sub><br><sub>[Level 1 Tick-Level Tier]</sub><br><sub>[Level 2 Aggregations Tier]</sub><br><sub>[Level 2 Tick-Level Tier]</sub></td><td><p><strong>REST API</strong></p><ul><li>1-second to 1-day granularity</li><li>History since 2010</li><li>Available for <a href="https://open-2v.gitbook.com/url/preview/site_mOwZN/~/revisions/VfuoK4elR8GzyzKvgWjR/coverage/cefi-spot-markets">CeFi spot</a>, <a href="https://docs.kaiko.com/coverage/cefi-derivative-markets">CeFi Derivative</a>, and <a href="https://docs.kaiko.com/coverage/defi-spot-markets">DeFi spot</a> markets</li></ul><p><br><a href="/spaces/v5MrdvtFK4Vl0U5hpSQz/pages/Bp6BRBuO5Twllpz764Hb" class="button secondary">See docs</a></p><hr><p><strong>Snowflake, BigQuery</strong></p><ul><li>Available as a once-a-day refresh or in near real-time</li><li>1-hour to 1-day granularity</li><li>History since 2010</li><li>Available for <a href="https://open-2v.gitbook.com/url/preview/site_mOwZN/~/revisions/VfuoK4elR8GzyzKvgWjR/coverage/cefi-spot-markets">CeFi spot</a>, <a href="https://docs.kaiko.com/coverage/cefi-derivative-markets">CeFi Derivative</a>, and <a href="https://docs.kaiko.com/coverage/defi-spot-markets">DeFi spot</a> markets</li></ul><p><br><a href="/spaces/195pnvvX8d8tAqU43UQY/pages/fnw18TIVNCPbJ8cLi2sX" class="button secondary">See docs</a></p></td></tr><tr><td>Value at Risk Calculation</td><td>Portfolio &#x26; Risk Management</td><td><p><strong>REST API</strong></p><ul><li>DEX historical data since genesis</li><li>CEX historical data since 2010</li><li>Intraday updates of daily VaR</li><li>Available for <a href="https://open-2v.gitbook.com/url/preview/site_mOwZN/~/revisions/VfuoK4elR8GzyzKvgWjR/coverage/cefi-spot-markets">CeFi spot</a> and <a href="https://docs.kaiko.com/coverage/defi-spot-markets">DeFi spot</a> markets</li></ul><p><br><a href="/spaces/ltAbhvgBfrAWlpUnC7ys/pages/vRJlzzSfDR7L6uu9gEfe" class="button secondary">See docs</a></p></td></tr><tr><td>VWAP</td><td>Level 1 &#x26; Level 2 Data<br><sub>[Level 1 Aggregations Tier]</sub><br><sub>[Level 1 Tick-Level Tier]</sub><br><sub>[Level 2 Aggregations Tier]</sub><br><sub>[Level 2 Tick-Level Tier]</sub></td><td><p><strong>Stream</strong></p><ul><li>Live data</li><li>1-second to 1-day granularity at a monthly level</li><li>1-hour, 3-hour, or 1-day granularity at a monthly level</li><li>72 hours of history on replay</li><li>Available for <a href="https://open-2v.gitbook.com/url/preview/site_mOwZN/~/revisions/VfuoK4elR8GzyzKvgWjR/coverage/cefi-spot-markets">CeFi spot</a>, <a href="https://docs.kaiko.com/coverage/cefi-derivative-markets">CeFi Derivative</a>, and <a href="https://docs.kaiko.com/coverage/defi-spot-markets">DeFi spot</a> markets</li></ul><p><br><a href="/spaces/v5MrdvtFK4Vl0U5hpSQz/pages/FDEteSFnQGMdjcOdfDG3" class="button secondary">See docs</a></p><hr><p><strong>REST API</strong></p><ul><li>1-second to 1-day granularity at a monthly level</li><li>1-hour, 3-hour, or 1-day granularity at a monthly level</li><li>72 hours of history on replay</li><li>Available for <a href="https://open-2v.gitbook.com/url/preview/site_mOwZN/~/revisions/VfuoK4elR8GzyzKvgWjR/coverage/cefi-spot-markets">CeFi spot</a>, <a href="https://docs.kaiko.com/coverage/cefi-derivative-markets">CeFi Derivative</a>, and <a href="https://docs.kaiko.com/coverage/defi-spot-markets">DeFi spot</a> markets</li></ul><p><br><a href="/spaces/ltAbhvgBfrAWlpUnC7ys/pages/X8tPneA9qD8yu0zRfVrn" class="button secondary">See docs</a></p><hr><p><strong>AWS, Azure, Google Cloud Platform (GCP)</strong></p><ul><li>New CSV once a day</li><li>1-second to 1-day granularity at a monthly level</li><li>1-hour, 3-hour, or 1-day granularity at a monthly level</li><li>History since 2010</li><li>Available for <a href="https://open-2v.gitbook.com/url/preview/site_mOwZN/~/revisions/VfuoK4elR8GzyzKvgWjR/coverage/cefi-spot-markets">CeFi spot</a>, <a href="https://docs.kaiko.com/coverage/cefi-derivative-markets">CeFi Derivative</a>, and <a href="https://docs.kaiko.com/coverage/defi-spot-markets">DeFi spot</a> markets</li></ul><p><br><a href="/spaces/195pnvvX8d8tAqU43UQY/pages/fnw18TIVNCPbJ8cLi2sX" class="button secondary">See docs</a></p><hr><p><strong>Snowflake, BigQuery</strong></p><ul><li>Available as a once-a-day refresh or in near real-time</li><li>1-second to 1-day granularity</li><li>History since 2010</li><li>Available for <a href="https://open-2v.gitbook.com/url/preview/site_mOwZN/~/revisions/VfuoK4elR8GzyzKvgWjR/coverage/cefi-spot-markets">CeFi spot</a>, <a href="https://docs.kaiko.com/coverage/cefi-derivative-markets">CeFi Derivative</a>, and <a href="https://docs.kaiko.com/coverage/defi-spot-markets">DeFi spot</a> markets</li></ul><p><br><a href="/spaces/195pnvvX8d8tAqU43UQY/pages/fnw18TIVNCPbJ8cLi2sX" class="button secondary">See docs</a></p></td></tr></tbody></table>


# Subscriptions: channel availability

| Subscription Name                                                      | Data Types                                                                                                               | Available Channel(s)                                                                       |
| ---------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------ |
| <mark style="color:blue;">**Level 1 & Level 2 Data**</mark>            |                                                                                                                          |                                                                                            |
| <mark style="color:blue;">•</mark> Level 1 Aggregations                | <p>Trade count</p><p><br>OHLCV</p><p><br>VWAP</p>                                                                        | Stream, REST API, AWS, Azure, Google Cloud Platform, Snowflake, BigQuery                   |
| <mark style="color:blue;">•</mark> Level 1 Tick-Level                  | All trades                                                                                                               | Stream, REST API, AWS, Azure, Google Cloud Platform, Snowflake, BigQuery, Private Networks |
| <mark style="color:blue;">•</mark> Level 1 Tick-Level                  | Best bids/asks (top of book)                                                                                             | Stream, AWS, Azure, Google Cloud Platform                                                  |
| <mark style="color:blue;">•</mark> Level 2 Aggregations                | Market depth, bid-ask-spread, Price slippage, Tokens in a liquidity pool, Interest rates, borrowed and deposited amounts | REST API                                                                                   |
| <mark style="color:blue;">•</mark> Level 2 Aggregations                | Raw order book snapshot                                                                                                  | AWS, Azure, Google Cloud Platform, Snowflake, BigQuery                                     |
| <mark style="color:blue;">•</mark> Level 2 Tick-Level                  | All bids and asks                                                                                                        | Stream, AWS, Azure, Google Cloud Platform                                                  |
| <mark style="color:blue;">•</mark> Level 2 Tick-Level                  | <p><br></p>                                                                                                              | REST API, AWS, Azure, Google Cloud Platform                                                |
| <mark style="color:blue;">**Reference Data**</mark>                    |                                                                                                                          |                                                                                            |
| <mark style="color:blue;">•</mark> Basic tier                          | Assets, exchanges, instruments, and associated codes                                                                     | REST API                                                                                   |
| <mark style="color:blue;">•</mark> Advanced tier                       | Derivatives pricing information                                                                                          | Stream, REST API                                                                           |
| <mark style="color:blue;">•</mark> Advanced tier                       | Derivatives contract information                                                                                         | REST API                                                                                   |
|                                                                        | Market capitalization and circulating supply                                                                             | REST API                                                                                   |
| <mark style="color:blue;">**Kaiko Fair Market Value**</mark>           |                                                                                                                          |                                                                                            |
| <mark style="color:blue;">•</mark> Standard subscription               | -                                                                                                                        | Stream, REST API                                                                           |
| <mark style="color:blue;">•</mark> Oanda FX add-on                     | -                                                                                                                        | REST API                                                                                   |
| <mark style="color:blue;">**Kaiko Best Execution**</mark>              |                                                                                                                          |                                                                                            |
|                                                                        | -                                                                                                                        | Stream                                                                                     |
| <mark style="color:blue;">**Kaiko Derivatives Risk Indicators**</mark> | Basic tier                                                                                                               |                                                                                            |
| <mark style="color:blue;">•</mark> Basic tier                          | Exchange-provided metrics                                                                                                | REST API, AWS, Azure, Google Cloud Platform                                                |
| <mark style="color:blue;">•</mark> Advanced tier                       | IV calculation, Token-level liquidation volumes                                                                          | REST API                                                                                   |
| <mark style="color:blue;">**Kaiko Portfolio & Risk Management**</mark> |                                                                                                                          |                                                                                            |
| <mark style="color:blue;">•</mark> Standard subscription               | Custom portfolio valuation, Value at risk calculation, expected shortfall                                                | REST API                                                                                   |
| <mark style="color:blue;">**Kaiko Blockchain Monitoring**</mark>       |                                                                                                                          |                                                                                            |
|                                                                        | -                                                                                                                        | AWS, Azure, Google Cloud Platform, BigQuery, REST API                                      |
| <mark style="color:blue;">**Kaiko Market Explorer**</mark>             |                                                                                                                          |                                                                                            |
| <mark style="color:blue;">•</mark> Standard subscription               | -                                                                                                                        | REST API, BigQuery                                                                         |
| <mark style="color:blue;">•</mark> Staking rates \[Add-on]             | -                                                                                                                        | REST API                                                                                   |
| <mark style="color:blue;">**Kaiko Benchmarks**</mark>                  |                                                                                                                          |                                                                                            |
| <mark style="color:blue;">•</mark> Single-assset                       | -                                                                                                                        | Stream, REST API                                                                           |
| <mark style="color:blue;">**Kaiko Indices**</mark>                     |                                                                                                                          |                                                                                            |
| <mark style="color:blue;">•</mark> Multi-assset                        |                                                                                                                          | Stream                                                                                     |


# Cefi spot markets

Our coverage for centralized spot markets.

{% hint style="info" %}
You can explore all exchanges, assets, and get codes for them using our [Instrument Explorer](https://instruments.kaiko.com/#/instruments). Alternatively, if you want to obtain the data in a more programmatic way, use our [reference data API](broken://spaces/bvJkzmxJbcDMceEJsq2K).
{% endhint %}

{% embed url="<https://datawrapper.dwcdn.net/a2eGo/5/>" fullWidth="true" %}


# Cefi derivative markets

{% embed url="<https://datawrapper.dwcdn.net/shzG3/19/>" fullWidth="true" %}


# Defi spot markets

{% hint style="info" %}
You can explore all exchanges, assets, and get codes for them using our [instrument explorer](https://instruments.kaiko.com/#/instruments). Alternatively, if you want to obtain the data in a more programmatic way, use our [reference data API](broken://spaces/bvJkzmxJbcDMceEJsq2K).
{% endhint %}

{% embed url="<https://datawrapper.dwcdn.net/Dd4rD/22/>" fullWidth="true" %}


# Defi lending and borrowing protocols

{% hint style="info" %}
You can explore all exchanges, assets, and codes, and obtain the data in a programmatic way using our [reference data API](broken://spaces/bvJkzmxJbcDMceEJsq2K).
{% endhint %}

{% embed url="<https://datawrapper.dwcdn.net/HXOIb/7/>" fullWidth="true" %}


# Supply and Market Cap

Market Cap and  Supply is available as part of our [Market Explorer](https://www.kaiko.com/products/monitoring/market-explorer) packages.

#### Coverage available for Market Cap and Supply&#x20;

BTC, ETH, USDT, XRP, BNB, USDC, SOL, TRX, DOGE, HYPE, ADA, BCH, LEO, LINK, USDe, CC, XLM, DAI, USD1, LTC, AVAX, PYUSD, HBAR, ZEC, SUI, SHIB, CRO, TON, TAO, WLFI, XAUt, DOT, M, MNT, PAXG, UNI, OKB, USDG, AAVE, NEAR, PI, ASTER, SKY, RLUSD, BGB, PEPE, ICP, ETC, ONDO, USDD, KAS, KCS, POL, U, WLD, ENA, RENDER, TRUMP, GT, APT, FLR, FIL, MORPHO, ZRO, PUMP, ARB, NEXO, JUP, BONK, FET, VIRTUAL, CAKE, ETHFI, EURC, FDUSD, CRV, IMX, AERO, SYRUP, SPX, FLOKI, GRT, OP, LDO, ENS, PENDLE, WIF, RAY, MYX


# Total Value Locked (TVL)

Total Value Locked is part of our [Market Explorer](broken://pages/UDVA1n20njGIs0CwKfta) packages.

#### Coverage available for TVL

aave, abracadabra-money, acala, across, aerodrome, agora, alongside, angle, ankr, anzen, aperture, apeswap, apollo, apollox, archblock, astar, avantprotocol, axelarnetwork, balancer, bancor, beethovenx, benqi-lsd, bifrostio, bitgo, blackhole, blackrock, blockchain-capital, bmx, bnsol, botto, bufferfinance, camelot, capapp, cbeth, centrifuge, circle, coinshift, compound, comtech, curve, dolomite, dopex, drift-protocol, dydx, eigenlayer, elixir-protocol, ethena, etherex, etherfi, euler, fathom, fd121limited, fidelity, franklintempleton, frax-finance, fraxlend, fraxstablecoin, friend-tech, gemini, globaldollarnetwork, gmx, hamiltonlane, hegic, holdstation, honeypop, hydradx, impossible-finance, index-cooperative, instadapp, inversefinance, ipor-protocol, jito, jpycoin, jupiter, kamino, katana, kyberswap, layerzero, level-finance, lido-finance, lighter, liquid-collective, liquity, listadao, loopring, lybra, lyra, makerdao, mamo, mantra, maple-finance, marinade, matrixdock, maverick, merkle-trade, metamask, metavault-trade, meteora, midas, monerium, moonwell, morpho, mummy-finance, mux, notional-finance, okutrade, ondo, openedendigital, opyn, orca, originprotocol, pancakeswap, pangolin, paxos, paypal, pendle, perpetual-protocol, pharaoh, pika-protocol, polymarket, premia, primenumbers, prisma, quickswap, radiant-capital, raft, ramses, raydium, reflexer, republicnote, reserve, ribbon-finance, ringsprotocol, ripplelabs, rocket-pool, sanctum, seamless-protocol, securitize, shadowexchange, shoebill-finance, silo, societegenerale, solidlizard, solv-protocol, sonne, spark, spiko, stader, stafi, stakestone, stakewise, superstate, sushiswap, swell, symbiotic, synapse, syncswap, synfutures, tether, thena, theo, thetanuts, thruster, tokemak, tokenlon, tornado-cash, toucan-protocol, tradable, trader-joe, uniswap, usual, vaneck, velodrome, venus, verse, vertex-protocol, vesta-finance, vnx, wisdomtree, worldlibertyfinancial, xdc, zerolend, zkswap, zksync-era-bridge, zyberswap


# Kaiko Blockchain Monitoring

[Kaiko Blockchain Monitoring](https://www.kaiko.com/products/monitoring/blockchain-monitoring) supports Bitcoin, Ethereum and Solana\* blockchains, with comprehensive coverage for each network, including:

* All native coin transfers
* All token transfers (e.g., ERC-20, where applicable)
* Staking deposits and withdrawals
* Gas fees

We provide [**historical data**](#user-content-fn-1)[^1] back to each chain's inception alongside real-time update&#x73;**.** We continuously expand our coverage, and can support new blockchains quickly.\
\
*\* Solana blockchain includes 30-days rolling history as part of any standard package. Custom packages offering longer rolling histories back to inception are also available.*

[^1]: Note: *Solana blockchain includes 30-days rolling history as part of any standard package. Custom packages offering longer rolling histories back to inception are also available.*


# Reference Rates

A list of our published Reference Rates

{% hint style="info" %}
You can also get a list of our published Benchmarks via API using the reference data [endpoint](broken://spaces/bvJkzmxJbcDMceEJsq2K/pages/LuRvxugUCfB4M5cHse52).
{% endhint %}

{% embed url="<https://datawrapper.dwcdn.net/QlERM/14/>" fullWidth="true" %}


# Instrument Explorer

The Kaiko Instrument explorer offers the same information as our various reference data endpoints, but in a user-friendly interface. [Go to the explorer](https://instruments.kaiko.com/#/instruments).

<figure><img src="/files/3e5I77sHFkFjzY4EbKLF" alt=""><figcaption></figcaption></figure>


# Status

To see the status of all Kaiko endpoints, visit [status.kaiko.com](https://status.kaiko.com/posts/dashboard).


# Introduction

### Welcome to the Kaiko REST API documentation.

#### Get started with the menu on the left.&#x20;

:arrow\_left: :arrow\_left: :arrow\_left:


# Getting Started


# API input

### Header <a href="#header" id="header"></a>

When interacting with Kaiko HTTP APIs, you are expected to pass two pieces of information in a header:

* `Accept: application/json`: API responses will be in JSON format.
* `Accept-Encoding: gzip`: All our endpoints benefit from use of compression.

```
curl --compressed -H 'Accept: application/json' 'https://<api_hostname>/<endpoint>'
```

### Timestamp input <a href="#timestamp-input" id="timestamp-input"></a>

All time parameters are in UTC time zone and returned in the following ISO 8601 datetime format:

`YYYY-MM-DD`**T**`hh:mm:ss.sss`**Z**

For example:

`2017-12-17T13:35:24.351Z`

The "T" separates the date from the time. The trailing "Z" indicates UTC time.

### Exchange codes <a href="#exchange-code" id="exchange-code"></a>

Find exchange codes here: [Broken mention](broken://spaces/bvJkzmxJbcDMceEJsq2K/pages/vGAuhofqiYGAJCYlarFi).

### Instrument codes

Find instrument codes here: [Broken mention](broken://spaces/bvJkzmxJbcDMceEJsq2K/pages/o4ZunsQ4PYoKpO528Uxw).&#x20;


# API output


# "taker\_side\_sell" Explained

For Centralized Exchange(CEX) `taker_side_sell` takes the value of `true` when a taker's sell order fills a maker's buy order and `false` when a taker's buy order fills a maker's sell order.

For Decentralized Exchanges (DEX) using Automatic Market Maker (AMM) protocols, the liquidity pool contract is considered the maker. The entity executing a transaction against the liquidity pool is the taker.

**If an exchange does not appear below, it can be assumed that all data we provide is normalized correctly.**&#x20;

For exchanges where we were unable to confirm as reporting data from either a taker or a maker's perspective, we have included the notation mapping from the exchange's trade direction field to our `taker_side_sell` field. This is necessary so that researchers who want to further study trade direction can make their own conclusions. For exchanges that classify trade direction differently or exclude the field entirely, we also include the notation mapping and a short explanation for how their variable differs.

Furthermore, there are some trades of the Australian Exchange `Independent Reserve`, where we cannot decide if it is the taker buy or taker sell. As such, it is the only exchange that has 3 values, which are `true`, `false` and `unknown`, in the field `taker_side_sell`.

Finally, we have made a couple of errors in classifying exchanges as "maker" or "taker", typically early on in the process of developing `taker_side_sell`. Rather than switch our trade reporting after years of data collection, we have simply marked exchanges where the inverse of the notation stated should be applied. For these exchanges, researchers should be aware that when `taker_side_sell: false`, the inverse should be assumed.

**Unconfirmed, Misclassified or Absent Trade Direction Field**

<table data-header-hidden><thead><tr><th width="223"></th><th width="257"></th><th></th><th></th></tr></thead><tbody><tr><td>Exchange</td><td>Exchange Notation</td><td>Kaiko <code>taker_side_sell: true</code> equivalent to:</td><td>Comment</td></tr><tr><td>BTCBox</td><td><code>"type":</code> <code>"buy" or "sell"</code></td><td><strong>inverse notation</strong>: <code>"type": "sell"</code></td><td>Inverse, but confirmed perspective from exchange.</td></tr><tr><td>Liquid (Quoine)</td><td><code>taker_side:</code> <code>"buy" or "sell"</code></td><td><strong>inverse notation</strong>: <code>taker_side: "buy"</code></td><td>Inverse, but confirmed perspective from exchange.</td></tr><tr><td>Bithumb</td><td><code>"type":</code> <code>"bid" or "ask"</code></td><td><strong>inverse notation</strong>: <code>"type": "bid"</code></td><td>Inverse, but confirmed perspective from exchange.</td></tr><tr><td>Coinone</td><td><code>"is_ask":</code> <code>"0"(if seller is taker)/"1"(if seller is maker)</code></td><td><strong>inverse notation</strong>: <code>"is_ask": "1"</code></td><td>Inverse, confirmed from exchange but slightly different notation format</td></tr><tr><td>Bitstamp</td><td><code>type:</code> <code>0 (buy) or 1 (sell)</code></td><td><code>type: 1</code></td><td>Unconfirmed perspective from exchange</td></tr><tr><td>Bit-Z</td><td><code>"s":</code> <code>"buy" or "sell"</code></td><td><code>"s": "sell"</code></td><td>Unconfirmed perspective from exchange</td></tr><tr><td>EXX</td><td><code>type":</code> <code>"buy" or "sell"</code></td><td><code>type: "sell"</code></td><td>Unconfirmed perspective from exchange</td></tr><tr><td>CEX.io</td><td><code>type:</code> <code>"buy" or "sell"</code></td><td><code>type: "sell"</code></td><td>Unconfirmed perspective from exchange</td></tr><tr><td>Yobit</td><td><code>"type":</code> <code>"bid" or "ask"</code></td><td><code>"type": "bid"</code></td><td>Unconfirmed perspective from exchange</td></tr><tr><td>itBit</td><td>None</td><td>Always returns <code>true</code></td><td>No buy/sell field</td></tr><tr><td>Korbit</td><td>None</td><td>Always returns <code>null</code></td><td>No buy/sell field</td></tr><tr><td>Coinflex</td><td>None</td><td>Always returns <code>null</code></td><td>No buy/sell field</td></tr><tr><td>Independent Reserve</td><td><code>"Side":</code> <code>"Buy"</code> or <code>"Sell"</code></td><td><code>"Side": "Sell"</code></td><td>Some trades have <code>"Unknown"</code></td></tr><tr><td>AsiaNext</td><td>None</td><td>Always returns <code>false</code></td><td>No buy/sell field provided</td></tr></tbody></table>


# Market open and close

Digital asset exchanges operate approximately 24x7x365. For daily aggregated data, the opening price is calculated as the first trade at or after 00:00:00 UTC. The closing price is calculated as the last trade prior to 00:00:00 UTC.


# Timestamp

**All Kaiko data is timestamped in the UTC time zone.**\
\
All timestamps are returned as [millisecond Unix timestamps](https://currentmillis.com/) (the number of milliseconds elapsed since 1970-01-01 00:00:00.000 UTC). For metadata fields, times are also returned in millisecond-resolution ISO 8601 datetime strings in the same format as input for convenience.


# Authentication

Each endpoint for the Market Data solution lives under its own hostname. You must include an API key in the header of every request you make. \
\
The format for the API key is:

```
X-Api-Key: <client-api-key>
```


# Data versioning

Kaiko takes transparency and accountability very seriously. Therefore, our provided datasets are versioned. Dataset versioning is orthogonal to API versioning.  Any potential breaking changes in results (e.g. semantical changes or corrections of historically incorrect data) will result in a new dataset version - no corrections or adjustments will be done in the dark. Addition of new data will not result in a new dataset version. Data is versioned on a per-base-data level.

The versioning is selected by selecting a base data set and a version. All current Market Data API endpoints take the `commodity` and `data_version` parameters.

By setting this to `latest`, you will get the most recent version. The returned version is always included in the `query` field and can be referred to if you would ever need to compare results, should we ever need to adjust historical data. [Paginating](/rest-api/general/getting-started/pagination) over a request with version set to `latest` will preserve the current version across subsequent pagination requests.

We recommend using the most current version explicitly in production integrations as the `latest` label might move at any time to a breaking change. For the `trades` and `order_book_snapshots` commodities the latest version is currently `v1`

<br>


# Envelope

All API responses are in JSON format. A `result` field, with a value of `success` or `error` is returned with each request. In the event of an error, a `message` field will provide an error message.

An `access` object is also echoed back. It contains two ranges of timestamps:

* `access_range`: The time range for which the Client has access to the API
* `data_range` : The time range of data the Client is authorized to access

| Key         | Data type  | Description                                       |
| ----------- | ---------- | ------------------------------------------------- |
| `access`    | `{}`       | Time ranges of accesses.                          |
| `data`      | `[] \| {}` | Response result data.                             |
| `message`   | `string`   | Error message, if query was not successful.       |
| `query`     | `{}`       | All handled query parameters echoed back.         |
| `result`    | `string`   | `success` if query successful, `error` otherwise. |
| `time`      | `string`   | The current time at our endpoint.                 |
| `timestamp` | `long`     | The current time at our endpoint.                 |


# Error codes

All API responses are in JSON format. A `result` field, with a value of `success` or `error` is returned with each request. In the event of an error, a `message` field will provide an error message.

**HTTP error codes**

The Kaiko platform API uses the following error codes:

| Error Code | Meaning                                                                                                                                                               |
| ---------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| 400        | Bad Request                                                                                                                                                           |
| 401        | Unauthorized -- You are not authenticated properly. See [Authentication](https://docs.kaiko.com/#authentication)[.](/rest-api/general/getting-started/authentication) |
| 403        | Forbidden -- You don't have access to the requested resource.                                                                                                         |
| 404        | Not Found                                                                                                                                                             |
| 405        | Method Not Allowed                                                                                                                                                    |
| 406        | Not Acceptable                                                                                                                                                        |
| 429        | Rate limit reached                                                                                                                                                    |
| 500        | Internal Server Error -- We had a problem with our service. Try again later.                                                                                          |
| 503        | Service Unavailable -- We're temporarily offline for maintenance.                                                                                                     |

<br>


# Pagination

For queries that result in a larger dataset than can be returned in a single response, a `continuation_token` field is included. Calling the same endpoint again with the `continuation_token` query parameter added will return the next result page. For convenience, a `next_url` field is also included, containing a URL that can be called directly to get the next page. Paginated endpoints also takes a `page_size` parameter that specifies the maximum number of items that should be included in each response. Only the first call should include `page_size`, all subsequent calls should only use `continuation_token`. Paginating over a request with [version](https://docs.kaiko.com/#data-versioning) set to `latest` will preserve the current version across subsequent pagination requests.

**Parameters**

| Parameter            | Required | Description                                         |
| -------------------- | -------- | --------------------------------------------------- |
| `continuation_token` | No       |                                                     |
| `page_size`          | No       | Maximum number of records to return in one response |

### Browsing pages when using Python

The following script can be used to browse pages in Python. Make sure to update your `trade_url` and `X-Api-Key`.

{% tabs %}
{% tab title="Python" %}

```javascript
import http.client
import json
conn = http.client.HTTPSConnection("us.market-api.kaiko.io")
endpoint = "/v2/data/trades.v1/spot_exchange_rate/btc/usd"
params = "?interval=1h&start_time=2024-09-01T00:00:00.000Z&end_time=2024-09-10T00:00:00.000Z"
headers = {
    "X-Api-Key": "XXX",
    "Accept": "application/json"
}
all_trades = []
next_url = endpoint + 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)}")
```

{% endtab %}

{% tab title="Python (with Pandas)" %}
**This example uses Pandas for convenience. If you're unfamiliar with them, use the standard Python example.**

{% code overflow="wrap" %}

```python
import requests
import pandas as pd

trade_url = "https://us.market-api.kaiko.io/v3/data/trades.v1/exchanges/usp3/spot/usdc-weth/trades?start_time=2022-11-01T00:00:00.000Z&end_time=2022-12-01T00:00:00.000Z"
headers = {"X-Api-Key": "XXX","Accept": "application/json"}
output = requests.get(trade_url, headers = headers).json()
df = pd.DataFrame(output["data"])

while "next_url" in output:
        output = requests.get(output["next_url"], headers = headers).json()
        df_to_add = pd.DataFrame(output["data"])
        print(df_to_add)
        df= pd.concat([df, df_to_add])
print(df)
```

{% endcode %}
{% endtab %}
{% endtabs %}


# Rate limiting

Our standard Rest API is limited to 6000 requests per API key per minute. If you query the API beyond that threshold, a `429` an error message will occur. \
\
If you'd like to discuss rate-limiting, please contact <support@kaiko.com>.


# Asset codes

{% hint style="info" %}

### This data is included in the following Kaiko packages:

* **Reference Data** \[Basic Tier]
* **Reference Data** \[Advanced Tier]
  {% endhint %}

### What is this endpoint for?

This endpoint retrieves a list of assets and associated codes.

### Endpoint

```
https://reference-data-api.kaiko.io/v1/assets
```

### Parameters

No parameters supported

### Fields

<table><thead><tr><th width="323">Field</th><th>Description</th></tr></thead><tbody><tr><td><code>asset_class</code></td><td>The asset's primary asset class</td></tr><tr><td><code>asset_classes</code></td><td>The asset's secondary asset classes</td></tr><tr><td><code>code</code></td><td>Kaiko identifier for the asset.</td></tr><tr><td><code>name</code></td><td>The asset name</td></tr></tbody></table>

### Request example

{% tabs %}
{% tab title="cURL" %}
{% code overflow="wrap" %}

```url
curl --compressed -H 'Accept: application/json' 'https://reference-data-api.kaiko.io/v1/assets'
```

{% endcode %}
{% endtab %}
{% endtabs %}

### Response example

{% tabs %}
{% tab title="JSON" %}
{% code fullWidth="false" %}

```json
{
  "result": "success",
  "data": [
    {
      "code": "btc",
      "name": "Bitcoin",
      "asset_class": "cryptocurrency",
      "asset_classes": [
        "cryptocurrency"
      ]
    },
    {
      "code": "bch",
      "name": "Bitcoin Cash",
      "asset_class": "crypto
```

{% endcode %}
{% endtab %}
{% endtabs %}


# Exchange codes

{% hint style="info" %}
You can explore all exchanges, assets, and get codes for them using our [instrument explorer](https://instruments.kaiko.com/#/exchanges). Alternatively, if you want to obtain the data in a more programmatic way, use this endpoint.
{% endhint %}

{% hint style="info" %}

### This data is included in the following Kaiko packages:

* **Reference Data** \[Basic Tier]
* **Reference Data** \[Advanced Tier]
  {% endhint %}

### What is this endpoint for?

This endpoint retrieves a list of exchanges and associated codes.

### Endpoint

```
https://reference-data-api.kaiko.io/v1/exchanges
```

### Parameters

No parameters supported

### Fields

<table><thead><tr><th width="344">Field</th><th>Description</th></tr></thead><tbody><tr><td><code>code</code></td><td>Kaiko identifier for the exchange.</td></tr><tr><td><code>kaiko_legacy_slug</code></td><td>Identifier used in delivery of aggregated data.</td></tr><tr><td><code>name</code></td><td>The exchange name.</td></tr></tbody></table>

### Request example

{% tabs %}
{% tab title="cURL" %}
{% code overflow="wrap" %}

```url
curl --compressed -H 'Accept: application/json' 'https://reference-data-api.kaiko.io/v1/exchanges'
```

{% endcode %}
{% endtab %}
{% endtabs %}

### Response example

{% tabs %}
{% tab title="JSON" %}
{% code fullWidth="false" %}

```json
{
  "result": "success",
  "data": [
    {
      "code": "bfly",
      "name": "bitFlyer",
      "kaiko_legacy_slug": "bl"
    },
    {
      "code": "bfnx",
      "name": "Bitfinex",
      "kaiko_legacy_slug": "bf"
    }
    /* ... */
  ]
}
```

{% endcode %}
{% endtab %}
{% endtabs %}

{% hint style="warning" %}
We strive to use only one exchange code to cover all the instrument classes such as spot, futures and etc. However, due the legacy issues, we might use different exchange codes for one exchange. The following exchanges are the exchanges that have more than one exchange codes, covering different instrument classes.&#x20;

* Binance
* Bybit
* Huobi
* Kraken
  {% endhint %}


# Exchange trading pair codes (instruments)

{% hint style="info" %}
You can explore all exchanges, assets, and get codes for them using our [instrument explorer](https://instruments.kaiko.com/#/instruments). Alternatively, if you want to obtain the data in a more programmatic way, use this endpoint.
{% endhint %}

{% hint style="info" %}

### This data is included in the following Kaiko packages:

* **Reference Data** \[Basic Tier]
* **Reference Data** \[Advanced Tier]
  {% endhint %}

### What is this endpoint for?

This endpoint retrieves information on instruments (exchange trading pairs) and their associated codes.

### Endpoint

```
https://reference-data-api.kaiko.io/v1/instruments
```

### Parameters

| Field                   | Required? | Description                                                                                            |
| ----------------------- | --------- | ------------------------------------------------------------------------------------------------------ |
| `exchange_code`         | No        | Exchange `code`. See [Broken mention](broken://pages/QiW5iUvcyBF9RISFmZFV)                             |
| `base_asset`            | No        | The desired base asset `code`. See [Broken mention](broken://pages/5iH1qlIc7aNEOOci4yMw)               |
| `quote_asset`           | No        | The desired quote asset `code`. See [Broken mention](broken://pages/5iH1qlIc7aNEOOci4yMw)              |
| `code`                  | No        | Kaiko identifier for the instrument. Always `base_asset-quote_asset` for `spot` instruments.           |
| `kaiko_legacy_symbol`   | No        | Kaiko legacy instrument symbol.                                                                        |
| `class`                 | No        | `spot`, `future`, `perpetual-future`, `option`, etc.                                                   |
| `base_asset_class`      | No        | Base asset `class`.                                                                                    |
| `quote_asset_class`     | No        | Quote asset `class`.                                                                                   |
| `trade_start_timestamp` | No        | Starting time in ISO 8601 (inclusive).                                                                 |
| `trade_end_timestamp`   | No        | Ending time in ISO 8601 (inclusive). Can also use "ongoing" to get ongoing instruments.                |
| `trade_count_min`       | No        | Minimum number of trades.                                                                              |
| `trade_count_max`       | No        | Maximum number of trades.                                                                              |
| `with_list_pools`       | No        | `true` or `false`. For pairs traded on DEXs, provides the list of underlying pools to each instrument. |
| `continuation_token`    | No        | See [Pagination](/rest-api/general/getting-started/pagination)                                         |
| `limit`                 | No        | Maximum number of records to return in one response                                                    |
| `orderBy`               | No        | Order results by a specific field. See below for all possible values.                                  |
| `order`                 | No        | Return the data in ascending (1) or descending (-1) order                                              |
| `blockchain`            | No        | Filter on a specific blockchain for on-chain instruments.                                              |

{% hint style="info" %}
**You can order your request by:**\
exchange\_code, class, kaiko\_legacy\_symbol, trade\_start\_timestamp, trade\_end\_timestamp, trade\_count, base\_asset, quote\_asset, code, trade\_count\_min, trade\_count\_max

\
**Repeated parameters**\
All parameters, except for `trade_count_min/max`, `trade_start/end_timestamp` can be repeated in the URL to filter. For example to get instruments for coinbase & deribit, the request would be `instruments?exchange_code=cbse&exchange_code=drbt`
{% endhint %}

### Fields

| Field                        | Description                                                                                                                                                                                                         |
| ---------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `base_asset`                 | Base asset.                                                                                                                                                                                                         |
| `class`                      | `spot`, `future`, `perpetual-future`,...                                                                                                                                                                            |
| `code`                       | Kaiko identifier for the instrument. Always `base_asset-quote_asset` for `spot` instruments.                                                                                                                        |
| `exchange_code`              | Exchange code. See [Broken mention](broken://pages/QiW5iUvcyBF9RISFmZFV)                                                                                                                                            |
| `exchange_pair_code`         | <p>Identifier for the instrument used by the exchange.<br><br>For perpetual futures pairs, the code may differ from the exchange's and include a <code>\_perp</code> suffix (e.g., <code>btcusdt\_perp)</code>.</p> |
| `kaiko_legacy_exchange_slug` | Legacy slug for the exchange. See [Broken mention](broken://pages/vGAuhofqiYGAJCYlarFi)                                                                                                                             |
| `kaiko_legacy_symbol`        | Identifier used in past deliveries of historical market data and Data Feed.                                                                                                                                         |
| `quote_asset`                | Quote asset                                                                                                                                                                                                         |
| `trade_start_time`           | Time of the first available trade in Kaiko's data set.                                                                                                                                                              |
| `trade_start_timestamp`      | Timestamp of the first available trade in Kaiko's data set.                                                                                                                                                         |
| `trade_end_time`             | Time of the last available trade in Kaiko's data set. `null` if instrument is still active                                                                                                                          |
| `trade_end_timestamp`        | Timestamp of the last available trade in Kaiko's data set. `null` if instrument is still active                                                                                                                     |
| `trade_count`                | The total number of trades available through Kaiko Rest API and Kaiko Stream. For active pairs, this is an approximation.                                                                                           |
| `trade_compressed_size`      | Approximate size in bytes of all available trades in Kaiko Stream.                                                                                                                                                  |
| `list_pools`                 | The list of the underlying pools to each instrument. (Only when arg `with_list_pools=true` is provided).                                                                                                            |

{% hint style="warning" %}
Some exchanges may refer to "base" and "quote" currencies differently.

* When we report the "price" of a trade, we're referring to the "base\_asset" price as reported by the exchange.
* When we report the "volume" involved in a trade, we're referring to volume od the "base\_asset" as reported by the exchange.

Note: some exchanges reverse the ordering of base/quote in their pair codes.&#x20;
{% endhint %}

### Request example

{% tabs %}
{% tab title="cURL" %}
{% code overflow="wrap" %}

```url
curl --compressed -H 'Accept: application/json' 'https://reference-data-api.kaiko.io/v1/instruments'
```

{% endcode %}
{% endtab %}
{% endtabs %}

### Response example

{% tabs %}
{% tab title="JSON" %}
{% code fullWidth="false" %}

```json
{
  "result": "success",
  "data": [
    {
      "kaiko_legacy_exchange_slug": "bf",
      "trade_start_time": "2017-08-09T23:36:33.0000000Z",
      "trade_end_time": null,
      "code": "xmr-btc",
      "exchange_code": "bfnx",
      "exchange_pair_code": "XMRBTC",
      "base_asset": "xmr",
      "quote_asset": "btc",
      "kaiko_legacy_symbol": "xmrbtc",
      "class": "spot",
      "trade_start_timestamp": 1502321793000,
      "trade_end_timestamp": null,
      "trade_count": 2439870,
      "trade_compressed_size": 35037071
    },
    {
      "kaiko_legacy_exchange_slug": "kk",
      "trade_start_time": "2017-08-08T20:10:04.0000000Z",
      "trade_end_time": null,
      "code": "gno-eth",
      "exchange_code": "krkn",
      "exchange_pair_code": "GNOETH",
      "base_asset": "gno",
      "quote_asset": "eth",
      "kaiko_legacy_symbol": "gnoeth",
      "class": "spot",
      "trade_start_timestamp": 1502223004345,
      "trade_end_timestamp": null,
      "trade_count": 380822,
      "trade_compressed_size": 21119034
    },
    /* ... */
  ]
}
```

{% endcode %}
{% endtab %}
{% endtabs %}


# DeFi protocol codes

{% hint style="info" %}
You can explore all exchanges, assets, and get codes for them using our [instrument explorer](https://instruments.kaiko.com/#/instruments). Alternatively, if you want to obtain the data in a more programmatic way, use this endpoint.
{% endhint %}

{% hint style="info" %}

### This data is included in the following Kaiko packages:

* **Reference Data** \[Basic Tier]
* **Reference Data** \[Advanced Tier]
  {% endhint %}

### What is this endpoint for?

This endpoint retrieves a list of defi protocols and associated codes. This can help you identify which exchanges are defi when working with our data.

### Endpoint

```
https://reference-data-api.kaiko.io/v1/pools-protocols
```

### Parameters

No parameters supported

### Fields

| Field      | Description                                        |
| ---------- | -------------------------------------------------- |
| `protocol` | The protocol code. ex:`crm`,`aav2`, `curv`, `blc2` |

### Request example

{% tabs %}
{% tab title="cURL" %}
{% code overflow="wrap" %}

```url
curl --compressed -H 'Accept: application/json' 'https://reference-data-api.kaiko.io/v1/pools-protocols'
```

{% endcode %}
{% endtab %}
{% endtabs %}

### Response example

{% tabs %}
{% tab title="JSON" %}
{% code fullWidth="false" %}

```json
{
    "result": "success",
    "data": [
        "crm",
        "cmpd",
        "pksp",
        "aav2",
        "curv",
        "qsp3",
        "aav3",
        "mkr",
        "tjv2",
        "qsp2",
        "usp2",
        "sush",
        "tj21",
        "blcr",
        "tjv1",
        "aav1",
        "blc2",
        "usp3",
        "crv2"
    ]
}
```

{% endcode %}
{% endtab %}
{% endtabs %}


# Onchain pools

{% hint style="info" %}
You can explore all exchanges, assets, and get codes for them using our [instrument explorer](https://instruments.kaiko.com/#/instruments). Alternatively, if you want to obtain the data in a more programmatic way, use this endpoint.
{% endhint %}

{% hint style="info" %}

### This data is included in the following Kaiko packages:

* **Reference Data** \[Basic Tier]
* **Reference Data** \[Advanced Tier]
  {% endhint %}

### What is this endpoint for?

This endpoint retrieves a list of all pools supported by Kaiko. This can help you identify which markets are available when working with our data.

### Endpoint

```
https://reference-data-api.kaiko.io/v1/pools
```

### Parameters

| Field        | Required? | Description                                                                         |
| ------------ | --------- | ----------------------------------------------------------------------------------- |
| `blockchain` | No        | Filter on a specific blockchain.                                                    |
| `protocol`   | No        | Exchange `code`. See [Broken mention](broken://pages/QiW5iUvcyBF9RISFmZFV)          |
| `tokens`     | No        | The desired asset `code`. See [Broken mention](broken://pages/5iH1qlIc7aNEOOci4yMw) |

No parameters supported

### Fields

| Field         | Description                                                                                                                                                                                                  |
| ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `blockchain`  | The blockchain.                                                                                                                                                                                              |
| `address`     | The blockchain address of the pool.                                                                                                                                                                          |
| `name`        | The name of the pool.                                                                                                                                                                                        |
| `protocol`    | <p>The protocol code.</p><p>Ex:<code>usp3</code>,<code>aav3</code>, <code>curv</code>, <code>blc2</code></p>                                                                                                 |
| `type`        | The pool type.                                                                                                                                                                                               |
| `fee`         | The fee tier.                                                                                                                                                                                                |
| `tokens`      | <p>Table of each token in the pool. Some pools have 1 token (lending vaults), some can have up to 8 tokens (Balancer DEX).</p><p>Format:</p><p><code>\[{blockchain, address, symbol, decimals}, ]</code></p> |
| `tickSpacing` | For concentrated liquidity pools.                                                                                                                                                                            |
| `weights`     | For Balancer weighted pools.                                                                                                                                                                                 |

### Request example

{% tabs %}
{% tab title="cURL" %}
{% code overflow="wrap" %}

```url
curl --compressed -H 'Accept: application/json' 'https://reference-data-api.kaiko.io/v1/pools'
```

{% endcode %}
{% endtab %}
{% endtabs %}

### Response example

{% tabs %}
{% tab title="JSON" %}
{% code fullWidth="false" %}

```json
{
    "result": "success",
    "count": 1537,
    "data":
    [
        {
            "blockchain": "bsc",
            "address": "0x0004222c2075e9a1291e41f1ca4c8d32141db501",
            "name": "MBOX-WBNB-0.003",
            "protocol": "pks3",
            "type": "liquidity_pool",
            "fee": "0.0025",
            "tokens":
            [
                {
                    "blockchain": "bsc",
                    "address": "0x3203c9e46ca618c8c1ce5dc67e7e9d75f5da2377",
                    "symbol": "mbox",
                    "decimals": "18"
                },
                {
                    "blockchain": "bsc",
                    "address": "0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c",
                    "symbol": "wbnb",
                    "decimals": "18"
                }
            ],
            "tickSpacing": "50"
        },
        /**********/
    ]
}
```

{% endcode %}
{% endtab %}
{% endtabs %}


# Blockchain codes

{% hint style="info" %}
You can explore all exchanges, assets, and get codes for them using our [instrument explorer](https://instruments.kaiko.com/#/instruments). Alternatively, if you want to obtain the data in a more programmatic way, use this endpoint.
{% endhint %}

{% hint style="info" %}

### This data is included in the following Kaiko packages:

* **Reference Data** \[Basic Tier]
* **Reference Data** \[Advanced Tier]
  {% endhint %}

### What is this endpoint for?

This endpoint retrieves the list of blockchains and associated codes.

### Endpoint

```
https://reference-data-api.kaiko.io/v1/blockchains
```

### Parameters

No parameters supported

### Fields

| Field    | Description                                  |
| -------- | -------------------------------------------- |
| `id`     | The blockchain's id in our reference data.   |
| `name`   | The blockchain's name in our reference data. |
| `is_evm` | If the blockchain is EVM-Compatible or not.  |

### Request example

{% tabs %}
{% tab title="cURL" %}
{% code overflow="wrap" %}

```url
curl --compressed -H 'Accept: application/json' 'https://reference-data-api.kaiko.io/v1/blockchains'
```

{% endcode %}
{% endtab %}
{% endtabs %}

### Response example

{% tabs %}
{% tab title="JSON" %}
{% code fullWidth="false" %}

```json
{
    "result":"success",
    "count": 10,
    "data":
    [
        {"id":1,"name":"ethereum","is_evm":true},
        {"id":2,"name":"bsc","is_evm":true},
        {"id":3,"name":"polygon","is_evm":true},
        {"id":4,"name":"arbitrum","is_evm":true},
        {"id":5,"name":"avalanche","is_evm":true},
        /* ... */
    ]
}
```

{% endcode %}
{% endtab %}
{% endtabs %}


# Derivatives contract details

{% hint style="info" %}

### This data is included in the following Kaiko packages:

* **Reference Data** \[Advanced Tier]
  {% endhint %}

### What is this endpoint for? <a href="#what-is-this-endpoint-for" id="what-is-this-endpoint-for"></a>

## What is this endpoint for?

This endpoint provides details of the contracts, including base asset, quote asset, contract size, contract size unit, listing\_timestamp, expiry, strike price, and underlying index.

### Endpoint

```url
https://<eu|us>.market-api.kaiko.io/v2/data/derivatives.v2/reference
```

### Path Parameters

| Parameter | Required? | Example                       |
| --------- | --------- | ----------------------------- |
| `region`  | Yes       | Choose between `eu` and `us`. |

### Query Parameters

<table><thead><tr><th width="163">Parameter</th><th width="98">Required</th><th>Description</th><th>Example</th></tr></thead><tbody><tr><td><code>exchange</code></td><td>Yes</td><td>Should be one of the exchanges currently supported</td><td><code>okex</code></td></tr><tr><td><code>instrument_class</code></td><td>Yes</td><td><code>future</code>, <code>perpetual-future</code>, or <code>option</code></td><td><code>future</code></td></tr><tr><td><code>instrument</code></td><td>No</td><td>Instrument <code>code</code>. <br><br>See <a data-mention href="/pages/8ywkQXfxfv1FjtyspEaU">/pages/8ywkQXfxfv1FjtyspEaU</a></td><td><code>ethusd220624</code>, <code>btc*220624</code>, <code>*usdt</code>, <code>btc*may22*</code></td></tr><tr><td><code>base_assets</code></td><td>No</td><td>For finding the instruments with the certain base asset</td><td><code>btc</code>, <code>eth</code></td></tr><tr><td><code>quote_assets</code></td><td>No</td><td>For finding the instruments with the certain quote asset</td><td><code>usd</code>, <code>usdt</code></td></tr><tr><td><code>option_type</code></td><td>No</td><td><code>option</code> only. For finding either only the call options or put options</td><td><code>C</code>, <code>P</code></td></tr><tr><td><code>min_strike</code></td><td>No</td><td><code>option</code> only. Used to retrieve options whose strike price is above this minimum value (exclusive/inclusive)</td><td><code>10000</code></td></tr><tr><td><code>max_strike</code></td><td>No</td><td><code>option</code> only. Used to retrieve options whose strike price is below this maximum value (exclusive/inclusive)</td><td><code>90000</code></td></tr><tr><td><code>start_time</code><br><br><strong>Deribit exchange only</strong></td><td>No</td><td><code>future</code> &#x26; <code>option</code> only. Used to retrieve futures and options that expire after this date and time (inclusive)</td><td><code>2022-06-23T00:01:00.000Z</code></td></tr><tr><td><code>end_time</code><br><br><strong>Deribit exchange only</strong></td><td>No</td><td><code>future</code> &#x26; <code>option</code> only. Used to retrieve futures and options that are listed before this date and time (exclusive)</td><td><code>2022-06-25T23:59:00.000Z</code></td></tr><tr><td><code>page_size</code></td><td>No</td><td>Number of snapshots to return data for. (default: 1000, min: 1, max: 1000). <br><br>See <a data-mention href="/pages/mP3amLsYqKTsrRBoblxX">/pages/mP3amLsYqKTsrRBoblxX</a></td><td><code>500</code></td></tr></tbody></table>

### Fields: Perpetual-Future

| Field                    | Description                                                                       | Example                   |
| ------------------------ | --------------------------------------------------------------------------------- | ------------------------- |
| `exchange`               | The exchange where the specified instrument is being traded                       | `binc`                    |
| `instrument_class`       | Shows wether the specified instrument is `future`, `perpetual-future` or `option` | `perpetual-future`        |
| `instrument`             | The specified instrument                                                          | `btc-usdc`                |
| `base`                   | The base asset of the instrument                                                  | `btc`                     |
| `quote`                  | The unit in which the instrument is quoted                                        | `usdc`                    |
| `contract_size`          | Size of the contract                                                              | `1`                       |
| `contract_size_unit`     | Unit in which contract is denominated                                             | `btc`                     |
| `listing_timestamp`      | Date listed by exchange                                                           | `2024-01-03 12:30:00 UTC` |
| `funding_rate_frequency` | Interval at which the funding rate is paid                                        | `8h`                      |

### Fields: Future

| Field                | Description                                                                       | Example                   |
| -------------------- | --------------------------------------------------------------------------------- | ------------------------- |
| `exchange`           | The exchange where the specified instrument is being traded                       | `okex`                    |
| `instrument_class`   | Shows wether the specified instrument is `future`, `perpetual-future` or `option` | `future`                  |
| `instrument`         | The specified instrument                                                          | `btcusdt250117`           |
| `base`               | The base asset of the instrument                                                  | `btc`                     |
| `quote`              | The unit in which the instrument is quoted                                        | `usdt`                    |
| `contract_size`      | Size of the contract                                                              | `0.01`                    |
| `contract_size_unit` | Unit in which contract is denominated                                             | `btc`                     |
| `listing_timestamp`  | The timestamp when a certain option instrument is listed on the exchange          | `2025-01-03 08:10:00 UTC` |
| `expiry`             | Expiration date of the contract                                                   | `2025-01-17 08:00:00 UTC` |

### Fields: Option

| Field                | Description                                                                       | Example                   |
| -------------------- | --------------------------------------------------------------------------------- | ------------------------- |
| `exchange`           | The exchange where the specified instrument is being traded                       | `drbt`                    |
| `instrument_class`   | Shows wether the specified instrument is `future`, `perpetual-future` or `option` | `option`                  |
| `instrument`         | The specified instrument                                                          | `btc10dec21100000c`       |
| `base`               | The base asset of the instrument                                                  | `btc`                     |
| `quote`              | The unit in which the instrument is quoted                                        | `usd`                     |
| `contract_size`      | Size of the contract                                                              | `1`                       |
| `contract_size_unit` | Unit in which contract is denominated                                             | `btc`                     |
| `listing_timestamp`  | The timestamp when a certain option instrument is listed on the exchange          | `2021-11-18 08:16:00 UTC` |
| `expiry`             | Expiration date of the contract                                                   | `2021-12-10 08:00:00 UTC` |
| `strike_price`       | The strike price of the contract in USD.                                          | `30000`                   |
| `underlying_index`   | Name of the underlying asset                                                      | `BTC-10DEC21`             |

### Request examples

{% tabs %}
{% tab title="cURL" %}
{% code overflow="wrap" %}

````url
curl --compressed -H 'Accept: application/json' -H 'X-Api-Key: <client-api-key>' \
'https://us.market-api.kaiko.io/v2/data/derivatives.v2/reference?exchange=drbt&instrument_class=option&base_assets=btc&page_size=50'```python
````

{% endcode %}
{% endtab %}

{% tab title="Python" %}
{% code overflow="wrap" %}

```python
##### 1. Import dependencies #####
import requests
import pandas as pd

##### 2. Choose the value of the query's parameters #####
# ---- Required parameters ---- #
exchange = "okex"
instrument_class = "future"

# ---- Optional parameters ---- #
instrument = None
base_assets = None
quote_assets = "btc"
option_type = None
min_strike = None
max_strike = None
start_time = None
end_time = None
page_size = 500

# ---- API key configuration ---- #
api_key = "YOUR_API_KEY"

##### 3. Get the data #####
# ---- Function to run an API call ---- # 
# Get the data in a dataframe --------- # 

def get_kaiko_data(api_key: str, exchange: str, instrument_class: str, instrument: str, base_assets: str, quote_assets: str, option_type: str, min_strike: int, max_strike: int, start_time: str, end_time: str, page_size: int):
    headers = {'Accept': 'application/json', 'X-Api-Key': api_key}
    
    url = f'https://us.market-api.kaiko.io/v2/data/derivatives.v2/reference'
    params = {
        "exchange": exchange,
        "instrument_class": instrument_class,
        "instrument": instrument,
        "base_assets": base_assets,
        "quote_assets": quote_assets,
        "option_type": option_type,
        "min_strike": min_strike,
        "max_strike": max_strike,
        "start_time": start_time,
        "end_time": end_time,
        "page_size": page_size
    }

    try:
        res = requests.get(url, headers=headers, params=params)
        res.raise_for_status() 
        data = res.json()
        if 'data' not in data:
            print("No data returned.")
            return pd.DataFrame() 
        df = pd.DataFrame(data['data'])

        # Handle pagination with continuation token
        while 'next_url' in data:
            next_url = data['next_url']
            if next_url is None:
                break
            res = requests.get(next_url, headers=headers)
            res.raise_for_status()
            data = res.json()
            if 'data' in data:
                df = pd.concat([df, pd.DataFrame(data['data'])], ignore_index=True)
        return df

    except requests.exceptions.RequestException as e:
        print(f"API request error: {e}")
        return pd.DataFrame() 

# ---- Get the data ---- #
df = get_kaiko_data(api_key=api_key, exchange=exchange, instrument_class=instrument_class, instrument=instrument, base_assets=base_assets, quote_assets=quote_assets, option_type=option_type, min_strike=min_strike, max_strike=max_strike, start_time=start_time, end_time=end_time, page_size=page_size)
print (df)
```

{% endcode %}
{% endtab %}
{% endtabs %}

### Response example

```json
{
    "query": {
        "exchange": "drbt",
        "instrument_class": "option",
        "base_assets": [
            "btc"
        ],
        "page_size": "50",
        "data_version": "v2",
        "commodity": "derivatives",
        "request_time": "2022-11-30T15:26:49.66Z"
    },
    "time": "2022-11-30T15:26:55.623Z",
    "timestamp": 1669822015623,
    "data": [
        {
            "exchange": "drbt",
            "instrument_class": "option",
            "instrument": "btc10apr204750c",
            "base": "btc",
            "quote": "usd",
            "contract_size": "1",
            "contract_size_unit": "btc",
            "listing_timestamp": "2020-03-28 03:21:00 UTC",
            "expiry": "2020-04-10 08:00:00 UTC",
            "strike_price": "4750",
            "underlying_index": "SYN.BTC-10APR20"
        },
        /*---*/
    ],
    "result": "success",
    "continuation_token": "VHoT1C16LjCmtrfParGdwd4mVJnV1Qaqx5AMgXWsYawuiw68Qfymdf215NBcg9LzPJNxA9cZsBjB5S8JBHd8Giw2qoFDFvJ1tP3M5",
    "next_url": "https://us.market-api.kaiko.io/v2/data/derivatives.v2/reference?continuation_token=VHoT1C16LjCmtrfParGdwd4mVJnV1Qaqx5AMgXWsYawuiw68Qfymdf215NBcg9LzPJNxA9cZsBjB5S8JBHd8Giw2qoFDFvJ1tP3M5",
    "access": {
        "access_range": {
            "start_timestamp": 1646006400000,
            "end_timestamp": null
        },
        "data_range": {
            "start_timestamp": null,
            "end_timestamp": null
        }
    }
}
```

Searching for contracts (Deribit exchange only)You can get a list of all the futures or options that can be traded between two specific times by using the `start_time` and `end_time` settings. For instance, if you're interested in all the futures or options that can be traded between October 1, 2022, and October 2, 2022, you would set start\_time as `2022-10-01T00:00:00.000Z` and end\_time as `2022-10-03T00:00:00.000Z`. If you want to find futures or options that were traded at a specific time, simply use the same time for both `start_time` and `end_time`. If you only provide one of the `start_time` or `end_time`, the other one will be automatically determined as shown in the table below.

| start\_time (ISO 8601) | end\_time (ISO 8601) | Description                                                                               |
| ---------------------- | -------------------- | ----------------------------------------------------------------------------------------- |
| Given                  | Given                | `start_time (ISO 8601)` and `end_time (ISO 8601)` are the specified datetime respectively |
| Given                  | Not given            | `end_time (ISO 8601)` = `start_time (ISO 8601)` + 1 day                                   |
| Not given              | Given                | `start_time (ISO 8601)` = `end_time (ISO 8601)` - 1 day                                   |
| Not given              | Not given            | all the instruments will be shown regardless of dates                                     |


# Derivatives price details

{% hint style="info" %}

### This data is included in the following Kaiko packages:

* **Reference Data** \[Advanced Tier]
  {% endhint %}

## What is this endpoint for?

This endpoint shows the mark price, index price, and price (last traded price) of a derivative.

### Endpoint

```http
https://eu.market-api.kaiko.io/v2/data/derivatives.v2/price
```

### Path Parameters

| Parameter | Required? | Example                       |
| --------- | --------- | ----------------------------- |
| `region`  | Yes       | Choose between `eu` and `us`. |

### Query Parameters

<table><thead><tr><th width="189">Parameter</th><th width="128">Required</th><th width="324">Description</th><th>Example</th></tr></thead><tbody><tr><td><code>exchange</code></td><td>Yes</td><td>Should be one of the exchanges currently supported</td><td><code>okex</code></td></tr><tr><td><code>instrument_class</code></td><td>Yes</td><td><code>future</code>, <code>perpetual-future</code>, or <code>option</code></td><td><code>future</code></td></tr><tr><td><code>instrument</code></td><td>Yes</td><td>Instrument <code>code</code>. <br><br>See <a data-mention href="/spaces/bvJkzmxJbcDMceEJsq2K/pages/o4ZunsQ4PYoKpO528Uxw">/spaces/bvJkzmxJbcDMceEJsq2K/pages/o4ZunsQ4PYoKpO528Uxw</a><br><br>One instrument returned per query.</td><td><code>btcusdt250117</code></td></tr><tr><td><code>interval</code></td><td>No</td><td>Interval period (can be one of <code>1m</code>, <code>1h</code>, <code>4h</code>, and <code>1d</code>). Default <code>1m</code><br><br>When you query data using an<code>interval</code> greater than one minute, we'll return the data from the last minute of that time period. For example, if you query data for <code>09:00</code> with the <code>interval</code> set at <code>1h</code>, we'll return data from <code>09:59</code> (since that's the last minute of the 09:00-10:00 hour period). </td><td><code>1h</code></td></tr><tr><td><code>page_size</code></td><td>No</td><td>Number of snapshots to return data for. (default: 100, min: 1, max: 1000). <br><br>See <a data-mention href="/pages/mP3amLsYqKTsrRBoblxX">/pages/mP3amLsYqKTsrRBoblxX</a></td><td><code>10</code></td></tr><tr><td><code>sort</code></td><td>No</td><td>Return the data in ascending (<code>asc</code>) or descending (<code>desc</code>) order. Default <code>desc</code></td><td><code>asc</code></td></tr><tr><td><code>start_time</code></td><td>No</td><td>Starting time in ISO 8601 (inclusive).</td><td><code>2025-01-01T00:00:00.000Z</code></td></tr><tr><td><code>end_time</code></td><td>No</td><td>Ending time in ISO 8601 (exclusive).</td><td><code>2025-01-04T00:00:00.000Z</code></td></tr></tbody></table>

### Fields: Perpetual-Future

<table><thead><tr><th width="189">Field</th><th width="341">Description</th><th>Example</th></tr></thead><tbody><tr><td><code>timestamp</code></td><td>Timestamp at which the interval begins. In milliseconds.</td><td><code>1650441900000</code></td></tr><tr><td><code>index_price</code></td><td>The price of the underlying index, often as a weighted average across multiple exchanges' spot prices</td><td><code>39713.3</code></td></tr><tr><td><code>mark_price</code></td><td>The mark price of the contract. It is used for calculating profit and loss (PnL) and liquidation price. Designed to be fair and avoid price manipulation.</td><td><code>39745.9</code></td></tr><tr><td><code>price</code></td><td>Most recent traded price of derivative contract</td><td><code>39767</code></td></tr></tbody></table>

### Fields: Future

<table><thead><tr><th width="189">Field</th><th width="341">Description</th><th>Example</th></tr></thead><tbody><tr><td><code>timestamp</code></td><td>Timestamp at which the interval begins. In milliseconds.</td><td><code>1735850520000</code></td></tr><tr><td><code>index_price</code></td><td>The price of the underlying index, often as a weighted average across multiple exchanges' spot prices</td><td><code>97353.8</code></td></tr><tr><td><code>mark_price</code></td><td>The mark price of the contract. It is used for calculating profit and loss (PnL) and liquidation price. Designed to be fair and avoid price manipulation.</td><td><code>104276.62</code></td></tr><tr><td><code>price</code></td><td>Most recent traded price of derivative contract</td><td><code>104293.8</code></td></tr></tbody></table>

### Fields: Option

<table><thead><tr><th width="189">Field</th><th width="341">Description</th><th>Example</th></tr></thead><tbody><tr><td><code>timestamp</code></td><td>Timestamp at which the interval begins. In milliseconds.</td><td><code>1735850520000</code></td></tr><tr><td><code>index_price</code></td><td>The price of the underlying index, often as a weighted average across multiple exchanges' spot prices</td><td><code>97508.58</code></td></tr><tr><td><code>mark_price</code></td><td>The mark price of the contract. It is used for calculating profit and loss (PnL) and liquidation price. Designed to be fair and avoid price manipulation.</td><td><code>0.0061</code></td></tr><tr><td><code>price</code></td><td>Most recent traded price of derivative contract</td><td><code>0.0065</code></td></tr></tbody></table>

### Request examples

{% tabs %}
{% tab title="cURL" %}
{% code overflow="wrap" %}

```url
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'
```

{% endcode %}
{% endtab %}

{% tab title="Python" %}
{% code overflow="wrap" %}

```python
##### 1. Import dependencies #####
import requests
import pandas as pd

##### 2. Choose the value of the query's parameters #####
# ---- Required parameters ---- #
exchange = "okex"
instrument_class = "perpetual-future"
instrument = "btc-usdt"

# ---- Optional parameters ---- #
interval = "1h"
page_size = 10
sort = "asc"
start_time = None
end_time = None

# ---- API key configuration ---- #
api_key = "YOUR_API_KEY"

##### 3. Get the data #####
# ---- Function to run an API call ---- # 
# Get the data in a dataframe --------- # 

def get_kaiko_data(api_key: str, exchange: str, instrument_class: str, instrument: str, interval: str, page_size: int, sort: str, start_time: str, end_time: str):
    headers = {'Accept': 'application/json', 'X-Api-Key': api_key}
    
    url = f'https://eu.market-api.kaiko.io/v2/data/derivatives.v2/price'
    params = {
        "exchange": exchange,
        "instrument_class": instrument_class,
        "instrument": instrument,
        "interval": interval,
        "page_size": page_size,
        "sort": sort,
        "start_time": start_time,
        "end_time": end_time
    }

    try:
        res = requests.get(url, headers=headers, params=params)
        res.raise_for_status() 
        data = res.json()
        if 'data' not in data:
            print("No data returned.")
            return pd.DataFrame() 
        df = pd.DataFrame(data['data'])

        # Handle pagination with continuation token
        while 'next_url' in data:
            next_url = data['next_url']
            if next_url is None:
                break
            res = requests.get(next_url, headers=headers)
            res.raise_for_status()
            data = res.json()
            if 'data' in data:
                df = pd.concat([df, pd.DataFrame(data['data'])], ignore_index=True)
        return df

    except requests.exceptions.RequestException as e:
        print(f"API request error: {e}")
        return pd.DataFrame() 

# ---- Get the data ---- #
df = get_kaiko_data(api_key=api_key, exchange=exchange, instrument_class=instrument_class, instrument=instrument, interval=interval, page_size=page_size, sort=sort, start_time=start_time, end_time=end_time)
print (df)
```

{% endcode %}
{% endtab %}

{% tab title="BigQuery" %}
Information from this endpoint can be accessed through Google BigQuery. \
\
To get started, read our [guide](broken://spaces/zwO3AMVXsp37KK2FngVc/pages/LFIZ1UwRtOxTg308jneZ).
{% endtab %}
{% endtabs %}

### Response example

{% code overflow="wrap" %}

```json
{
    "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
        }
    }
}
```

{% endcode %}


# Introduction

Basic information about Kaiko Data Feeds.

## About our Data Feeds

Our Data feeds help with front and mid-office operations, business intelligence, and risk management. We offer Level 1 and Level 2 market data, alongside crypto reference insight.


# Trade aggregations


# Trade Count, OHLCV, & VWAP

{% hint style="info" %}

### This data is included in the following Kaiko packages:

* Level 1 & Level 2 Data \[Level 1 Aggregations Tier]
* Level 1 & Level 2 Data \[Level 1 Tick-Level Tier]
* Level 1 & Level 2 Data \[Level 2 Aggregations Tier]
* Level 1 & Level 2 Data \[Level 2 Tick-Level Tier]

*CeFi spot ticker packs.*
{% endhint %}

## What is this endpoint for?&#x20;

This endpoint retrieves the Trade Count, OHLCV and VWAP history for any instrument on an exchange. The `interval` parameter is suffixed with `s`, `m`, `h` or `d` to specify seconds, minutes, hours or days, respectively. By making use of the `sort` parameter, data can be returned in ascending `asc` (default) or descending `desc` order.

{% hint style="warning" %}
You can use this same endpoint to get data for all market types. Kaiko subscriptions are sold per market type.
{% endhint %}

### Endpoint

{% code overflow="wrap" %}

```http
https://<eu|us>.market-api.kaiko.io/v2/data/trades.v1/exchanges/{exchange}/spot/{instrument}/aggregations/count_ohlcv_vwap
```

{% endcode %}

### Path Parameters

<table><thead><tr><th width="203">Parameter</th><th>Required?</th><th>Description</th></tr></thead><tbody><tr><td><code>region</code></td><td>Yes</td><td>Choose between <code>eu</code> and <code>us</code>.</td></tr><tr><td><code>exchange</code></td><td>Yes</td><td><p>Exchange <code>code.</code> </p><p><br>See <br><a data-mention href="/pages/QiW5iUvcyBF9RISFmZFV">/pages/QiW5iUvcyBF9RISFmZFV</a></p></td></tr><tr><td><code>instrument_class</code></td><td>Yes</td><td>Instrument <code>class</code>. <br><br>See <br><a data-mention href="/pages/8ywkQXfxfv1FjtyspEaU">/pages/8ywkQXfxfv1FjtyspEaU</a></td></tr><tr><td><code>instrument</code></td><td>Yes</td><td>Instrument <code>code</code>.<br><br><a data-mention href="/pages/8ywkQXfxfv1FjtyspEaU">/pages/8ywkQXfxfv1FjtyspEaU</a></td></tr></tbody></table>

### Query Parameters

<table><thead><tr><th width="253">Parameter</th><th width="117">Required</th><th>Description</th></tr></thead><tbody><tr><td><code>continuation_token</code></td><td>No</td><td>See <a data-mention href="/pages/mP3amLsYqKTsrRBoblxX">/pages/mP3amLsYqKTsrRBoblxX</a></td></tr><tr><td><code>end_time</code></td><td>No</td><td>Ending time in ISO 8601 (exclusive).<br><br><em>Automatically included in continuation tokens.</em></td></tr><tr><td><code>interval</code></td><td>No</td><td>The interval parameter is suffixed with <code>s</code>, <code>m</code>, <code>h</code> or <code>d</code> to specify seconds, minutes, hours or days, respectively.<br><br>Any arbitrary value between one second and one day can be used, as long as it sums up to a maximum of 1 day. The suffixes are <code>s</code> (second), <code>m</code> (minute), <code>h</code> (hour) and <code>d</code> (day).<br><br> Default <code>1d</code>.</td></tr><tr><td><code>page_size</code></td><td>No</td><td>See <a data-mention href="/pages/mP3amLsYqKTsrRBoblxX">/pages/mP3amLsYqKTsrRBoblxX</a><br><br><em>Automatically included in continuation tokens.</em></td></tr><tr><td><code>start_time</code></td><td>No</td><td>Starting time in ISO 8601 (inclusive).<br><br><em>Automatically included in continuation tokens.</em></td></tr><tr><td><code>sort</code></td><td>No</td><td>Return the data in ascending (<code>asc</code>) or descending (<code>desc</code>) order. Default <code>desc</code><br><br><em>Automatically included in continuation tokens.</em></td></tr></tbody></table>

### Fields

| Field       | Description                                                                         |
| ----------- | ----------------------------------------------------------------------------------- |
| `timestamp` | Timestamp at which the interval begins.                                             |
| `count`     | Then number of trades. `0` when no trades reported.                                 |
| `open`      | Opening price of interval. `null` when no trades reported.                          |
| `high`      | Highest price during interval. `null` when no trades reported.                      |
| `low`       | Lowest price during interval. `null` when no trades reported.                       |
| `close`     | Closing price of interval. `null` when no trades reported.                          |
| `volume`    | Volume traded in interval. `0` when no trades reported.                             |
| `price`     | The volume weighted price during the time interval. `null` when no trades reported. |

### Request examples

{% tabs %}
{% tab title="cURL" %}
{% code overflow="wrap" %}

```url
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/count_ohlcv_vwap'
```

{% endcode %}
{% endtab %}

{% tab title="Python" %}
{% code overflow="wrap" %}

````python
```python
##### 1. Import dependencies #####
import requests
import pandas as pd

##### 2. Choose the value of the query's parameters #####
# ---- Required parameters ---- #
exchange = "cbse" 
instrument_class = "spot"
pair = "btc-usd" #called "instrument" in the documentation

# ---- Optional parameters ---- #
interval = "1d"  
sort = "desc"
page_size = 100
start_time= "2023-01-01T00:00:00Z"
end_time= "2023-12-31T23:59:59Z"

# ---- API key configuration ---- #
api_key = "YOUR_API_KEY"

##### 3. Get the data #####
# ---- Function to run an API call ---- # 
# Get the data in a dataframe --------- # 

def get_kaiko_data(api_key: str, exchange: str, pair: str, instrument_class: str, start_time: str, end_time: str, interval: str, sort: str, page_size: int):
    headers = {'Accept': 'application/json', 'X-Api-Key': api_key}
    
    url = f'https://us.market-api.kaiko.io/v2/data/trades.v1/exchanges/{exchange}/{instrument_class}/{pair}/aggregations/count_ohlcv_vwap'
    params = {
        "start_time": start_time,
        "end_time": end_time,
        "sort": sort,
        "page_size": page_size,
        "interval": interval
    }

    try:
        res = requests.get(url, headers=headers, params=params)
        res.raise_for_status() 
        data = res.json()
        if 'data' not in data:
            print("No data returned.")
            return pd.DataFrame() 
        df = pd.DataFrame(data['data'])

        # Handle pagination with continuation token
        while 'next_url' in data:
            res = requests.get(data['next_url'], headers=headers)
            res.raise_for_status()
            data = res.json()
            if 'data' in data:
                df = pd.concat([df, pd.DataFrame(data['data'])], ignore_index=True)
        return df

    except requests.exceptions.RequestException as e:
        print(f"API request error: {e}")
        return pd.DataFrame() 

# ---- Get the data ---- #
df = get_kaiko_data(api_key=api_key, exchange=exchange, pair=pair, instrument_class=instrument_class, start_time=start_time, end_time=end_time ,interval=interval, sort=sort, page_size=page_size)
```
````

{% endcode %}
{% endtab %}

{% tab title="BigQuery" %}
Trade Count and OHLCV can be accessed through Google BigQuery. \
\
To get started, read our [guide](broken://spaces/zwO3AMVXsp37KK2FngVc/pages/LFIZ1UwRtOxTg308jneZ).
{% endtab %}
{% endtabs %}

### Response example

```json
{
    "query": {
        "page_size": 100,
        "exchange": "cbse",
        "instrument_class": "spot",
        "instrument": "btc-usd",
        "interval": "1d",
        "sort": "desc",
        "aggregation": "count_ohlcv_vwap",
        "data_version": "v1",
        "commodity": "trades",
        "request_time": "2020-11-12T16:55:42.588Z"
    },
    "time": "2020-11-12T16:55:42.710Z",
    "timestamp": 1605200142710,
    "data": [
        {
            "timestamp": 1605139200000,
            "open": "15705.79",
            "high": "16185.87",
            "low": "15446.82",
            "close": "16139.93",
            "volume": "14829.124546730012",
            "price": "15880.01873841608",
            "count": 95111
        },
        {
            "timestamp": 1605052800000,
            "open": "15315.46",
            "high": "16000",
            "low": "15293.04",
            "close": "15705.79",
            "volume": "15123.844197729988",
            "price": "15664.643871798791",
            "count": 114205
        },
    /* ... */
  ],
  "result": "success",
  "continuation_token": "rbd1XbkjMwv2SyUfvJwsqFGmCKzg3WToTvqigui1bejckYnxd9DM1V3v58iqMCdXa4dJSXap6p6fBuvzz32tiHVrv5LC76MyRyYNbZyvSEoVzd1krSWWeXYEtEtR",
  "next_url": "https://<eu|us>.market-api.kaiko.io/v2/data/trades.v1/exchanges/cbse/spot/btc-usd/aggregations/count_ohlcv_vwap?continuation_token=rbd1XbkjMwv2SyUfvJwsui1bejckYnxd9DM1V3v58iqMCdXa4dJSXap6p6fBuvzz32tiHVrv5LC76MyRyYNbZyvSEoVzd1krSWWeXYEtEtR",
  "access": {
    "access_range": {
      "start_timestamp": 1546300800000,
      "end_timestamp": 1577836800000
    },
    "data_range": {
      "start_timestamp": 1417391000000,
      "end_timestamp": 1577836800000
    }
  }
}

```


# OHLCV only

{% hint style="info" %}

### This data is included in the following Kaiko packages:

* Level 1 & Level 2 Data \[Level 1 Aggregations Tier]
* Level 1 & Level 2 Data \[Level 1 Tick-Level Tier]
* Level 1 & Level 2 Data \[Level 2 Aggregations Tier]
* Level 1 & Level 2 Data \[Level 2 Tick-Level Tier]

*CeFi spot ticker packs.*
{% endhint %}

## What is this endpoint for?&#x20;

This endpoint retrieves the OHLCV history for an instrument on an exchange.

{% hint style="warning" %}
You can use this same endpoint to get data for all market types. Kaiko subscriptions are sold per market type.
{% endhint %}

### Endpoint

{% code overflow="wrap" %}

```http
https://<eu|us>.market-api.kaiko.io/v2/data/trades.v1/exchanges/{exchange}/spot/{instrument}/aggregations/ohlcv
```

{% endcode %}

### Path Parameters

<table><thead><tr><th width="203">Parameter</th><th>Required?</th><th>Description</th></tr></thead><tbody><tr><td><code>region</code></td><td>Yes</td><td>Choose between <code>eu</code> and <code>us</code>.</td></tr><tr><td><code>exchange</code></td><td>Yes</td><td><p>Exchange <code>code.</code> </p><p><br>See <br><a data-mention href="/pages/QiW5iUvcyBF9RISFmZFV">/pages/QiW5iUvcyBF9RISFmZFV</a></p></td></tr><tr><td><code>instrument_class</code></td><td>Yes</td><td>Instrument <code>class</code>. <br><br>See <br><a data-mention href="/pages/8ywkQXfxfv1FjtyspEaU">/pages/8ywkQXfxfv1FjtyspEaU</a></td></tr><tr><td><code>instrument</code></td><td>Yes</td><td>Instrument <code>code</code>.<br><br>See <br><a data-mention href="/pages/8ywkQXfxfv1FjtyspEaU">/pages/8ywkQXfxfv1FjtyspEaU</a></td></tr></tbody></table>

### Query Parameters

<table><thead><tr><th width="233">Parameter</th><th width="144">Required</th><th>Description</th></tr></thead><tbody><tr><td><code>end_time</code></td><td>No</td><td>Ending time in ISO 8601 (exclusive).<br><br><em>Automatically included in continuation tokens.</em></td></tr><tr><td><code>continuation_token</code></td><td>No</td><td>See <a data-mention href="/pages/mP3amLsYqKTsrRBoblxX">/pages/mP3amLsYqKTsrRBoblxX</a></td></tr><tr><td><code>interval</code></td><td>No</td><td>The interval parameter is suffixed with <code>s</code>, <code>m</code>, <code>h</code> or <code>d</code> to specify seconds, minutes, hours or days, respectively.<br><br>Any arbitrary value between one second and one day can be used, as long as it sums up to a maximum of 1 day. The suffixes are <code>s</code> (second), <code>m</code> (minute), <code>h</code> (hour) and <code>d</code> (day).<br><br> Default <code>1d</code>.</td></tr><tr><td><code>page_size</code></td><td>No</td><td>(min: 1, default: 100, max: 100000).<br><br>See <a data-mention href="/pages/mP3amLsYqKTsrRBoblxX">/pages/mP3amLsYqKTsrRBoblxX</a> <br><br><em>Automatically included in continuation tokens.</em></td></tr><tr><td><code>start_time</code></td><td>No</td><td>Starting time in ISO 8601 (inclusive).</td></tr><tr><td><code>sort</code></td><td>No</td><td>Return the data in ascending (<code>asc</code>) or descending (<code>desc</code>) order. Default <code>desc</code><br><br><em>Automatically included in continuation tokens.</em></td></tr></tbody></table>

### Fields

<table><thead><tr><th width="385">Field</th><th>Description</th></tr></thead><tbody><tr><td><code>timestamp</code></td><td>Timestamp at which the interval begins.</td></tr><tr><td><code>open</code></td><td>Opening price of interval. <code>null</code> when no trades reported.</td></tr><tr><td><code>high</code></td><td>Highest price during interval. <code>null</code> when no trades reported.</td></tr><tr><td><code>low</code></td><td>Lowest price during interval. <code>null</code> when no trades reported.</td></tr><tr><td><code>close</code></td><td>Closing price of interval. <code>null</code> when no trades reported.</td></tr><tr><td><code>volume</code></td><td>Volume traded in interval. <code>0</code> when no trades reported.</td></tr></tbody></table>

### Request examples

{% tabs %}
{% tab title="cURL" %}
{% code overflow="wrap" %}

```url
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/ohlcv'
```

{% endcode %}
{% endtab %}

{% tab title="Python" %}
{% code overflow="wrap" %}

```python
##### 1. Import dependencies #####
import requests
import pandas as pd

##### 2. Choose the value of the query's parameters #####
# ---- Required parameters ---- #
exchange = "cbse" 
instrument_class = "spot"
pair = "btc-usd" #called "instrument" in the documentation

# ---- Optional parameters ---- #
interval = "1d"  
sort = "desc"
page_size = 100
start_time= "2023-01-01T00:00:00Z"
end_time= "2023-12-31T23:59:59Z"

# ---- API key configuration ---- #
api_key = "YOUR_API_KEY"

##### 3. Get the data #####
# ---- Function to run an API call ---- # 
# Get the data in a dataframe --------- # 

def get_kaiko_data(api_key: str, exchange: str, pair: str, instrument_class: str, start_time: str, end_time: str, interval: str, sort: str, page_size: int):
    headers = {'Accept': 'application/json', 'X-Api-Key': api_key}
    
    url = f'https://us.market-api.kaiko.io/v2/data/trades.v1/exchanges/{exchange}/{instrument_class}/{pair}/aggregations/ohlcv'
    params = {
        "start_time": start_time,
        "end_time": end_time,
        "sort": sort,
        "page_size": page_size,
        "interval": interval
    }

    try:
        res = requests.get(url, headers=headers, params=params)
        res.raise_for_status() 
        data = res.json()
        if 'data' not in data:
            print("No data returned.")
            return pd.DataFrame() 
        df = pd.DataFrame(data['data'])

        # Handle pagination with continuation token
        while 'next_url' in data:
            next_url = data['next_url']
            if next_url is None:
                break
            res = requests.get(next_url, headers=headers)
            res.raise_for_status()
            data = res.json()
            if 'data' in data:
                df = pd.concat([df, pd.DataFrame(data['data'])], ignore_index=True)
        return df

    except requests.exceptions.RequestException as e:
        print(f"API request error: {e}")
        return pd.DataFrame() 

# ---- Get the data ---- #
df = get_kaiko_data(api_key=api_key, exchange=exchange, pair=pair, instrument_class=instrument_class, start_time=start_time, end_time=end_time ,interval=interval, sort=sort, page_size=page_size)
```

{% endcode %}
{% endtab %}

{% tab title="BigQuery" %}
Information from this endpoint can be accessed through Google BigQuery. \
\
To get started, read our [guide](broken://spaces/zwO3AMVXsp37KK2FngVc/pages/LFIZ1UwRtOxTg308jneZ).
{% endtab %}
{% endtabs %}

### Response example

```json
{
    "query": {
        "page_size": 100,
        "exchange": "cbse",
        "instrument_class": "spot",
        "instrument": "btc-usd",
        "interval": "1d",
        "sort": "desc",
        "aggregation": "ohlcv",
        "data_version": "v1",
        "commodity": "trades",
        "request_time": "2020-05-26T17:25:56.221Z"
    },
    "time": "2020-05-26T17:26:00.160Z",
    "timestamp": 1590513960160,
    "data": [
        {
            "timestamp": 1590451200000,
            "open": "8900.0",
            "high": "9016.99",
            "low": "8694.23",
            "close": "8811.36",
            "volume": "9014.60281966"
        },
        {
            "timestamp": 1590364800000,
            "open": "8715.69",
            "high": "8977.0",
            "low": "8632.93",
            "close": "8899.31",
            "volume": "12091.06145914"
        },
  /* ... */
  ],
  "result": "success",
  "continuation_token": "rbd2bcDp35GmDscQbvZ9YzQHZJkT3jdeFx9fSBDdVmcCZaHvQRTCTfmfQ6QCrvDNp5ciRRuGPTedVL5LMZv1qmSXhRpZFbpvBW2uA62RSYpfJ1hVykJKZfhtmXXrxz",
  "next_url": "https://us.market-api.kaiko.io/v2/data/trades.v1/exchanges/krkn/spot/btc-usd/aggregations/ohlcv?continuation_token=rbd2bcDp35GmDqdfaz3fZJkT3jdeFx9fSBDdVmcCZaHvQRTCTfmfQ6QCrvDNp5ciRRuGPTedVL5LMZv1qmSXhRpZFbpvBW2uA62RSYpfJ1hVykJKZfhtmXXrxz",
  "access": {
    "access_range": {
      "start_timestamp": null,
      "end_timestamp": null
    },
    "data_range": {
      "start_timestamp": null,
      "end_timestamp": null
    }
  }
}

```


# VWAP only

{% hint style="info" %}

### This data is included in the following Kaiko packages

* Level 1 & Level 2 Data \[Level 1 Aggregations Tier]
* Level 1 & Level 2 Data \[Level 1 Tick-Level Tier]
* Level 1 & Level 2 Data \[Level 2 Aggregations Tier]
* Level 1 & Level 2 Data \[Level 2 Tick-Level Tier]

*CeFi spot ticker packs.*
{% endhint %}

## What is this endpoint for?&#x20;

This endpoint retrieves aggregated VWAP (volume-weighted average price) history for an instrument on an exchange.

{% hint style="warning" %}
You can use this same endpoint to get data for all market types. Kaiko subscriptions are sold per market type.
{% endhint %}

### Endpoint

{% code overflow="wrap" %}

```http
https://<eu|us>.market-api.kaiko.io/v2/data/trades.v2/exchanges/{exchange}/spot/{instrument}/aggregations/vwap
```

{% endcode %}

### Path Parameters

<table><thead><tr><th width="203">Parameter</th><th>Required?</th><th>Description</th></tr></thead><tbody><tr><td><code>region</code></td><td>Yes</td><td>Choose between <code>eu</code> and <code>us</code>.</td></tr><tr><td><code>exchange</code></td><td>Yes</td><td><p>Exchange <code>code.</code> </p><p><br>See <br><a data-mention href="/pages/QiW5iUvcyBF9RISFmZFV">/pages/QiW5iUvcyBF9RISFmZFV</a></p></td></tr><tr><td><code>instrument_class</code></td><td>Yes</td><td>Instrument <code>class</code>. <br><br>See <br><a data-mention href="/pages/8ywkQXfxfv1FjtyspEaU">/pages/8ywkQXfxfv1FjtyspEaU</a></td></tr><tr><td><code>instrument</code></td><td>Yes</td><td>Instrument <code>code</code>.<br><br>See <br><a data-mention href="/pages/8ywkQXfxfv1FjtyspEaU">/pages/8ywkQXfxfv1FjtyspEaU</a></td></tr></tbody></table>

### Query Parameters

<table><thead><tr><th width="187">Parameter</th><th width="114">Required</th><th>Description</th></tr></thead><tbody><tr><td><code>continuation_token</code></td><td>No</td><td>See <a data-mention href="/pages/mP3amLsYqKTsrRBoblxX">/pages/mP3amLsYqKTsrRBoblxX</a></td></tr><tr><td><code>end_time</code></td><td>No</td><td>Ending time in ISO 8601 (exclusive).<br><br><em>Automatically included in continuation tokens.</em></td></tr><tr><td><code>interval</code></td><td>No</td><td>The interval parameter is suffixed with <code>s</code>, <code>m</code>, <code>h</code> or <code>d</code> to specify seconds, minutes, hours or days, respectively.<br><br>Any arbitrary value between one second and one day can be used, as long as it sums up to a maximum of 1 day. The suffixes are <code>s</code> (second), <code>m</code> (minute), <code>h</code> (hour) and <code>d</code> (day).<br><br> Default <code>1d</code>.</td></tr><tr><td><code>page_size</code></td><td>No</td><td>(min: 1, default: 100, max: 100000).<br><br>See <a data-mention href="/pages/mP3amLsYqKTsrRBoblxX">/pages/mP3amLsYqKTsrRBoblxX</a><br><br><em>Automatically included in continuation tokens.</em></td></tr><tr><td><code>start_time</code></td><td>No</td><td>Starting time in ISO 8601 (inclusive).<br><br><em>Automatically included in continuation tokens.</em></td></tr><tr><td><code>sort</code></td><td>No</td><td>Return the data in ascending (<code>asc</code>) or descending (<code>desc</code>) order. <br><br>Default: <code>desc</code><br><br><em>Automatically included in continuation tokens.</em></td></tr></tbody></table>

### Fields

<table><thead><tr><th width="190">Field</th><th>Description</th></tr></thead><tbody><tr><td><code>timestamp</code></td><td>Timestamp at which the interval begins.</td></tr><tr><td><code>price</code></td><td>VWAP. <code>null</code> when no trades reported.</td></tr></tbody></table>

### Request examples

{% tabs %}
{% tab title="cURL" %}
{% code overflow="wrap" %}

```url
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'
```

{% endcode %}
{% endtab %}

{% tab title="Python" %}

```python
##### 1. Import dependencies #####
import requests
import pandas as pd

##### 2. Choose the value of the query's parameters #####
# ---- Required parameters ---- #
exchange = "cbse" 
instrument_class = "spot"
pair = "btc-usd" #called "instrument" in the documentation

# ---- Optional parameters ---- #
interval = "1d"  
sort = "desc"
page_size = 100
start_time= "2023-01-01T00:00:00Z"
end_time= "2023-12-31T23:59:59Z"

# ---- API key configuration ---- #
api_key = "YOUR_API_KEY"

##### 3. Get the data #####
# ---- Function to run an API call ---- # 
# Get the data in a dataframe --------- # 

def get_kaiko_data(api_key: str, exchange: str, pair: str, instrument_class: str, start_time: str, end_time: str, interval: str, sort: str, page_size: int):
    headers = {'Accept': 'application/json', 'X-Api-Key': api_key}
    
    url = f'https://us.market-api.kaiko.io/v2/data/trades.v1/exchanges/{exchange}/{instrument_class}/{pair}/aggregations/vwap'
    params = {
        "start_time": start_time,
        "end_time": end_time,
        "sort": sort,
        "page_size": page_size,
        "interval": interval
    }

    try:
        res = requests.get(url, headers=headers, params=params)
        res.raise_for_status() 
        data = res.json()
        if 'data' not in data:
            print("No data returned.")
            return pd.DataFrame() 
        df = pd.DataFrame(data['data'])

        # Handle pagination with continuation token
        while 'next_url' in data:
            next_url = data['next_url']
            if next_url is None:
                break
            res = requests.get(next_url, headers=headers)
            res.raise_for_status()
            data = res.json()
            if 'data' in data:
                df = pd.concat([df, pd.DataFrame(data['data'])], ignore_index=True)
        return df

    except requests.exceptions.RequestException as e:
        print(f"API request error: {e}")
        return pd.DataFrame() 

# ---- Get the data ---- #
df = get_kaiko_data(api_key=api_key, exchange=exchange, pair=pair, instrument_class=instrument_class, start_time=start_time, end_time=end_time ,interval=interval, sort=sort, page_size=page_size)
```

{% endtab %}
{% endtabs %}

### Response example

```json
{
    "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
    }
  }
}
```


# Tick-level trades

{% hint style="info" %}

### This data is included in the following Kaiko packages:

* **Level 1 & Level 2 Data** \[Level 1 Tick-Level Tier]
* **Level 1 & Level 2 Data** \[Level 2 Aggregations Tier]
* **Level 1 & Level 2 Data** \[Level 2 Tick-Level Tier]

*CeFi Spot ticker packs.*
{% endhint %}

### What is this endpoint for? <a href="#what-is-this-endpoint-for" id="what-is-this-endpoint-for"></a>

Tick-level data is the most granular level of trading data and contains every single trade that occurs on centralized and decentralized exchanges. The data is normalized and timestamped and contains information such as the price and volume of each trade. For DEXs specifically, we also provide additional information on the user address, the blockchain, the pool address, and the transaction hash related to the trade.\
\
Read our DEX trade data methodology [here](https://25446524.fs1.hubspotusercontent-eu1.net/hubfs/25446524/Case%20Studies%20%2B%20Data%20Gudies/DEX%20Methodology.pdf).&#x20;

{% hint style="warning" %}
You can use this same endpoint to get data for all market types. Kaiko subscriptions are sold per market type.
{% endhint %}

### Endpoint

{% code overflow="wrap" %}

```http
https://{region}.market-api.kaiko.io/v3/data/trades.v1/exchanges/{exchange}/spot/{instrument}/trades
```

{% endcode %}

### Path Parameters

<table><thead><tr><th width="203">Parameter</th><th>Required?</th><th>Description</th></tr></thead><tbody><tr><td><code>region</code></td><td>Yes</td><td>Choose between <code>eu</code> and <code>us</code>.</td></tr><tr><td><code>exchange</code></td><td>Yes</td><td><p>Exchange <code>code.</code> </p><p><br>See <a data-mention href="/pages/QiW5iUvcyBF9RISFmZFV">/pages/QiW5iUvcyBF9RISFmZFV</a></p></td></tr><tr><td><code>instrument_class</code></td><td>Yes</td><td>Instrument <code>class</code>. <br><br>See <a data-mention href="/pages/8ywkQXfxfv1FjtyspEaU">/pages/8ywkQXfxfv1FjtyspEaU</a></td></tr><tr><td><code>instrument</code></td><td>Yes</td><td>Instrument <code>code</code>.<br><br>See <a data-mention href="/pages/8ywkQXfxfv1FjtyspEaU">/pages/8ywkQXfxfv1FjtyspEaU</a></td></tr></tbody></table>

### Query Parameters

<table><thead><tr><th width="231">Parameter</th><th width="109">Required</th><th width="379">Description</th></tr></thead><tbody><tr><td><code>start_time</code></td><td>No</td><td>Starting time in ISO 8601 (inclusive). <br><br><em>Automatically included in continuation tokens.</em></td></tr><tr><td><code>end_time</code></td><td>No</td><td>Ending time in ISO 8601 (exclusive). <br><br><em>Automatically included in continuation tokens.</em></td></tr><tr><td><code>page_size</code></td><td>No</td><td>See <a data-mention href="/pages/mP3amLsYqKTsrRBoblxX">/pages/mP3amLsYqKTsrRBoblxX</a><br><br><em>Automatically included in continuation tokens.</em></td></tr><tr><td><code>continuation_token</code></td><td>No</td><td>See <a data-mention href="/pages/mP3amLsYqKTsrRBoblxX">/pages/mP3amLsYqKTsrRBoblxX</a></td></tr><tr><td><code>sort</code></td><td>No</td><td>Return the data in ascending (asc) or descending (desc) order. Default desc.</td></tr></tbody></table>

### Fields

| Field             | Description                                                                                                      |
| ----------------- | ---------------------------------------------------------------------------------------------------------------- |
| `timestamp`       | The timestamp provided by the exchange or the collection timestamp in Unix Timestamp (in nanoseconds)            |
| `trade_id`        | Unique trade ID (unique to the exchange). In case the exchange does not provide an ID, we generate it ourselves. |
| `price`           | Price displayed in quote currency.                                                                               |
| `amount`          | Quantity of asset bought or sold (can be in base\_asset, quote\_asset or the number of contracts).               |
| `taker_side_sell` | See ["taker\_side\_sell" Explained](/rest-api/general/getting-started/api-output/taker_side_sell-explained)      |

| Field              | Description                                          |
| ------------------ | ---------------------------------------------------- |
| `blockchain`       | The blockchain on which the trade happened.          |
| `transaction_hash` | Transaction hash.                                    |
| `log_index`        | The log index of the event (in base 10).             |
| `pool_address`     | The address of the pool in which the trade happened. |
| `user_address`     | Trader address (beneficiary).                        |

### Request examples

{% tabs %}
{% tab title="cURL" %}
{% code overflow="wrap" %}

```url
curl --compressed -H 'Accept: application/json' -H 'X-Api-Key: <client-api-key>' \
  'https://us.market-api.kaiko.io/v3/data/trades.v1/exchanges/bfnx/spot/btc-usd/trades'
```

{% endcode %}
{% endtab %}

{% tab title="Python" %}
{% code overflow="wrap" %}

```python
##### 1. Import dependencies #####
import requests
import pandas as pd

##### 2. Choose the value of the query's parameters #####
# ---- Required parameters ---- #
exchange = "cbse" 
instrument_class = "spot"
pair = "btc-usd" #called "instrument" in the documentation

# ---- Optional parameters ---- #
sort = "desc"
page_size = "100"
start_time= "2023-01-01T00:00:00Z"
end_time= "2023-01-01T00:03:00Z"

# ---- API key configuration ---- #
api_key = "YOUR_API_KEY"

##### 3. Get the data #####
# ---- Function to run an API call ---- # 
# Get the data in a dataframe --------- # 

def get_kaiko_data(api_key: str, exchange: str, pair: str, instrument_class: str, start_time: str, end_time: str, sort: str, page_size: int):
    headers = {'Accept': 'application/json', 'X-Api-Key': api_key}
    
    url = f'https://us.market-api.kaiko.io/v3/data/trades.v1/exchanges/{exchange}/{instrument_class}/{pair}/trades'
    params = {
        "start_time": start_time,
        "end_time": end_time,
        "sort": sort,
        "page_size": page_size
    }

    try:
        res = requests.get(url, headers=headers, params=params)
        res.raise_for_status() 
        data = res.json()
        if 'data' not in data:
            print("No data returned.")
            return pd.DataFrame() 
        df = pd.DataFrame(data['data'])

        # Handle pagination with continuation token
        while 'next_url' in data:
            next_url = data['next_url']
            if next_url is None:
                break
            res = requests.get(next_url, headers=headers)
            res.raise_for_status()
            data = res.json()
            if 'data' in data:
                df = pd.concat([df, pd.DataFrame(data['data'])], ignore_index=True)
        return df

    except requests.exceptions.RequestException as e:
        print(f"API request error: {e}")
        return pd.DataFrame() 

# ---- Get the data ---- #
df = get_kaiko_data(api_key=api_key, exchange=exchange, pair=pair, instrument_class=instrument_class, start_time=start_time, end_time=end_time ,sort=sort, page_size=int(page_size))
```

{% endcode %}
{% endtab %}
{% endtabs %}

### Response example

```json
{
    "query": {
        "page_size": 100,
        "exchange": "bfnx",
        "instrument_class": "spot",
        "instrument": "btc-usd",
        "sort": "desc",
        "data_version": "v1",
        "commodity": "trades",
        "request_time": "2020-11-12T16:33:20.575Z"
    },
    "time": "2020-11-12T16:33:20.869Z",
    "timestamp": 1605198800869,
    "access": {
        "access_range": {
            "start_timestamp": null,
            "end_timestamp": null
        },
        "data_range": {
            "start_timestamp": null,
            "end_timestamp": null
        }
    },
    "data": [
        {
            "timestamp": 1605198775855,
            "trade_id": "522419198",
            "price": "16026",
            "amount": "0.025",
            "taker_side_sell": true
        },
        {
            "timestamp": 1605198775031,
            "trade_id": "522419197",
            "price": "16026",
            "amount": "0.01",
            "taker_side_sell": true
        },
  /* ... */
  ],
  "result": "success",
  "continuation_token": "rbd28vrmb1cwaxfykuJBKAABhNi1Bfv1EY55P3QPSnYnm8VuX1LqLhA2d3yVfYgMKtfBYxJg7sHrkTfkQGysW23Lm9Lp9rsVpVk2Esmgz9VQZvNE4xWN8hh3LgLrCa7ty4B3YGCwtH",
  "next_url": "https://us.market-api.kaiko.io/v3/data/trades.v1/exchanges/bfnx/spot/btc-usd/trades?continuation_token=rbd28vrmb1cwaxfykuJBKAABhNi1Bfv1EY55P3QPSnYnm8VuX1LqLhA2d3yVfYgMKtfBYxJg7sHrkTfkQGysW23Lm9Lp9rsVpVk2Esmgz9VQZvNE4xWN8hh3LgLrCa7ty4B3YGCwtH"
}
```

{% tabs %}
{% tab title="JSON" %}

```json
{
    "query": {
        "page_size": 100,
        "exchange": "bfnx",
        "instrument_class": "spot",
        "instrument": "btc-usd",
        "sort": "desc",
        "data_version": "v1",
        "commodity": "trades",
        "request_time": "2020-11-12T16:33:20.575Z"
    },
    "time": "2020-11-12T16:33:20.869Z",
    "timestamp": 1605198800869,
    "access": {
        "access_range": {
            "start_timestamp": null,
            "end_timestamp": null
        },
        "data_range": {
            "start_timestamp": null,
            "end_timestamp": null
        }
    },
    "data": [
        {
            "timestamp": 1605198775855,
            "trade_id": "522419198",
            "price": "16026",
            "amount": "0.025",
            "taker_side_sell": true
        },
        {
            "timestamp": 1605198775031,
            "trade_id": "522419197",
            "price": "16026",
            "amount": "0.01",
            "taker_side_sell": true
        },
  /* ... */
  ],
  "result": "success",
  "continuation_token": "rbd28vrmb1cwaxfykuJBKAABhNi1Bfv1EY55P3QPSnYnm8VuX1LqLhA2d3yVfYgMKtfBYxJg7sHrkTfkQGysW23Lm9Lp9rsVpVk2Esmgz9VQZvNE4xWN8hh3LgLrCa7ty4B3YGCwtH",
  "next_url": "https://us.market-api.kaiko.io/v3/data/trades.v1/exchanges/bfnx/spot/btc-usd/trades?continuation_token=rbd28vrmb1cwaxfykuJBKAABhNi1Bfv1EY55P3QPSnYnm8VuX1LqLhA2d3yVfYgMKtfBYxJg7sHrkTfkQGysW23Lm9Lp9rsVpVk2Esmgz9VQZvNE4xWN8hh3LgLrCa7ty4B3YGCwtH"
}
```

{% endtab %}
{% endtabs %}


# Order book aggregations


# Market depth (snapshot)

{% hint style="info" %}
"Snapshots" show a point-in-time view generated every 30 seconds, whereas "aggregations" show an aggregation of all 30-second snapshots from the period requested.
{% endhint %}

{% hint style="info" %}

### This data is included in the following Kaiko packages:

* **Level 1 & Level 2 Data** \[Level 2 Aggregations Tier]
* **Level 1 & Level 2 Data** \[Level 2 Tick-Level Tier]

*CeFi Spot ticker packs.*
{% endhint %}

### What is this endpoint for? <a href="#what-is-this-endpoint-for" id="what-is-this-endpoint-for"></a>

This endpoint uses our [Raw order book snapshot](/rest-api/cefi-spot-market-data/order-book-aggregations/raw-order-book-snapshot) as source data and enhances its raw data with the Market Depth metric.&#x20;

Market Depth provides insight into the "depth" of an exchange's order book by aggregating the volume of bids and asks within 0-10% of the best bid or ask, respectively. A higher volume of bids and asks at each level implies more liquidity.

{% hint style="info" %}
We are unable to collect the full 10% snapshot from all exchanges we cover. Thus, for some exchanges, 'Market Depth' does not accurately portray the exchange's order book volume.
{% endhint %}

### Endpoint

{% code overflow="wrap" %}

```http
https://us.market-api.kaiko.io/v2/data/order_book_snapshots.v1/exchanges/{exchange}/spot/{instrument}/snapshots/depth
```

{% endcode %}

### Path Parameters

<table><thead><tr><th width="203">Parameter</th><th>Required?</th><th>Description</th></tr></thead><tbody><tr><td><code>region</code></td><td>Yes</td><td>Choose between <code>eu</code> and <code>us</code>.</td></tr><tr><td><code>exchange</code></td><td>Yes</td><td><p>Exchange <code>code.</code> </p><p><br>See <a data-mention href="/pages/QiW5iUvcyBF9RISFmZFV">/pages/QiW5iUvcyBF9RISFmZFV</a></p></td></tr><tr><td><code>instrument_class</code></td><td>Yes</td><td>Instrument <code>class</code>. <br><br>See <a data-mention href="/pages/8ywkQXfxfv1FjtyspEaU">/pages/8ywkQXfxfv1FjtyspEaU</a></td></tr><tr><td><code>instrument</code></td><td>Yes</td><td>Instrument <code>code</code>.<br><br>See <a data-mention href="/pages/8ywkQXfxfv1FjtyspEaU">/pages/8ywkQXfxfv1FjtyspEaU</a></td></tr></tbody></table>

### Query Parameters

<table><thead><tr><th>Parameter</th><th width="112">Required</th><th>Description</th></tr></thead><tbody><tr><td><code>continuation_token</code></td><td>No</td><td>See <a data-mention href="/pages/mP3amLsYqKTsrRBoblxX">/pages/mP3amLsYqKTsrRBoblxX</a></td></tr><tr><td><code>start_time</code></td><td>No</td><td>Starting time in ISO 8601 (inclusive).<br><br><em>Automatically included in continuation tokens.</em></td></tr><tr><td><code>end_time</code></td><td>No</td><td>Ending time in ISO 8601 (exclusive).<br><br><em>Automatically included in continuation tokens.</em></td></tr><tr><td><code>page_size</code></td><td>No</td><td>Number of snapshots to return data for. (default: 10, max: 100). <br><br>See <a data-mention href="/pages/mP3amLsYqKTsrRBoblxX">/pages/mP3amLsYqKTsrRBoblxX</a><br> <br><em>Automatically included in continuation tokens.</em></td></tr><tr><td><code>sort</code></td><td>No</td><td>Return the data in ascending <code>asc</code> or descending <code>desc</code> order. <br><br>Default: <code>desc.</code><br><br><em>Automatically included in continuation tokens.</em></td></tr></tbody></table>

### Fields

<table><thead><tr><th width="233">Field</th><th>Description</th></tr></thead><tbody><tr><td><code>poll_timestamp</code></td><td>The timestamp at which the raw data snapshot was taken.</td></tr><tr><td><code>poll_date</code></td><td>The date at which the raw data snapshot was taken.</td></tr><tr><td><code>timestamp</code></td><td>The timestamp provided by the exchange. <code>null</code> when not provided.</td></tr><tr><td><code>bid_volume_x</code></td><td>The volume of bids placed within 0 and x% of the best bid.<br><br>This is what we call "Market Depth".</td></tr><tr><td><code>ask_volume_x</code></td><td>The volume of asks placed within 0 and x% of the best ask.<br><br>This is what we call "Market Depth"</td></tr></tbody></table>

### Request examples

{% tabs %}
{% tab title="cURL" %}
{% code overflow="wrap" %}

```url
curl --compressed -H 'Accept: application/json' -H 'X-Api-Key: <client-api-key>' \
  'https://us.market-api.kaiko.io/v2/data/order_book_snapshots.v1/exchanges/krkn/spot/btc-usd/snapshots/depth?page_size=10'
```

{% endcode %}
{% endtab %}

{% tab title="Python" %}
{% code overflow="wrap" %}

```python
##### 1. Import dependencies #####
import requests
import pandas as pd

##### 2. Choose the value of the query's parameters #####
# ---- Required parameters ---- #
exchange = "krkn" 
instrument_class = "spot"
pair = "btc-usd" #called "instrument" in the documentation

# ---- Optional parameters ---- #
sort = "desc"
page_size = 100
start_time= "2025-03-03T00:00:00Z"
end_time= "2025-03-05T00:00:00Z"

# ---- API key configuration ---- #
api_key = "YOUR_API_KEY"

##### 3. Get the data #####
# ---- Function to run an API call ---- # 
# Get the data in a dataframe --------- # 

def get_kaiko_data(api_key: str, exchange: str, pair: str, instrument_class: str, start_time: str, end_time: str, sort: str, page_size: int):
    headers = {'Accept': 'application/json', 'X-Api-Key': api_key}
    
    url = f'https://us.market-api.kaiko.io/v2/data/order_book_snapshots.v1/exchanges/{exchange}/{instrument_class}/{pair}/snapshots/depth'
    params = {
        "start_time": start_time,
        "end_time": end_time,
        "sort": sort,
        "page_size": page_size
    }

    try:
        res = requests.get(url, headers=headers, params=params)
        res.raise_for_status() 
        data = res.json()
        if 'data' not in data:
            print("No data returned.")
            return pd.DataFrame() 
        df = pd.DataFrame(data['data'])

        # Handle pagination with continuation token
        while 'next_url' in data:
            next_url = data['next_url']
            if next_url is None:
                break
            res = requests.get(next_url, headers=headers)
            res.raise_for_status()
            data = res.json()
            if 'data' in data:
                df = pd.concat([df, pd.DataFrame(data['data'])], ignore_index=True)
        return df

    except requests.exceptions.RequestException as e:
        print(f"API request error: {e}")
        return pd.DataFrame() 

# ---- Get the data ---- #
df = get_kaiko_data(api_key=api_key, exchange=exchange, pair=pair, instrument_class=instrument_class, start_time=start_time, end_time=end_time ,sort=sort, page_size=int(page_size))
```

{% endcode %}
{% endtab %}
{% endtabs %}

### Response example

```json
{
    "query": {
        "page_size": 10,
        "exchange": "krkn",
        "instrument_class": "spot",
        "instrument": "btc-usd",
        "slippage": 0,
        "limit_orders": 0,
        "slippage_ref": "mid_price",
        "sort": "desc",
        "metric": "depth",
        "data_version": "v1",
        "commodity": "order_book_snapshots",
        "request_time": "2020-05-26T14:29:44.757Z"
    },
    "time": "2020-05-26T14:29:44.816Z",
    "timestamp": 1590503384816,
    "data": [
        {
            "poll_timestamp": 1590503344916,
            "poll_date": "2020-05-26T14:29:04.916Z",
            "timestamp": null,
            "bid_volume0_1": "37.606",
            "bid_volume0_2": "102.304",
            "bid_volume0_3": "141.907",
            "bid_volume0_4": "177.446",
            "bid_volume0_5": "203.634",
            "bid_volume0_6": "218.450",
            "bid_volume0_7": "283.128",
            "bid_volume0_8": "293.533",
            "bid_volume0_9": "321.986",
            "bid_volume1": "348.213",
            "bid_volume1_5": "405.080",
            "bid_volume2": "444.782",
            "bid_volume4": "837.949",
            "bid_volume6": "1110.065",
            "bid_volume8": "1110.065",
            "bid_volume10": "1110.065",
            "ask_volume0_1": "7.401",
            "ask_volume0_2": "13.744",
            "ask_volume0_3": "58.917",
            "ask_volume0_4": "131.104",
            "ask_volume0_5": "165.971",
            "ask_volume0_6": "193.786",
            "ask_volume0_7": "257.001",
            "ask_volume0_8": "286.384",
            "ask_volume0_9": "312.040",
            "ask_volume1": "319.040",
            "ask_volume1_5": "382.927",
            "ask_volume2": "475.467",
            "ask_volume4": "909.144",
            "ask_volume6": "1229.664",
            "ask_volume8": "1323.505",
            "ask_volume10": "1323.505"
        },
      /* ... */
],
    "result": "success",
    "continuation_token": "Z8FjYwcAjf7MZEG382e5MpmZx7wkuziQTyy2k5fVgSrcF8jAYqUpRgPH5cbQ9MhJiFaxGRbwiERMp3cWhXJshy",
    "next_url": "https://us.market-api.kaiko.io/v2/data/order_book_snapshots.v1/exchanges/cbse/spot/btc-usd/snapshots/depth?continuation_token=Z8FjYwcAjf7MZEG382e5MpmZx7wkuziQTyy2k5fVgSrcF8jAYqUpRgPH5cbQ9MhJiFaxGRbwiERMp3cWhXJshy",
    "access": {
        "access_range": {
            "start_timestamp": null,
            "end_timestamp": null
        },
        "data_range": {
            "start_timestamp": null,
            "end_timestamp": null
        }
    }
}        
```


# Market depth (aggregation)

{% hint style="info" %}
"Snapshots" show a point-in-time view generated every 30 seconds, whereas "aggregations" show an aggregation of all 30-second snapshots from the period requested.
{% endhint %}

{% hint style="info" %}

### This data is included in the following Kaiko packages:

* **Level 1 & Level 2 Data** \[Level 2 Aggregations Tier]
* **Level 1 & Level 2 Data** \[Level 2 Tick-Level Tier]

*CeFi Spot ticker packs.*
{% endhint %}

### What is this endpoint for? <a href="#what-is-this-endpoint-for" id="what-is-this-endpoint-for"></a>

This endpoint returns the **average** market depth for the requested period.&#x20;

{% hint style="warning" %}
We are unable to collect the full 10% snapshot from all exchanges we cover. Thus, for some exchanges, 'Market Depth' does not accurately portray the exchange's order book volume.
{% endhint %}

### Endpoint

{% code overflow="wrap" %}

```http
https://us.market-api.kaiko.io/v2/data/order_book_snapshots.v1/exchanges/{exchange}/spot/{instrument}/ob_aggregations/depth
```

{% endcode %}

### Path Parameters

<table><thead><tr><th width="203">Parameter</th><th>Required?</th><th>Description</th></tr></thead><tbody><tr><td><code>region</code></td><td>Yes</td><td>Choose between <code>eu</code> and <code>us</code>.</td></tr><tr><td><code>exchange</code></td><td>Yes</td><td><p>Exchange <code>code.</code> </p><p><br>See <a data-mention href="/pages/QiW5iUvcyBF9RISFmZFV">/pages/QiW5iUvcyBF9RISFmZFV</a></p></td></tr><tr><td><code>instrument_class</code></td><td>Yes</td><td>Instrument <code>class</code>. <br><br>See <a data-mention href="/pages/8ywkQXfxfv1FjtyspEaU">/pages/8ywkQXfxfv1FjtyspEaU</a></td></tr><tr><td><code>instrument</code></td><td>Yes</td><td>Instrument <code>code</code>.<br><br>See <a data-mention href="/pages/8ywkQXfxfv1FjtyspEaU">/pages/8ywkQXfxfv1FjtyspEaU</a></td></tr></tbody></table>

### Query Parameters

<table><thead><tr><th>Parameter</th><th width="99">Required</th><th>Description</th></tr></thead><tbody><tr><td><code>end_time</code></td><td>No</td><td>Ending time in ISO 8601 (exclusive).<br><br><em>Automatically included in continuation tokens.</em></td></tr><tr><td><code>continuation_token</code></td><td>No</td><td>See <a data-mention href="/pages/mP3amLsYqKTsrRBoblxX">/pages/mP3amLsYqKTsrRBoblxX</a></td></tr><tr><td><code>interval</code></td><td>No</td><td>The interval parameter is suffixed with <code>s</code>, <code>m</code>, <code>h</code> or <code>d</code> to specify seconds, minutes, hours or days, respectively.<br><br>Any arbitrary value between one second and one day can be used, as long as it sums up to a maximum of 1 day. The suffixes are <code>s</code> (second), <code>m</code> (minute), <code>h</code> (hour) and <code>d</code> (day).<br><br> Default <code>1h</code>.</td></tr><tr><td><code>page_size</code></td><td>No</td><td>Number of snapshots to return data for. (default: 10, max: 100). <br><br>See <a data-mention href="/pages/mP3amLsYqKTsrRBoblxX">/pages/mP3amLsYqKTsrRBoblxX</a><br> <br><em>Automatically included in continuation tokens.</em></td></tr><tr><td><code>sort</code></td><td>No</td><td>Return the data in ascending <code>asc</code> or descending <code>desc</code> order. Default desc<br><br><em>Automatically included in continuation tokens.</em></td></tr><tr><td><code>start_time</code></td><td>No</td><td>Starting time in ISO 8601 (inclusive).<br><br><em>Automatically included in continuation tokens.</em></td></tr></tbody></table>

### Fields

| `poll_timestamp` | The timestamp at which the interval begins                                                   |
| ---------------- | -------------------------------------------------------------------------------------------- |
| `bid_volume_x`   | The average volume of bids placed within 0 and x% of the best bid over a specified interval. |
| `ask_volume_x`   | The average volume of asks placed within 0 and x% of the best ask over a specified interval. |

### Request examples

{% tabs %}
{% tab title="JavaScript" %}
{% code overflow="wrap" %}

```javascript
curl --compressed -H 'Accept: application/json' -H 'X-Api-Key: <client-api-key>' \
  'https://us.market-api.kaiko.io/v2/data/order_book_snapshots.v1/exchanges/krkn/spot/btc-usd/ob_aggregations/depth?page_size=10&interval=1h'
```

{% endcode %}
{% endtab %}

{% tab title="Python" %}
{% code overflow="wrap" %}

```python
##### 1. Import dependencies #####
import requests
import pandas as pd

##### 2. Choose the value of the query's parameters #####
# ---- Required parameters ---- #
exchange = "krkn" 
instrument_class = "spot"
pair = "btc-usd" #called "instrument" in the documentation

# ---- Optional parameters ---- #
sort = "desc"
page_size = 100
start_time= "2025-03-03T00:00:00Z"
end_time= "2025-03-05T00:00:00Z"

# ---- API key configuration ---- #
api_key = "YOUR_API_KEY"

##### 3. Get the data #####
# ---- Function to run an API call ---- # 
# Get the data in a dataframe --------- # 

def get_kaiko_data(api_key: str, exchange: str, pair: str, instrument_class: str, start_time: str, end_time: str, sort: str, page_size: int):
    headers = {'Accept': 'application/json', 'X-Api-Key': api_key}
    
    url = f'https://us.market-api.kaiko.io/v2/data/order_book_snapshots.v1/exchanges/{exchange}/{instrument_class}/{pair}/ob_aggregations/depth'
    params = {
        "start_time": start_time,
        "end_time": end_time,
        "sort": sort,
        "page_size": page_size
    }

    try:
        res = requests.get(url, headers=headers, params=params)
        res.raise_for_status() 
        data = res.json()
        if 'data' not in data:
            print("No data returned.")
            return pd.DataFrame() 
        df = pd.DataFrame(data['data'])

        # Handle pagination with continuation token
        while 'next_url' in data:
            next_url = data['next_url']
            if next_url is None:
                break
            res = requests.get(next_url, headers=headers)
            res.raise_for_status()
            data = res.json()
            if 'data' in data:
                df = pd.concat([df, pd.DataFrame(data['data'])], ignore_index=True)
        return df

    except requests.exceptions.RequestException as e:
        print(f"API request error: {e}")
        return pd.DataFrame() 

# ---- Get the data ---- #
df = get_kaiko_data(api_key=api_key, exchange=exchange, pair=pair, instrument_class=instrument_class, start_time=start_time, end_time=end_time ,sort=sort, page_size=int(page_size))
```

{% endcode %}
{% endtab %}

{% tab title="Ruby" %}

```ruby
message = "hello world"
puts message
```

{% endtab %}
{% endtabs %}

### Response example

```json
{
    "query": {
        "page_size": 10,
        "exchange": "krkn",
        "instrument_class": "spot",
        "instrument": "btc-usd",
        "interval": "1h",
        "slippage": 0,
        "slippage_ref": "mid_price",
        "sort": "desc",
        "aggregation": "depth",
        "data_version": "v1",
        "commodity": "order_book_snapshots",
        "request_time": "2020-05-26T14:58:55.582Z"
    },
    "time": "2020-05-26T14:58:56.395Z",
    "timestamp": 1590505136395,
    "data": [
        {
            "poll_timestamp": 1590501600000,
            "bid_volume0_1": "31.31635593220339",
            "bid_volume0_2": "90.78996610169492",
            "bid_volume0_3": "144.16212711864407",
            "bid_volume0_4": "182.9676525423729",
            "bid_volume0_5": "219.1858220338983",
            "bid_volume0_6": "263.02182203389833",
            "bid_volume0_7": "296.666686440678",
            "bid_volume0_8": "322.5334237288136",
            "bid_volume0_9": "340.6282881355932",
            "bid_volume1": "356.4558474576271",
            "bid_volume1_5": "427.1106949152542",
            "bid_volume2": "475.76238135593223",
            "bid_volume4": "863.1048559322035",
            "bid_volume6": "1137.2281271186441",
            "bid_volume8": "1137.5447796610172",
            "bid_volume10": "1137.5447796610172",
            "ask_volume0_1": "22.772533898305085",
            "ask_volume0_2": "36.96916101694915",
            "ask_volume0_3": "78.57454237288135",
            "ask_volume0_4": "144.87783898305085",
            "ask_volume0_5": "195.61884745762714",
            "ask_volume0_6": "237.96824576271186",
            "ask_volume0_7": "282.3425338983051",
            "ask_volume0_8": "314.0606779661017",
            "ask_volume0_9": "330.76757627118644",
            "ask_volume1": "344.3153644067797",
            "ask_volume1_5": "413.4595423728814",
            "ask_volume2": "475.48172033898305",
            "ask_volume4": "886.8459152542373",
            "ask_volume6": "1272.5998644067795",
            "ask_volume8": "1371.7920847457626",
            "ask_volume10": "1371.7920847457626"
        },
      /* ... */
    ],
    "result": "success",
    "access": {
        "access_range": {
            "start_timestamp": null,
            "end_timestamp": null
        },
        "data_range": {
            "start_timestamp": null,
            "end_timestamp": null
        }
    }
}
```


# Price slippage (snapshot)

{% hint style="info" %}
"Snapshots" show a point-in-time view generated every 30 seconds, whereas "aggregations" show an aggregation of all 30-second snapshots from the period requested.
{% endhint %}

{% hint style="info" %}

### This data is included in the following Kaiko packages:

* **Level 1 & Level 2 Data** \[Level 2 Aggregations Tier]
* **Level 1 & Level 2 Data** \[Level 2 Tick-Level Tier]

*CeFi Spot ticker packs.*
{% endhint %}

### What is this endpoint for? <a href="#what-is-this-endpoint-for" id="what-is-this-endpoint-for"></a>

This endpoint uses our [Raw order book snapshot](/rest-api/cefi-spot-market-data/order-book-aggregations/raw-order-book-snapshot) as source data and enhances its raw data with the Price Slippage metric.

Price Slippage calculates the potential slippage for a market buy order if it were placed at the time the Order Book Snapshot was taken.

### Endpoint

{% code overflow="wrap" %}

```http
https://us.market-api.kaiko.io/v2/data/order_book_snapshots.v1/exchanges/{exchange}/spot/{instrument}/snapshots/slippage
```

{% endcode %}

### Path Parameters

<table><thead><tr><th width="203">Parameter</th><th>Required?</th><th>Description</th></tr></thead><tbody><tr><td><code>region</code></td><td>Yes</td><td>Choose between <code>eu</code> and <code>us</code>.</td></tr><tr><td><code>exchange</code></td><td>Yes</td><td><p>Exchange <code>code.</code> </p><p><br>See <a data-mention href="/pages/QiW5iUvcyBF9RISFmZFV">/pages/QiW5iUvcyBF9RISFmZFV</a></p></td></tr><tr><td><code>instrument_class</code></td><td>Yes</td><td>Instrument <code>class</code>. <br><br>See <a data-mention href="/pages/8ywkQXfxfv1FjtyspEaU">/pages/8ywkQXfxfv1FjtyspEaU</a></td></tr><tr><td><code>instrument</code></td><td>Yes</td><td>Instrument <code>code</code>.<br><br>See <a data-mention href="/pages/8ywkQXfxfv1FjtyspEaU">/pages/8ywkQXfxfv1FjtyspEaU</a></td></tr></tbody></table>

### Query Parameters

<table><thead><tr><th width="240">Parameter</th><th width="109">Required</th><th>Description</th></tr></thead><tbody><tr><td><code>continuation_token</code></td><td>No</td><td>See <a data-mention href="/pages/mP3amLsYqKTsrRBoblxX">/pages/mP3amLsYqKTsrRBoblxX</a></td></tr><tr><td><code>page_size</code></td><td>No</td><td>Number of snapshots to return data for. <br><br>Default: <code>10</code><br>Max: <code>100</code><br><br>See <a data-mention href="/pages/mP3amLsYqKTsrRBoblxX">/pages/mP3amLsYqKTsrRBoblxX</a><br> <br><em>Automatically included in continuation tokens.</em></td></tr><tr><td><code>sort</code></td><td>No</td><td>Return the data in ascending (asc) or descending (desc) order. <br><br>Default: <code>desc</code><br><br><em>Automatically included in continuation tokens.</em></td></tr><tr><td><code>start_time</code></td><td>No</td><td>Starting time in ISO 8601 (inclusive).<br><br><em>Automatically included in continuation tokens.</em></td></tr><tr><td><code>end_time</code></td><td>No</td><td>Ending time in ISO 8601 (exclusive).<br><br><em>Automatically included in continuation tokens.</em></td></tr><tr><td><code>slippage</code></td><td>No</td><td>Order size (in quote asset) for which to calculate the percentage of slippage. <br><br>Default: <code>0</code>. <br><br>When <code>null</code> is returned, not enough volume is present on the order book to execute the order.</td></tr><tr><td><code>slippage_ref</code></td><td>No</td><td>Price point for which to calculate slippage from. Either from the mid price (<code>mid_price</code>) or from the best bid/ask (<code>best</code>). <br><br>Default: <code>mid_price</code>.</td></tr></tbody></table>

### Fields

<table><thead><tr><th width="272">Field</th><th>Description</th></tr></thead><tbody><tr><td><code>poll_timestamp</code></td><td>The timestamp at which the raw data snapshot was taken.</td></tr><tr><td><code>poll_date</code></td><td>The date at which the raw data snapshot was taken.</td></tr><tr><td><code>timestamp</code></td><td>The timestamp provided by the exchange. <code>null</code> when not provided.</td></tr><tr><td><code>ask_slippage</code></td><td>The percentage price slippage for a market buy order placed at the time that the order book snapshot was taken.</td></tr><tr><td><code>bid_slippage</code></td><td>The percentage price slippage for a market sell order placed at the time that the order book snapshot was taken.</td></tr></tbody></table>

### Request examples

{% tabs %}
{% tab title="cURL" %}
{% code overflow="wrap" %}

```url
curl --compressed -H 'Accept: application/json' -H 'X-Api-Key: <client-api-key>' \
  https://us.market-api.kaiko.io/v2/data/order_book_snapshots.v1/exchanges/krkn/spot/btc-usd/snapshots/slippage?end_time=2019-12-09T00:00:00Z&slippage_ref=best&start_time=2019-12-01T00:00:00Z&slippage=1000000&page_size=10'
```

{% endcode %}
{% endtab %}

{% tab title="Python" %}
{% code overflow="wrap" %}

```python
##### 1. Import dependencies #####
import requests
import pandas as pd

##### 2. Choose the value of the query's parameters #####
# ---- Required parameters ---- #
exchange = "krkn" 
instrument_class = "spot"
pair = "btc-usd" #called "instrument" in the documentation

# ---- Optional parameters ---- #
sort = "desc"
page_size = 100
start_time= "2025-03-03T00:00:00Z"
end_time= "2025-03-05T00:00:00Z"

# ---- API key configuration ---- #
api_key = "YOUR_API_KEY"

##### 3. Get the data #####
# ---- Function to run an API call ---- # 
# Get the data in a dataframe --------- # 

def get_kaiko_data(api_key: str, exchange: str, pair: str, instrument_class: str, start_time: str, end_time: str, sort: str, page_size: int):
    headers = {'Accept': 'application/json', 'X-Api-Key': api_key}
    
    url = f'https://us.market-api.kaiko.io/v2/data/order_book_snapshots.v1/exchanges/{exchange}/{instrument_class}/{pair}/snapshots/slippage'
    params = {
        "start_time": start_time,
        "end_time": end_time,
        "sort": sort,
        "page_size": page_size
    }

    try:
        res = requests.get(url, headers=headers, params=params)
        res.raise_for_status() 
        data = res.json()
        if 'data' not in data:
            print("No data returned.")
            return pd.DataFrame() 
        df = pd.DataFrame(data['data'])

        # Handle pagination with continuation token
        while 'next_url' in data:
            next_url = data['next_url']
            if next_url is None:
                break
            res = requests.get(next_url, headers=headers)
            res.raise_for_status()
            data = res.json()
            if 'data' in data:
                df = pd.concat([df, pd.DataFrame(data['data'])], ignore_index=True)
        return df

    except requests.exceptions.RequestException as e:
        print(f"API request error: {e}")
        return pd.DataFrame() 

# ---- Get the data ---- #
df = get_kaiko_data(api_key=api_key, exchange=exchange, pair=pair, instrument_class=instrument_class, start_time=start_time, end_time=end_time ,sort=sort, page_size=int(page_size))
```

{% endcode %}
{% endtab %}
{% endtabs %}

### Response example

{% code overflow="wrap" %}

```json
{
    "query": {
        "page_size": 10,
        "exchange": "krkn",
        "instrument_class": "spot",
        "instrument": "btc-usd",
        "slippage": 100000,
        "limit_orders": 0,
        "slippage_ref": "best",
        "sort": "desc",
        "metric": "slippage",
        "data_version": "v1",
        "commodity": "order_book_snapshots",
        "request_time": "2020-05-26T14:42:17.053Z"
    },
    "time": "2020-05-26T14:42:17.123Z",
    "timestamp": 1590504137123,
    "data": [
        {
            "poll_timestamp": 1590504124917,
            "poll_date": "2020-05-26T14:42:04.917Z",
            "timestamp": null,
            "ask_slippage": "0.0001057219873253085790064266041007855",
            "bid_slippage": "0.0001581287020485902479395059349031256"
        },
        {
            "poll_timestamp": 1590504075786,
            "poll_date": "2020-05-26T14:41:15.786Z",
            "timestamp": null,
            "ask_slippage": "0.00001534073225141691226479256404443437",
            "bid_slippage": "0.0002555856086571344339622641509433962"
        },
      /* ... */
    ],
    "result": "success",
    "continuation_token": "Z8Fj1yUWjj3uvv1U2d8fASeGLm4jZ4iHCopdsZLKUyDJE8KrBaDXwQQWXHJQxm",
    "next_url": "https://us.market-api.kaiko.io/v2/data/order_book_snapshots.v1/exchanges/cbse/spot/btc-usd/snapshots/slippage?continuation_token=Z8Fj1yUWjj3uvv1U2d8fASeGLm4jZ4iHCopdsZLKUyDJE8KrBaDXwQQWXHJQxm",
    "access": {
        "access_range": {
            "start_timestamp": null,
            "end_timestamp": null
        },
        "data_range": {
            "start_timestamp": null,
            "end_timestamp": null
        }
    }
}
```

{% endcode %}


# Price slippage (aggregation)

{% hint style="info" %}

### This data is included in the following Kaiko packages:

* **Level 1 & Level 2 Data** \[Level 2 Aggregations Tier]
* **Level 1 & Level 2 Data** \[Level 2 Tick-Level Tier]

*CeFi Spot ticker packs.*
{% endhint %}

### What is this endpoint for? <a href="#what-is-this-endpoint-for" id="what-is-this-endpoint-for"></a>

This endpoint returns the **average** price slippage for the requested period. Read more about how the aggregation period works here: [Broken mention](broken://pages/olCeJDk3CCuULSNviPd9).&#x20;

### Endpoint

{% code overflow="wrap" %}

```http
https://us.market-api.kaiko.io/v2/data/order_book_snapshots.v1/exchanges/{exchange}/spot/{instrument}/ob_aggregations/slippage
```

{% endcode %}

### Path Parameters

<table><thead><tr><th width="203">Parameter</th><th>Required?</th><th>Description</th></tr></thead><tbody><tr><td><code>region</code></td><td>Yes</td><td>Choose between <code>eu</code> and <code>us</code>.</td></tr><tr><td><code>exchange</code></td><td>Yes</td><td><p>Exchange <code>code.</code> </p><p><br>See <a data-mention href="/pages/QiW5iUvcyBF9RISFmZFV">/pages/QiW5iUvcyBF9RISFmZFV</a></p></td></tr><tr><td><code>instrument_class</code></td><td>Yes</td><td>Instrument <code>class</code>. <br><br>See <a data-mention href="/pages/8ywkQXfxfv1FjtyspEaU">/pages/8ywkQXfxfv1FjtyspEaU</a></td></tr><tr><td><code>instrument</code></td><td>Yes</td><td>Instrument <code>code</code>.<br><br>See <a data-mention href="/pages/8ywkQXfxfv1FjtyspEaU">/pages/8ywkQXfxfv1FjtyspEaU</a></td></tr></tbody></table>

### Query Parameters

<table><thead><tr><th width="246">Parameter</th><th width="119">Required</th><th>Description</th></tr></thead><tbody><tr><td><code>continuation_token</code></td><td>No</td><td>See <a data-mention href="/pages/mP3amLsYqKTsrRBoblxX">/pages/mP3amLsYqKTsrRBoblxX</a></td></tr><tr><td><code>end_time</code></td><td>No</td><td>Ending time in ISO 8601 (exclusive).<br><br><em>Automatically included in continuation tokens.</em></td></tr><tr><td><code>interval</code></td><td>No</td><td>The interval parameter is suffixed with <code>s</code>, <code>m</code>, <code>h</code> or <code>d</code> to specify seconds, minutes, hours or days, respectively.<br><br>Any arbitrary value between one second and one day can be used, as long as it sums up to a maximum of 1 day. The suffixes are <code>s</code> (second), <code>m</code> (minute), <code>h</code> (hour) and <code>d</code> (day).<br><br> Default <code>1h</code>.</td></tr><tr><td><code>page_size</code></td><td>No</td><td>Number of snapshots to return data for. (default: 10, max: 100). <br><br>See <a data-mention href="/pages/mP3amLsYqKTsrRBoblxX">/pages/mP3amLsYqKTsrRBoblxX</a><br> <br><em>Automatically included in continuation tokens.</em></td></tr><tr><td><code>sort</code></td><td>No</td><td>Return the data in ascending <code>asc</code> or descending <code>desc</code> order. Default desc<br><br><em>Automatically included in continuation tokens.</em></td></tr><tr><td><code>start_time</code></td><td>No</td><td>Starting time in ISO 8601 (inclusive).<br><br><em>Automatically included in continuation tokens.</em></td></tr><tr><td><code>slippage</code></td><td>No</td><td>Order size (in quote asset) for which to calculate the percentage of slippage. <br><br>Default: <code>0</code>. <br><br>When <code>null</code> is returned, not enough volume is present on the order book to execute the order.</td></tr><tr><td><code>slippage_ref</code></td><td>No</td><td>Price point for which to calculate slippage from. Either from the mid price (<code>mid_price</code>) or from the best bid/ask (<code>best</code>). <br><br>Default: <code>mid_price</code>.</td></tr></tbody></table>

### Fields

<table><thead><tr><th width="274">Field</th><th>Description</th></tr></thead><tbody><tr><td><code>poll_timestamp</code></td><td>The timestamp at which the interval begins.</td></tr><tr><td><code>ask_slippage</code></td><td>The average percentage of price slippage for a market buy order over a specified interval.</td></tr><tr><td><code>bid_slippage</code></td><td>The average percentage of price slippage for a market sell order over a specified interval.</td></tr></tbody></table>

### Request examples

{% tabs %}
{% tab title="cURL" %}
{% code overflow="wrap" %}

```url
 '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'
```

{% endcode %}
{% endtab %}

{% tab title="Python" %}
{% code overflow="wrap" %}

```python
##### 1. Import dependencies #####
import requests
import pandas as pd

##### 2. Choose the value of the query's parameters #####
# ---- Required parameters ---- #
exchange = "krkn" 
instrument_class = "spot"
pair = "btc-usd" #called "instrument" in the documentation

# ---- Optional parameters ---- #
sort = "desc"
page_size = 100
start_time= "2025-01-03T00:00:00Z"
end_time= "2025-03-05T00:00:00Z"
slippage = 1000  
slippage_ref = "mid_price"  

# ---- API key configuration ---- #
api_key = "YOUR_API_KEY"

##### 3. Get the data #####
# ---- Function to run an API call ---- # 
# Get the data in a dataframe --------- # 

def get_kaiko_data(api_key: str, exchange: str, pair: str, instrument_class: str, start_time: str, end_time: str, sort: str, page_size: int, slippage: int, slippage_ref: str):
    headers = {'Accept': 'application/json', 'X-Api-Key': api_key}
    
    url = f'https://us.market-api.kaiko.io/v2/data/order_book_snapshots.v1/exchanges/{exchange}/{instrument_class}/{pair}/ob_aggregations/slippage'
    params = {
        "start_time": start_time,
        "end_time": end_time,
        "sort": sort,
        "page_size": page_size,
        "slippage": slippage,
        "slippage_ref": slippage_ref
    }

    try:
        res = requests.get(url, headers=headers, params=params)
        res.raise_for_status() 
        data = res.json()
        if 'data' not in data:
            print("No data returned.")
            return pd.DataFrame() 
        df = pd.DataFrame(data['data'])

        # Handle pagination with continuation token
        while 'next_url' in data:
            next_url = data['next_url']
            if next_url is None:
                break
            res = requests.get(next_url, headers=headers)
            res.raise_for_status()
            data = res.json()
            if 'data' in data:
                df = pd.concat([df, pd.DataFrame(data['data'])], ignore_index=True)
        return df

    except requests.exceptions.RequestException as e:
        print(f"API request error: {e}")
        return pd.DataFrame() 

# ---- Get the data ---- #
df = get_kaiko_data(api_key=api_key, exchange=exchange, pair=pair, instrument_class=instrument_class, start_time=start_time, end_time=end_time ,sort=sort, page_size=int(page_size), slippage=slippage, slippage_ref=slippage_ref)
```

{% endcode %}
{% endtab %}

{% tab title="Ruby" %}

```ruby
message = "hello world"
puts message
```

{% endtab %}
{% endtabs %}

### Response example

```json
{
    "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
        }
    }
}
```


# Bid-ask spread

{% hint style="info" %}
"Snapshots" show a point-in-time view generated every 30 seconds, whereas "aggregations" show an aggregation of all 30-second snapshots from the period requested.
{% endhint %}

{% hint style="info" %}

### This data is included in the following Kaiko packages:

* **Level 1 & Level 2 Data** \[Level 2 Aggregations Tier]
* **Level 1 & Level 2 Data** \[Level 2 Tick-Level Tier]

*CeFi Spot ticker packs.*
{% endhint %}

### What is this endpoint for? <a href="#what-is-this-endpoint-for" id="what-is-this-endpoint-for"></a>

This endpoint returns the following metrics, **averaged** for the requested period. &#x20;

* Bid volume
* Ask volume
* Bid-ask spread
* Price Slippage&#x20;

{% hint style="warning" %}
We are unable to collect the full 10% snapshot from all exchanges we cover. Thus, for some exchanges, 'Market Depth' does not accurately portray the exchange's order book volume.
{% endhint %}

### Endpoint

{% code overflow="wrap" %}

```http
https://us.market-api.kaiko.io/v2/data/order_book_snapshots.v1/exchanges/{exchange}/spot/{instrument}/ob_aggregations/full
```

{% endcode %}

### Path Parameters

<table><thead><tr><th width="203">Parameter</th><th>Required?</th><th>Description</th></tr></thead><tbody><tr><td><code>region</code></td><td>Yes</td><td>Choose between <code>eu</code> and <code>us</code>.</td></tr><tr><td><code>exchange</code></td><td>Yes</td><td><p>Exchange <code>code.</code> </p><p><br>See <a data-mention href="/pages/QiW5iUvcyBF9RISFmZFV">/pages/QiW5iUvcyBF9RISFmZFV</a></p></td></tr><tr><td><code>instrument_class</code></td><td>Yes</td><td>Instrument <code>class</code>. <br><br>See <a data-mention href="/pages/8ywkQXfxfv1FjtyspEaU">/pages/8ywkQXfxfv1FjtyspEaU</a></td></tr><tr><td><code>instrument</code></td><td>Yes</td><td>Instrument <code>code</code>.<br><br>See <a data-mention href="/pages/8ywkQXfxfv1FjtyspEaU">/pages/8ywkQXfxfv1FjtyspEaU</a></td></tr></tbody></table>

### Query Parameters

<table><thead><tr><th width="241">Parameter</th><th width="97">Required</th><th>Description</th></tr></thead><tbody><tr><td><code>end_time</code></td><td>No</td><td>Ending time in ISO 8601 (exclusive).<br><br><em>Automatically included in continuation tokens.</em></td></tr><tr><td><code>continuation_token</code></td><td>No</td><td>See <a data-mention href="/pages/mP3amLsYqKTsrRBoblxX">/pages/mP3amLsYqKTsrRBoblxX</a></td></tr><tr><td><code>interval</code></td><td>No</td><td>The interval parameter is suffixed with <code>s</code>, <code>m</code>, <code>h</code> or <code>d</code> to specify seconds, minutes, hours or days, respectively.<br><br>Any arbitrary value between one second and one day can be used, as long as it sums up to a maximum of 1 day. The suffixes are <code>s</code> (second), <code>m</code> (minute), <code>h</code> (hour) and <code>d</code> (day).<br><br> Default <code>1h</code>.</td></tr><tr><td><code>page_size</code></td><td>No</td><td>Number of snapshots to return data for. (default: 10, max: 100). <br><br>See <a data-mention href="/pages/mP3amLsYqKTsrRBoblxX">/pages/mP3amLsYqKTsrRBoblxX</a><br> <br><em>Automatically included in continuation tokens.</em></td></tr><tr><td><code>sort</code></td><td>No</td><td>Return the data in ascending <code>asc</code> or descending <code>desc</code> order. Default desc<br><br><em>Automatically included in continuation tokens.</em></td></tr><tr><td><code>start_time</code></td><td>No</td><td>Starting time in ISO 8601 (inclusive).<br><br><em>Automatically included in continuation tokens.</em></td></tr><tr><td><code>slippage</code></td><td>No</td><td>Order size (in quote asset) for which to calculate the percentage of slippage. Default: 0. When <code>null</code> is returned, not enough volume is present on the order book to execute the order.</td></tr><tr><td><code>slippage_ref</code></td><td>No</td><td>Price point for which to calculate slippage from. Either from the mid price (<code>mid_price</code>) or from the best bid/ask (<code>best</code>). Default: <code>mid_price</code>.</td></tr></tbody></table>

### Fields

<table><thead><tr><th width="233">Field</th><th>Description</th></tr></thead><tbody><tr><td><code>poll_timestamp</code></td><td>The timestamp at which the interval begins.</td></tr><tr><td><code>bid_volume_x</code></td><td>The average volume of bids placed within 0 and x% of the best bid over a specified interval.</td></tr><tr><td><code>ask_volume_x</code></td><td>The average volume of asks placed within 0 and x% of the best ask over a specified interval.</td></tr><tr><td><code>spread</code></td><td>The average difference between the best bid and the best ask over a specified interval.</td></tr><tr><td><code>mid_price</code></td><td>The average mid price between the best bid and the best ask over a specified interval</td></tr><tr><td><code>ask_slippage</code></td><td>The average percentage of price slippage for a market buy order over a specified interval.</td></tr><tr><td><code>bid_slippage</code></td><td>The average percentage of price slippage for a market sell order over a specified interval.</td></tr></tbody></table>

### Request examples

{% tabs %}
{% tab title="cURL" %}
{% code overflow="wrap" %}

```url
curl --compressed -H 'Accept: application/json' -H 'X-Api-Key: <client-api-key>' \
  'https://us.market-api.kaiko.io/v2/data/order_book_snapshots.v1/exchanges/krkn/spot/btc-usd/ob_aggregations/full?page_size=10&slippage=100000&interval=1h&start_time=2019-12-04T00:00:00Z&end_time=2019-12-06T00:00:00Z'
```

{% endcode %}
{% endtab %}

{% tab title="Python" %}

<pre class="language-python" data-overflow="wrap"><code class="lang-python">##### 1. Import dependencies #####
import requests
import pandas as pd

##### 2. Choose the value of the query's parameters #####
# ---- Required parameters ---- #
<strong>exchange = "krkn" 
</strong>instrument_class = "spot"
pair = "btc-usd" #called "instrument" in the documentation

# ---- Optional parameters ---- #
sort = "desc"
page_size = 100
start_time= "2025-03-03T00:00:00Z"
end_time= "2025-03-05T00:00:00Z"

# ---- API key configuration ---- #
api_key = "YOUR_API_KEY"

##### 3. Get the data #####
# ---- Function to run an API call ---- # 
# Get the data in a dataframe --------- # 

def get_kaiko_data(api_key: str, exchange: str, pair: str, instrument_class: str, start_time: str, end_time: str, sort: str, page_size: int):
    headers = {'Accept': 'application/json', 'X-Api-Key': api_key}
    
    url = f'https://us.market-api.kaiko.io/v2/data/order_book_snapshots.v1/exchanges/{exchange}/{instrument_class}/{pair}/snapshots/slippage'
    params = {
        "start_time": start_time,
        "end_time": end_time,
        "sort": sort,
        "page_size": page_size
    }

    try:
        res = requests.get(url, headers=headers, params=params)
        res.raise_for_status() 
        data = res.json()
        if 'data' not in data:
            print("No data returned.")
            return pd.DataFrame() 
        df = pd.DataFrame(data['data'])

        # Handle pagination with continuation token
        while 'next_url' in data:
            next_url = data['next_url']
            if next_url is None:
                break
            res = requests.get(next_url, headers=headers)
            res.raise_for_status()
            data = res.json()
            if 'data' in data:
                df = pd.concat([df, pd.DataFrame(data['data'])], ignore_index=True)
        return df

    except requests.exceptions.RequestException as e:
        print(f"API request error: {e}")
        return pd.DataFrame() 

# ---- Get the data ---- #
df = get_kaiko_data(api_key=api_key, exchange=exchange, pair=pair, instrument_class=instrument_class, start_time=start_time, end_time=end_time ,sort=sort, page_size=int(page_size))
</code></pre>

{% endtab %}
{% endtabs %}

### Response example

{% tabs %}
{% tab title="JSON" %}

```json
{
    "query": {
        "page_size": 10,
        "exchange": "krkn",
        "instrument_class": "spot",
        "instrument": "btc-usd",
        "interval": "1h",
        "slippage": 100000,
        "slippage_ref": "mid_price",
        "sort": "desc",
        "aggregation": "full",
        "data_version": "v1",
        "commodity": "order_book_snapshots",
        "request_time": "2020-05-26T14:46:00.561Z"
    },
    "time": "2020-05-26T14:46:03.776Z",
    "timestamp": 1590504363776,
    "data": [
        {
            "poll_timestamp": 1590501600000,
            "ask_slippage": "0.00032766083806437735",
            "bid_slippage": "0.0002206511273162024",
            "bid_volume0_1": "31.751239130434783",
            "bid_volume0_2": "87.33763043478261",
            "bid_volume0_3": "139.32403260869566",
            "bid_volume0_4": "177.62314130434783",
            "bid_volume0_5": "206.71984782608695",
            "bid_volume0_6": "251.4888043478261",
            "bid_volume0_7": "287.1503043478261",
            "bid_volume0_8": "317.3515869565217",
            "bid_volume0_9": "335.79671739130436",
            "bid_volume1": "352.03117391304346",
            "bid_volume1_5": "419.0988260869565",
            "bid_volume2": "470.6285",
            "bid_volume4": "859.7884347826086",
            "bid_volume6": "1134.0595760869564",
            "bid_volume8": "1134.4657173913045",
            "bid_volume10": "1134.4657173913045",
            "ask_volume0_1": "21.558043478260867",
            "ask_volume0_2": "37.20532608695652",
            "ask_volume0_3": "78.02648913043478",
            "ask_volume0_4": "143.83753260869565",
            "ask_volume0_5": "192.98572826086954",
            "ask_volume0_6": "235.31961956521738",
            "ask_volume0_7": "280.5659565217391",
            "ask_volume0_8": "309.4857717391304",
            "ask_volume0_9": "327.8923152173913",
            "ask_volume1": "341.79707608695657",
            "ask_volume1_5": "411.3568043478261",
            "ask_volume2": "475.6048586956521",
            "ask_volume4": "885.1007826086956",
            "ask_volume6": "1263.1216413043478",
            "ask_volume8": "1364.2838369565218",
            "ask_volume10": "1364.2838369565218",
            "mid_price": "8830.427717391303",
            "spread": "1.175"
        }
      /* ... */
    ],
    "result": "success",
    "access": {
        "access_range": {
            "start_timestamp": null,
            "end_timestamp": null
        },
        "data_range": {
            "start_timestamp": null,
            "end_timestamp": null
        }
    }
}
```

{% endtab %}
{% endtabs %}


# Raw order book snapshot

{% hint style="info" %}

### This data is included in the following Kaiko packages:

* Level 1 & Level 2 Data \[Level 2 Aggregations]
* Level 1 & Level 2 Data \[Level 2 Tick-Level]

*CeFi Spot ticker packs.*
{% endhint %}

### What is this endpoint for? <a href="#what-is-this-endpoint-for" id="what-is-this-endpoint-for"></a>

The raw data on which our Level 2 Aggregations such as market depth , bid/ask spread, and price slippage are built. Details a point-in-time view of the bids and asks on an exchange's order book to 10% depth. Used to build your own custom level 2 aggregations.&#x20;

### Endpoint

{% code overflow="wrap" %}

```url
https://us.market-api.kaiko.io/v2/data/order_book_snapshots.v1/exchanges/{exchange}/spot/{instrument}/snapshots/raw
```

{% endcode %}

### Path Parameters

<table><thead><tr><th width="203">Parameter</th><th>Required?</th><th>Description</th></tr></thead><tbody><tr><td><code>region</code></td><td>Yes</td><td>Choose between <code>eu</code> and <code>us</code>.</td></tr><tr><td><code>exchange</code></td><td>Yes</td><td><p>Exchange <code>code.</code> </p><p><br>See <a data-mention href="/pages/QiW5iUvcyBF9RISFmZFV">/pages/QiW5iUvcyBF9RISFmZFV</a></p></td></tr><tr><td><code>instrument_class</code></td><td>Yes</td><td>Instrument <code>class</code>. <br><br>See <a data-mention href="/pages/8ywkQXfxfv1FjtyspEaU">/pages/8ywkQXfxfv1FjtyspEaU</a></td></tr><tr><td><code>instrument</code></td><td>Yes</td><td>Instrument <code>code</code>.<br><br>See <a data-mention href="/pages/8ywkQXfxfv1FjtyspEaU">/pages/8ywkQXfxfv1FjtyspEaU</a></td></tr></tbody></table>

### Query Parameters

<table><thead><tr><th width="220">Parameter</th><th width="129">Required</th><th>Description</th></tr></thead><tbody><tr><td><code>continuation_token</code></td><td>No</td><td>See <a data-mention href="/pages/mP3amLsYqKTsrRBoblxX">/pages/mP3amLsYqKTsrRBoblxX</a></td></tr><tr><td><code>limit_orders</code></td><td>No</td><td>Number of orders to return on bid and ask side per snapshot.<br><br>To retreive the best bid/ask, set this parameter to <code>1</code> <br><br>Default: <code>10</code></td></tr><tr><td><code>page_size</code></td><td>No</td><td>Number of snapshots to return data for. <br><br>Default: <code>10</code><br>Max: <code>100</code><br><br>See <a data-mention href="/pages/mP3amLsYqKTsrRBoblxX">/pages/mP3amLsYqKTsrRBoblxX</a><br> <br><em>Automatically included in continuation tokens.</em></td></tr><tr><td><code>sort</code></td><td>No</td><td>Return the data in ascending (asc) or descending (desc) order. <br><br>Default: <code>desc</code><br><br><em>Automatically included in continuation tokens.</em></td></tr><tr><td><code>start_time</code></td><td>No</td><td>Starting time in ISO 8601 (inclusive).<br><br><em>Automatically included in continuation tokens.</em></td></tr><tr><td><code>end_time</code></td><td>No</td><td>Ending time in ISO 8601 (exclusive).<br><br><em>Automatically included in continuation tokens.</em></td></tr></tbody></table>

### Fields

<table><thead><tr><th width="294">Field</th><th>Description</th></tr></thead><tbody><tr><td><code>poll_timestamp</code></td><td>The timestamp at which the raw data snapshot was taken.</td></tr><tr><td><code>poll_date</code></td><td>The date at which the raw data snapshot was taken.</td></tr><tr><td><code>timestamp</code></td><td>The timestamp provided by the exchange. <code>null</code> when not provided.</td></tr><tr><td><code>asks</code></td><td>The sell orders in the snapshot. If the <code>limit_oders</code> parameter is used, this will be reflected here. <code>amount</code> is the quantity of asset to sell, displayed in the base currency. <code>price</code> is displayed in the quote currency.</td></tr><tr><td><code>bids</code></td><td>The buy orders in the snapshot. If the <code>limit_oders</code> parameter is used, this will be reflected here. <code>amount</code> is the quantity of asset to buy, displayed in the base currency. <code>price</code> is displayed in the quote currency.</td></tr></tbody></table>

### Request examples

{% tabs %}
{% tab title="cURL" %}
{% code overflow="wrap" %}

```url
curl --compressed -H 'Accept: application/json' -H 'X-Api-Key: <client-api-key>' \
  'https://us.market-api.kaiko.io/v2/data/order_book_snapshots.v1/exchanges/krkn/spot/btc-usd/snapshots/raw?page_size=10&limit_orders=2'
```

{% endcode %}
{% endtab %}

{% tab title="Python" %}
{% code overflow="wrap" %}

```python
##### 1. Import dependencies #####
import requests
import pandas as pd

##### 2. Choose the value of the query's parameters #####
# ---- Required parameters ---- #
exchange = "krkn" 
instrument_class = "spot"
pair = "btc-usd" #called "instrument" in the documentation

# ---- Optional parameters ---- #
sort = "desc"
page_size = 100
start_time= "2025-03-03T00:00:00Z"
end_time= "2025-03-05T00:00:00Z"
limit_orders = 10

# ---- API key configuration ---- #
api_key = "YOUR_API_KEY"

##### 3. Get the data #####
# ---- Function to run an API call ---- # 
# Get the data in a dataframe --------- # 

def get_kaiko_data(api_key: str, exchange: str, pair: str, instrument_class: str, start_time: str, end_time: str, sort: str, page_size: int, limit_orders: int):
    headers = {'Accept': 'application/json', 'X-Api-Key': api_key}
    
    url = f'https://us.market-api.kaiko.io/v2/data/order_book_snapshots.v1/exchanges/{exchange}/{instrument_class}/{pair}/snapshots/raw'
    params = {
        "start_time": start_time,
        "end_time": end_time,
        "sort": sort,
        "page_size": page_size,
        "limit_orders": limit_orders
    }

    try:
        res = requests.get(url, headers=headers, params=params)
        res.raise_for_status() 
        data = res.json()
        if 'data' not in data:
            print("No data returned.")
            return pd.DataFrame() 
        df = pd.DataFrame(data['data'])

        # Handle pagination with continuation token
        while 'next_url' in data:
            next_url = data['next_url']
            if next_url is None:
                break
            res = requests.get(next_url, headers=headers)
            res.raise_for_status()
            data = res.json()
            if 'data' in data:
                df = pd.concat([df, pd.DataFrame(data['data'])], ignore_index=True)
        return df

    except requests.exceptions.RequestException as e:
        print(f"API request error: {e}")
        return pd.DataFrame() 

# ---- Get the data ---- #
df = get_kaiko_data(api_key=api_key, exchange=exchange, pair=pair, instrument_class=instrument_class, start_time=start_time, end_time=end_time ,sort=sort, page_size=int(page_size), limit_orders=limit_orders)
```

{% endcode %}
{% endtab %}
{% endtabs %}

### Response example

```json
{
    "query": {
        "page_size": 10,
        "exchange": "krkn",
        "instrument_class": "spot",
        "instrument": "btc-usd",
        "slippage": 0,
        "limit_orders": 2,
        "slippage_ref": "mid_price",
        "sort": "desc",
        "metric": "raw",
        "data_version": "v1",
        "commodity": "order_book_snapshots",
        "request_time": "2020-05-26T14:13:08.823Z"
    },
    "time": "2020-05-26T14:13:08.899Z",
    "timestamp": 1590502388899,
    "data": [
        {
            "poll_timestamp": 1590502335760,
            "poll_date": "2020-05-26T14:12:15.760Z",
            "timestamp": null,
            "asks": [
                {
                    "amount": "12",
                    "price": "8830"
                },
                {
                    "amount": "3.67",
                    "price": "8832.9"
                }
            ],
            "bids": [
                {
                    "amount": "13.316",
                    "price": "8829.9"
                },
                {
                    "amount": "0.097",
                    "price": "8829.4"
                }
            ]
        }
      /* ... */         
    ],
    "result": "success",
    "continuation_token": "Z8FjTagUoHd3UCqMvqmRJXlwzbTxSnSXpxxZpHWNCmrsrcnhSpMG2gdcmFKRPd88",
    "next_url": "https://us.market-api.kaiko.io/v2/data/order_book_snapshots.v1/exchanges/cbse/spot/btc-usd/snapshots/raw?continuation_token=Z8FjTagUoHd3UCqMvqmRJXlwzbTxSnSXpxxZpHWNCmrsrcnhSpMG2gdcmFKRPd88",
    "access": {
        "access_range": {
            "start_timestamp": null,
            "end_timestamp": null
        },
        "data_range": {
            "start_timestamp": null,
            "end_timestamp": null
        }
    }
}
```


# Raw order book snapshot + market depth, bid/ask spread & price slippage

{% hint style="info" %}

### This data is included in the following Kaiko packages:

* Level 1 & Level 2 Data \[Level 2 Aggregations]
* Level 1 & Level 2 Data \[Level 2 Tick-Level]

*CeFi Spot ticker packs.*
{% endhint %}

### What is this endpoint for? <a href="#what-is-this-endpoint-for" id="what-is-this-endpoint-for"></a>

This endpoint returns raw order book used to calculate our aggregations, alongside the aggregations:

* **Market Depth** - provides insight into the "depth" of an exchange's order book by aggregating the volume of bids and asks within 0-10% of the best bid or ask, respectively. A higher volume of bids and asks at each level implies more liquidity.
* **Price Slippage** - calculates the potential slippage for a market buy order if it were placed at the time the Order Book Snapshot was taken.
* **Bid-ask Spread** - The bid-ask spread is the difference between the highest price that a buyer is willing to pay for an asset (the bid) and the lowest price that a seller is willing to accept (the ask). A smaller spread implies more liquidity.

### Endpoint

{% code overflow="wrap" %}

```http
https://us.market-api.kaiko.io/v2/data/order_book_snapshots.v1/exchanges/{exchange}/spot/{instrument}/snapshots/full
```

{% endcode %}

### Path Parameters

<table><thead><tr><th width="203">Parameter</th><th>Required?</th><th>Description</th></tr></thead><tbody><tr><td><code>region</code></td><td>Yes</td><td>Choose between <code>eu</code> and <code>us</code>.</td></tr><tr><td><code>exchange</code></td><td>Yes</td><td><p>Exchange <code>code.</code> </p><p><br>See <a data-mention href="/pages/QiW5iUvcyBF9RISFmZFV">/pages/QiW5iUvcyBF9RISFmZFV</a></p></td></tr><tr><td><code>instrument_class</code></td><td>Yes</td><td>Instrument <code>class</code>. <br><br>See <a data-mention href="/pages/8ywkQXfxfv1FjtyspEaU">/pages/8ywkQXfxfv1FjtyspEaU</a></td></tr><tr><td><code>instrument</code></td><td>Yes</td><td>Instrument <code>code</code>.<br><br>See <a data-mention href="/pages/8ywkQXfxfv1FjtyspEaU">/pages/8ywkQXfxfv1FjtyspEaU</a></td></tr></tbody></table>

### Query Parameters

<table><thead><tr><th width="239">Parameter</th><th width="95">Required</th><th>Description</th></tr></thead><tbody><tr><td><code>continuation_token</code></td><td>No</td><td>See <a data-mention href="/pages/mP3amLsYqKTsrRBoblxX">/pages/mP3amLsYqKTsrRBoblxX</a></td></tr><tr><td><code>end_time</code></td><td>No</td><td>Ending time in ISO 8601 (exclusive).<br><br><em>Automatically included in continuation tokens.</em></td></tr><tr><td><code>limit_orders</code></td><td>No</td><td>Number of orders to return on bid and ask side per snapshot.<br><br>To retrieve the best bid/ask, set this parameter to <code>1</code> <br><br>Default: <code>10</code></td></tr><tr><td><code>page_size</code></td><td>No</td><td>Number of snapshots to return (default: 10, max: 100).<br><br>See <a data-mention href="/pages/mP3amLsYqKTsrRBoblxX">/pages/mP3amLsYqKTsrRBoblxX</a><br><br><em>Automatically included in continuation tokens.</em></td></tr><tr><td><code>sort</code></td><td>No</td><td>Return the data in ascending <code>asc</code> or descending <code>desc</code> order. <br><br>Default: <code>desc.</code><br><br><em>Automatically included in continuation tokens.</em></td></tr><tr><td><code>start_time</code></td><td>No</td><td>Starting time in ISO 8601 (inclusive).<br><br><em>Automatically included in continuation tokens.</em></td></tr><tr><td><code>slippage</code></td><td>No</td><td>Order size (in quote asset) for which to calculate the percentage of slippage. <br><br>Default: <code>0</code>. <br><br>When <code>null</code> is returned, not enough volume is present on the order book to execute the order.</td></tr><tr><td><code>slippage_ref</code></td><td>No</td><td>Price point for which to calculate slippage from. Either from the mid-price (<code>mid_price</code>) or from the best bid/ask (<code>best</code>). <br><br>Default: <code>mid_price</code>.</td></tr></tbody></table>

### Fields

<table><thead><tr><th width="241">Field</th><th>Description</th></tr></thead><tbody><tr><td><code>poll_timestamp</code></td><td>The timestamp at which the raw data snapshot was taken.</td></tr><tr><td><code>poll_date</code></td><td>The date at which the raw data snapshot was taken.</td></tr><tr><td><code>timestamp</code></td><td>The timestamp provided by the exchange. <code>null</code> when not provided.</td></tr><tr><td><code>bid_volume_x</code></td><td>The volume of bids placed within 0 and x% of the best bid.<br><br>This is what we call "Market Depth"</td></tr><tr><td><code>ask_volume_x</code></td><td>The volume of asks placed within 0 and x% of the best ask.<br><br>This is what we call "Market Depth"</td></tr><tr><td><code>spread</code></td><td>The difference between the best bid and the best ask at the time the snapshot was taken.<br><br>This is what we call "Bid Ask Spread"</td></tr><tr><td><code>mid_price</code></td><td>The mid price between the best bid and the best ask.</td></tr><tr><td><code>ask_slippage</code></td><td>The percentage price slippage for a market buy order placed at the time that the order book snapshot was taken.</td></tr><tr><td><code>bid_slippage</code></td><td>The percentage price slippage for a market sell order placed at the time that the order book snapshot was taken.</td></tr><tr><td><code>asks</code></td><td>The sell orders in the snapshot. If the <code>limit_oders</code> parameter is used, this will be reflected here. <code>amount</code> is the quantity of asset to sell, displayed in the base currency. <code>price</code> is displayed in the quote currency.</td></tr><tr><td><code>bids</code></td><td>The buy orders in the snapshot. If the <code>limit_oders</code> parameter is used, this will be reflected here. <code>amount</code> is the quantity of asset to buy, displayed in the base currency. <code>price</code> is displayed in the quote currency.</td></tr></tbody></table>

### Request example

{% tabs %}
{% tab title="cURL" %}
{% code overflow="wrap" %}

```url
curl --compressed -H 'Accept: application/json' -H 'X-Api-Key: <client-api-key>' \
'https://us.market-api.kaiko.io/v2/data/order_book_snapshots.v1/exchanges/krkn/spot/btc-usd/snapshots/full?slippage=100000&page_size=10&limit_orders=2&slippage_ref=best'
```

{% endcode %}
{% endtab %}

{% tab title="Python" %}
{% code overflow="wrap" %}

```python
##### 1. Import dependencies #####
import requests
import pandas as pd

##### 2. Choose the value of the query's parameters #####
# ---- Required parameters ---- #
exchange = "krkn" 
instrument_class = "spot"
pair = "btc-usd" #called "instrument" in the documentation

# ---- Optional parameters ---- #
sort = "desc"
page_size = 100
start_time= "2025-03-03T00:00:00Z"
end_time= "2025-03-05T00:00:00Z"
limit_orders= 10
slippage= 0
slippage_ref= "mid_price"

# ---- API key configuration ---- #
api_key = "YOUR_API_KEY"

##### 3. Get the data #####
# ---- Function to run an API call ---- # 
# Get the data in a dataframe --------- # 

def get_kaiko_data(api_key: str, exchange: str, pair: str, instrument_class: str, start_time: str, end_time: str, sort: str, page_size: int, limit_orders: int, slippage: int, slippage_ref: str):
    headers = {'Accept': 'application/json', 'X-Api-Key': api_key}
    
    url = f'https://us.market-api.kaiko.io/v2/data/order_book_snapshots.v1/exchanges/{exchange}/{instrument_class}/{pair}/snapshots/full'
    params = {
        "start_time": start_time,
        "end_time": end_time,
        "sort": sort,
        "page_size": page_size,
        "limit_orders": limit_orders,
        "slippage": slippage,
        "slippage_ref": slippage_ref
    }

    try:
        res = requests.get(url, headers=headers, params=params)
        res.raise_for_status() 
        data = res.json()
        if 'data' not in data:
            print("No data returned.")
            return pd.DataFrame() 
        df = pd.DataFrame(data['data'])

        # Handle pagination with continuation token
        while 'next_url' in data:
            next_url = data['next_url']
            if next_url is None:
                break
            res = requests.get(next_url, headers=headers)
            res.raise_for_status()
            data = res.json()
            if 'data' in data:
                df = pd.concat([df, pd.DataFrame(data['data'])], ignore_index=True)
        return df

    except requests.exceptions.RequestException as e:
        print(f"API request error: {e}")
        return pd.DataFrame() 

# ---- Get the data ---- #
df = get_kaiko_data(api_key=api_key, exchange=exchange, pair=pair, instrument_class=instrument_class, start_time=start_time, end_time=end_time ,sort=sort, page_size=int(page_size), limit_orders=limit_orders, slippage=slippage, slippage_ref=slippage_ref)
```

{% endcode %}
{% endtab %}
{% endtabs %}

### Response example

{% tabs %}
{% tab title="JSON" %}

```json
{
    "query": {
        "page_size": 10,
        "exchange": "krkn",
        "instrument_class": "spot",
        "instrument": "btc-usd",
        "slippage": 100000,
        "limit_orders": 2,
        "slippage_ref": "best",
        "sort": "desc",
        "metric": "full",
        "data_version": "v1",
        "commodity": "order_book_snapshots",
        "request_time": "2020-05-26T14:10:06.320Z"
    },
    "time": "2020-05-26T14:10:06.418Z",
    "timestamp": 1590502206418,
    "data": [
        {
            "poll_timestamp": 1590502155757,
            "poll_date": "2020-05-26T14:09:15.757Z",
            "timestamp": null,
            "bid_volume0_1": "46.595",
            "bid_volume0_2": "110.570",
            "bid_volume0_3": "167.920",
            "bid_volume0_4": "198.416",
            "bid_volume0_5": "243.554",
            "bid_volume0_6": "346.467",
            "bid_volume0_7": "354.090",
            "bid_volume0_8": "359.058",
            "bid_volume0_9": "381.422",
            "bid_volume1": "384.066",
            "bid_volume1_5": "467.014",
            "bid_volume2": "522.441",
            "bid_volume4": "918.911",
            "bid_volume6": "1187.306",
            "bid_volume8": "1187.306",
            "bid_volume10": "1187.306",
            "ask_volume0_1": "13.158",
            "ask_volume0_2": "40.072",
            "ask_volume0_3": "71.129",
            "ask_volume0_4": "179.463",
            "ask_volume0_5": "259.140",
            "ask_volume0_6": "266.315",
            "ask_volume0_7": "324.288",
            "ask_volume0_8": "353.024",
            "ask_volume0_9": "376.738",
            "ask_volume1": "405.965",
            "ask_volume1_5": "467.665",
            "ask_volume2": "506.326",
            "ask_volume4": "862.843",
            "ask_volume6": "1322.553",
            "ask_volume8": "1428.856",
            "ask_volume10": "1428.856",
            "spread": "0.1",
            "mid_price": "8819.95",
            "ask_slippage": "0.0002782477139043083900226757369614512",
            "bid_slippage": "0.0",
            "asks": [
                {
                    "amount": "5.914",
                    "price": "8820"
                },
                {
                    "amount": "0.08",
                    "price": "8821"
                }
            ],
            "bids": [
                {
                    "amount": "11.814",
                    "price": "8819.9"
                },
                {
                    "amount": "4.197",
                    "price": "8819.8"
                }
            ]
        },
      /* ... */
],
    "result": "success",
    "continuation_token": "Ehad6pjoEpvpZSkvbtsyx8WxTj9vgc4s5VSow1USG8pXP1UGFSxSF7fTacxA54rYoqebnMTdCpE3ZxB3nSTM5CYNModkKRASDWMHymPFHNXnGL73RdkHSVUv6UYa4YwrRinH7JbwRqbB5HwmZdxWaonnaVkeZZc1wZiuK2oR4ePQdotGEnvKY8spPjYwnX8s3D6w1bCqZqL6ENaNH5Pa6b53MdbmyQBjE8F",
    "next_url": "https://us.market-api.kaiko.io/v2/data/order_book_snapshots.v1/exchanges/krkn/spot/btc-usd/snapshots/full?continuation_token=Ehad6pjoEpvpZSkvbtsyx8WxTjvgc4s5VSow1USG8pXP1UGFSxSF7fTacxA54rYoqebnMTdCpE3ZxB3nSTM5CYNModkKRASDWMHymPFHNXnGL73RdkHSVUv6UYa4YwrRinH7JbwRqbB5HwmZdxWaonnaVkeZZc1wZiuK2oR4ePQdotGEnvKY8spPjYwnX8s3D6w1bCqZqL6ENaNH5Pa6b53MdbmyQBjE8F",
    "access": {
        "access_range": {
            "start_timestamp": null,
            "end_timestamp": null
        },
        "data_range": {
            "start_timestamp": null,
            "end_timestamp": null
        }
    }
}
```

{% endtab %}
{% endtabs %}


# Raw trades

{% hint style="info" %}

### This data is included in the following Kaiko packages:

* **Level 1 & Level 2 Data** \[Level 1 Tick-Level Tier]
* **Level 1 & Level 2 Data** \[Level 2 Aggregations Tier]
* **Level 1 & Level 2 Data** \[Level 2 Tick-Level Tier]

*CeFi derivatives ticker packs.*
{% endhint %}

### What is this endpoint for? <a href="#what-is-this-endpoint-for" id="what-is-this-endpoint-for"></a>

Tick-level data is the most granular level of trading data and contains every single trade that occurs on centralized and decentralized exchanges. The data is normalized and timestamped and contains information such as the price and volume of each trade. For DEXs specifically, we also provide additional information on the user address, the blockchain, the pool address, and the transaction hash related to the trade.

### Endpoint

{% code overflow="wrap" %}

```http
https://{region}.market-api.kaiko.io/v3/data/trades.v1/exchanges/{exchange}/spot/{instrument}/trades
```

{% endcode %}

### Path Parameters

<table><thead><tr><th width="203">Parameter</th><th>Required?</th><th>Description</th></tr></thead><tbody><tr><td><code>region</code></td><td>Yes</td><td>Choose between <code>eu</code> and <code>us</code>.</td></tr><tr><td><code>exchange</code></td><td>Yes</td><td><p>Exchange <code>code.</code> </p><p><br>See <a data-mention href="/pages/QiW5iUvcyBF9RISFmZFV">/pages/QiW5iUvcyBF9RISFmZFV</a></p></td></tr><tr><td><code>instrument_class</code></td><td>Yes</td><td>Instrument <code>class</code>. <br><br>See <a data-mention href="/pages/8ywkQXfxfv1FjtyspEaU">/pages/8ywkQXfxfv1FjtyspEaU</a></td></tr><tr><td><code>instrument</code></td><td>Yes</td><td>Instrument <code>code</code>.<br><br>See <a data-mention href="/pages/8ywkQXfxfv1FjtyspEaU">/pages/8ywkQXfxfv1FjtyspEaU</a></td></tr></tbody></table>

### Query Parameters

<table><thead><tr><th width="231">Parameter</th><th width="109">Required</th><th width="379">Description</th></tr></thead><tbody><tr><td><code>start_time</code></td><td>No</td><td>Starting time in ISO 8601 (inclusive). <br><br><em>Automatically included in continuation tokens.</em></td></tr><tr><td><code>end_time</code></td><td>No</td><td>Ending time in ISO 8601 (exclusive). <br><br><em>Automatically included in continuation tokens.</em></td></tr><tr><td><code>page_size</code></td><td>No</td><td>See <a data-mention href="/pages/mP3amLsYqKTsrRBoblxX">/pages/mP3amLsYqKTsrRBoblxX</a><br><br><em>Automatically included in continuation tokens.</em></td></tr><tr><td><code>continuation_token</code></td><td>No</td><td>See <a data-mention href="/pages/mP3amLsYqKTsrRBoblxX">/pages/mP3amLsYqKTsrRBoblxX</a></td></tr><tr><td><code>sort</code></td><td>No</td><td>Return the data in ascending (asc) or descending (desc) order. Default desc.</td></tr></tbody></table>

### Fields

| Field             | Description                                                                                                      |
| ----------------- | ---------------------------------------------------------------------------------------------------------------- |
| `timestamp`       | The timestamp provided by the exchange or the collection timestamp in Unix Timestamp (in milliseconds)           |
| `trade_id`        | Unique trade ID (unique to the exchange). In case the exchange does not provide an ID, we generate it ourselves. |
| `price`           | Price displayed in quote currency.                                                                               |
| `amount`          | Quantity of asset bought or sold (can be in base\_asset, quote\_asset or the number of contracts).               |
| `taker_side_sell` | See ["taker\_side\_sell" Explained](/rest-api/general/getting-started/api-output/taker_side_sell-explained)      |

### Request examples

{% tabs %}
{% tab title="cURL" %}
{% code overflow="wrap" %}

```url
curl --compressed -H 'Accept: application/json' -H 'X-Api-Key: <client-api-key>' \
  'https://us.market-api.kaiko.io/v2/data/trades.v1/exchanges/bfnx/spot/btc-usd/trades'
```

{% endcode %}
{% endtab %}

{% tab title="Python" %}
{% code overflow="wrap" %}

```python
##### 1. Import dependencies #####
import requests
import pandas as pd

##### 2. Choose the value of the query's parameters #####
# ---- Required parameters ---- #
exchange = "cbse" 
instrument_class = "spot"
pair = "btc-usd" #called "instrument" in the documentation

# ---- Optional parameters ---- #
sort = "desc"
page_size = "100"
start_time= "2023-01-01T00:00:00Z"
end_time= "2023-01-01T00:03:00Z"

# ---- API key configuration ---- #
api_key = "YOUR_API_KEY"

##### 3. Get the data #####
# ---- Function to run an API call ---- # 
# Get the data in a dataframe --------- # 

def get_kaiko_data(api_key: str, exchange: str, pair: str, instrument_class: str, start_time: str, end_time: str, sort: str, page_size: int):
    headers = {'Accept': 'application/json', 'X-Api-Key': api_key}
    
    url = f'https://us.market-api.kaiko.io/v3/data/trades.v1/exchanges/{exchange}/{instrument_class}/{pair}/trades'
    params = {
        "start_time": start_time,
        "end_time": end_time,
        "sort": sort,
        "page_size": page_size
    }

    try:
        res = requests.get(url, headers=headers, params=params)
        res.raise_for_status() 
        data = res.json()
        if 'data' not in data:
            print("No data returned.")
            return pd.DataFrame() 
        df = pd.DataFrame(data['data'])

        # Handle pagination with continuation token
        while 'next_url' in data:
            next_url = data['next_url']
            if next_url is None:
                break
            res = requests.get(next_url, headers=headers)
            res.raise_for_status()
            data = res.json()
            if 'data' in data:
                df = pd.concat([df, pd.DataFrame(data['data'])], ignore_index=True)
        return df

    except requests.exceptions.RequestException as e:
        print(f"API request error: {e}")
        return pd.DataFrame() 

# ---- Get the data ---- #
df = get_kaiko_data(api_key=api_key, exchange=exchange, pair=pair, instrument_class=instrument_class, start_time=start_time, end_time=end_time ,sort=sort, page_size=int(page_size))
```

{% endcode %}
{% endtab %}
{% endtabs %}

### Response example

```json
{
    "query": {
        "page_size": 100,
        "exchange": "bfnx",
        "instrument_class": "spot",
        "instrument": "btc-usd",
        "sort": "desc",
        "data_version": "v1",
        "commodity": "trades",
        "request_time": "2020-11-12T16:33:20.575Z"
    },
    "time": "2020-11-12T16:33:20.869Z",
    "timestamp": 1605198800869,
    "data": [
        {
            "timestamp": 1605198775855,
            "trade_id": "522419198",
            "price": "16026",
            "amount": "0.025",
            "taker_side_sell": true
        },
        {
            "timestamp": 1605198775031,
            "trade_id": "522419197",
            "price": "16026",
            "amount": "0.01",
            "taker_side_sell": true
        },
  /* ... */
  ],
  "result": "success",
  "continuation_token": "rbd28vrmb1cwaxfykuJBKAABhNi1Bfv1EY55P3QPSnYnm8VuX1LqLhA2d3yVfYgMKtfBYxJg7sHrkTfkQGysW23Lm9Lp9rsVpVk2Esmgz9VQZvNE4xWN8hh3LgLrCa7ty4B3YGCwtH",
  "next_url": "https://us.market-api.kaiko.io/v2/data/trades.v1/exchanges/bfnx/spot/btc-usd/trades?continuation_token=rbd28vrmb1cwaxfykuJBKAABhNi1Bfv1EY55P3QPSnYnm8VuX1LqLhA2d3yVfYgMKtfBYxJg7sHrkTfkQGysW23Lm9Lp9rsVpVk2Esmgz9VQZvNE4xWN8hh3LgLrCa7ty4B3YGCwtH",
  "access": {
    "access_range": {
      "start_timestamp": null,
      "end_timestamp": null
    },
    "data_range": {
      "start_timestamp": null,
      "end_timestamp": null
    }
  }
}
```

{% tabs %}
{% tab title="JSON" %}

```json
{
    "query": {
        "page_size": 100,
        "exchange": "bfnx",
        "instrument_class": "spot",
        "instrument": "btc-usd",
        "sort": "desc",
        "data_version": "v1",
        "commodity": "trades",
        "request_time": "2020-11-12T16:33:20.575Z"
    },
    "time": "2020-11-12T16:33:20.869Z",
    "timestamp": 1605198800869,
    "data": [
        {
            "timestamp": 1605198775855,
            "trade_id": "522419198",
            "price": "16026",
            "amount": "0.025",
            "taker_side_sell": true
        },
        {
            "timestamp": 1605198775031,
            "trade_id": "522419197",
            "price": "16026",
            "amount": "0.01",
            "taker_side_sell": true
        },
  /* ... */
  ],
  "result": "success",
  "continuation_token": "rbd28vrmb1cwaxfykuJBKAABhNi1Bfv1EY55P3QPSnYnm8VuX1LqLhA2d3yVfYgMKtfBYxJg7sHrkTfkQGysW23Lm9Lp9rsVpVk2Esmgz9VQZvNE4xWN8hh3LgLrCa7ty4B3YGCwtH",
  "next_url": "https://us.market-api.kaiko.io/v2/data/trades.v1/exchanges/bfnx/spot/btc-usd/trades?continuation_token=rbd28vrmb1cwaxfykuJBKAABhNi1Bfv1EY55P3QPSnYnm8VuX1LqLhA2d3yVfYgMKtfBYxJg7sHrkTfkQGysW23Lm9Lp9rsVpVk2Esmgz9VQZvNE4xWN8hh3LgLrCa7ty4B3YGCwtH",
  "access": {
    "access_range": {
      "start_timestamp": null,
      "end_timestamp": null
    },
    "data_range": {
      "start_timestamp": null,
      "end_timestamp": null
    }
  }
}
```

{% endtab %}
{% endtabs %}


# Trade aggregations


# Trade Count, OHLCV, & VWAP

{% hint style="info" %}

### This data is included in the following Kaiko packages:

* Level 1 & Level 2 Data \[Level 1 Aggregations]
* Level 1 & Level 2 Data \[Level 1 Tick-Level]
* Level 1 & Level 2 Data \[Level 2 Aggregations]
* Level 1 & Level 2 Data \[Level 2 Tick-Level]

*CeFi derivative ticker packs.*
{% endhint %}

## What is this endpoint for?&#x20;

This endpoint retrieves the Trade Count, OHLCV and VWAP history for any instrument on an exchange. The `interval` parameter is suffixed with `s`, `m`, `h` or `d` to specify seconds, minutes, hours or days, respectively. By making use of the `sort` parameter, data can be returned in ascending `asc` (default) or descending `desc` order.

### Endpoint

{% code overflow="wrap" %}

```http
https://<eu|us>.market-api.kaiko.io/v2/data/trades.v1/exchanges/{exchange}/spot/{instrument}/aggregations/count_ohlcv_vwap
```

{% endcode %}

### Path Parameters

<table><thead><tr><th width="203">Parameter</th><th>Required?</th><th>Description</th></tr></thead><tbody><tr><td><code>region</code></td><td>Yes</td><td>Choose between <code>eu</code> and <code>us</code>.</td></tr><tr><td><code>exchange</code></td><td>Yes</td><td><p>Exchange <code>code.</code> </p><p><br>See <br><a data-mention href="/pages/QiW5iUvcyBF9RISFmZFV">/pages/QiW5iUvcyBF9RISFmZFV</a></p></td></tr><tr><td><code>instrument_class</code></td><td>Yes</td><td>Instrument <code>class</code>. <br><br>See <br><a data-mention href="/pages/8ywkQXfxfv1FjtyspEaU">/pages/8ywkQXfxfv1FjtyspEaU</a></td></tr><tr><td><code>instrument</code></td><td>Yes</td><td>Instrument <code>code</code>.<br><br><a data-mention href="/pages/8ywkQXfxfv1FjtyspEaU">/pages/8ywkQXfxfv1FjtyspEaU</a></td></tr></tbody></table>

### Query Parameters

<table><thead><tr><th width="253">Parameter</th><th width="117">Required</th><th>Description</th></tr></thead><tbody><tr><td><code>continuation_token</code></td><td>No</td><td>See <a data-mention href="/pages/mP3amLsYqKTsrRBoblxX">/pages/mP3amLsYqKTsrRBoblxX</a></td></tr><tr><td><code>end_time</code></td><td>No</td><td>Ending time in ISO 8601 (exclusive).<br><br><em>Automatically included in continuation tokens.</em></td></tr><tr><td><code>interval</code></td><td>No</td><td>The interval parameter is suffixed with <code>s</code>, <code>m</code>, <code>h</code> or <code>d</code> to specify seconds, minutes, hours or days, respectively.<br><br>Any arbitrary value between one second and one day can be used, as long as it sums up to a maximum of 1 day. The suffixes are <code>s</code> (second), <code>m</code> (minute), <code>h</code> (hour) and <code>d</code> (day).<br><br> Default <code>1d</code>.</td></tr><tr><td><code>page_size</code></td><td>No</td><td>See <a data-mention href="/pages/mP3amLsYqKTsrRBoblxX">/pages/mP3amLsYqKTsrRBoblxX</a><br><br><em>Automatically included in continuation tokens.</em></td></tr><tr><td><code>start_time</code></td><td>No</td><td>Starting time in ISO 8601 (inclusive).<br><br><em>Automatically included in continuation tokens.</em></td></tr><tr><td><code>sort</code></td><td>No</td><td>Return the data in ascending (<code>asc</code>) or descending (<code>desc</code>) order. Default <code>desc</code><br><br><em>Automatically included in continuation tokens.</em></td></tr></tbody></table>

### Fields

| Field       | Description                                                                         |
| ----------- | ----------------------------------------------------------------------------------- |
| `timestamp` | Timestamp at which the interval begins.                                             |
| `count`     | Then number of trades. `0` when no trades reported.                                 |
| `open`      | Opening price of interval. `null` when no trades reported.                          |
| `high`      | Highest price during interval. `null` when no trades reported.                      |
| `low`       | Lowest price during interval. `null` when no trades reported.                       |
| `close`     | Closing price of interval. `null` when no trades reported.                          |
| `volume`    | Volume traded in interval. `0` when no trades reported.                             |
| `price`     | The volume weighted price during the time interval. `null` when no trades reported. |

### Request examples

{% tabs %}
{% tab title="cURL" %}
{% code overflow="wrap" %}

```url
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/count_ohlcv_vwap'
```

{% endcode %}
{% endtab %}

{% tab title="Python" %}
{% code overflow="wrap" %}

````python
```python
##### 1. Import dependencies #####
import requests
import pandas as pd

##### 2. Choose the value of the query's parameters #####
# ---- Required parameters ---- #
exchange = "cbse" 
instrument_class = "spot"
pair = "btc-usd" #called "instrument" in the documentation

# ---- Optional parameters ---- #
interval = "1d"  
sort = "desc"
page_size = 100
start_time= "2023-01-01T00:00:00Z"
end_time= "2023-12-31T23:59:59Z"

# ---- API key configuration ---- #
api_key = "YOUR_API_KEY"

##### 3. Get the data #####
# ---- Function to run an API call ---- # 
# Get the data in a dataframe --------- # 

def get_kaiko_data(api_key: str, exchange: str, pair: str, instrument_class: str, start_time: str, end_time: str, interval: str, sort: str, page_size: int):
    headers = {'Accept': 'application/json', 'X-Api-Key': api_key}
    
    url = f'https://us.market-api.kaiko.io/v2/data/trades.v1/exchanges/{exchange}/{instrument_class}/{pair}/aggregations/count_ohlcv_vwap'
    params = {
        "start_time": start_time,
        "end_time": end_time,
        "sort": sort,
        "page_size": page_size,
        "interval": interval
    }

    try:
        res = requests.get(url, headers=headers, params=params)
        res.raise_for_status() 
        data = res.json()
        if 'data' not in data:
            print("No data returned.")
            return pd.DataFrame() 
        df = pd.DataFrame(data['data'])

        # Handle pagination with continuation token
        while 'next_url' in data:
            res = requests.get(data['next_url'], headers=headers)
            res.raise_for_status()
            data = res.json()
            if 'data' in data:
                df = pd.concat([df, pd.DataFrame(data['data'])], ignore_index=True)
        return df

    except requests.exceptions.RequestException as e:
        print(f"API request error: {e}")
        return pd.DataFrame() 

# ---- Get the data ---- #
df = get_kaiko_data(api_key=api_key, exchange=exchange, pair=pair, instrument_class=instrument_class, start_time=start_time, end_time=end_time ,interval=interval, sort=sort, page_size=page_size)
```
````

{% endcode %}
{% endtab %}

{% tab title="BigQuery" %}
Trade Count and OHLCV can be accessed through Google BigQuery. \
\
To get started, read our [guide](broken://spaces/zwO3AMVXsp37KK2FngVc/pages/LFIZ1UwRtOxTg308jneZ).
{% endtab %}
{% endtabs %}

### Response example

```json
{
    "query": {
        "page_size": 100,
        "exchange": "cbse",
        "instrument_class": "spot",
        "instrument": "btc-usd",
        "interval": "1d",
        "sort": "desc",
        "aggregation": "count_ohlcv_vwap",
        "data_version": "v1",
        "commodity": "trades",
        "request_time": "2020-11-12T16:55:42.588Z"
    },
    "time": "2020-11-12T16:55:42.710Z",
    "timestamp": 1605200142710,
    "data": [
        {
            "timestamp": 1605139200000,
            "open": "15705.79",
            "high": "16185.87",
            "low": "15446.82",
            "close": "16139.93",
            "volume": "14829.124546730012",
            "price": "15880.01873841608",
            "count": 95111
        },
        {
            "timestamp": 1605052800000,
            "open": "15315.46",
            "high": "16000",
            "low": "15293.04",
            "close": "15705.79",
            "volume": "15123.844197729988",
            "price": "15664.643871798791",
            "count": 114205
        },
    /* ... */
  ],
  "result": "success",
  "continuation_token": "rbd1XbkjMwv2SyUfvJwsqFGmCKzg3WToTvqigui1bejckYnxd9DM1V3v58iqMCdXa4dJSXap6p6fBuvzz32tiHVrv5LC76MyRyYNbZyvSEoVzd1krSWWeXYEtEtR",
  "next_url": "https://<eu|us>.market-api.kaiko.io/v2/data/trades.v1/exchanges/cbse/spot/btc-usd/aggregations/count_ohlcv_vwap?continuation_token=rbd1XbkjMwv2SyUfvJwsui1bejckYnxd9DM1V3v58iqMCdXa4dJSXap6p6fBuvzz32tiHVrv5LC76MyRyYNbZyvSEoVzd1krSWWeXYEtEtR",
  "access": {
    "access_range": {
      "start_timestamp": 1546300800000,
      "end_timestamp": 1577836800000
    },
    "data_range": {
      "start_timestamp": 1417391000000,
      "end_timestamp": 1577836800000
    }
  }
}

```


# OHLCV only

{% hint style="info" %}

### This data is included in the following Kaiko packages:

* Level 1 & Level 2 Data \[Level 1 Aggregations]
* Level 1 & Level 2 Data \[Level 1 Tick-Level]
* Level 1 & Level 2 Data \[Level 2 Aggregations]
* Level 1 & Level 2 Data \[Level 2 Tick-Level]

*CeFi derivative ticker packs.*
{% endhint %}

## What is this endpoint for?&#x20;

This endpoint retrieves the OHLCV history for an instrument on an exchange.

### Endpoint

{% code overflow="wrap" %}

```http
https://<eu|us>.market-api.kaiko.io/v2/data/trades.v1/exchanges/{exchange}/spot/{instrument}/aggregations/ohlcv
```

{% endcode %}

### Path Parameters

<table><thead><tr><th width="203">Parameter</th><th>Required?</th><th>Description</th></tr></thead><tbody><tr><td><code>region</code></td><td>Yes</td><td>Choose between <code>eu</code> and <code>us</code>.</td></tr><tr><td><code>exchange</code></td><td>Yes</td><td><p>Exchange <code>code.</code> </p><p><br>See <br><a data-mention href="/pages/QiW5iUvcyBF9RISFmZFV">/pages/QiW5iUvcyBF9RISFmZFV</a></p></td></tr><tr><td><code>instrument_class</code></td><td>Yes</td><td>Instrument <code>class</code>. <br><br>See <br><a data-mention href="/pages/8ywkQXfxfv1FjtyspEaU">/pages/8ywkQXfxfv1FjtyspEaU</a></td></tr><tr><td><code>instrument</code></td><td>Yes</td><td>Instrument <code>code</code>.<br><br>See <br><a data-mention href="/pages/8ywkQXfxfv1FjtyspEaU">/pages/8ywkQXfxfv1FjtyspEaU</a></td></tr></tbody></table>

### Query Parameters

<table><thead><tr><th width="233">Parameter</th><th width="144">Required</th><th>Description</th></tr></thead><tbody><tr><td><code>end_time</code></td><td>No</td><td>Ending time in ISO 8601 (exclusive).<br><br><em>Automatically included in continuation tokens.</em></td></tr><tr><td><code>continuation_token</code></td><td>No</td><td>See <a data-mention href="/pages/mP3amLsYqKTsrRBoblxX">/pages/mP3amLsYqKTsrRBoblxX</a></td></tr><tr><td><code>interval</code></td><td>No</td><td>The interval parameter is suffixed with <code>s</code>, <code>m</code>, <code>h</code> or <code>d</code> to specify seconds, minutes, hours or days, respectively.<br><br>Any arbitrary value between one second and one day can be used, as long as it sums up to a maximum of 1 day. The suffixes are <code>s</code> (second), <code>m</code> (minute), <code>h</code> (hour) and <code>d</code> (day).<br><br> Default <code>1d</code>.</td></tr><tr><td><code>page_size</code></td><td>No</td><td>(min: 1, default: 100, max: 100000).<br><br>See <a data-mention href="/pages/mP3amLsYqKTsrRBoblxX">/pages/mP3amLsYqKTsrRBoblxX</a> <br><br><em>Automatically included in continuation tokens.</em></td></tr><tr><td><code>start_time</code></td><td>No</td><td>Starting time in ISO 8601 (inclusive).</td></tr><tr><td><code>sort</code></td><td>No</td><td>Return the data in ascending (<code>asc</code>) or descending (<code>desc</code>) order. Default <code>desc</code><br><br><em>Automatically included in continuation tokens.</em></td></tr></tbody></table>

### Fields

<table><thead><tr><th width="385">Field</th><th>Description</th></tr></thead><tbody><tr><td><code>timestamp</code></td><td>Timestamp at which the interval begins.</td></tr><tr><td><code>open</code></td><td>Opening price of interval. <code>null</code> when no trades reported.</td></tr><tr><td><code>high</code></td><td>Highest price during interval. <code>null</code> when no trades reported.</td></tr><tr><td><code>low</code></td><td>Lowest price during interval. <code>null</code> when no trades reported.</td></tr><tr><td><code>close</code></td><td>Closing price of interval. <code>null</code> when no trades reported.</td></tr><tr><td><code>volume</code></td><td>Volume traded in interval. <code>0</code> when no trades reported.</td></tr></tbody></table>

### Request examples

{% tabs %}
{% tab title="cURL" %}
{% code overflow="wrap" %}

```url
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/ohlcv'
```

{% endcode %}
{% endtab %}

{% tab title="Python" %}
{% code overflow="wrap" %}

```python
##### 1. Import dependencies #####
import requests
import pandas as pd

##### 2. Choose the value of the query's parameters #####
# ---- Required parameters ---- #
exchange = "cbse" 
instrument_class = "spot"
pair = "btc-usd" #called "instrument" in the documentation

# ---- Optional parameters ---- #
interval = "1d"  
sort = "desc"
page_size = 100
start_time= "2023-01-01T00:00:00Z"
end_time= "2023-12-31T23:59:59Z"

# ---- API key configuration ---- #
api_key = "YOUR_API_KEY"

##### 3. Get the data #####
# ---- Function to run an API call ---- # 
# Get the data in a dataframe --------- # 

def get_kaiko_data(api_key: str, exchange: str, pair: str, instrument_class: str, start_time: str, end_time: str, interval: str, sort: str, page_size: int):
    headers = {'Accept': 'application/json', 'X-Api-Key': api_key}
    
    url = f'https://us.market-api.kaiko.io/v2/data/trades.v1/exchanges/{exchange}/{instrument_class}/{pair}/aggregations/ohlcv'
    params = {
        "start_time": start_time,
        "end_time": end_time,
        "sort": sort,
        "page_size": page_size,
        "interval": interval
    }

    try:
        res = requests.get(url, headers=headers, params=params)
        res.raise_for_status() 
        data = res.json()
        if 'data' not in data:
            print("No data returned.")
            return pd.DataFrame() 
        df = pd.DataFrame(data['data'])

        # Handle pagination with continuation token
        while 'next_url' in data:
            next_url = data['next_url']
            if next_url is None:
                break
            res = requests.get(next_url, headers=headers)
            res.raise_for_status()
            data = res.json()
            if 'data' in data:
                df = pd.concat([df, pd.DataFrame(data['data'])], ignore_index=True)
        return df

    except requests.exceptions.RequestException as e:
        print(f"API request error: {e}")
        return pd.DataFrame() 

# ---- Get the data ---- #
df = get_kaiko_data(api_key=api_key, exchange=exchange, pair=pair, instrument_class=instrument_class, start_time=start_time, end_time=end_time ,interval=interval, sort=sort, page_size=page_size)
```

{% endcode %}
{% endtab %}

{% tab title="BigQuery" %}
Information from this endpoint can be accessed through Google BigQuery. \
\
To get started, read our [guide](broken://spaces/zwO3AMVXsp37KK2FngVc/pages/LFIZ1UwRtOxTg308jneZ).
{% endtab %}
{% endtabs %}

### Response example

```json
{
    "query": {
        "page_size": 100,
        "exchange": "cbse",
        "instrument_class": "spot",
        "instrument": "btc-usd",
        "interval": "1d",
        "sort": "desc",
        "aggregation": "ohlcv",
        "data_version": "v1",
        "commodity": "trades",
        "request_time": "2020-05-26T17:25:56.221Z"
    },
    "time": "2020-05-26T17:26:00.160Z",
    "timestamp": 1590513960160,
    "data": [
        {
            "timestamp": 1590451200000,
            "open": "8900.0",
            "high": "9016.99",
            "low": "8694.23",
            "close": "8811.36",
            "volume": "9014.60281966"
        },
        {
            "timestamp": 1590364800000,
            "open": "8715.69",
            "high": "8977.0",
            "low": "8632.93",
            "close": "8899.31",
            "volume": "12091.06145914"
        },
  /* ... */
  ],
  "result": "success",
  "continuation_token": "rbd2bcDp35GmDscQbvZ9YzQHZJkT3jdeFx9fSBDdVmcCZaHvQRTCTfmfQ6QCrvDNp5ciRRuGPTedVL5LMZv1qmSXhRpZFbpvBW2uA62RSYpfJ1hVykJKZfhtmXXrxz",
  "next_url": "https://us.market-api.kaiko.io/v2/data/trades.v1/exchanges/krkn/spot/btc-usd/aggregations/ohlcv?continuation_token=rbd2bcDp35GmDqdfaz3fZJkT3jdeFx9fSBDdVmcCZaHvQRTCTfmfQ6QCrvDNp5ciRRuGPTedVL5LMZv1qmSXhRpZFbpvBW2uA62RSYpfJ1hVykJKZfhtmXXrxz",
  "access": {
    "access_range": {
      "start_timestamp": null,
      "end_timestamp": null
    },
    "data_range": {
      "start_timestamp": null,
      "end_timestamp": null
    }
  }
}

```


# VWAP only

{% hint style="info" %}

### This data is included in the following Kaiko packages:

* Level 1 & Level 2 Data \[Level 1 Aggregations]
* Level 1 & Level 2 Data \[Level 1 Tick-Level]
* Level 1 & Level 2 Data \[Level 2 Aggregations]
* Level 1 & Level 2 Data \[Level 2 Tick-Level]

*CeFi derivative ticker packs.*
{% endhint %}

## What is this endpoint for?&#x20;

This endpoint retrieves aggregated VWAP (volume-weighted average price) history for an instrument on an exchange.

### Endpoint

{% code overflow="wrap" %}

```http
https://<eu|us>.market-api.kaiko.io/v2/data/trades.v2/exchanges/{exchange}/spot/{instrument}/aggregations/vwap
```

{% endcode %}

### Path Parameters

<table><thead><tr><th width="203">Parameter</th><th>Required?</th><th>Description</th></tr></thead><tbody><tr><td><code>region</code></td><td>Yes</td><td>Choose between <code>eu</code> and <code>us</code>.</td></tr><tr><td><code>exchange</code></td><td>Yes</td><td><p>Exchange <code>code.</code> </p><p><br>See <br><a data-mention href="/pages/QiW5iUvcyBF9RISFmZFV">/pages/QiW5iUvcyBF9RISFmZFV</a></p></td></tr><tr><td><code>instrument_class</code></td><td>Yes</td><td>Instrument <code>class</code>. <br><br>See <br><a data-mention href="/pages/8ywkQXfxfv1FjtyspEaU">/pages/8ywkQXfxfv1FjtyspEaU</a></td></tr><tr><td><code>instrument</code></td><td>Yes</td><td>Instrument <code>code</code>.<br><br>See <br><a data-mention href="/pages/8ywkQXfxfv1FjtyspEaU">/pages/8ywkQXfxfv1FjtyspEaU</a></td></tr></tbody></table>

### Query Parameters

<table><thead><tr><th width="187">Parameter</th><th width="114">Required</th><th>Description</th></tr></thead><tbody><tr><td><code>continuation_token</code></td><td>No</td><td>See <a data-mention href="/pages/mP3amLsYqKTsrRBoblxX">/pages/mP3amLsYqKTsrRBoblxX</a></td></tr><tr><td><code>end_time</code></td><td>No</td><td>Ending time in ISO 8601 (exclusive).<br><br><em>Automatically included in continuation tokens.</em></td></tr><tr><td><code>interval</code></td><td>No</td><td>The interval parameter is suffixed with <code>s</code>, <code>m</code>, <code>h</code> or <code>d</code> to specify seconds, minutes, hours or days, respectively.<br><br>Any arbitrary value between one second and one day can be used, as long as it sums up to a maximum of 1 day. The suffixes are <code>s</code> (second), <code>m</code> (minute), <code>h</code> (hour) and <code>d</code> (day).<br><br> Default <code>1d</code>.</td></tr><tr><td><code>page_size</code></td><td>No</td><td>(min: 1, default: 100, max: 100000).<br><br>See <a data-mention href="/pages/mP3amLsYqKTsrRBoblxX">/pages/mP3amLsYqKTsrRBoblxX</a><br><br><em>Automatically included in continuation tokens.</em></td></tr><tr><td><code>start_time</code></td><td>No</td><td>Starting time in ISO 8601 (inclusive).<br><br><em>Automatically included in continuation tokens.</em></td></tr><tr><td><code>sort</code></td><td>No</td><td>Return the data in ascending (<code>asc</code>) or descending (<code>desc</code>) order. <br><br>Default: <code>desc</code><br><br><em>Automatically included in continuation tokens.</em></td></tr></tbody></table>

### Fields

<table><thead><tr><th width="190">Field</th><th>Description</th></tr></thead><tbody><tr><td><code>timestamp</code></td><td>Timestamp at which the interval begins.</td></tr><tr><td><code>price</code></td><td>VWAP. <code>null</code> when no trades reported.</td></tr></tbody></table>

### Request examples

{% tabs %}
{% tab title="cURL" %}
{% code overflow="wrap" %}

```url
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'
```

{% endcode %}
{% endtab %}

{% tab title="Python" %}

```python
##### 1. Import dependencies #####
import requests
import pandas as pd

##### 2. Choose the value of the query's parameters #####
# ---- Required parameters ---- #
exchange = "cbse" 
instrument_class = "spot"
pair = "btc-usd" #called "instrument" in the documentation

# ---- Optional parameters ---- #
interval = "1d"  
sort = "desc"
page_size = 100
start_time= "2023-01-01T00:00:00Z"
end_time= "2023-12-31T23:59:59Z"

# ---- API key configuration ---- #
api_key = "YOUR_API_KEY"

##### 3. Get the data #####
# ---- Function to run an API call ---- # 
# Get the data in a dataframe --------- # 

def get_kaiko_data(api_key: str, exchange: str, pair: str, instrument_class: str, start_time: str, end_time: str, interval: str, sort: str, page_size: int):
    headers = {'Accept': 'application/json', 'X-Api-Key': api_key}
    
    url = f'https://us.market-api.kaiko.io/v2/data/trades.v1/exchanges/{exchange}/{instrument_class}/{pair}/aggregations/vwap'
    params = {
        "start_time": start_time,
        "end_time": end_time,
        "sort": sort,
        "page_size": page_size,
        "interval": interval
    }

    try:
        res = requests.get(url, headers=headers, params=params)
        res.raise_for_status() 
        data = res.json()
        if 'data' not in data:
            print("No data returned.")
            return pd.DataFrame() 
        df = pd.DataFrame(data['data'])

        # Handle pagination with continuation token
        while 'next_url' in data:
            next_url = data['next_url']
            if next_url is None:
                break
            res = requests.get(next_url, headers=headers)
            res.raise_for_status()
            data = res.json()
            if 'data' in data:
                df = pd.concat([df, pd.DataFrame(data['data'])], ignore_index=True)
        return df

    except requests.exceptions.RequestException as e:
        print(f"API request error: {e}")
        return pd.DataFrame() 

# ---- Get the data ---- #
df = get_kaiko_data(api_key=api_key, exchange=exchange, pair=pair, instrument_class=instrument_class, start_time=start_time, end_time=end_time ,interval=interval, sort=sort, page_size=page_size)
```

{% endtab %}
{% endtabs %}

### Response example

```json
{
    "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
    }
  }
}
```


# Derivative liquidation events

Each and every derivative liquidation event

{% hint style="info" %}

### This data is available as an add-on for the following Kaiko packages:&#x20;

* Level 1 & Level 2 Data \[Level 1 Tick-Level]
* Level 1 & Level 2 Data \[Level 2 Aggregations]
* Level 1 & Level 2 Data \[Level 2 Tick-Level]

*CeFi derivative ticker packs.*
{% endhint %}

### What is this endpoint for? <a href="#what-is-this-endpoint-for" id="what-is-this-endpoint-for"></a>

This endpoint returns all derivative liquidation events for a given instrument on an exchange. It includes all details available for the event like price and position. Data is available for futures and perpetual futures.\
\
For exchange coverage, see [Cefi derivative markets](/coverage/cefi-derivative-markets).

### Endpoint

{% code overflow="wrap" %}

```url
https://{region}.market-api.kaiko.io/v2/data/liquidation.v1/trades/{exchange}/{instrument_class}/{instrument}
```

{% endcode %}

### Path Parameters

| Parameter          | Required? | Example                                                                                                                            |
| ------------------ | --------- | ---------------------------------------------------------------------------------------------------------------------------------- |
| `region`           | Yes       | <p>Choose between: <br><br><code>eu</code> <br><code>us</code></p>                                                                 |
| `exchange`         | Yes       | <p>Exchange <code>code</code>.<br><br>See <a data-mention href="/pages/QiW5iUvcyBF9RISFmZFV">/pages/QiW5iUvcyBF9RISFmZFV</a></p>   |
| `instrument_class` | Yes       | <p>Choose between : <br><br><code>future</code><br><code>perpetual-future</code></p>                                               |
| `instrument`       | Yes       | <p>Instrument <code>code</code>.<br><br>See <a data-mention href="/pages/8ywkQXfxfv1FjtyspEaU">/pages/8ywkQXfxfv1FjtyspEaU</a></p> |

### Query Parameters

<table><thead><tr><th width="163">Parameter</th><th width="98">Required</th><th>Description</th><th>Example</th></tr></thead><tbody><tr><td><code>start_time</code></td><td>No</td><td>Starting time in ISO 8601 (inclusive). <br><br><em>Automatically included in continuation tokens.</em></td><td><code>2025-01-23T00:01:00.000Z</code></td></tr><tr><td><code>end_time</code></td><td>No</td><td>Ending time in ISO 8601 (exclusive). <br><br><em>Automatically included in continuation tokens.</em></td><td><code>2025-02-25T23:59:00.000Z</code></td></tr><tr><td><code>sort</code></td><td>No</td><td>Return the data in ascending (<code>asc</code>) or descending (<code>desc</code>) order. <br><br>Default: <code>desc</code></td><td><code>asc</code></td></tr><tr><td><code>page_size</code></td><td>No</td><td><p>See <a data-mention href="/pages/mP3amLsYqKTsrRBoblxX">/pages/mP3amLsYqKTsrRBoblxX</a><br><br>Default: <code>100</code></p><p>Maximum: <code>1000</code></p></td><td><code>500</code></td></tr></tbody></table>

### Fields

<table><thead><tr><th>Field</th><th width="281">Description</th><th>Example</th></tr></thead><tbody><tr><td><code>amount</code></td><td>The quantity, displayed in base currency.</td><td><code>0.113</code></td></tr><tr><td><code>amount_quote</code></td><td>The quantity, displayed in the quote asset.</td><td><code>9362.592400000001</code></td></tr><tr><td><code>amount_usd</code></td><td>The quantity, displayed in USD.</td><td><code>9359.689996356</code></td></tr><tr><td><code>price</code></td><td>The price at which the liquidation was executed, displayed in USD.</td><td><code>82854.8</code></td></tr><tr><td><code>rate</code></td><td>Rate used  to convert quote currency to USD. <br><br>For example:<br><br>1 USDT = 0.997 USD</td><td><code>0.99969</code></td></tr><tr><td><code>position_side</code></td><td>The position liquidated</td><td><code>long</code></td></tr><tr><td><code>timestamp</code></td><td>The timestamp provided by the exchange or the collection timestamp in Unix Timestamp (in milliseconds)</td><td><code>1741785829372000000</code></td></tr><tr><td><code>trade_id</code></td><td>Unique trade ID (unique to the exchange). In case the exchange does not provide an ID, we generate it ourselves.</td><td><code>d472cae0135..dfdh6_g</code></td></tr></tbody></table>

### Request examples

{% tabs %}
{% tab title="cURL" %}
{% code overflow="wrap" %}

```url
curl --compressed -H 'Accept: application/json' -H 'X-Api-Key: <client-api-key>' \
'https://us.market-api.kaiko.io/v2/data/liquidation.v1/trades/bbit/perpetual-future/eth-usdt?start_time=2025-04-12T00:00:00Z&end_time=2025-04-12T08:00:00Z&page_size=10'
```

{% endcode %}
{% endtab %}

{% tab title="Python" %}
{% code overflow="wrap" %}

```python
##### 1. Import dependencies #####
import requests
import pandas as pd
from urllib.parse import urlencode

##### 2. Choose the value of the query's parameters #####
# ---- Required parameters ---- #
exchange = "bbit"
instrument_class = "perpetual-future"
instrument = "eth-usdt"

# ---- Optional parameters ---- #
page_size = 10
sort = "desc"
start_time = "2025-04-12T00:00:00Z"
end_time = "2025-04-12T08:00:00Z"

# ---- API key configuration ---- #
api_key = "YOUR_API_KEY"

##### 3. Get the data #####
# ---- Function to run an API call ---- # 
# Get the data in a dataframe --------- # 
def get_kaiko_liquidation_trades(api_key: str, exchange: str, instrument_class: str, instrument: str, 
                                 start_time: str, end_time: str, sort: str, page_size: int):
    headers = {'Accept': 'application/json', 'X-Api-Key': api_key}
    
    base_url = f'https://us.market-api.kaiko.io/v2/data/liquidation.v1/trades/{exchange}/{instrument_class}/{instrument}'
    params = {
        "start_time": start_time,
        "end_time": end_time,
        "sort": sort,
        "page_size": page_size
    }
    
    # Debug: Show the URL being generated
    query_string = urlencode(params)
    full_url = f"{base_url}?{query_string}"
    print(f"DEBUG - Making request to URL: {full_url}")
    print(f"DEBUG - Headers: {headers}")
    
    try:
        res = requests.get(base_url, headers=headers, params=params)
        
        # Debug: Show the actual URL that requests used
        print(f"DEBUG - Actual request URL: {res.url}")
        print(f"DEBUG - Response status code: {res.status_code}")
        
        res.raise_for_status() 
        data = res.json()
        
        if 'data' not in data:
            print("No data returned.")
            return pd.DataFrame() 
            
        df = pd.DataFrame(data['data'])
        print(f"DEBUG - Initial data fetch successful, got {len(df)} records")
        
        # Handle pagination with continuation token
        page_count = 1
        while 'next_url' in data:
            next_url = data['next_url']
            if next_url is None:
                break
                
            print(f"DEBUG - Fetching page {page_count + 1} with URL: {next_url}")
            res = requests.get(next_url, headers=headers)
            res.raise_for_status()
            data = res.json()
            
            if 'data' in data:
                new_records = len(data['data'])
                df = pd.concat([df, pd.DataFrame(data['data'])], ignore_index=True)
                print(f"DEBUG - Fetched additional {new_records} records, total now: {len(df)}")
                page_count += 1
            else:
                print("DEBUG - No more data in pagination response")
                break
        
        return df
    except requests.exceptions.RequestException as e:
        print(f"API request error: {e}")
        print(f"Response status code: {e.response.status_code if hasattr(e, 'response') else 'N/A'}")
        print(f"Response text: {e.response.text if hasattr(e, 'response') else 'N/A'}")
        return pd.DataFrame() 

# ---- Get the data ---- #
print("Starting API request...")
df = get_kaiko_liquidation_trades(
    api_key=api_key, 
    exchange=exchange,
    instrument_class=instrument_class,
    instrument=instrument,
    start_time=start_time, 
    end_time=end_time,
    sort=sort, 
    page_size=page_size
)
```

{% endcode %}
{% endtab %}
{% endtabs %}

### Response example

````json
```json
{
   "query": {
      "exchange": "bbit",
      "instrument": "eth-usdt",
      "instrument_class": "perpetual-future",
      "commodity": "liquidationEvents",
      "request_time": "2025-04-04T11:58:32.545Z",
      "start_time": "2025-02-12T00:00:01.000Z",
      "start_timestamp": 1739318401000,
      "end_time": "2025-02-24T23:59:37.000Z",
      "end_timestamp": 1740441577000,
      "page_size": 10,
      "sort": "desc",
      "data_version": "v1"
   },
   "answer_time": "2025-04-04T11:58:32.554Z",
   "answer_timestamp": 1743767912554,
   "access": {
      "access_range": {
         "start_timestamp": 1688428800000,
         "end_timestamp": 2177539199000
      },
      "data_range": {
         "start_timestamp": null,
         "end_timestamp": null
      }
   },
   "data": [
      {
         "amount": 0.1,
         "amount_quote": 249.77100000000002,
         "amount_usd": 249.76370743089532,
         "price": 2497.71,
         "rate": 0.9999708029791101,
         "position_side": "long",
         "timestamp": 1740441553739,
         "trade_id": "376def42502a7a307b85d7ffdebec8c8c08990b19f6fb165e0f97c8fd058a1b2"
      },
      {
         "amount": 0.04,
         "amount_quote": 99.7556,
         "amount_usd": 99.75268743366291,
         "price": 2493.89,
         "rate": 0.9999708029791101,
         "position_side": "long",
         "timestamp": 1740441446020,
         "trade_id": "f1062a8c42743ffbddc3d129d65f1ae6848227b871361d6fd66f3bbbbb4b10da"
      },
        /*---*/
    ],
    */....
    
"continuation_token": "3RuQ1KYk3AEZTJXXqsaUMrdUKSYH4CVdGUFQCZC5pts7AYMafCjbnYSuedeLMFu72PsXKepcvdtpvZmNzXmotWV1ARAF8hJxLfaDXn75MmkN3zMq6ma9Ym",
   "next_url": "https://us.market-api.kaiko.io/v2/data/liquidation.v1/trades/bbit/perpetual-future/eth-usdt?continuation_token=3RuQ1KYk3AEZTJXXqsaUMrdUKSYH4CVdGUFQCZC5pts7AYMafCjbnYSuedeLMFu72PsXKepcvdtpvZmNzXmotWV1ARAF8hJxLfaDXn75MmkN3zMq6ma9Ym"
}
````


# Raw order book snapshot

{% hint style="info" %}

### This data is included in the following Kaiko packages:

* Level 1 & Level 2 Data \[Level 2 Aggregations]
* Level 1 & Level 2 Data \[Level 2 Tick-Level]

*CeFi Derivative ticker packs.*
{% endhint %}

### What is this endpoint for? <a href="#what-is-this-endpoint-for" id="what-is-this-endpoint-for"></a>

Raw data used to build your own custom level 2 aggregations.&#x20;

### Endpoint

{% code overflow="wrap" %}

```url
https://us.market-api.kaiko.io/v2/data/order_book_snapshots.v1/exchanges/{exchange}/spot/{instrument}/snapshots/raw
```

{% endcode %}

### Path Parameters

<table><thead><tr><th width="203">Parameter</th><th>Required?</th><th>Description</th></tr></thead><tbody><tr><td><code>region</code></td><td>Yes</td><td>Choose between <code>eu</code> and <code>us</code>.</td></tr><tr><td><code>exchange</code></td><td>Yes</td><td><p>Exchange <code>code.</code> </p><p><br>See <a data-mention href="/pages/QiW5iUvcyBF9RISFmZFV">/pages/QiW5iUvcyBF9RISFmZFV</a></p></td></tr><tr><td><code>instrument_class</code></td><td>Yes</td><td>Instrument <code>class</code>. <br><br>See <a data-mention href="/pages/8ywkQXfxfv1FjtyspEaU">/pages/8ywkQXfxfv1FjtyspEaU</a></td></tr><tr><td><code>instrument</code></td><td>Yes</td><td>Instrument <code>code</code>.<br><br>See <a data-mention href="/pages/8ywkQXfxfv1FjtyspEaU">/pages/8ywkQXfxfv1FjtyspEaU</a></td></tr></tbody></table>

### Query Parameters

<table><thead><tr><th width="220">Parameter</th><th width="129">Required</th><th>Description</th></tr></thead><tbody><tr><td><code>continuation_token</code></td><td>No</td><td>See <a data-mention href="/pages/mP3amLsYqKTsrRBoblxX">/pages/mP3amLsYqKTsrRBoblxX</a></td></tr><tr><td><code>limit_orders</code></td><td>No</td><td>Number of orders to return on bid and ask side per snapshot.<br><br>To retreive the best bid/ask, set this parameter to <code>1</code> <br><br>Default: <code>10</code></td></tr><tr><td><code>page_size</code></td><td>No</td><td>Number of snapshots to return data for. <br><br>Default: <code>10</code><br>Max: <code>100</code><br><br>See <a data-mention href="/pages/mP3amLsYqKTsrRBoblxX">/pages/mP3amLsYqKTsrRBoblxX</a><br> <br><em>Automatically included in continuation tokens.</em></td></tr><tr><td><code>sort</code></td><td>No</td><td>Return the data in ascending (asc) or descending (desc) order. <br><br>Default: <code>desc</code><br><br><em>Automatically included in continuation tokens.</em></td></tr><tr><td><code>start_time</code></td><td>No</td><td>Starting time in ISO 8601 (inclusive).<br><br><em>Automatically included in continuation tokens.</em></td></tr><tr><td><code>end_time</code></td><td>No</td><td>Ending time in ISO 8601 (exclusive).<br><br><em>Automatically included in continuation tokens.</em></td></tr></tbody></table>

### Fields

<table><thead><tr><th width="294">Field</th><th>Description</th></tr></thead><tbody><tr><td><code>poll_timestamp</code></td><td>The timestamp at which the raw data snapshot was taken.</td></tr><tr><td><code>poll_date</code></td><td>The date at which the raw data snapshot was taken.</td></tr><tr><td><code>timestamp</code></td><td>The timestamp provided by the exchange. <code>null</code> when not provided.</td></tr><tr><td><code>asks</code></td><td>The sell orders in the snapshot. If the <code>limit_oders</code> parameter is used, this will be reflected here. <code>amount</code> is the quantity of asset to sell, displayed in the base currency. <code>price</code> is displayed in the quote currency.</td></tr><tr><td><code>bids</code></td><td>The buy orders in the snapshot. If the <code>limit_oders</code> parameter is used, this will be reflected here. <code>amount</code> is the quantity of asset to buy, displayed in the base currency. <code>price</code> is displayed in the quote currency.</td></tr></tbody></table>

### Request examples

{% tabs %}
{% tab title="cURL" %}
{% code overflow="wrap" %}

```url
curl --compressed -H 'Accept: application/json' -H 'X-Api-Key: <client-api-key>' \
  'https://us.market-api.kaiko.io/v2/data/order_book_snapshots.v1/exchanges/krkn/spot/btc-usd/snapshots/raw?page_size=10&limit_orders=2'
```

{% endcode %}
{% endtab %}

{% tab title="Python" %}
{% code overflow="wrap" %}

```python
##### 1. Import dependencies #####
import requests
import pandas as pd

##### 2. Choose the value of the query's parameters #####
# ---- Required parameters ---- #
exchange = "krkn" 
instrument_class = "spot"
pair = "btc-usd" #called "instrument" in the documentation

# ---- Optional parameters ---- #
sort = "desc"
page_size = 100
start_time= "2025-03-03T00:00:00Z"
end_time= "2025-03-05T00:00:00Z"
limit_orders = 10

# ---- API key configuration ---- #
api_key = "YOUR_API_KEY"

##### 3. Get the data #####
# ---- Function to run an API call ---- # 
# Get the data in a dataframe --------- # 

def get_kaiko_data(api_key: str, exchange: str, pair: str, instrument_class: str, start_time: str, end_time: str, sort: str, page_size: int, limit_orders: int):
    headers = {'Accept': 'application/json', 'X-Api-Key': api_key}
    
    url = f'https://us.market-api.kaiko.io/v2/data/order_book_snapshots.v1/exchanges/{exchange}/{instrument_class}/{pair}/snapshots/raw'
    params = {
        "start_time": start_time,
        "end_time": end_time,
        "sort": sort,
        "page_size": page_size,
        "limit_orders": limit_orders
    }

    try:
        res = requests.get(url, headers=headers, params=params)
        res.raise_for_status() 
        data = res.json()
        if 'data' not in data:
            print("No data returned.")
            return pd.DataFrame() 
        df = pd.DataFrame(data['data'])

        # Handle pagination with continuation token
        while 'next_url' in data:
            next_url = data['next_url']
            if next_url is None:
                break
            res = requests.get(next_url, headers=headers)
            res.raise_for_status()
            data = res.json()
            if 'data' in data:
                df = pd.concat([df, pd.DataFrame(data['data'])], ignore_index=True)
        return df

    except requests.exceptions.RequestException as e:
        print(f"API request error: {e}")
        return pd.DataFrame() 

# ---- Get the data ---- #
df = get_kaiko_data(api_key=api_key, exchange=exchange, pair=pair, instrument_class=instrument_class, start_time=start_time, end_time=end_time ,sort=sort, page_size=int(page_size), limit_orders=limit_orders)
```

{% endcode %}
{% endtab %}
{% endtabs %}

### Response example

```json
{
    "query": {
        "page_size": 10,
        "exchange": "krkn",
        "instrument_class": "spot",
        "instrument": "btc-usd",
        "slippage": 0,
        "limit_orders": 2,
        "slippage_ref": "mid_price",
        "sort": "desc",
        "metric": "raw",
        "data_version": "v1",
        "commodity": "order_book_snapshots",
        "request_time": "2020-05-26T14:13:08.823Z"
    },
    "time": "2020-05-26T14:13:08.899Z",
    "timestamp": 1590502388899,
    "data": [
        {
            "poll_timestamp": 1590502335760,
            "poll_date": "2020-05-26T14:12:15.760Z",
            "timestamp": null,
            "asks": [
                {
                    "amount": "12",
                    "price": "8830"
                },
                {
                    "amount": "3.67",
                    "price": "8832.9"
                }
            ],
            "bids": [
                {
                    "amount": "13.316",
                    "price": "8829.9"
                },
                {
                    "amount": "0.097",
                    "price": "8829.4"
                }
            ]
        }
      /* ... */         
    ],
    "result": "success",
    "continuation_token": "Z8FjTagUoHd3UCqMvqmRJXlwzbTxSnSXpxxZpHWNCmrsrcnhSpMG2gdcmFKRPd88",
    "next_url": "https://us.market-api.kaiko.io/v2/data/order_book_snapshots.v1/exchanges/cbse/spot/btc-usd/snapshots/raw?continuation_token=Z8FjTagUoHd3UCqMvqmRJXlwzbTxSnSXpxxZpHWNCmrsrcnhSpMG2gdcmFKRPd88",
    "access": {
        "access_range": {
            "start_timestamp": null,
            "end_timestamp": null
        },
        "data_range": {
            "start_timestamp": null,
            "end_timestamp": null
        }
    }
}
```


# Raw trades

{% hint style="info" %}

### This data is included in the following Kaiko packages:

* **Level 1 & Level 2 Data** \[Level 1 Tick-Level Tier]
* **Level 1 & Level 2 Data** \[Level 2 Aggregations Tier]
* **Level 1 & Level 2 Data** \[Level 2 Tick-Level Tier]

*DeFi spot ticker packs.*
{% endhint %}

### What is this endpoint for? <a href="#what-is-this-endpoint-for" id="what-is-this-endpoint-for"></a>

Tick-level data is the most granular level of trading data and contains every single trade that occurs on centralized and decentralized exchanges. The data is normalized and timestamped and contains information such as the price and volume of each trade. For DEXs specifically, we also provide additional information on the user address, the blockchain, the pool address, and the transaction hash related to the trade.

### Endpoint

{% code overflow="wrap" %}

```http
https://{region}.market-api.kaiko.io/v3/data/trades.v1/exchanges/{exchange}/{instrument_class}/{instrument}/trades
```

{% endcode %}

### Path Parameters

<table><thead><tr><th width="203">Parameter</th><th>Required?</th><th>Description</th></tr></thead><tbody><tr><td><code>region</code></td><td>Yes</td><td>Choose between <code>eu</code> and <code>us</code>.</td></tr><tr><td><code>exchange</code></td><td>Yes</td><td><p>Exchange <code>code.</code> </p><p><br>See <a data-mention href="/pages/QiW5iUvcyBF9RISFmZFV">/pages/QiW5iUvcyBF9RISFmZFV</a></p></td></tr><tr><td><code>instrument_class</code></td><td>Yes</td><td>Instrument <code>class</code>. <br><br>See <a data-mention href="/pages/8ywkQXfxfv1FjtyspEaU">/pages/8ywkQXfxfv1FjtyspEaU</a></td></tr><tr><td><code>instrument</code></td><td>Yes</td><td>Instrument <code>code</code>.<br><br>See <a data-mention href="/pages/8ywkQXfxfv1FjtyspEaU">/pages/8ywkQXfxfv1FjtyspEaU</a></td></tr></tbody></table>

### Query Parameters

<table><thead><tr><th width="231">Parameter</th><th width="109">Required</th><th width="379">Description</th></tr></thead><tbody><tr><td><code>start_time</code></td><td>No</td><td>Starting time in ISO 8601 (inclusive). <br><br><em>Automatically included in continuation tokens.</em></td></tr><tr><td><code>end_time</code></td><td>No</td><td>Ending time in ISO 8601 (exclusive). <br><br><em>Automatically included in continuation tokens.</em></td></tr><tr><td><code>page_size</code></td><td>No</td><td>See <a data-mention href="/pages/mP3amLsYqKTsrRBoblxX">/pages/mP3amLsYqKTsrRBoblxX</a><br><br><em>Automatically included in continuation tokens.</em></td></tr><tr><td><code>continuation_token</code></td><td>No</td><td>See <a data-mention href="/pages/mP3amLsYqKTsrRBoblxX">/pages/mP3amLsYqKTsrRBoblxX</a></td></tr><tr><td><code>sort</code></td><td>No</td><td>Return the data in ascending (asc) or descending (desc) order. Default desc.</td></tr><tr><td><code>blockchain</code></td><td>No</td><td>Filter on a specific blockchain. (Default: ethereum).</td></tr><tr><td><code>pool_address</code></td><td>No</td><td>Filter on a specific pool address.</td></tr><tr><td><code>transaction_hash</code></td><td>No</td><td>Filter on a specific transaction hash. (Several trades can happen within a single transaction).</td></tr><tr><td><code>user_address</code></td><td>No</td><td>Filter on a specific address.</td></tr><tr><td><code>start_block</code></td><td>No</td><td>Starting block height (inclusive).</td></tr><tr><td><code>end_block</code></td><td>No</td><td>Ending block height (inclusive).</td></tr></tbody></table>

### Fields

| Field              | Description                                                                                                      |
| ------------------ | ---------------------------------------------------------------------------------------------------------------- |
| `timestamp`        | The timestamp provided by the exchange or the collection timestamp in Unix Timestamp (in milliseconds)           |
| `trade_id`         | Unique trade ID (unique to the exchange). In case the exchange does not provide an ID, we generate it ourselves. |
| `price`            | Price displayed in quote currency.                                                                               |
| `amount`           | Quantity of asset bought or sold (can be in base\_asset, quote\_asset or the number of contracts).               |
| `taker_side_sell`  | See ["taker\_side\_sell" Explained](/rest-api/general/getting-started/api-output/taker_side_sell-explained)      |
| `blockchain`       | The blockchain on which the trade happened.                                                                      |
| `transaction_hash` | Transaction hash.                                                                                                |
| `log_index`        | The log index of the transaction (in base 10).                                                                   |
| `pool_address`     | The address of the pool in which the trade happened.                                                             |
| `user_address`     | Address that triggered the transaction.                                                                          |

### Request examples

{% tabs %}
{% tab title="cURL" %}
{% code overflow="wrap" %}

```url
curl --compressed -H 'Accept: application/json' -H 'X-Api-Key: <client-api-key>' \
  'https://us.market-api.kaiko.io/v2/data/trades.v1/exchanges/bfnx/spot/btc-usd/trades'
```

{% endcode %}
{% endtab %}

{% tab title="Python" %}
{% code overflow="wrap" %}

```python
##### 1. Import dependencies #####
import requests
import pandas as pd

##### 2. Choose the value of the query's parameters #####
# ---- Required parameters ---- #
exchange = "cbse" 
instrument_class = "spot"
pair = "btc-usd" #called "instrument" in the documentation

# ---- Optional parameters ---- #
sort = "desc"
page_size = "100"
start_time= "2023-01-01T00:00:00Z"
end_time= "2023-01-01T00:03:00Z"

# ---- API key configuration ---- #
api_key = "YOUR_API_KEY"

##### 3. Get the data #####
# ---- Function to run an API call ---- # 
# Get the data in a dataframe --------- # 

def get_kaiko_data(api_key: str, exchange: str, pair: str, instrument_class: str, start_time: str, end_time: str, sort: str, page_size: int):
    headers = {'Accept': 'application/json', 'X-Api-Key': api_key}
    
    url = f'https://us.market-api.kaiko.io/v3/data/trades.v1/exchanges/{exchange}/{instrument_class}/{pair}/trades'
    params = {
        "start_time": start_time,
        "end_time": end_time,
        "sort": sort,
        "page_size": page_size
    }

    try:
        res = requests.get(url, headers=headers, params=params)
        res.raise_for_status() 
        data = res.json()
        if 'data' not in data:
            print("No data returned.")
            return pd.DataFrame() 
        df = pd.DataFrame(data['data'])

        # Handle pagination with continuation token
        while 'next_url' in data:
            next_url = data['next_url']
            if next_url is None:
                break
            res = requests.get(next_url, headers=headers)
            res.raise_for_status()
            data = res.json()
            if 'data' in data:
                df = pd.concat([df, pd.DataFrame(data['data'])], ignore_index=True)
        return df

    except requests.exceptions.RequestException as e:
        print(f"API request error: {e}")
        return pd.DataFrame() 

# ---- Get the data ---- #
df = get_kaiko_data(api_key=api_key, exchange=exchange, pair=pair, instrument_class=instrument_class, start_time=start_time, end_time=end_time ,sort=sort, page_size=int(page_size))
```

{% endcode %}
{% endtab %}
{% endtabs %}

### Response example

```json
{
    "query": {
        "page_size": 100,
        "exchange": "bfnx",
        "instrument_class": "spot",
        "instrument": "btc-usd",
        "sort": "desc",
        "data_version": "v1",
        "commodity": "trades",
        "request_time": "2020-11-12T16:33:20.575Z"
    },
    "time": "2020-11-12T16:33:20.869Z",
    "timestamp": 1605198800869,
    "data": [
        {
            "timestamp": 1605198775855,
            "trade_id": "522419198",
            "price": "16026",
            "amount": "0.025",
            "taker_side_sell": true
        },
        {
            "timestamp": 1605198775031,
            "trade_id": "522419197",
            "price": "16026",
            "amount": "0.01",
            "taker_side_sell": true
        },
  /* ... */
  ],
  "result": "success",
  "continuation_token": "rbd28vrmb1cwaxfykuJBKAABhNi1Bfv1EY55P3QPSnYnm8VuX1LqLhA2d3yVfYgMKtfBYxJg7sHrkTfkQGysW23Lm9Lp9rsVpVk2Esmgz9VQZvNE4xWN8hh3LgLrCa7ty4B3YGCwtH",
  "next_url": "https://us.market-api.kaiko.io/v2/data/trades.v1/exchanges/bfnx/spot/btc-usd/trades?continuation_token=rbd28vrmb1cwaxfykuJBKAABhNi1Bfv1EY55P3QPSnYnm8VuX1LqLhA2d3yVfYgMKtfBYxJg7sHrkTfkQGysW23Lm9Lp9rsVpVk2Esmgz9VQZvNE4xWN8hh3LgLrCa7ty4B3YGCwtH",
  "access": {
    "access_range": {
      "start_timestamp": null,
      "end_timestamp": null
    },
    "data_range": {
      "start_timestamp": null,
      "end_timestamp": null
    }
  }
}
```

{% tabs %}
{% tab title="JSON" %}

```json
{
    "query": {
        "page_size": 100,
        "exchange": "bfnx",
        "instrument_class": "spot",
        "instrument": "btc-usd",
        "sort": "desc",
        "data_version": "v1",
        "commodity": "trades",
        "request_time": "2020-11-12T16:33:20.575Z"
    },
    "time": "2020-11-12T16:33:20.869Z",
    "timestamp": 1605198800869,
    "data": [
        {
            "timestamp": 1605198775855,
            "trade_id": "522419198",
            "price": "16026",
            "amount": "0.025",
            "taker_side_sell": true
        },
        {
            "timestamp": 1605198775031,
            "trade_id": "522419197",
            "price": "16026",
            "amount": "0.01",
            "taker_side_sell": true
        },
  /* ... */
  ],
  "result": "success",
  "continuation_token": "rbd28vrmb1cwaxfykuJBKAABhNi1Bfv1EY55P3QPSnYnm8VuX1LqLhA2d3yVfYgMKtfBYxJg7sHrkTfkQGysW23Lm9Lp9rsVpVk2Esmgz9VQZvNE4xWN8hh3LgLrCa7ty4B3YGCwtH",
  "next_url": "https://us.market-api.kaiko.io/v2/data/trades.v1/exchanges/bfnx/spot/btc-usd/trades?continuation_token=rbd28vrmb1cwaxfykuJBKAABhNi1Bfv1EY55P3QPSnYnm8VuX1LqLhA2d3yVfYgMKtfBYxJg7sHrkTfkQGysW23Lm9Lp9rsVpVk2Esmgz9VQZvNE4xWN8hh3LgLrCa7ty4B3YGCwtH",
  "access": {
    "access_range": {
      "start_timestamp": null,
      "end_timestamp": null
    },
    "data_range": {
      "start_timestamp": null,
      "end_timestamp": null
    }
  }
}
```

{% endtab %}
{% endtabs %}


# Trade aggregations


# Trade Count, OHLCV, & VWAP

{% hint style="info" %}

### This data is included in the following Kaiko packages:

* Level 1 & Level 2 Data \[Level 1 Aggregations]
* Level 1 & Level 2 Data \[Level 1 Tick-Level]
* Level 1 & Level 2 Data \[Level 2 Aggregations]
* Level 1 & Level 2 Data \[Level 2 Tick-Level]

*DeFi spot ticker packs.*
{% endhint %}

## What is this endpoint for?&#x20;

This endpoint retrieves the Trade Count, OHLCV and VWAP history for any instrument on an exchange. The `interval` parameter is suffixed with `s`, `m`, `h` or `d` to specify seconds, minutes, hours or days, respectively. By making use of the `sort` parameter, data can be returned in ascending `asc` (default) or descending `desc` order.

### Endpoint

{% code overflow="wrap" %}

```http
https://<eu|us>.market-api.kaiko.io/v2/data/trades.v1/exchanges/{exchange}/{instrument_class}/{instrument}/aggregations/count_ohlcv_vwap
```

{% endcode %}

### Path Parameters

<table><thead><tr><th width="203">Parameter</th><th>Required?</th><th>Description</th></tr></thead><tbody><tr><td><code>region</code></td><td>Yes</td><td>Choose between <code>eu</code> and <code>us</code>.</td></tr><tr><td><code>exchange</code></td><td>Yes</td><td><p>Exchange <code>code.</code> </p><p><br>See <br><a data-mention href="/pages/QiW5iUvcyBF9RISFmZFV">/pages/QiW5iUvcyBF9RISFmZFV</a></p></td></tr><tr><td><code>instrument_class</code></td><td>Yes</td><td>Instrument <code>class</code>. <br><br>See <br><a data-mention href="/pages/8ywkQXfxfv1FjtyspEaU">/pages/8ywkQXfxfv1FjtyspEaU</a></td></tr><tr><td><code>instrument</code></td><td>Yes</td><td>Instrument <code>code</code>.<br><br><a data-mention href="/pages/8ywkQXfxfv1FjtyspEaU">/pages/8ywkQXfxfv1FjtyspEaU</a></td></tr></tbody></table>

### Query Parameters

<table><thead><tr><th width="253">Parameter</th><th width="117">Required</th><th>Description</th></tr></thead><tbody><tr><td><code>continuation_token</code></td><td>No</td><td>See <a data-mention href="/pages/mP3amLsYqKTsrRBoblxX">/pages/mP3amLsYqKTsrRBoblxX</a></td></tr><tr><td><code>end_time</code></td><td>No</td><td>Ending time in ISO 8601 (exclusive).<br><br><em>Automatically included in continuation tokens.</em></td></tr><tr><td><code>interval</code></td><td>No</td><td>The interval parameter is suffixed with <code>s</code>, <code>m</code>, <code>h</code> or <code>d</code> to specify seconds, minutes, hours or days, respectively.<br><br>Any arbitrary value between one second and one day can be used, as long as it sums up to a maximum of 1 day. The suffixes are <code>s</code> (second), <code>m</code> (minute), <code>h</code> (hour) and <code>d</code> (day).<br><br> Default <code>1d</code>.</td></tr><tr><td><code>page_size</code></td><td>No</td><td>See <a data-mention href="/pages/mP3amLsYqKTsrRBoblxX">/pages/mP3amLsYqKTsrRBoblxX</a><br><br><em>Automatically included in continuation tokens.</em></td></tr><tr><td><code>start_time</code></td><td>No</td><td>Starting time in ISO 8601 (inclusive).<br><br><em>Automatically included in continuation tokens.</em></td></tr><tr><td><code>sort</code></td><td>No</td><td>Return the data in ascending (<code>asc</code>) or descending (<code>desc</code>) order. Default <code>desc</code><br><br><em>Automatically included in continuation tokens.</em></td></tr></tbody></table>

### Fields

| Field       | Description                                                                         |
| ----------- | ----------------------------------------------------------------------------------- |
| `timestamp` | Timestamp at which the interval begins.                                             |
| `count`     | Then number of trades. `0` when no trades reported.                                 |
| `open`      | Opening price of interval. `null` when no trades reported.                          |
| `high`      | Highest price during interval. `null` when no trades reported.                      |
| `low`       | Lowest price during interval. `null` when no trades reported.                       |
| `close`     | Closing price of interval. `null` when no trades reported.                          |
| `volume`    | Volume traded in interval. `0` when no trades reported.                             |
| `price`     | The volume weighted price during the time interval. `null` when no trades reported. |

### Request examples

{% tabs %}
{% tab title="cURL" %}
{% code overflow="wrap" %}

```url
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/count_ohlcv_vwap'
```

{% endcode %}
{% endtab %}

{% tab title="Python" %}
{% code overflow="wrap" %}

````python
```python
##### 1. Import dependencies #####
import requests
import pandas as pd

##### 2. Choose the value of the query's parameters #####
# ---- Required parameters ---- #
exchange = "cbse" 
instrument_class = "spot"
pair = "btc-usd" #called "instrument" in the documentation

# ---- Optional parameters ---- #
interval = "1d"  
sort = "desc"
page_size = 100
start_time= "2023-01-01T00:00:00Z"
end_time= "2023-12-31T23:59:59Z"

# ---- API key configuration ---- #
api_key = "YOUR_API_KEY"

##### 3. Get the data #####
# ---- Function to run an API call ---- # 
# Get the data in a dataframe --------- # 

def get_kaiko_data(api_key: str, exchange: str, pair: str, instrument_class: str, start_time: str, end_time: str, interval: str, sort: str, page_size: int):
    headers = {'Accept': 'application/json', 'X-Api-Key': api_key}
    
    url = f'https://us.market-api.kaiko.io/v2/data/trades.v1/exchanges/{exchange}/{instrument_class}/{pair}/aggregations/count_ohlcv_vwap'
    params = {
        "start_time": start_time,
        "end_time": end_time,
        "sort": sort,
        "page_size": page_size,
        "interval": interval
    }

    try:
        res = requests.get(url, headers=headers, params=params)
        res.raise_for_status() 
        data = res.json()
        if 'data' not in data:
            print("No data returned.")
            return pd.DataFrame() 
        df = pd.DataFrame(data['data'])

        # Handle pagination with continuation token
        while 'next_url' in data:
            res = requests.get(data['next_url'], headers=headers)
            res.raise_for_status()
            data = res.json()
            if 'data' in data:
                df = pd.concat([df, pd.DataFrame(data['data'])], ignore_index=True)
        return df

    except requests.exceptions.RequestException as e:
        print(f"API request error: {e}")
        return pd.DataFrame() 

# ---- Get the data ---- #
df = get_kaiko_data(api_key=api_key, exchange=exchange, pair=pair, instrument_class=instrument_class, start_time=start_time, end_time=end_time ,interval=interval, sort=sort, page_size=page_size)
```
````

{% endcode %}
{% endtab %}

{% tab title="BigQuery" %}
Trade Count and OHLCV can be accessed through Google BigQuery. \
\
To get started, read our [guide](broken://spaces/zwO3AMVXsp37KK2FngVc/pages/LFIZ1UwRtOxTg308jneZ).
{% endtab %}
{% endtabs %}

### Response example

```json
{
    "query": {
        "page_size": 100,
        "exchange": "cbse",
        "instrument_class": "spot",
        "instrument": "btc-usd",
        "interval": "1d",
        "sort": "desc",
        "aggregation": "count_ohlcv_vwap",
        "data_version": "v1",
        "commodity": "trades",
        "request_time": "2020-11-12T16:55:42.588Z"
    },
    "time": "2020-11-12T16:55:42.710Z",
    "timestamp": 1605200142710,
    "data": [
        {
            "timestamp": 1605139200000,
            "open": "15705.79",
            "high": "16185.87",
            "low": "15446.82",
            "close": "16139.93",
            "volume": "14829.124546730012",
            "price": "15880.01873841608",
            "count": 95111
        },
        {
            "timestamp": 1605052800000,
            "open": "15315.46",
            "high": "16000",
            "low": "15293.04",
            "close": "15705.79",
            "volume": "15123.844197729988",
            "price": "15664.643871798791",
            "count": 114205
        },
    /* ... */
  ],
  "result": "success",
  "continuation_token": "rbd1XbkjMwv2SyUfvJwsqFGmCKzg3WToTvqigui1bejckYnxd9DM1V3v58iqMCdXa4dJSXap6p6fBuvzz32tiHVrv5LC76MyRyYNbZyvSEoVzd1krSWWeXYEtEtR",
  "next_url": "https://<eu|us>.market-api.kaiko.io/v2/data/trades.v1/exchanges/cbse/spot/btc-usd/aggregations/count_ohlcv_vwap?continuation_token=rbd1XbkjMwv2SyUfvJwsui1bejckYnxd9DM1V3v58iqMCdXa4dJSXap6p6fBuvzz32tiHVrv5LC76MyRyYNbZyvSEoVzd1krSWWeXYEtEtR",
  "access": {
    "access_range": {
      "start_timestamp": 1546300800000,
      "end_timestamp": 1577836800000
    },
    "data_range": {
      "start_timestamp": 1417391000000,
      "end_timestamp": 1577836800000
    }
  }
}

```


# OHLCV only

{% hint style="info" %}

### This data is included in the following Kaiko packages:

* Level 1 & Level 2 Data \[Level 1 Aggregations]
* Level 1 & Level 2 Data \[Level 1 Tick-Level]
* Level 1 & Level 2 Data \[Level 2 Aggregations]
* Level 1 & Level 2 Data \[Level 2 Tick-Level]

*DeFi spot ticker packs.*
{% endhint %}

## What is this endpoint for?&#x20;

This endpoint retrieves the OHLCV history for an instrument on an exchange.

### Endpoint

{% code overflow="wrap" %}

```http
https://<eu|us>.market-api.kaiko.io/v2/data/trades.v1/exchanges/{exchange}/{instrument_class}/{instrument}/aggregations/ohlcv
```

{% endcode %}

### Path Parameters

<table><thead><tr><th width="203">Parameter</th><th>Required?</th><th>Description</th></tr></thead><tbody><tr><td><code>region</code></td><td>Yes</td><td>Choose between <code>eu</code> and <code>us</code>.</td></tr><tr><td><code>exchange</code></td><td>Yes</td><td><p>Exchange <code>code.</code> </p><p><br>See <br><a data-mention href="/pages/QiW5iUvcyBF9RISFmZFV">/pages/QiW5iUvcyBF9RISFmZFV</a></p></td></tr><tr><td><code>instrument_class</code></td><td>Yes</td><td>Instrument <code>class</code>. <br><br>See <br><a data-mention href="/pages/8ywkQXfxfv1FjtyspEaU">/pages/8ywkQXfxfv1FjtyspEaU</a></td></tr><tr><td><code>instrument</code></td><td>Yes</td><td>Instrument <code>code</code>.<br><br>See <br><a data-mention href="/pages/8ywkQXfxfv1FjtyspEaU">/pages/8ywkQXfxfv1FjtyspEaU</a></td></tr></tbody></table>

### Query Parameters

<table><thead><tr><th width="233">Parameter</th><th width="144">Required</th><th>Description</th></tr></thead><tbody><tr><td><code>end_time</code></td><td>No</td><td>Ending time in ISO 8601 (exclusive).<br><br><em>Automatically included in continuation tokens.</em></td></tr><tr><td><code>continuation_token</code></td><td>No</td><td>See <a data-mention href="/pages/mP3amLsYqKTsrRBoblxX">/pages/mP3amLsYqKTsrRBoblxX</a></td></tr><tr><td><code>interval</code></td><td>No</td><td>The interval parameter is suffixed with <code>s</code>, <code>m</code>, <code>h</code> or <code>d</code> to specify seconds, minutes, hours or days, respectively.<br><br>Any arbitrary value between one second and one day can be used, as long as it sums up to a maximum of 1 day. The suffixes are <code>s</code> (second), <code>m</code> (minute), <code>h</code> (hour) and <code>d</code> (day).<br><br> Default <code>1d</code>.</td></tr><tr><td><code>page_size</code></td><td>No</td><td>(min: 1, default: 100, max: 100000).<br><br>See <a data-mention href="/pages/mP3amLsYqKTsrRBoblxX">/pages/mP3amLsYqKTsrRBoblxX</a> <br><br><em>Automatically included in continuation tokens.</em></td></tr><tr><td><code>start_time</code></td><td>No</td><td>Starting time in ISO 8601 (inclusive).</td></tr><tr><td><code>sort</code></td><td>No</td><td>Return the data in ascending (<code>asc</code>) or descending (<code>desc</code>) order. Default <code>desc</code><br><br><em>Automatically included in continuation tokens.</em></td></tr></tbody></table>

### Fields

<table><thead><tr><th width="385">Field</th><th>Description</th></tr></thead><tbody><tr><td><code>timestamp</code></td><td>Timestamp at which the interval begins.</td></tr><tr><td><code>open</code></td><td>Opening price of interval. <code>null</code> when no trades reported.</td></tr><tr><td><code>high</code></td><td>Highest price during interval. <code>null</code> when no trades reported.</td></tr><tr><td><code>low</code></td><td>Lowest price during interval. <code>null</code> when no trades reported.</td></tr><tr><td><code>close</code></td><td>Closing price of interval. <code>null</code> when no trades reported.</td></tr><tr><td><code>volume</code></td><td>Volume traded in interval. <code>0</code> when no trades reported.</td></tr></tbody></table>

### Request examples

{% tabs %}
{% tab title="cURL" %}
{% code overflow="wrap" %}

```url
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/ohlcv'
```

{% endcode %}
{% endtab %}

{% tab title="Python" %}
{% code overflow="wrap" %}

```python
##### 1. Import dependencies #####
import requests
import pandas as pd

##### 2. Choose the value of the query's parameters #####
# ---- Required parameters ---- #
exchange = "cbse" 
instrument_class = "spot"
pair = "btc-usd" #called "instrument" in the documentation

# ---- Optional parameters ---- #
interval = "1d"  
sort = "desc"
page_size = 100
start_time= "2023-01-01T00:00:00Z"
end_time= "2023-12-31T23:59:59Z"

# ---- API key configuration ---- #
api_key = "YOUR_API_KEY"

##### 3. Get the data #####
# ---- Function to run an API call ---- # 
# Get the data in a dataframe --------- # 

def get_kaiko_data(api_key: str, exchange: str, pair: str, instrument_class: str, start_time: str, end_time: str, interval: str, sort: str, page_size: int):
    headers = {'Accept': 'application/json', 'X-Api-Key': api_key}
    
    url = f'https://us.market-api.kaiko.io/v2/data/trades.v1/exchanges/{exchange}/{instrument_class}/{pair}/aggregations/ohlcv'
    params = {
        "start_time": start_time,
        "end_time": end_time,
        "sort": sort,
        "page_size": page_size,
        "interval": interval
    }

    try:
        res = requests.get(url, headers=headers, params=params)
        res.raise_for_status() 
        data = res.json()
        if 'data' not in data:
            print("No data returned.")
            return pd.DataFrame() 
        df = pd.DataFrame(data['data'])

        # Handle pagination with continuation token
        while 'next_url' in data:
            next_url = data['next_url']
            if next_url is None:
                break
            res = requests.get(next_url, headers=headers)
            res.raise_for_status()
            data = res.json()
            if 'data' in data:
                df = pd.concat([df, pd.DataFrame(data['data'])], ignore_index=True)
        return df

    except requests.exceptions.RequestException as e:
        print(f"API request error: {e}")
        return pd.DataFrame() 

# ---- Get the data ---- #
df = get_kaiko_data(api_key=api_key, exchange=exchange, pair=pair, instrument_class=instrument_class, start_time=start_time, end_time=end_time ,interval=interval, sort=sort, page_size=page_size)
```

{% endcode %}
{% endtab %}

{% tab title="BigQuery" %}
Information from this endpoint can be accessed through Google BigQuery. \
\
To get started, read our [guide](broken://spaces/zwO3AMVXsp37KK2FngVc/pages/LFIZ1UwRtOxTg308jneZ).
{% endtab %}
{% endtabs %}

### Response example

```json
{
    "query": {
        "page_size": 100,
        "exchange": "cbse",
        "instrument_class": "spot",
        "instrument": "btc-usd",
        "interval": "1d",
        "sort": "desc",
        "aggregation": "ohlcv",
        "data_version": "v1",
        "commodity": "trades",
        "request_time": "2020-05-26T17:25:56.221Z"
    },
    "time": "2020-05-26T17:26:00.160Z",
    "timestamp": 1590513960160,
    "data": [
        {
            "timestamp": 1590451200000,
            "open": "8900.0",
            "high": "9016.99",
            "low": "8694.23",
            "close": "8811.36",
            "volume": "9014.60281966"
        },
        {
            "timestamp": 1590364800000,
            "open": "8715.69",
            "high": "8977.0",
            "low": "8632.93",
            "close": "8899.31",
            "volume": "12091.06145914"
        },
  /* ... */
  ],
  "result": "success",
  "continuation_token": "rbd2bcDp35GmDscQbvZ9YzQHZJkT3jdeFx9fSBDdVmcCZaHvQRTCTfmfQ6QCrvDNp5ciRRuGPTedVL5LMZv1qmSXhRpZFbpvBW2uA62RSYpfJ1hVykJKZfhtmXXrxz",
  "next_url": "https://us.market-api.kaiko.io/v2/data/trades.v1/exchanges/krkn/spot/btc-usd/aggregations/ohlcv?continuation_token=rbd2bcDp35GmDqdfaz3fZJkT3jdeFx9fSBDdVmcCZaHvQRTCTfmfQ6QCrvDNp5ciRRuGPTedVL5LMZv1qmSXhRpZFbpvBW2uA62RSYpfJ1hVykJKZfhtmXXrxz",
  "access": {
    "access_range": {
      "start_timestamp": null,
      "end_timestamp": null
    },
    "data_range": {
      "start_timestamp": null,
      "end_timestamp": null
    }
  }
}

```


# VWAP only

{% hint style="info" %}

### This data is included in the following Kaiko packages:

* Level 1 & Level 2 Data \[Level 1 Aggregations]
* Level 1 & Level 2 Data \[Level 1 Tick-Level]
* Level 1 & Level 2 Data \[Level 2 Aggregations]
* Level 1 & Level 2 Data \[Level 2 Tick-Level]

*DeFi spot ticker packs.*
{% endhint %}

## What is this endpoint for?&#x20;

This endpoint retrieves aggregated VWAP (volume-weighted average price) history for an instrument on an exchange.

### Endpoint

{% code overflow="wrap" %}

```http
https://<eu|us>.market-api.kaiko.io/v2/data/trades.v2/exchanges/{exchange}/{instrument_class}/{instrument}/aggregations/vwap
```

{% endcode %}

### Path Parameters

<table><thead><tr><th width="203">Parameter</th><th>Required?</th><th>Description</th></tr></thead><tbody><tr><td><code>region</code></td><td>Yes</td><td>Choose between <code>eu</code> and <code>us</code>.</td></tr><tr><td><code>exchange</code></td><td>Yes</td><td><p>Exchange <code>code.</code> </p><p><br>See <br><a data-mention href="/pages/QiW5iUvcyBF9RISFmZFV">/pages/QiW5iUvcyBF9RISFmZFV</a></p></td></tr><tr><td><code>instrument_class</code></td><td>Yes</td><td>Instrument <code>class</code>. <br><br>See <br><a data-mention href="/pages/8ywkQXfxfv1FjtyspEaU">/pages/8ywkQXfxfv1FjtyspEaU</a></td></tr><tr><td><code>instrument</code></td><td>Yes</td><td>Instrument <code>code</code>.<br><br>See <br><a data-mention href="/pages/8ywkQXfxfv1FjtyspEaU">/pages/8ywkQXfxfv1FjtyspEaU</a></td></tr></tbody></table>

### Query Parameters

<table><thead><tr><th width="187">Parameter</th><th width="114">Required</th><th>Description</th></tr></thead><tbody><tr><td><code>continuation_token</code></td><td>No</td><td>See <a data-mention href="/pages/mP3amLsYqKTsrRBoblxX">/pages/mP3amLsYqKTsrRBoblxX</a></td></tr><tr><td><code>end_time</code></td><td>No</td><td>Ending time in ISO 8601 (exclusive).<br><br><em>Automatically included in continuation tokens.</em></td></tr><tr><td><code>interval</code></td><td>No</td><td>The interval parameter is suffixed with <code>s</code>, <code>m</code>, <code>h</code> or <code>d</code> to specify seconds, minutes, hours or days, respectively.<br><br>Any arbitrary value between one second and one day can be used, as long as it sums up to a maximum of 1 day. The suffixes are <code>s</code> (second), <code>m</code> (minute), <code>h</code> (hour) and <code>d</code> (day).<br><br> Default <code>1d</code>.</td></tr><tr><td><code>page_size</code></td><td>No</td><td>(min: 1, default: 100, max: 100000).<br><br>See <a data-mention href="/pages/mP3amLsYqKTsrRBoblxX">/pages/mP3amLsYqKTsrRBoblxX</a><br><br><em>Automatically included in continuation tokens.</em></td></tr><tr><td><code>start_time</code></td><td>No</td><td>Starting time in ISO 8601 (inclusive).<br><br><em>Automatically included in continuation tokens.</em></td></tr><tr><td><code>sort</code></td><td>No</td><td>Return the data in ascending (<code>asc</code>) or descending (<code>desc</code>) order. <br><br>Default: <code>desc</code><br><br><em>Automatically included in continuation tokens.</em></td></tr></tbody></table>

### Fields

<table><thead><tr><th width="190">Field</th><th>Description</th></tr></thead><tbody><tr><td><code>timestamp</code></td><td>Timestamp at which the interval begins.</td></tr><tr><td><code>price</code></td><td>VWAP. <code>null</code> when no trades reported.</td></tr></tbody></table>

### Request examples

{% tabs %}
{% tab title="cURL" %}
{% code overflow="wrap" %}

```url
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'
```

{% endcode %}
{% endtab %}

{% tab title="Python" %}

```python
##### 1. Import dependencies #####
import requests
import pandas as pd

##### 2. Choose the value of the query's parameters #####
# ---- Required parameters ---- #
exchange = "cbse" 
instrument_class = "spot"
pair = "btc-usd" #called "instrument" in the documentation

# ---- Optional parameters ---- #
interval = "1d"  
sort = "desc"
page_size = 100
start_time= "2023-01-01T00:00:00Z"
end_time= "2023-12-31T23:59:59Z"

# ---- API key configuration ---- #
api_key = "YOUR_API_KEY"

##### 3. Get the data #####
# ---- Function to run an API call ---- # 
# Get the data in a dataframe --------- # 

def get_kaiko_data(api_key: str, exchange: str, pair: str, instrument_class: str, start_time: str, end_time: str, interval: str, sort: str, page_size: int):
    headers = {'Accept': 'application/json', 'X-Api-Key': api_key}
    
    url = f'https://us.market-api.kaiko.io/v2/data/trades.v1/exchanges/{exchange}/{instrument_class}/{pair}/aggregations/vwap'
    params = {
        "start_time": start_time,
        "end_time": end_time,
        "sort": sort,
        "page_size": page_size,
        "interval": interval
    }

    try:
        res = requests.get(url, headers=headers, params=params)
        res.raise_for_status() 
        data = res.json()
        if 'data' not in data:
            print("No data returned.")
            return pd.DataFrame() 
        df = pd.DataFrame(data['data'])

        # Handle pagination with continuation token
        while 'next_url' in data:
            next_url = data['next_url']
            if next_url is None:
                break
            res = requests.get(next_url, headers=headers)
            res.raise_for_status()
            data = res.json()
            if 'data' in data:
                df = pd.concat([df, pd.DataFrame(data['data'])], ignore_index=True)
        return df

    except requests.exceptions.RequestException as e:
        print(f"API request error: {e}")
        return pd.DataFrame() 

# ---- Get the data ---- #
df = get_kaiko_data(api_key=api_key, exchange=exchange, pair=pair, instrument_class=instrument_class, start_time=start_time, end_time=end_time ,interval=interval, sort=sort, page_size=page_size)
```

{% endtab %}
{% endtabs %}

### Response example

```json
{
    "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
    }
  }
}
```


# Mints and burns

{% hint style="info" %}

### This data is included in the following Kaiko packages:

* Level 1 & Level 2 Data \[Level 2 Tick-Level]

*DeFi spot ticker packs.*
{% endhint %}

### What is this endpoint for? <a href="#what-is-this-endpoint-for" id="what-is-this-endpoint-for"></a>

This endpoint includes event data related to the addition (mint) and removal (burn) of tokens from a liquidity pool.&#x20;

Read our DEX liquidity event data methodology [here](https://25446524.fs1.hubspotusercontent-eu1.net/hubfs/25446524/Case%20Studies%20%2B%20Data%20Gudies/DEX%20Methodology.pdf).

### Endpoint

{% code overflow="wrap" %}

```http
https://eu.market-api.kaiko.io/v2/data/liquidity.v1/events
```

{% endcode %}

### Parameters

<table><thead><tr><th>Parameter</th><th width="98">Required</th><th>Description</th><th>Example</th></tr></thead><tbody><tr><td><code>blockchain</code></td><td>No</td><td>Should be one of the currently supported blockchains.<br><br>See <a data-mention href="/pages/a2ImeIv5a9wmXExkWX8W">/pages/a2ImeIv5a9wmXExkWX8W</a></td><td><code>ethereum</code></td></tr><tr><td><code>protocol</code></td><td>No</td><td>Filter on a currently supported DEX.</td><td><code>usp2</code></td></tr><tr><td><code>pool_address</code></td><td>No</td><td>Pool address related to the liquidity event. <br><br>Default: all liquidity pools.</td><td><code>0x14de8287adc90f0f95bf567c0707670de52e3813</code></td></tr><tr><td><code>pool_contains</code></td><td>No</td><td>Mints and burns including the requested token. <br><br>Default: all available tokens.</td><td><code>weth</code> or <code>weth,usdt,usdc</code></td></tr><tr><td><code>block_number</code></td><td>No</td><td>Block height.</td><td><code>129876</code></td></tr><tr><td><code>user_addresses</code></td><td>No</td><td>Filter on specific user addresses (comma separated).</td><td><code>0x479bc**</code></td></tr><tr><td><code>live</code></td><td>No</td><td>Shows the data as soon as the block is validated. <br><br>(Default: <code>false</code>, in case of block reorganization).</td><td><code>true</code></td></tr><tr><td><code>tx_hash</code></td><td>No</td><td>Filter on a specific transaction hash.</td><td><code>0xe68b84740**</code></td></tr><tr><td><code>start_block</code></td><td>No</td><td>Starting block height (inclusive).</td><td><code>129870</code></td></tr><tr><td><code>end_block</code></td><td>No</td><td>Ending block height (inclusive).</td><td><code>130000</code></td></tr><tr><td><code>start_time</code></td><td>No</td><td>Starting time in ISO 8601 (inclusive).</td><td><code>2022-04-01T00:00:00.000Z</code></td></tr><tr><td><code>end_time</code></td><td>No</td><td>Ending time in ISO 8601 (inclusive).</td><td><code>2022-05-01T00:00:00.000Z</code></td></tr><tr><td><code>sort</code></td><td>No</td><td>Returns the data in ascending <code>asc</code> or descending <code>desc</code> order. <br><br>Default: <code>desc</code>.</td><td><code>asc</code></td></tr><tr><td><code>type</code></td><td>No</td><td>Event type. By default both burn and mint are shown.</td><td><code>burn</code> or <code>mint</code></td></tr><tr><td><code>page_size</code></td><td>No</td><td>Number of snapshots to return data for. (default: 1000, min: 1, max: 1000). <br><br>See <a data-mention href="/pages/mP3amLsYqKTsrRBoblxX">/pages/mP3amLsYqKTsrRBoblxX</a></td><td><code>500</code></td></tr></tbody></table>

### Fields

<table><thead><tr><th width="219">Field</th><th>Description</th><th>Example</th></tr></thead><tbody><tr><td><code>blockchain</code></td><td>The blockchain on which the transaction happened.</td><td><code>ethereum</code></td></tr><tr><td><code>block_number</code></td><td>The height of the block in which the transaction happened.</td><td><code>129876</code></td></tr><tr><td><code>type</code></td><td>Event type: mint or burn.</td><td><code>burn</code> or <code>mint</code></td></tr><tr><td><code>pool_name</code></td><td>Name of the pool as it is written on the blockchain.</td><td><code>USDC-WETH-0.001</code></td></tr><tr><td><code>pool_address</code></td><td>Address of the contract of the pool.</td><td><code>0x88e6a0c2ddd26feeb64f039a2c41296fcb3f5640</code></td></tr><tr><td><code>exchange</code></td><td>Code of the DEX.</td><td><code>usp3</code></td></tr><tr><td><code>transaction_hash</code></td><td>Transaction hash</td><td><code>0x3d28ec9f35692ee6e9264735cd4f92c48bccda82487144d26ebc12376a418cdc</code></td></tr><tr><td><code>log_index</code></td><td>The log index of the transaction (in base 10)</td><td><code>152</code></td></tr><tr><td><code>user_address</code></td><td>Address that triggered the transaction.</td><td><code>0x479bc00624e58398f4cf59d78884d12fb515790a</code></td></tr><tr><td><code>price</code></td><td>Price of the token at the moment of the event.</td><td><code>0.000358096</code></td></tr><tr><td><code>amounts</code></td><td>Amounts of the tokens</td><td>See example</td></tr><tr><td><code>datetime</code></td><td>Timestamp at which the interval begins. In seconds.</td><td><code>1650441900</code></td></tr><tr><td><code>metadata</code></td><td>Only for Uniswap v3. Upper and lower ticker of the interval on which the liquidity is provided</td><td><code>{"lower_ticker": 190650, "upper_ticker": 195610}</code></td></tr></tbody></table>

### Request example

{% tabs %}
{% tab title="cURL" %}
{% code overflow="wrap" %}

```url
curl --compressed -H "Accept: application/json" -H "X-Api-Key: <client-api-key>" \
  "https://eu.market-api.kaiko.io/v2/data/liquidity.v1/events"
```

{% endcode %}
{% endtab %}

{% tab title="Python" %}
{% code overflow="wrap" %}

```python
##### 1. Import dependencies #####
import requests
import pandas as pd

##### 2. Choose the value of the query's parameters #####
# ---- Required parameters ---- #
blockchain = "ethereum" 
protocol = "usp2"
pool_address = None
pool_contains = "weth"
block_number = None
user_addresses = None
live = "false"
tx_hash = None
start_block = None
end_block = None
start_time = "2025-03-05T13:00:00Z"
end_time = None
sort = "asc"
type = "burn"
page_size = 500

# ---- API key configuration ---- #
api_key = "YOUR_API_KEY"

##### 3. Get the data #####
# ---- Function to run an API call ---- # 
# Get the data in a dataframe --------- # 

def get_kaiko_data(api_key: str, blockchain: str, protocol: str, pool_address: str, pool_contains: str, block_number: int, user_addresses: str, live: str, tx_hash: str, start_block: int, end_block: int, start_time: str, end_time: str, sort: str, type: str, page_size: int):
    headers = {'Accept': 'application/json', 'X-Api-Key': api_key}
    
    url = f'https://eu.market-api.kaiko.io/v2/data/liquidity.v1/events'
    params = {
        "blockchain": blockchain,
        "protocol": protocol,
        "pool_address": pool_address,
        "pool_contains": pool_contains,
        "block_number": block_number,
        "user_addresses": user_addresses,
        "live": live,
        "tx_hash": tx_hash,
        "start_block": start_block,
        "end_block": end_block,
        "start_time": start_time,
        "end_time": end_time,
        "sort": sort,
        "type": type,
        "page_size": page_size
    }

    try:
        res = requests.get(url, headers=headers, params=params)
        res.raise_for_status() 
        data = res.json()
        if 'data' not in data:
            print("No data returned.")
            return pd.DataFrame() 
        df = pd.DataFrame(data['data'])

        # Handle pagination with continuation token
        while 'next_url' in data:
            next_url = data['next_url']
            if next_url is None:
                break
            res = requests.get(next_url, headers=headers)
            res.raise_for_status()
            data = res.json()
            if 'data' in data:
                df = pd.concat([df, pd.DataFrame(data['data'])], ignore_index=True)
        return df

    except requests.exceptions.RequestException as e:
        print(f"API request error: {e}")
        return pd.DataFrame() 

# ---- Get the data ---- #
df = get_kaiko_data(api_key=api_key, blockchain=blockchain, protocol=protocol, pool_address=pool_address, pool_contains=pool_contains, block_number=block_number, user_addresses=user_addresses, live=live, tx_hash=tx_hash, start_block=start_block, end_block=end_block, start_time=start_time, end_time=end_time, sort=sort, type=type, page_size=page_size)
print (df)
```

{% endcode %}
{% endtab %}
{% endtabs %}

### Response example

```json
{
  "query": {
    "blockchain": "*",
    "exchange": "*",
    "pool_address": "0x7bea39867e4169dbe237d55c8242a8f2fcdcc387",
    "block_number": "*",
    "type": "*",
    "user_addresses": "*",
    "tx_hash": "*",
    "start_time": "2022-04-01 00:00:00 +0000 UTC",
    "end_time": "2022-05-01 00:00:00 +0000 UTC",
    "sort": "descending",
    "pool_contains": "*",
    "page_size": "1000"
  },
  "time": "2022-05-17T14:26:27.274Z",
  "timestamp": 1652797587,
  "data": [
    {
      "blockchain": "ethereum",
      "block_number": 14682526,
      "type": "mint",
      "pool_name": "USDC-WETH-0.010",
      "pool_address": "0x7bea39867e4169dbe237d55c8242a8f2fcdcc387",
      "exchange": "usp3",
      "transaction_hash": "0x02127cbf00c43fff6a1ec381703e66035b975e49f901ade55f1b12652e07b544",
      "log_index": 187,
      "user_address": "0x3cbd83d4a4ee504bf8b78d9c2927a9f22f27cce5",
      "price": 0.0003564194488230487,
      "amounts": [
        {"symbol": "USDC", "address": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", "amount": 31.063585},
        {"symbol": "WETH", "address": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", "amount": 0.5833806413127403}
      ],
      "datetime": 1651280001,
      "metadata": {"lower_ticker": 192600, "upper_ticker": 197000}
    }
    /* ... */
  ],
  "continuation_token": "xxx",
  "next_url": "https://eu.market-api.kaiko.io/v2/data/liquidity.v1/events?continuation_token=xxx"
}
```


# Borrows, repayments, liquidations, and withdrawals

{% hint style="info" %}

### This data is included in the following Kaiko packages:

* Level 1 & Level 2 Data \[Level 1 Tick-Level]
* Level 1 & Level 2 Data \[Level 2 Aggregations]
* Level 1 & Level 2 Data \[Level 2 Tick-Level]

*DeFi lending & borrowing ticker packs.*
{% endhint %}

### What is this endpoint for? <a href="#what-is-this-endpoint-for" id="what-is-this-endpoint-for"></a>

This endpoint returns transactions (borrows, repayments, withdrawals, deposits and liquidations) registered on-chain, for the main L\&B protocols.

Learn about our methodologies for [DEX data](https://25446524.fs1.hubspotusercontent-eu1.net/hubfs/25446524/Case%20Studies%20%2B%20Data%20Gudies/DEX%20Methodology.pdf) and [Uniswap V3](https://25446524.fs1.hubspotusercontent-eu1.net/hubfs/25446524/Factsheets%20and%20Methodologies/Uniswap_V3_snapshot_Dec22.pdf).

### Endpoint

{% code overflow="wrap" %}

```http
https://eu.market-api.kaiko.io/v2/data/lending.v1/events
```

{% endcode %}

### Parameters

<table><thead><tr><th>Parameter</th><th width="95">Required</th><th>Description</th><th>Example</th></tr></thead><tbody><tr><td><code>blockchain</code></td><td>No</td><td>Should be one or several of the currently supported blockchains. <br><br>See <a data-mention href="/pages/a2ImeIv5a9wmXExkWX8W">/pages/a2ImeIv5a9wmXExkWX8W</a></td><td><code>ethereum</code></td></tr><tr><td><code>protocol</code></td><td>No</td><td>Should be one or several of the currently supported L&#x26;B protocols.</td><td><code>aav1,aav2</code></td></tr><tr><td><code>user_address</code></td><td>No</td><td>Filter on a specific wallet addresses (comma separated).</td><td><code>0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045</code></td></tr><tr><td><code>live</code></td><td>No</td><td>Shows the data as soon as the block is validated. <br><br>(Default: <code>false</code>, in case of block reorganization).</td><td><code>true</code></td></tr><tr><td><code>tx_hash</code></td><td>No</td><td>Filter on a specific transaction hash.</td><td><code>0xe68b84740**</code></td></tr><tr><td><code>asset</code></td><td>No</td><td>L&#x26;B events including the requested token. Default: all available tokens.</td><td><code>weth or weth,usdt,usdc</code></td></tr><tr><td><code>type</code></td><td>No</td><td>Event type: borrow, deposit, withdraw, repayment or liquidation.</td><td><code>borrow,withdraw</code></td></tr><tr><td><code>block_number</code></td><td>No</td><td>Block height.</td><td><code>10795593</code></td></tr><tr><td><code>start_block</code></td><td>No</td><td>Starting block height (inclusive).</td><td><code>129870</code></td></tr><tr><td><code>end_block</code></td><td>No</td><td>Ending block height (inclusive).</td><td><code>130000</code></td></tr><tr><td><code>start_time</code></td><td>No</td><td>Starting time in ISO 8601 (inclusive).</td><td><code>2022-04-01T00:00:00.000Z</code></td></tr><tr><td><code>end_time</code></td><td>No</td><td>Ending time in ISO 8601 (inclusive).</td><td><code>2022-05-01T00:00:00.000Z</code></td></tr><tr><td><code>sort</code></td><td>No</td><td>Returns the data in ascending or descending order.<br><br>Default: <code>desc</code>.</td><td><code>ascending</code></td></tr><tr><td><code>page_size</code></td><td>No</td><td>Number of snapshots to return data for. (default: 100, min: 1, max: 1000). <br><br>See <a data-mention href="/pages/mP3amLsYqKTsrRBoblxX">/pages/mP3amLsYqKTsrRBoblxX</a></td><td><code>1000</code></td></tr></tbody></table>

### Fields

| Field              | Description                                                      | Example                                      |
| ------------------ | ---------------------------------------------------------------- | -------------------------------------------- |
| `blockchain`       | The blockchain on which the transaction happened.                | `ethereum`                                   |
| `block_number`     | The height of the block in which the transaction happened.       | `16025918`                                   |
| `datetime`         | The timestamp of the block in which the transaction happened.    | `1669124591`                                 |
| `transaction_hash` | Transaction hash                                                 | ---                                          |
| `log_index`        | Log index of the transaction                                     | `152`                                        |
| `protocol`         | Code of the L\&B protocol.                                       | `aave/v2`                                    |
| `type`             | Event type: Borrow, deposit, withdraw, repayment or liquidation. | `borrow`, `deposit`, etc                     |
| `user_address`     | Address of the user.                                             | `0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045` |
| `asset_symbol`     | Symbol of the underlying asset.                                  | `crv`                                        |
| `asset_address`    | Address of the underlying asset.                                 | `0xd533a949740bb3306d119cc777fa900ba034cd52` |
| `asset_decimals`   | Decimals of the underlying asset.                                | `18`                                         |
| `receipt_symbol`   | Symbol of the receipt asset.                                     | `acrv`                                       |
| `receipt_address`  | Address of the receipt asset.                                    | `0x8dae6cb04688c62d939ed9b68d32bc62e49970b1` |
| `receipt_decimals` | Decimals of the receipt asset.                                   | `18`                                         |
| `amount`           | Amounts of the borrowed token.                                   | `299894.78`                                  |
| `metadata`         | Metadata linked to the event type and protocol.                  | More information below.                      |

### Metadata information

**Borrow event:**

| Field            | Description                                                                          | Example                                      |
| ---------------- | ------------------------------------------------------------------------------------ | -------------------------------------------- |
| `amount_receipt` | Amounts of the receipt token.                                                        | `299899`                                     |
| `rate`           | Borrow rate (at the event level or at the contract level depending on the protocol). | `0.02820253961814756`                        |
| `rate_type`      | Stable (1) or Variable (2)                                                           | `1` or `2`                                   |
| `on_behalf_of`   | The address of user who will incur the debt.                                         | `0xeffc18fc3b7eb8e676dac549e0c693ad50d1ce31` |

**Deposit event:**

| Field            | Description                                       | Example                                      |
| ---------------- | ------------------------------------------------- | -------------------------------------------- |
| `amount_receipt` | Amounts of the receipt token.                     | `299899`                                     |
| `rate`           | Supply rate of the overall lending pool.          | `0.000203088325657998768898798`              |
| `on_behalf_of`   | The address that will receive the receipt tokens. | `0xeffc18fc3b7eb8e676dac549e0c693ad50d1ce31` |

**Withdraw event:**&#x20;

| Field            | Description                                         | Example                                      |
| ---------------- | --------------------------------------------------- | -------------------------------------------- |
| `amount_receipt` | Amounts of the receipt token.                       | `299899`                                     |
| `on_behalf_of`   | The address that will receive the underlying token. | `0xeffc18fc3b7eb8e676dac549e0c693ad50d1ce31` |

**Repayment event**

| Field              | Description                                  | Example                                      |
| ------------------ | -------------------------------------------- | -------------------------------------------- |
| `amount_receipt`   | Amounts of the receipt token.                | `299899`                                     |
| `on_behalf_of`     | The address of user who will incur the debt. | `0xeffc18fc3b7eb8e676dac549e0c693ad50d1ce31` |
| `borrow_rate_mode` | Stable (1) or Variable (2)                   | `1` or `2`                                   |

**Liquidation event**

<table><thead><tr><th width="263">Field</th><th width="247">Description</th><th>Example</th></tr></thead><tbody><tr><td><code>liquidation_debt_asset_symbol</code></td><td>Symbol of the debt asset.</td><td><code>renfil</code></td></tr><tr><td><code>liquidation_debt_asset_address</code></td><td>Address of the debt asset.</td><td><code>0xd5147bc8e386d91cc5dbe72099dac6c9b99276f5</code></td></tr><tr><td><code>liquidation_debt_asset_decimals</code></td><td>Decimals of the debt asset.</td><td><code>18</code></td></tr><tr><td><code>liquidation_debt_amount_in_asset</code></td><td>Amount of the debt asset.</td><td><code>1899</code></td></tr><tr><td><code>liquidation_caller_address</code></td><td>The address that triggered the liquidation transaction.</td><td><code>0xdfd3bd446f1b7fd96dc995126ee845af0b1254cd</code></td></tr><tr><td><code>receive_receipt_token</code></td><td>The liquidator chooses to receive the collateral's asset (False) or recept token (True).</td><td><code>True</code> or <code>False</code></td></tr><tr><td><code>liquidation_type</code></td><td>Debt (1) or Collateral (2)</td><td><code>1</code></td></tr></tbody></table>

### Request examples

{% tabs %}
{% tab title="cURL" %}
{% code overflow="wrap" %}

```url
curl --compressed -H 'Accept: application/json' -H 'X-Api-Key: KAIKO_API_KEY' \
  'https://us.market-api.kaiko.io/v2/data/lending.v1/events?blockchain=ethereum&start_time=2024-09-27T13:13:53.441Z&end_time=2024-09-29T13:13:53.441Z'
```

{% endcode %}
{% endtab %}

{% tab title="Python" %}
{% code overflow="wrap" %}

```python
##### 1. Import dependencies #####
import requests
import pandas as pd

##### 2. Choose the value of the query's parameters #####
# ---- Required parameters ---- #
blockchain = "ethereum" 
protocol = "aav2"

# ---- Optional parameters ---- #
user_address = None
live = "false"
tx_hash = None
asset = "weth"
type = "borrow"
block_number = None
start_block = None
end_block = None
start_time = "2025-03-01T13:00:00Z"
end_time = None
sort = "desc"
page_size = 1000

# ---- API key configuration ---- #
api_key = "YOUR_API_KEY"

##### 3. Get the data #####
# ---- Function to run an API call ---- # 
# Get the data in a dataframe --------- # 

def get_kaiko_data(api_key: str, blockchain: str, protocol: str, user_address: str, live: str, tx_hash: str, asset: str, type: str, block_number: int, start_block: int, end_block: int, start_time: str, end_time: str, sort: str, page_size: int):
    headers = {'Accept': 'application/json', 'X-Api-Key': api_key}
    
    url = f'https://eu.market-api.kaiko.io/v2/data/lending.v1/events'
    params = {
        "blockchain": blockchain,
        "protocol": protocol,
        "user_address": user_address,
        "live": live,
        "tx_hash": tx_hash,
        "asset": asset,
        "type": type,
        "block_number": block_number,
        "start_block": start_block,
        "end_block": end_block,
        "start_time": start_time,
        "end_time": end_time,
        "sort": sort,
        "page_size": page_size
    }

    try:
        res = requests.get(url, headers=headers, params=params)
        res.raise_for_status() 
        data = res.json()
        if 'data' not in data:
            print("No data returned.")
            return pd.DataFrame() 
        df = pd.DataFrame(data['data'])

        # Handle pagination with continuation token
        while 'next_url' in data:
            next_url = data['next_url']
            if next_url is None:
                break
            res = requests.get(next_url, headers=headers)
            res.raise_for_status()
            data = res.json()
            if 'data' in data:
                df = pd.concat([df, pd.DataFrame(data['data'])], ignore_index=True)
        return df

    except requests.exceptions.RequestException as e:
        print(f"API request error: {e}")
        return pd.DataFrame() 

# ---- Get the data ---- #
df = get_kaiko_data(api_key=api_key, blockchain=blockchain, protocol=protocol, user_address=user_address, live=live, tx_hash=tx_hash, asset=asset, type=type, block_number=block_number, start_block=start_block, end_block=end_block, start_time=start_time, end_time=end_time, sort=sort, page_size=page_size)
print (df)
```

{% endcode %}
{% endtab %}
{% endtabs %}

### Response example

```json
{
  "query": {
        "blockchain": "*",
        "block_number": "*",
        "asset": "*",
        "user_address": "*",
        "tx_hash": "*",
        "type": "*",
        "start_time": "*",
        "end_time": "*",
        "protocol": "*",
        "sort": "descending",
        "page_size": "1000",
        "start_block": "*",
        "end_block": "*"
    },
    "time": "2022-05-17T14:26:27.274Z",
    "timestamp": 1652797587,
    "data":
    [
        {
            "blockchain": "ethereum",
            "block_number": 16025918,
            "datetime": 1669124591,
            "transaction_hash":"0xa49cfa9c026e728614ca0bdf7272eaaad5b3dd8881fd263ea19ef7d648d9c941",
            "exchange_code": "aave/v2",
            "type": "repayment",
            "user_address": "0x4f381fb46dfde2bc9dcae2d881705749b1ed6e1a",
            "asset_symbol": "crv",
            "asset_address": "0xd533a949740bb3306d119cc777fa900ba034cd52",
            "asset_decimals": 18,
            "receipt_symbol": "acrv",
            "receipt_address": "0x8dae6cb04688c62d939ed9b68d32bc62e49970b1",
            "receipt_decimals": 18,
            "amount": 299894.78,
            "metadata": {
                "borrowRateMode": 2,
                "amountInReceiptAsset": "299894.77",
                "onBehalfOf": "0x4f381fb46dfde2bc9dcae2d881705749b1ed6e1a"
            }
        }
        /* ... */
    ],
    "continuation_token": "xxx",
    "next_url": "https://eu.market-api.kaiko.io/v2/data/lending.v1/events?continuation_token=xxx"
}
```


# Tokens in a liquidity pool

{% hint style="info" %}

### This data is included in the following Kaiko packages:

* Level 1 & Level 2 Data \[Level 2 Aggregations]
* Level 1 & Level 2 Data \[Level 2 Tick-Level]

*DeFi lending & borrowing ticker packs.*
{% endhint %}

### What is this endpoint for? <a href="#what-is-this-endpoint-for" id="what-is-this-endpoint-for"></a>

This indicates the amount of each token available for trading in a liquidity pool, identified through its blockchain pool address. A separate endpoint provides this data specifically for Uniswap V3 liquidity pools.

Read our DEX liquidity snapshot data methodology [here](https://25446524.fs1.hubspotusercontent-eu1.net/hubfs/25446524/Case%20Studies%20%2B%20Data%20Gudies/DEX%20Methodology.pdf).&#x20;

### Endpoint

{% code overflow="wrap" %}

```http
https://us.market-api.kaiko.io/v2/data/liquidity.v1/snapshots
```

{% endcode %}

### Parameters

<table><thead><tr><th width="187">Parameter</th><th width="100">Required</th><th>Description</th><th>Example</th></tr></thead><tbody><tr><td><code>blockchain</code></td><td>No</td><td>Should be one of the currently supported blockchains.<br><br>See <a data-mention href="/pages/a2ImeIv5a9wmXExkWX8W">/pages/a2ImeIv5a9wmXExkWX8W</a></td><td><code>ethereum</code></td></tr><tr><td><code>pool_address</code></td><td>Yes</td><td>Pool address.</td><td><code>0x0d4a11d5eeaac28ec3f61d100daf4d40471f1852</code></td></tr><tr><td><code>live</code></td><td>No</td><td>Shows the data as soon as the block is validated. (Default: false, in case of block reorganization).</td><td><code>true</code></td></tr><tr><td><code>start_block</code></td><td>No</td><td>Starting block height (inclusive).</td><td><code>19645000</code></td></tr><tr><td><code>end_block</code></td><td>No</td><td>Ending block height (inclusive).</td><td><code>19645010</code></td></tr><tr><td><code>start_time</code></td><td>No</td><td>Starting time in ISO 8601 (inclusive).</td><td><code>2022-04-01T00:00:00.000Z</code></td></tr><tr><td><code>end_time</code></td><td>No</td><td>Ending time in ISO 8601 (inclusive).</td><td><code>2022-05-01T00:00:00.000Z</code></td></tr><tr><td><code>sort</code></td><td>No</td><td>Returns the data in ascending (asc) or descending (desc) order. Default: desc.</td><td><code>asc</code></td></tr><tr><td><code>page_size</code></td><td>No</td><td>Number of snapshots to return data for. (default: 1000, min: 1, max: 1000). <br><br>See <a data-mention href="/pages/mP3amLsYqKTsrRBoblxX">/pages/mP3amLsYqKTsrRBoblxX</a></td><td><code>100</code></td></tr></tbody></table>

### Fields

<table><thead><tr><th width="184">Field</th><th width="309">Description</th><th>Example</th></tr></thead><tbody><tr><td><code>blockchain</code></td><td>The blockchain on which the transaction happened.</td><td><code>ethereum</code></td></tr><tr><td><code>block_number</code></td><td>The height of the block.</td><td><code>129876</code></td></tr><tr><td><code>pool_name</code></td><td>Name of the pool as it is written on the blockchain.</td><td><code>WETH-USDT</code></td></tr><tr><td><code>pool_address</code></td><td>Address of the contract of the pool.</td><td><code>0x0d4a11d5eeaac28ec3f61d100daf4d40471f1852</code></td></tr><tr><td><code>exchange</code></td><td>Code of the DEX.</td><td><code>usp2</code></td></tr><tr><td><code>amounts</code></td><td>Snapshot of the liquidity pool's tokens.</td><td>See example</td></tr><tr><td><code>datetime</code></td><td>Timestamp at which the interval begins. In seconds.</td><td><code>1650441900</code></td></tr></tbody></table>

### Request examples

{% tabs %}
{% tab title="cURL" %}
{% code overflow="wrap" %}

```url
curl --compressed -H 'Accept: application/json' -H 'X-Api-Key: KAIKO_API_KEY' \
  'https://us.market-api.kaiko.io/v2/data/liquidity.v1/snapshots?pool_address=0x0d4a11d5eeaac28ec3f61d100daf4d40471f1852&start_block=129870&end_block=129880'
```

{% endcode %}
{% endtab %}

{% tab title="Python" %}
{% code overflow="wrap" %}

```python
##### 1. Import dependencies #####
import requests
import pandas as pd

##### 2. Choose the value of the query's parameters #####
# ---- Required parameters ---- #
pool_address = "0x0d4a11d5eeaac28ec3f61d100daf4d40471f1852"

# ---- Optional parameters ---- #
blockchain = "ethereum"
live = "false"
start_block = "129870"
end_block = "129880"
start_time = None
end_time = None
sort = "desc"
page_size = 100

# ---- API key configuration ---- #
api_key = "YOUR_API_KEY"

##### 3. Get the data #####
# ---- Function to run an API call ---- # 
# Get the data in a dataframe --------- # 
def get_kaiko_data(api_key: str, pool_address: str, blockchain: str, live: str, start_block: str, end_block: str, start_time: str, end_time: str, sort: str, page_size: int):
    headers = {'Accept': 'application/json', 'X-Api-Key': api_key}
    
    url = f'https://eu.market-api.kaiko.io/v2/data/liquidity.v1/snapshots'
    params = {
        "pool_address": pool_address,
        "blockchain": blockchain,
        "live": live,
        "start_block": start_block,
        "end_block": end_block,
        "start_time": start_time,
        "end_time": end_time,
        "sort": sort,
        "page_size": page_size
    }
    
    try:
        res = requests.get(url, headers=headers, params=params)
        res.raise_for_status() 
        data = res.json()
        if 'data' not in data:
            print("No data returned.")
            return pd.DataFrame() 
        df = pd.DataFrame(data['data'])
        # Handle pagination with continuation token
        while 'next_url' in data:
            next_url = data['next_url']
            if next_url is None:
                break
            res = requests.get(next_url, headers=headers)
            res.raise_for_status()
            data = res.json()
            if 'data' in data:
                df = pd.concat([df, pd.DataFrame(data['data'])], ignore_index=True)
        return df
    except requests.exceptions.RequestException as e:
        print(f"API request error: {e}")
        return pd.DataFrame() 

# ---- Get the data ---- #
df = get_kaiko_data(api_key=api_key, pool_address=pool_address, blockchain=blockchain, 
                   live=live, start_block=start_block, end_block=end_block, 
                   start_time=start_time, end_time=end_time, sort=sort, 
                   page_size=int(page_size))
```

{% endcode %}
{% endtab %}
{% endtabs %}

### Response example

```json
{
    "query": {
        "blockchain": "ethereum",
        "protocol": "*",
        "pool_address": "0x0d4a11d5eeaac28ec3f61d100daf4d40471f1852",
        "start_block": "*",
        "end_block": "*",
        "start_time": "*",
        "end_time": "*",
        "live": "false",
        "sort": "descending",
        "page_size": "100",
        "live": "false"
    },
    "time": "2025-03-31T11:16:39.168Z",
    "timestamp": 1743419799,
    "data": [
        {
            "block_number": "22166374",
            "pool_name": "WETH-USDT",
            "pool_address": "0x0d4a11d5eeaac28ec3f61d100daf4d40471f1852",
            "exchange": "usp2",
            "price": 0.000553562,
            "amounts":
            [
                {
                    "symbol": "WETH",
                    "address": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
                    "amount": 3005.5794298594374
                },
                {
                    "symbol": "USDT",
                    "address": "0xdac17f958d2ee523a2206206994597c13d831ec7",
                    "amount": 5389884.464753
                }
            ],
            "datetime": 1743417755,
            "blockchain": "ethereum"
        },
        ...
    ],
    "continuation_token": "xxx",
    "next_url": "https://us.market-api.kaiko.io/v2/data/liquidity.v1/snapshots?continuation_token=xxx"
}
```


# Tokens in a liquidity pool (Uniswap v3)

{% hint style="info" %}

### This data is included in the following Kaiko packages:

* Level 1 & Level 2 Data \[Level 2 Aggregations]
* Level 1 & Level 2 Data \[Level 2 Tick-Level]

*DeFi lending & borrowing ticker packs.*
{% endhint %}

### What is this endpoint for? <a href="#what-is-this-endpoint-for" id="what-is-this-endpoint-for"></a>

The Uniswap V3 Liquidity Estimator offers insight into the token reserves on Uniswap V3.&#x20;

{% hint style="info" %}
This data shows the liquidity across all the price levels for a specific pair of tokens on Uniswap V3. Each price level has a range, which is shown as `lower_tick` (the lowest price of the level) and `upper_tick` (the highest price of the level). The data shows you the amount of tokens and liquidity available at each price level. \
\
We display all price-levels up to 10% either side of the current block price. The data is provided in a block-by-block granularity.\
\
Access the methodology [here](https://www.kaiko.com/reports/the-dex-data-handbook?p=2920\&preview=true\&preview_id=2920\&classic=true).
{% endhint %}

### Endpoint

{% code overflow="wrap" %}

```http
https://eu.market-api.kaiko.io/v2/data/liquidity.v1/snapshots/usp3
```

{% endcode %}

### Parameters

<table><thead><tr><th>Parameter</th><th width="103">Required</th><th>Description</th><th>Example</th></tr></thead><tbody><tr><td><code>pool_address</code></td><td>Yes</td><td>Pool address.</td><td><code>0x88e6a0c2ddd26feeb64f039a2c41296fcb3f5640</code></td></tr><tr><td><code>blockchain</code></td><td>No</td><td>Should be one of the currently supported blockchains.<br><br><a data-mention href="/pages/a2ImeIv5a9wmXExkWX8W">/pages/a2ImeIv5a9wmXExkWX8W</a></td><td><code>ethereum</code></td></tr><tr><td><code>live</code></td><td>No</td><td>Shows the data as soon as the block is validated. <br><br>(Default: <code>false</code>, in case of block reorganization).</td><td><code>true</code></td></tr><tr><td><code>start_block</code></td><td>No</td><td>Starting block height (inclusive).</td><td><code>19645000</code></td></tr><tr><td><code>end_block</code></td><td>No</td><td>Ending block height (inclusive).</td><td><code>19645010</code></td></tr><tr><td><code>start_time</code></td><td>No</td><td>Starting time in ISO 8601 (inclusive).</td><td><code>2022-04-01T00:00:00.000Z</code></td></tr><tr><td><code>end_time</code></td><td>No</td><td>Ending time in ISO 8601 (inclusive).</td><td><code>2022-05-01T00:00:00.000Z</code></td></tr><tr><td><code>price_range</code></td><td>No</td><td>The interval of price around the current price, in % (min: 0, default: 0.1, max: 0.2).</td><td><code>0.05</code></td></tr><tr><td><code>page_size</code></td><td>No</td><td>Number of snapshots to return data for. (default: 10, min: 1, max: 10). <br><br>See <a data-mention href="/pages/mP3amLsYqKTsrRBoblxX">/pages/mP3amLsYqKTsrRBoblxX</a></td><td><code>10</code></td></tr></tbody></table>

### Fields

| Field           | Description                                                                   | Example                                      |
| --------------- | ----------------------------------------------------------------------------- | -------------------------------------------- |
| `blockchain`    | The blockchain on which the transaction happened.                             | `ethereum`                                   |
| `block_number`  | The height of the block.                                                      | `16028979`                                   |
| `pool_name`     | Name of the pool as it is written on the blockchain.                          | `USDC-WETH-0.001`                            |
| `pool_address`  | Address of the contract of the pool.                                          | `0x88e6a0c2ddd26feeb64f039a2c41296fcb3f5640` |
| `current_tick`  | The current tick at this block.                                               | `-58580`                                     |
| `current_price` | The current price at this block, normalized using the pool’s tokens decimals. | `0.0028577887443084`                         |
| `datetime`      | The timestamp of the block. In seconds.                                       | `1669161611`                                 |
| `snapshots`     | The snapshot of the liquidity at each tick of the pool.                       | See table below.                             |

**Field snapshots**

<table><thead><tr><th>Field snapshot</th><th width="278">Description</th><th>Example</th></tr></thead><tbody><tr><td><code>amount0</code></td><td>The amount of token0 in the specified tick range, normalized using the token0 decimals.</td><td><code>0</code></td></tr><tr><td><code>amount1</code></td><td>The amount of token1 in the specified tick range, normalized using the token1 decimals.</td><td><code>26.4381078606</code></td></tr><tr><td><code>amount</code></td><td>The amount of liquidity in the specified tick range.</td><td><code>1.7305248294559624e+23</code></td></tr><tr><td><code>lower_tick</code></td><td>The lower tick of the range.</td><td><code>-59580</code></td></tr><tr><td><code>upper_tick</code></td><td>The upper tick of the range.</td><td><code>-59520</code></td></tr></tbody></table>

### Request examples

{% tabs %}
{% tab title="cURL" %}
{% code overflow="wrap" %}

```url
curl --compressed -H 'Accept: application/json' -H 'X-Api-Key: KAIKO_API_KEY' \
  'https://us.market-api.kaiko.io/v2/data/liquidity.v1/snapshots/usp3?pool_address=0x88e6a0c2ddd26feeb64f039a2c41296fcb3f5640'
```

{% endcode %}
{% endtab %}

{% tab title="Python" %}
{% code overflow="wrap" %}

```python
##### 1. Import dependencies #####
import requests
import pandas as pd

##### 2. Choose the value of the query's parameters #####
# ---- Required parameters ---- #
pool_address = "0x88e6a0c2ddd26feeb64f039a2c41296fcb3f5640"

# ---- Optional parameters ---- #
blockchain = "ethereum"
live = "false"
start_block = None
end_block = None
start_time = "2022-04-01T00:00:00.000Z"
end_time = "2022-04-01T00:02:00.000Z"
sort = "desc"
price_range = None
page_size = 100

# ---- API key configuration ---- #
api_key = "YOUR_API_KEY"

##### 3. Get the data #####
# ---- Function to run an API call ---- # 
# Get the data in a dataframe --------- # 
def get_kaiko_data(api_key: str, pool_address: str, blockchain: str, live: str, 
                  start_block: str, end_block: str, start_time: str, 
                  end_time: str, sort: str, price_range: str, page_size: int):
    headers = {'Accept': 'application/json', 'X-Api-Key': api_key}
    
    url = f'https://eu.market-api.kaiko.io/v2/data/liquidity.v1/snapshots/usp3'
    params = {
        "pool_address": pool_address,
        "blockchain": blockchain,
        "live": live,
        "start_block": start_block,
        "end_block": end_block,
        "start_time": start_time,
        "end_time": end_time,
        "sort": sort,
        "price_range": price_range,
        "page_size": page_size
    }
    
    try:
        res = requests.get(url, headers=headers, params=params)
        res.raise_for_status() 
        data = res.json()
        if 'data' not in data:
            return pd.DataFrame() 
        df = pd.DataFrame(data['data'])
        # Handle pagination with continuation token
        while 'next_url' in data:
            next_url = data['next_url']
            if next_url is None:
                break
            res = requests.get(next_url, headers=headers)
            res.raise_for_status()
            data = res.json()
            if 'data' in data:
                df = pd.concat([df, pd.DataFrame(data['data'])], ignore_index=True)
        return df
    except requests.exceptions.RequestException as e:
        return pd.DataFrame() 

# ---- Get the data ---- #
df = get_kaiko_data(api_key=api_key, pool_address=pool_address, blockchain=blockchain, 
                   live=live, start_block=start_block, end_block=end_block, 
                   start_time=start_time, end_time=end_time, sort=sort, 
                   price_range=price_range, page_size=int(page_size))
```

{% endcode %}
{% endtab %}
{% endtabs %}

### Response example&#x20;

```json
{
    "query": {
        "blockchain": "ethereum",
        "protocol": "usp3",
        "pool_address": "0x88e6a0c2ddd26feeb64f039a2c41296fcb3f5640",
        "start_block": "*",
        "end_block": "*",
        "start_time": "*",
        "end_time": "*",
        "sort": "descending",
        "page_size": "10",
        "live": "false",
        "price_range": "0.1"
    },
    "time": "2024-09-27T14:03:53.973Z",
    "timestamp": 1727445833,
    "data": [
        {
            "block_number": "20842364",
            "pool_name": "liquidity_pool",
            "pool_address": "0x88e6a0c2ddd26feeb64f039a2c41296fcb3f5640",
            "current_tick": "197507",
            "current_price": 0.00037773843033961135,
            "datetime": 1727444963,
            "blockchain": "ethereum",
            "exchange": "usp3",
            "snapshots": [
                {
                    "amount0": 0,
                    "amount1": 21.540770877363897,
                    "amount": 2335301572930716700,
                    "lower_tick": 196460,
                    "upper_tick": 196470
                },
                {
                    "amount0": 0,
                    "amount1": 21.58927177741234,
                    "amount": 2339389776616961000,
                    "lower_tick": 196470,
                    "upper_tick": 196480
                },
                ...
            ]
        },
        ...
     ],
    "continuation_token": "xxx",
    "next_url": "https://us.market-api.kaiko.io/v2/data/liquidity.v1/snapshots/usp3?continuation_token=xxx"
 }
     
```


# Interest rates, borrowed and deposited amounts

{% hint style="info" %}

### This data is included in the following Kaiko packages:

* Level 1 & Level 2 Data \[Level 2 Aggregations]
* Level 1 & Level 2 Data \[Level 2 Tick-Level]

*DeFi lending & borrowing ticker packs.*
{% endhint %}

### What is this endpoint for? <a href="#what-is-this-endpoint-for" id="what-is-this-endpoint-for"></a>

This endpoint provides information about lending pools. It shows data such as how many tokens has been deposited and borrowed, as well as the interest rates for lending and borrowing at each block.

### Endpoint

{% code overflow="wrap" %}

```http
https://eu.market-api.kaiko.io/v2/data/lending.v1/snapshots
```

{% endcode %}

### Parameters

<table><thead><tr><th>Parameter</th><th width="88" data-type="checkbox">Mandatory?</th><th width="272">Description</th><th>Example</th></tr></thead><tbody><tr><td><code>blockchain</code></td><td>false</td><td>One or several of the currently supported blockchain. <br><br>Default: <code>ethereum</code>.<br><br>See <a data-mention href="/pages/a2ImeIv5a9wmXExkWX8W">/pages/a2ImeIv5a9wmXExkWX8W</a></td><td><code>ethereum</code></td></tr><tr><td><code>protocol</code></td><td>true</td><td>One or several of the currently supported L&#x26;B protocols.</td><td><code>aav1</code></td></tr><tr><td><code>asset</code></td><td>true</td><td>L&#x26;B events including the requested token. Default: all available tokens.</td><td><code>tusd</code></td></tr><tr><td><code>live</code></td><td>false</td><td>Shows the data as soon as the block is validated. <br><br>(Default: <code>false</code>, in case of block reorganization).</td><td><code>true</code></td></tr><tr><td><code>block_number</code></td><td>false</td><td>Block height.</td><td><code>10795593</code></td></tr><tr><td><code>start_block</code></td><td>false</td><td>Starting block height (inclusive).</td><td><code>129870</code></td></tr><tr><td><code>end_block</code></td><td>false</td><td>Ending block height (inclusive).</td><td><code>130000</code></td></tr><tr><td><code>start_time</code></td><td>false</td><td>Starting time in ISO 8601 (inclusive).</td><td><code>2022-04-01T00:00:00.000Z</code></td></tr><tr><td><code>end_time</code></td><td>false</td><td>Ending time in ISO 8601 (inclusive).</td><td><code>2022-05-01T00:00:00.000Z</code></td></tr><tr><td><code>interval</code></td><td>false</td><td>Interval between each snapshot. The suffixes are s (second), m (minute), h (hour), d (day), b (block), change (whenever a change happens). Default: 1b.</td><td><code>152s</code></td></tr><tr><td><code>sort</code></td><td>false</td><td>Returns the data in ascending or descending order. Default: desc.</td><td><code>ascending</code></td></tr><tr><td><code>page_size</code></td><td>false</td><td>Number of snapshots to return data for. <br><br>(default: <code>100</code>, min: 1, max: <code>1000</code>). <br><br>See <a data-mention href="/pages/mP3amLsYqKTsrRBoblxX">/pages/mP3amLsYqKTsrRBoblxX</a></td><td><code>1000</code></td></tr></tbody></table>

### Fields

| Field                  | Description                                                   | Example                                      |
| ---------------------- | ------------------------------------------------------------- | -------------------------------------------- |
| `blockchain`           | The blockchain on which the transaction happened.             | `ethereum`                                   |
| `block_number`         | The height of the block in which the transaction happened.    | `16025918`                                   |
| `datetime`             | The timestamp of the block in which the transaction happened. | `1669124591`                                 |
| `protocol`             | Code of the L\&B protocol.                                    | `aave/v2`                                    |
| `asset_symbol`         | Symbol of the underlying asset.                               | `crv`                                        |
| `asset_address`        | Address of the underlying asset.                              | `0xd533a949740bb3306d119cc777fa900ba034cd52` |
| `asset_decimals`       | Decimals of the underlying asset.                             | `18`                                         |
| `receipt_symbol`       | Symbol of the receipt asset.                                  | `acrv`                                       |
| `receipt_address`      | Address of the receipt asset.                                 | `0x8dae6cb04688c62d939ed9b68d32bc62e49970b1` |
| `receipt_decimals`     | Decimals of the receipt asset.                                | `18`                                         |
| `total_liquidity`      | The total amount of liquidity for this pool.                  | `1486160`                                    |
| `available_liquidity`  | The total amount of available liquidity for this pool.        | `1279630`                                    |
| `total_borrowed`       | The total amount of tokens borrowed for this pool.            | `206535`                                     |
| `supply_rate`          | The supply rate.                                              | `0.00289186`                                 |
| `stable_borrow_rate`   | The stable borrow rate.                                       | `0.0442648`                                  |
| `variable_borrow_rate` | The variable borrow rate.                                     | `0.0208089`                                  |
| `metadata`             | Metadata specific to each protocol.                           | More information below                       |

### Metadata information

**AAVE v1**

<table><thead><tr><th>Field</th><th width="334">Description</th><th>Example</th></tr></thead><tbody><tr><td><code>total_borrowed_stable</code></td><td>The total amount of assets borrowed with a stable rate for this pool.</td><td><code>0</code></td></tr><tr><td><code>total_borrowed_variable</code></td><td>The total amount of assets borrowed with a variable rate for this pool.</td><td><code>41872.928778</code></td></tr></tbody></table>

**AAVE v2**

<table><thead><tr><th>Field</th><th width="333">Description</th><th>Example</th></tr></thead><tbody><tr><td><code>total_borrowed_stable</code></td><td>The total amount of assets borrowed with a stable rate for this pool.</td><td><code>4162389.524515</code></td></tr><tr><td><code>total_borrowed_variable</code></td><td>The total amount of assets borrowed with a variable rate for this pool.</td><td><code>345075360.304631</code></td></tr><tr><td><code>total_reserves</code></td><td>Total liquidity - All of the debt tokens supply.</td><td><code>51387128.92415</code></td></tr></tbody></table>

**Compound**

<table><thead><tr><th>Field</th><th width="288">Description</th><th>Example</th></tr></thead><tbody><tr><td><code>total_reserves</code></td><td>Total liquidity - All of the debt tokens supply.</td><td><code>3486037.365878</code></td></tr></tbody></table>

**Cream**

<table><thead><tr><th>Field</th><th width="298">Description</th><th>Example</th></tr></thead><tbody><tr><td><code>total_reserves</code></td><td>Total liquidity - All of the debt tokens supply.</td><td><code>033661.402437</code></td></tr></tbody></table>

**Maker**

<table><thead><tr><th>Field</th><th width="305">Description</th><th>Example</th></tr></thead><tbody><tr><td><code>collateral_ratio</code></td><td>Minimum ratio of collateral before liquidation.</td><td><code>1.5</code></td></tr><tr><td><code>debt_ceiling</code></td><td>Maximum amount of DAI that can be emitted on this type of vault.</td><td><code>2500000</code></td></tr><tr><td><code>debt_floor</code></td><td>Minimum amount of DAI that can be minted for this type of Vault.</td><td><code>2000</code></td></tr></tbody></table>

### Request example

{% tabs %}
{% tab title="cURL" %}
{% code overflow="wrap" %}

```url
curl --compressed \
  -H 'Accept: application/json' \
  -H 'X-Api-Key: <client-api-key>' \
  'https://eu.market-api.kaiko.io/v2/data/lending.v1/snapshots?protocol=aav1&asset=tusd'
```

{% endcode %}
{% endtab %}

{% tab title="Python" %}

```python
##### 1. Import dependencies #####
import requests
import pandas as pd

##### 2. Choose the value of the query's parameters #####
# ---- Required parameters ---- #
blockchain = "ethereum" 
protocol = "aav2"
asset = "tusd"

# ---- Optional parameters ---- #
user_address = None
live = "false"
tx_hash = None
block_number = None
start_block = None
end_block = None
start_time = "2025-03-01T13:00:00Z"
end_time = "2025-03-01T13:10:00Z"
sort = "desc"
page_size = 1000
interval = None

# ---- API key configuration ---- #
api_key = "YOUR_API_KEY"

##### 3. Get the data #####
# ---- Function to run an API call ---- # 
# Get the data in a dataframe --------- # 

def get_kaiko_data(api_key: str, blockchain: str, protocol: str, asset: str, user_address: str, live: str, tx_hash: str, block_number: int, start_block: int, end_block: int, start_time: str, end_time: str, interval: str, sort: str, page_size: int):
    headers = {'Accept': 'application/json', 'X-Api-Key': api_key}
    
    url = f'https://eu.market-api.kaiko.io/v2/data/lending.v1/snapshots'
    params = {
        "blockchain": blockchain,
        "protocol": protocol,
        "asset": asset,
        "user_address": user_address,
        "live": live,
        "tx_hash": tx_hash,
        "block_number": block_number,
        "start_block": start_block,
        "end_block": end_block,
        "start_time": start_time,
        "end_time": end_time,
        "interval": interval,
        "sort": sort,
        "page_size": page_size
    }

    try:
        res = requests.get(url, headers=headers, params=params)
        res.raise_for_status() 
        data = res.json()
        if 'data' not in data:
            print("No data returned.")
            return pd.DataFrame() 
        df = pd.DataFrame(data['data'])

        # Handle pagination with continuation token
        while 'next_url' in data:
            next_url = data['next_url']
            if next_url is None:
                break
            res = requests.get(next_url, headers=headers)
            res.raise_for_status()
            data = res.json()
            if 'data' in data:
                df = pd.concat([df, pd.DataFrame(data['data'])], ignore_index=True)
        return df

    except requests.exceptions.RequestException as e:
        print(f"API request error: {e}")
        return pd.DataFrame() 

# ---- Get the data ---- #
df = get_kaiko_data(api_key=api_key, blockchain=blockchain, protocol=protocol, asset=asset, user_address=user_address, live=live, tx_hash=tx_hash, block_number=block_number, start_block=start_block, end_block=end_block, start_time=start_time, end_time=end_time, interval=interval, sort=sort, page_size=page_size)
print (df)
```

{% endtab %}
{% endtabs %}

### Response example

```json
{
            "blockchain": "ethereum",
            "block_number": "21093894",
            "datetime": 1730477315,
            "market_id": "aave/v1/tusd",
            "protocol": "aav1",
            "asset_symbol": "tusd",
            "asset_address": "0x0000000000085d4780b73119b644ae5ecd22b376",
            "asset_decimals": "18",
            "receipt_symbol": "atusd",
            "receipt_address": "0x4da9b813057d04baef4e5800e36083717b4a0341",
            "receipt_decimals": "18",
            "available_liquidity": 293515.77258708066,
            "total_borrowed": 10897.083558481298,
            "total_liquidity": 304412.85614556196,
            "supply_rate": 0,
            "stable_borrow_rate": 0,
            "variable_borrow_rate": 0,
            "metadata": {
                "total_borrowed_stable": "0",
                "total_borrowed_variable": "10897.083558481297049061"
            }
        },
```


# Fair Market Value

Accurately value your digital assets to meet fair value standards and regulatory requirements.


# Direct price

{% hint style="info" %}

### This data is included in the following Kaiko packages:

* Kaiko Fair Market Value \[Established Assets]
* Kaiko Fair Market Value \[Full Coverage]
  {% endhint %}

### What is this endpoint for? <a href="#what-is-this-endpoint-for" id="what-is-this-endpoint-for"></a>

This endpoint returns a price calculation for a specific pair by aggregating prices from our Trade Data.&#x20;

Read the full methodology [here](https://25446524.fs1.hubspotusercontent-eu1.net/hubfs/25446524/Factsheets/Kaiko%20Pricing%20Services%20Methodology.pdf).&#x20;

{% hint style="info" %}
If a null value is returned, it means there are not enough trades to calculate a direct price. In this case, use [Synthetic price](/rest-api/analytics/fair-market-value/synthetic-price) instead.
{% endhint %}

### Endpoint

{% code overflow="wrap" %}

```http
https://<eu|us>.market-api.kaiko.io/v2/data/trades.v1/robust_pair_price/{base_asset}/{quote_asset}
```

{% endcode %}

### Path parameters

<table><thead><tr><th width="203">Parameter	</th><th width="106">Required</th><th>Description</th></tr></thead><tbody><tr><td><code>base_asset</code></td><td>Yes</td><td>The desired base asset <code>code</code>.<br><br>See <a data-mention href="/pages/5iH1qlIc7aNEOOci4yMw">/pages/5iH1qlIc7aNEOOci4yMw</a></td></tr><tr><td><code>quote_asset</code></td><td>Yes</td><td>The desired quote asset <code>code</code>.<br><br>See <a data-mention href="/pages/5iH1qlIc7aNEOOci4yMw">/pages/5iH1qlIc7aNEOOci4yMw</a></td></tr><tr><td><code>sort</code></td><td>No</td><td>Return the data in ascending (<code>asc</code>) or descending (<code>desc</code>) order. Default is <code>desc</code>.</td></tr></tbody></table>

### Query parameters

<table><thead><tr><th width="248.64453125">Parameter	</th><th width="105.84375">Required</th><th>Description</th></tr></thead><tbody><tr><td><code>interval</code></td><td>Yes</td><td>The interval parameter is suffixed with <code>s</code>, <code>m</code>, <code>h</code> or <code>d</code> to specify seconds, minutes, hours or days, respectively.<br><br>Any arbitrary value between one second and one day can be used, as long as it sums up to a maximum of 1 day. The suffixes are <code>s</code> (second), <code>m</code> (minute), <code>h</code> (hour) and <code>d</code> (day).<br><br> Default <code>24h</code>.</td></tr><tr><td><code>start_time</code></td><td>No</td><td>Starting time in ISO 8601 (inclusive).<br><br><em>Automatically included in continuation tokens.</em></td></tr><tr><td><code>end_time</code></td><td>No</td><td>Ending time in ISO 8601 (exclusive)<br><br><em>Automatically included in continuation tokens.</em></td></tr><tr><td><code>page_size</code></td><td>No</td><td><p>See <a data-mention href="/pages/mP3amLsYqKTsrRBoblxX">/pages/mP3amLsYqKTsrRBoblxX</a><br><br><strong>Page size limits differ by the <code>interval</code> selected:</strong></p><ul><li>Less than or equal to <code>1m</code><br> Default: <code>10</code>, Max: <code>100</code></li><li><code>1m</code> to <code>1h</code><br>Default: <code>4</code>, Max: <code>10</code></li><li>More than <code>1h</code><br>Default: <code>1</code>, Max: <code>4</code></li></ul><p><em>Automatically included in continuation tokens.</em></p></td></tr><tr><td><code>sort</code></td><td>No</td><td>Return the data in ascending (<code>asc</code>) or descending (<code>desc</code>) order. Default is <code>desc</code>.</td></tr><tr><td><code>include_exchanges</code></td><td>No</td><td>List of exchanges' <code>code</code> to include in the calculation.<br><br><a data-mention href="/pages/QiW5iUvcyBF9RISFmZFV">/pages/QiW5iUvcyBF9RISFmZFV</a><br><br>Default is all exchanges.<br><br><em>Automatically included in continuation tokens.</em></td></tr><tr><td><code>exclude_exchanges</code></td><td>No</td><td>List of exchanges' <code>code</code> to exclude in the calculation.<br><br><a data-mention href="/spaces/bvJkzmxJbcDMceEJsq2K/pages/vGAuhofqiYGAJCYlarFi">/spaces/bvJkzmxJbcDMceEJsq2K/pages/vGAuhofqiYGAJCYlarFi</a><br><br><em>Automatically included in continuation tokens.</em></td></tr><tr><td><code>extrapolate_missing_values</code></td><td>No</td><td>When <code>true</code>, if there are any <code>null</code> (missing) prices for the calculation, they will be filled in using the last available price from the window requested. This is useful for assets that don't have a lot of trades or for data that is collected very frequently.<br><br>However, if the parameter is set to <code>true</code> and no prices were available in that window, a <code>null</code> value will still be returned.</td></tr><tr><td><code>enable_price_metrics</code></td><td>No</td><td>When <code>true</code>, the response includes a <code>price_metrics</code> object containing the <code>stress_market_indicator</code>, a standardized metric indicating how fragmented or stressed the market is at a given point in time.</td></tr></tbody></table>

### Fields

<table><thead><tr><th width="283">Field</th><th>Description</th></tr></thead><tbody><tr><td><code>timestamp</code></td><td>Timestamp at which the interval begins.</td></tr><tr><td><code>price</code></td><td><a href="https://hal.science/hal-04017151v1/document">RWM Robust Weighted Median</a>. <br><br><code>null</code> when no trades reported, except if <code>extrapolate_missing_values</code> is <code>true</code></td></tr><tr><td><code>volume</code></td><td><p>Total volume in base asset traded in the interval. <br></p><p><code>0</code> when no trades are reported, except if <code>extrapolate_missing_values</code> is <code>true</code>.</p></td></tr><tr><td><code>count</code></td><td>Total amount of trades reported during the interval. <br><br><code>0</code> when no trades are reported, except if <code>extrapolate_missing_values</code> is <code>true</code>.</td></tr><tr><td><code>extrapolate_missing_values</code></td><td><code>true</code> if the value has been extrapolated from the last computed value available, <code>false</code> if not.</td></tr><tr><td><code>price_metrics</code></td><td>Contains <code>ci_left</code> and <code>ci_right</code> , the lower and upper bounds of the 99% confidence interval around the direct price. And the <code>stress_market_indicator</code>.</td></tr></tbody></table>

### Request examples

{% tabs %}
{% tab title="cURL" %}
{% code overflow="wrap" %}

```url
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'
```

{% endcode %}
{% endtab %}

{% tab title="Python" %}
{% code overflow="wrap" %}

```python
##### 1. Import dependencies #####
import requests
import pandas as pd

##### 2. Choose the value of the query's parameters #####
# ---- Required parameters ---- #
base_asset = "btc"
quote_asset = "usd"
interval = "1h"

# ---- Optional parameters ---- #
sort = "desc"
page_size = 4
start_time= "2023-01-01T00:00:00Z"
end_time= "2023-01-01T23:59:59Z"
include_exchanges = None
exclude_exchanges = None
extrapolate_missing_values = None

# ---- API key configuration ---- #
api_key = "YOUR_API_KEY"

##### 3. Get the data #####
# ---- Function to run an API call ---- # 
# Get the data in a dataframe --------- # 

def get_kaiko_data(api_key: str, base_asset: str, quote_asset: str, interval: str, start_time: str, end_time: str, sort: str, page_size: int, include_exchanges: list = None, exclude_exchanges: list = None, extrapolate_missing_values: bool = None):
    headers = {'Accept': 'application/json', 'X-Api-Key': api_key}
    
    url = f'https://us.market-api.kaiko.io/v2/data/trades.v1/robust_pair_price/{base_asset}/{quote_asset}'
    params = {
        "start_time": start_time,
        "end_time": end_time,
        "sort": sort,
        "page_size": page_size,
        "interval": interval,
        "include_exchanges": include_exchanges,
        "exclude_exchanges": exclude_exchanges,
        "extrapolate_missing_values": extrapolate_missing_values
    }

    try:
        res = requests.get(url, headers=headers, params=params)
        res.raise_for_status() 
        data = res.json()
        if 'data' not in data:
            print("No data returned.")
            return pd.DataFrame() 
        df = pd.DataFrame(data['data'])

           # Handle pagination with continuation token
        while 'next_url' in data:
            next_url = data['next_url']
            if next_url is None:
                break
            res = requests.get(next_url, headers=headers)
            res.raise_for_status()
            data = res.json()
            if 'data' in data:
                df = pd.concat([df, pd.DataFrame(data['data'])], ignore_index=True)
        return df

    except requests.exceptions.RequestException as e:
        print(f"API request error: {e}")
        return pd.DataFrame() 

# ---- Get the data ---- #
df = get_kaiko_data(api_key=api_key, base_asset=base_asset, quote_asset=quote_asset, interval=interval, start_time=start_time, end_time=end_time, sort=sort, page_size=page_size, include_exchanges=include_exchanges, exclude_exchanges=exclude_exchanges, extrapolate_missing_values=extrapolate_missing_values)
print (df)
```

{% endcode %}
{% endtab %}
{% endtabs %}

### Response example

```json
{
  "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
    }
  }
}
```


# Synthetic price

{% hint style="info" %}

### This data is included in the following Kaiko packages:

* Kaiko Fair Market Value \[Established Assets]
* Kaiko Fair Market Value \[Full Coverage]
  {% endhint %}

### What is this endpoint for? <a href="#what-is-this-endpoint-for" id="what-is-this-endpoint-for"></a>

This endpoint calculates a synthetic price when there is no liquidity (historic trades) between two assets (fiat or digital). Let's say, for example, there was no liquidity between NEXO and GBP, but you need a price. To calculate this, the liquidity engine will use a series of intermediary assets where there is liquidity (lots of trading history) to calculate the price for NEXO > GBP.  \
\
To demonstrate how this calculation works, the engine might take the price for NEXO > BTC (where there is plenty of liquidity) and then the price of BTC > GBP (where there is also lots of liquidity) and combine the two to determine a robust synthetic price for NEXO > GBP. The engine will always use the path of highest liquidity, meaning several intermediary assets might be used.&#x20;

Read the full methodology [here](https://25446524.fs1.hubspotusercontent-eu1.net/hubfs/25446524/Factsheets/Kaiko%20Pricing%20Services%20Methodology.pdf).&#x20;

{% hint style="warning" %}
When using a synthetic price, in order to to meet IFRS-compliance standards, any fiat currency value should be requested in USD and converted using the [Oanda FX Rates add-on](/rest-api/analytics/fair-market-value/synthetic-price/convert-with-oanda-fx-rates).&#x20;
{% endhint %}

### HTTP Request

{% code overflow="wrap" %}

```http
https://<eu|us>.market-api.kaiko.io/v2/data/trades.v2/spot_exchange_rate/{base_asset}/{quote_asset}
```

{% endcode %}

### Path parameters

<table><thead><tr><th width="182">Parameter</th><th width="105">Required</th><th>Description</th></tr></thead><tbody><tr><td><code>base_asset</code></td><td>Yes</td><td>The desired base asset <code>code</code>.<br><br>See <a data-mention href="/pages/5iH1qlIc7aNEOOci4yMw">/pages/5iH1qlIc7aNEOOci4yMw</a></td></tr><tr><td><code>quote_asset</code></td><td>Yes</td><td>The desired quote asset <code>code</code>.<br><br>See <a data-mention href="/pages/5iH1qlIc7aNEOOci4yMw">/pages/5iH1qlIc7aNEOOci4yMw</a></td></tr></tbody></table>

### Query parameters

<table><thead><tr><th width="182">Parameter</th><th width="105">Required</th><th>Description</th></tr></thead><tbody><tr><td><code>start_time</code></td><td>No</td><td>Start time in ISO 8601 (exclusive).<br><br><em>Automatically included in continuation tokens.</em></td></tr><tr><td><code>end_time</code></td><td>No</td><td>Ending time in ISO 8601 (exclusive).<br><br><em>Automatically included in continuation tokens.</em></td></tr><tr><td><code>interval</code></td><td>No</td><td>The interval parameter is suffixed with <code>s</code>, <code>m</code>, <code>h</code> or <code>d</code> to specify seconds, minutes, hours or days, respectively.<br><br>Any arbitrary value between one second and one day can be used, as long as it sums up to a maximum of 1 day. The suffixes are <code>s</code> (second), <code>m</code> (minute), <code>h</code> (hour) and <code>d</code> (day).<br><br> Default <code>1d</code>.</td></tr><tr><td><code>page_size</code></td><td>No</td><td><p>See <a data-mention href="/pages/mP3amLsYqKTsrRBoblxX">/pages/mP3amLsYqKTsrRBoblxX</a><br><br><strong>Page size limits differ by the <code>interval</code> selected:</strong></p><ul><li>Less than or equal to <code>1m</code><br> Default: <code>10</code>, Max: <code>100</code></li><li><code>1m</code> to <code>1h</code><br>Default: <code>4</code>, Max: <code>10</code></li><li>More than <code>1h</code><br>Default: <code>1</code>, Max: <code>4</code></li></ul><p><em>Automatically included in continuation tokens.</em></p></td></tr><tr><td><code>sort</code></td><td>No</td><td>Return the data in ascending (<code>asc</code>) or descending (<code>desc</code>) order. Default is <code>desc</code>.<br><br><em>Automatically included in continuation tokens.</em></td></tr><tr><td><code>include_exchanges</code></td><td>No</td><td>List of exchanges' <code>code</code> to include in the calculation.<br><br><a data-mention href="/pages/QiW5iUvcyBF9RISFmZFV">/pages/QiW5iUvcyBF9RISFmZFV</a><br><br>Default is all exchanges.<br><br><em>Automatically included in continuation tokens.</em></td></tr><tr><td><code>exclude_exchanges</code></td><td>No</td><td>List of exchanges' <code>code</code> to exclude in the calculation.<br><br><a data-mention href="/spaces/bvJkzmxJbcDMceEJsq2K/pages/vGAuhofqiYGAJCYlarFi">/spaces/bvJkzmxJbcDMceEJsq2K/pages/vGAuhofqiYGAJCYlarFi</a><br><br><em>Automatically included in continuation tokens.</em></td></tr><tr><td><code>extrapolate_missing_values</code></td><td>No</td><td>When <code>true</code>, if there are any <code>null</code> (missing) prices for the calculation, they will be filled in using the last available price from the window requested. This is useful for assets that don't have a lot of trades or for data that is collected very frequently.<br><br>However, if the parameter is set to <code>true</code> and no prices were available in that window, a <code>null</code> value will still be returned.</td></tr><tr><td><code>sources</code></td><td>No</td><td>When <code>true,</code> the response includes the intermediary pair price details used to calculate the price.<br><br>Default: <code>false</code></td></tr><tr><td><code>enable_price_metrics</code></td><td>No</td><td>When <code>true</code>, the response includes a <code>price_metrics</code> object containing the <code>stress_market_indicator</code>, a standardized metric indicating how fragmented or stressed the market is at a given point in time.</td></tr></tbody></table>

### Fields

<table><thead><tr><th width="224">Field</th><th>Description</th></tr></thead><tbody><tr><td><code>timestamp</code></td><td>Timestamp at which the interval begins.</td></tr><tr><td><code>price</code></td><td>Aggregated <a href="https://hal.science/hal-04017151v1/document">Robust Weighted Median</a> using liquidity path engine. <br><br><code>null</code> when no trades reported, except if <code>extrapolate_missing_values</code> is <code>true</code>.<br><br><em>Liquidity path is calculated every 4 hours seeking for the most liquid pairs to convert from base asset to quote asset.</em></td></tr><tr><td><code>extrapolate_missing_values</code></td><td><code>true</code> if the value has been extrapolated from the last computed value available, <code>false</code> if not.</td></tr><tr><td><code>price_metrics</code></td><td>Contains <code>ci_left</code> and <code>ci_right</code> , the lower and upper bounds of the 99% confidence interval around the direct price. And the <code>stress_market_indicator</code>.</td></tr></tbody></table>

### Request examples

{% tabs %}
{% tab title="cURL" %}
{% code overflow="wrap" %}

```url
curl --compressed -H 'Accept: application/json' -H 'X-Api-Key: <client-api-key>' \
  'https://us.market-api.kaiko.io/v2/data/trades.v2/spot_exchange_rate/dash/usd?interval=1m&extrapolate_missing_values=true&start_time=2023-05-03T00:01:00.000Z&end_time=2023-05-04T00:00:00.000Z'
```

{% endcode %}
{% endtab %}

{% tab title="Python" %}

```python
##### 1. Import dependencies #####
import requests
import pandas as pd

##### 2. Choose the value of the query's parameters #####
# ---- Required parameters ---- #
base_asset = "btc"
quote_asset = "usd"

# ---- Optional parameters ---- #
interval = "1h"
sort = "desc"
page_size = 4
start_time= "2023-01-01T00:00:00Z"
end_time= "2023-01-01T23:59:59Z"
include_exchanges = None
exclude_exchanges = None
extrapolate_missing_values = None
sources = None

# ---- API key configuration ---- #
api_key = "YOUR_API_KEY"

##### 3. Get the data #####
# ---- Function to run an API call ---- # 
# Get the data in a dataframe --------- # 

def get_kaiko_data(api_key: str, base_asset: str, quote_asset: str, start_time: str, end_time: str, interval: str, sort: str, page_size: int, include_exchanges: list = None, exclude_exchanges: list = None, extrapolate_missing_values: bool = None, sources: bool = None):
    headers = {'Accept': 'application/json', 'X-Api-Key': api_key}
    
    url = f'https://us.market-api.kaiko.io/v2/data/trades.v2/spot_exchange_rate/{base_asset}/{quote_asset}'
    params = {
        "start_time": start_time,
        "end_time": end_time,
        "sort": sort,
        "page_size": page_size,
        "interval": interval,
        "include_exchanges": include_exchanges,
        "exclude_exchanges": exclude_exchanges,
        "extrapolate_missing_values": extrapolate_missing_values,
        "sources": sources
    }

    try:
        res = requests.get(url, headers=headers, params=params)
        res.raise_for_status() 
        data = res.json()
        if 'data' not in data:
            print("No data returned.")
            return pd.DataFrame() 
        df = pd.DataFrame(data['data'])

        # Handle pagination with continuation token
        while 'next_url' in data:
            next_url = data['next_url']
            if next_url is None:
                break
            res = requests.get(next_url, headers=headers)
            res.raise_for_status()
            data = res.json()
            if 'data' in data:
                df = pd.concat([df, pd.DataFrame(data['data'])], ignore_index=True)
        return df

    except requests.exceptions.RequestException as e:
        print(f"API request error: {e}")
        return pd.DataFrame() 

# ---- Get the data ---- #
df = get_kaiko_data(api_key=api_key, base_asset=base_asset, quote_asset=quote_asset, interval=interval, start_time=start_time, end_time=end_time, sort=sort, page_size=page_size, include_exchanges=include_exchanges, exclude_exchanges=exclude_exchanges, extrapolate_missing_values=extrapolate_missing_values, sources=sources)
print (df)
```

{% endtab %}
{% endtabs %}

### Response example

```json
{
  "query": {
    "start_time": "2023-05-03T00:01:00Z",
    "end_time": "2023-05-04T00:00:00Z",
    "page_size": 10,
    "base_asset": "dash",
    "quote_asset": "usd",
    "interval": "1m",
    "sort": "desc",
    "sources": false,
    "include_exchanges": [],
    "exclude_exchanges": [],
    "data_version": "v1",
    "commodity": "trades",
    "request_time": "2024-07-11T08:10:21.828Z",
    "instruments": [
      "bbsp:spot:btc-usdt",
      "bfnx:spot:btc-usdt",
      "bgon:spot:btc-usdt",
      "binc:spot:btc-usdt",
      "bnus:spot:btc-usdt",
      "bull:spot:btc-usdt",
      "cbse:spot:btc-usdt",
      "cnex:spot:btc-usdt",
      "gmni:spot:btc-usdt",
      "kcon:spot:btc-usdt",
      "krkn:spot:btc-usdt",
      "okex:spot:btc-usdt",
      "stmp:spot:btc-usdt",
      "bfnx:spot:dash-btc",
      "binc:spot:dash-btc",
      "cbse:spot:dash-btc",
      "cnex:spot:dash-btc",
      "yobt:spot:dash-btc",
      "bfnx:spot:usdt-usd",
      "bnus:spot:usdt-usd",
      "cbse:spot:usdt-usd",
      "gmni:spot:usdt-usd",
      "krkn:spot:usdt-usd",
      "stmp:spot:usdt-usd"
    ],
    "start_timestamp": 1683157800000,
    "end_timestamp": 1683158400000,
    "extrapolate_missing_values": true
  },
  "time": "2024-07-11T08:10:21.891Z",
  "timestamp": 1720685421891,
  "data": [
    {
      "timestamp": 1683158340000,
      "price": "49.263380298334226",
      "extrapolated": false
    },
    {
      "timestamp": 1683158280000,
      "price": "49.24160302106242",
      "extrapolated": false
    },
		/*...*/
	],
  "result": "success",
  "continuation_token": "AV2cWacBUPR8PvJTwoHZtPBUSEuqNYcv2iNgL96oZpT6MqqGc6ajQo7XM66wySCwViwNjs9C8Gu1xS2rRwGMrCT6rCRxFDCFnnKusyGFo34HkuY7Em7KqgpSzNADLhciV7w5UPeJrvm6cDgTnsaKVUgLMpj2ZioT",
  "next_url": "https://us.market-api.kaiko.io/v2/data/trades.v2/spot_exchange_rate/dash/usd?continuation_token=AV2cWacBUPR8PvJTwoHZtPBUSEuqNYcv2iNgL96oZpT6MqqGc6ajQo7XM66wySCwViwNjs9C8Gu1xS2rRwGMrCT6rCRxFDCFnnKusyGFo34HkuY7Em7KqgpSzNADLhciV7w5UPeJrvm6cDgTnsaKVUgLMpj2ZioT",
  "access": {
    "access_range": {
      "start_timestamp": 1262995200000,
      "end_timestamp": 2186006399000
    },
    "data_range": {
      "start_timestamp": null,
      "end_timestamp": null
    }
  }
}
```




---

[Next Page](/llms-full.txt/1)

