Only this pageAll pages
Powered by GitBook
1 of 18

Kaiko Indices

GETTING STARTED

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Reference Rates

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Multi-Asset Indices

Loading...

Customized Indices

Loading...

API Key

You'll need to provide your API Key to access Kaiko Indices services.

Using Kaiko Stream

Include your API key in your access credentials - see the code examples provided.

Using REST API

When using REST API, include your API key in the header - see the code examples provided.

General information

Headers

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

  • Accept: application/json: API responses will be in JSON format.

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

Timestamp input

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

YYYY-MM-DDThh:mm:ss.sssZ

For example:

2017-12-17T13:35:24.351Z

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

Exchange codes

Find exchange codes here: .

Instrument codes

Find instrument codes here: .

Timestamps

All timestamps use the ISO 8601 format in the UTC zone.

For example: 2024-11-26T14:17:15.124Z

About Kaiko Indices

Trusted Rates and Indices for Financial Professionals

Kaiko Indices provides innovative and trusted rates and indices solutions throughout the crypto industry. These underpin financial products for some of the most respected exchanges and issuers in the world, delivering a strong foundation to help them build, innovate, and grow.

Here, you will find everything you need to use Kaiko Indices solutions effectively.

For any customers still using formerly Vinter APIs, please visit the dedicated section .

REST API Pagination

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 set to latest will preserve the current version across subsequent pagination requests.

Parameters

Parameter
Required?
Description

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.

FOREX conversion

Convert your USD rate into a currency of your choosing.

What is this endpoint for?

This endpoint retrieves any single-asset Benchmark Reference Rate and converts USD into a local currency of your choosing using as the source for the conversion. Currencies available are:

  • CHF

continuation_token

No

The token auto-generated at when a response hits its page_size limit.

page_size

No

Maximum number of records to return in one response

version
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)}")py
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)

EUR

  • GBP

  • JPY

  • KRW

  • Endpoints

    gateway-v0-grpc.kaiko.ovh
    gateway-v0-http.kaiko.ovh
    https://gateway-v0-http.kaiko.ovh/api/stream/index_forex_rate_v1

    Request parameters

    Parameter
    Description
    Examples

    index_code

    The Kaiko Benchmark Reference Rate ticker. You can find a full list of our tickers .

    KK_RR_BTCUS

    Requesting multiple tickers at the same time To configure multiple tickers in the same stream, provide the indexCode as a comma separated list eg KK_PR_BTCUSD,KK_AAVE_USD Alternatively, use a wildcard by entering a * and you'll receive all tickers you have as part of you Kaiko subscription.

    Response fields

    Field
    Description

    indexCode

    The ticker identifying the rate.

    commodity

    The type of publication. Either real-time or fixings

    interval_startTime

    The start time for the interval.

    interval_endTime

    The end time for the interval.

    composition_underlying_name

    The Kaiko Reference Rate Ticker.

    composition_underlying_tsEvent

    The exact time of original reference rate publication.

    Request examples

    cURL requests are intended for testing purposes only.

    For more advanced users, you can access our full SDK here, where you'll find more coding languages, examples and guidance.

    Response Example

    TP-ICAP
    curl -X POST "https://gateway-v0-http.kaiko.ovh/api/stream/index_forex_rate_v1" -H "accept: application/json" -H "X-Api-Key: $KAIKO_API_KEY" -H "Content-Type: application/json" -d "{\"indexCode\": \"KK_BRR_BTCUSD\"}"
    {
      "indexCode": "KK_BRR_BTCUSD_EUR",
      "commodity": "SIC_REAL_TIME",
      "interval": {
        "startTime": "2024-09-12T21:42:35Z",
        "endTime": "2024-09-12T21:42:50Z"
      },
      "composition": {
        "underlying": {
          "name": "KK_BRR_BTCUSD",
          "tsEvent": "2024-09-12T21:42:50.658126160Z"
        },
        "fxrate": {
          "name": "USD/EUR",
          "tsEvent": "2024-09-12T21:42:01.048683287Z"
        }
      },
      "price": 52215.539302000085,
      "tsEvent": "2024-09-12T21:42:50.857862111Z",
      "detail": {
        "underlying": {
          "name": "KK_BRR_BTCUSD",
          "price": 57826.099,
          "tsEvent": "2024-09-12T21:42:50.658126160Z"
        },
        "fxrate": {
          "name": "USD/EUR",
          "price": 0.9029753036254458,
          "tsEvent": "2024-09-12T21:42:01.048683287Z"
        }
      }
    }

    price

    The price of the Reference Rate in the converted currency.

    tsEvent

    The exact time of converted reference rate publication.

    detail_underlying_name

    The ticker of the underlying reference rate.

    detail_underlying_price

    The original published price of the Reference Rate in USD.

    detail_underlying_tsEvent

    The exact timestamp of original reference rate publication.

    fxrate_name

    The name of the FOREX conversion rate we've sourced to convert USD into your chosen currency.

    fxrate_price

    The price of the FOREX conversion rate we've used to convert USD into your chosen currency.

    fxrate_tsEvent

    The timestamp for when we collected the FOREX conversion rate we've used to convert USD into your chosen currency.

    here

    Index codes

    When querying any API, you will need to include an index code (also known as tickers). You can find a list of all our tickers here or using the reference api.

    Subscribe

    How to configure a Kaiko mono-asset rate stream.

    What is this endpoint for?

    Single-asset reference rates that average the prices over a period of time to determine an average value and daily “close” prices (as crypto is 24/7, "close" prices are always synthetic). They can be used for several use cases from settlement of derivatives contracts to asset pricing and valuation. More information on the specific rates can be found here.

    Endpoints

    Request parameters

    Parameter
    Description
    Examples

    Requesting multiple tickers at the same time To configure multiple tickers in the same stream, provide the indexCode as a comma separated list eg KK_PR_BTCUSD,KK_AAVE_USD Alternatively, use a wildcard by entering a * and you'll receive all tickers you have as part of you Kaiko subscription.

    Response fields

    Field
    Description

    Request examples

    This example demonstrates how to request historical data using replay. The maximum amount of data you can request for one replay cannot exceed a total of 24 hours in hours, seconds, and minutes. Replay data is available on a 72-hour rolling basis and should only be used to retrieve missed data. If full history is required, please use Rest API or CSV deployment methods.

    cURL requests are intended for testing purposes only.

    For more advanced users, you can access our full SDK , where you'll find more coding languages, examples and guidance.

    Response Example

    Composition data

    What is this endpoint for?

    This endpoint retrieves the historical compositions of our Reference Rates, determined by our periodic rate rebalances. You can learn more about our Reference Rates here.

    Endpoint

    Request parameters

    Parameter
    Required
    Description
    Example

    Response Fields

    Field
    Description

    ** These are the exchanges that constitute the eligible universe of trading venues for the queried rate and time.

    For each publication of a rate, the methodology will use trade data from these source exchanges based on actual trading activity.

    Being listed as a source exchange does not guarantee that trades from exchange will be included in any given rate calculation. For the specific exchanges used for each publication, use the .

    Request example

    Response example

    Reference data

    What is this endpoint for?

    This endpoint retrieves a list of our Single-Asset Rates. You can learn more about Kaiko Rates and Indices here.

    Endpoint

    Request parameters

    No parameters supported

    Response Fields

    Field
    Description

    Request example

    Response example

    aa

    Historical prices

    What is this endpoint for?

    This endpoint returns our historical values for our Reference Rates. To subscribe to the live rate, please use . More information on the rates and its methodology can be found .

    Endpoint

    https://us.market-api.kaiko.io/v2/data/index.v1/digital_asset_rates_compo
    https://us.market-api.kaiko.io/v2/data/index_reference_data.v1/rates

    result

    Status of the query

    index_code

    Yes

    The desired rate ticker

    KK_BRR_BTCUSD

    start_time

    No

    Starting time in ISO 8601 (inclusive).

    2023-01-25T00:00:00.000Z

    end_time

    No

    Ending time in ISO 8601 (exclusive).

    index_code

    The ticker of the rate

    start_period

    Start of the composition period

    end_period

    End of the composition period

    exchanges

    Exchanges used during the composition period **

    window_seconds

    Calculation window in seconds for the period

    partition_seconds

    Partition size in seconds for the period

    replication data endpoint

    2023-04-25T00:00:00.000Z

    base

    Long and short name of the base asset

    pair

    Asset pair represented by the rate.

    launch_date

    Date when the rate was launched and entered into production.

    inception_date

    Earliest effective date of historical data for a rate.

    brand

    Qualifies if the rate is issued from a partnership or from Kaiko standard offer.

    isin

    The ISIN code of the rate

    exposition

    "Public" : Indicates that it is open reference data accessible to all users.

    ticker

    The ticker of the rate.

    long_name

    Extensive name format of the rate issued

    short_name

    Short name format of the rate issued

    type

    Category to which the rate belongs . i.e . Reference Rate or Benchmark Reference Rate

    dissemination

    Frequency of publication of the rate

    quote

    Long and short name of the quote asset

    curl -H "X-Api-Key: $KAIKO_API_KEY" \
         -H 'Accept: application/json' \
        "https://us.market-api.kaiko.io/v2/data/index.v1/digital_asset_rates_compo?index_code=KK_BRR_BTCUSD&start_time=2025-06-01T00:00:00Z"
    {
      "query": {
        "data_version": "v1",
        "request_time": "2025-09-22T12:39:25.097Z",
        "start_time": "2025-02-01T00:00:00Z",
        "end_time": "2025-04-01T00:00:00Z"
      },
      "time": "2025-09-22T12:39:25.107Z",
      "timestamp": 1758544765107,
      "data": [
        {
          "index_code": "KK_BRR_BTCUSD",
          "start_period": "2025-03-24T21:04:22.523Z",
          "end_period": "2025-06-23T21:06:13.244716Z",
          "exchanges": [
            "cbse",
            "gmni",
            "krkn",
            "lmax",
            "stmp"
          ],
          "window_seconds": 15,
          "partition_seconds": 3
        },
        {
          "index_code": "KK_BRR_BTCUSD",
          "start_period": "2025-01-07T22:00:58.271494Z",
          "end_period": "2025-03-24T21:29:22.526544Z",
          "exchanges": [
            "cbse",
            "gmni",
            "krkn",
            "lmax",
            "stmp"
          ],
          "window_seconds": 15,
          "partition_seconds": 3
        },
        {
          "index_code": "KK_BRR_ETHUSD",
          "start_period": "2025-03-24T21:04:22.523Z",
          "end_period": "2025-06-23T21:06:13.244716Z",
          "exchanges": [
            "cbse",
            "crco",
            "krkn",
            "lmax",
            "stmp"
          ],
          "window_seconds": 15,
          "partition_seconds": 3
        },
        {
          "index_code": "KK_BRR_ETHUSD",
          "start_period": "2025-01-07T22:00:58.271494Z",
          "end_period": "2025-03-24T21:29:22.526544Z",
          "exchanges": [
            "cbse",
            "crco",
            "krkn",
            "lmax",
            "stmp"
          ],
          "window_seconds": 15,
          "partition_seconds": 3
        }
      ],
      "result": "success"
    }
    curl --compressed -H 'Accept: application/json' 'https://us.market-api.kaiko.io/v2/data/index_reference_data.v1/rates'
    
    {'query': {'data_version': 'v1', 'commodity': 'indices', 'request_time': ''},
     'time': '2024-10-28T09:11:18.832Z',
     'timestamp': 1730106678832,
     'data': [{'ticker': 'KK_RFR_KNCUSD_SGP',
       'long_name': 'Kaiko KNC Reference_Rate Daily Fixing SGP',
       'short_name': 'Kaiko KNC Reference_Rate SGP',
       'type': 'Reference_Rate',
       'dissemination': 'Daily Fixing SGP',
       'quote': {'short_name': 'usd', 'long_name': 'United States Dollar'},
       'base': {'short_name': 'knc', 'long_name': 'Kyber Network'},
       'pair': 'knc-usd',
       'launch_date': '2024-03-04T00:00:00Z',
       'inception_date': '2024-03-04T00:00:00Z',
       'brand': 'Kaiko',
       'isin': 'NA',
       'exposition': 'Public'},
      ...],
     'result': 'success'}

    percentages

    The different distribution levels included in the price computation.

    price

    The value of the rate in the quote denomination.

    pairs

    The list of pairs combined with additional details included in the computation.

    tsEvent

    The exact time of price publication.

    index_code

    The Kaiko Benchmark Reference Rate ticker. You can find a full list of our tickers here or by API .

    KK_BRR_BTCUSD

    indexCode

    The ticker identifying the rate.

    commodity

    The type of publication. Either real-time or fixings

    interval

    The time period in which transaction data are considered for the calculation of the rate. If a rate's calculation methodology has an interval of 15 seconds, startTime and endTime will be separated by 15s.

    quote

    The quote asset used for the rate denomination.

    bases

    The list of base assets included in the rate and their weight. For reference rates, this will always be a single asset.

    exchanges

    The exchanges involved in the computation. This list may change every quarter during the rebalancing period and depending on the new results of the Kaiko Exchange Ranking.

    gateway-v0-grpc.kaiko.ovh
    gateway-v0-http.kaiko.ovh
    https://gateway-v0-http.kaiko.ovh/api/stream/index_v1
    here
    Path Parameters
    Parameter
    Required
    Description
    Example

    index_code

    Yes

    The desired rate ticker

    KK_BRR_BTCUSD

    Query Parameters

    Parameter
    Required
    Description
    Example

    start_time

    Yes

    Starting time in ISO 8601 (inclusive).

    2023-01-25T00:00:00.000Z

    end_time

    Yes

    Ending time in ISO 8601 (exclusive).

    2023-01-26T00:00:00.000Z

    parameters

    No

    boolean. If true, returns the underlying composition data of the rate such as exchanges and calculation window Default: false

    Fields

    Field
    Description
    Example

    interval_start

    Starting timestamp of calculation window

    2023-01-25T01:01:00.000Z

    interval_end

    Ending timestamp of calculation window

    2023-01-25T01:02:00.000Z

    price

    Price of the reference rate at interval_end

    67685.61363636363

    parameters

    Underlying composition data of the rate such as exchanges and calculation window

    'asset': 'btc',

    'exchanges': ['cbse', 'gmni', 'krkn', 'lmax', 'stmp'],

    'calc_window': 300

    Request examples

    Response example

    here

    Replication data

    Identify the underlying trades used to calculate each rate publication

    What is this endpoint for?

    Kaiko Reference Rates are available exclusively through our Stream Service. This helps you identify the underlying trades used to calculate each publication. Simply take the sequence_id field from any published rate you receive via Stream, and query this endpoint. The endpoint then generates a URL to query our endpoint where you'll see all the trades.

    We support publications for up to 72 hours using this endpoint. If you require the trades for a rate published more than 72 hours ago, contact our operations team.

    Endpoint

    Request parameters

    Parameter
    Required
    Description
    Example

    Response fields

    Field
    Description
    Example

    Request example

    Response example

    curl -X POST "https://gateway-v0-http.kaiko.ovh/api/stream/index_v1" -H "accept: application/json" -H "X-Api-Key: $KAIKO_API_KEY" -H "Content-Type: application/json" -d "{\"indexCode\": \"KK_BRR_BTCUSD\"}"
    {
      "indexCode": "KK_BRR_BTCUSD",
      "commodity": "SIC_REAL_TIME",
      "interval": {
        "startTime": "2024-08-12T13:48:45Z",
        "endTime": "2024-08-12T13:53:45Z"
      },
      "quote": "usd",
      "bases": [
        {
          "asset": "btc",
          "weight": 1.0
        }
      ],
      "exchanges": [
        "bfnx",
        "cbse",
        "krkn",
        "lmax",
        "stmp"
      ],
      "percentages": [
        {
          "percentage": 1.0,
          "price": 58461.761090909094,
          "pairs": [
            {
              "pair": "btc-usd",
              "weight": 1.0,
              "instruments": [
                {
                  "partition": "0",
                  "price": 58404.37,
                  "volume": 24.361215079999987,
                  "count": "545",
                  "underlyingTrade": {
                    "volume": 0.28,
                    "exchange": "cbse",
                    "id": "679495522",
                    "datetime": "2024-08-12T13:48:48.227119Z"
                  }
                },
                {
                  "partition": "1",
                  "price": 58447.35,
                  "volume": 17.22527984999999,
                  "count": "589",
                  "underlyingTrade": {
                    "volume": 0.33870923,
                    "exchange": "cbse",
                    "id": "679496144",
                    "datetime": "2024-08-12T13:49:23.817896Z"
                  }
                },
                {
                  "partition": "2",
                  "price": 58428.69,
                  "volume": 10.035586310000001,
                  "count": "419",
                  "underlyingTrade": {
                    "volume": 0.33303204,
                    "exchange": "cbse",
                    "id": "679496499",
                    "datetime": "2024-08-12T13:49:45.100184Z"
                  }
                },
                {
                  "partition": "3",
                  "price": 58464.3,
                  "volume": 16.12647133000001,
                  "count": "452",
                  "underlyingTrade": {
                    "volume": 0.125,
                    "exchange": "cbse",
                    "id": "679497072",
                    "datetime": "2024-08-12T13:50:27.115087Z"
                  }
                },
                {
                  "partition": "6",
                  "price": 58491.69,
                  "volume": 19.274423530000025,
                  "count": "477",
                  "underlyingTrade": {
                    "volume": 0.044,
                    "exchange": "cbse",
                    "id": "679498527",
                    "datetime": "2024-08-12T13:52:03.221419Z"
                  }
                },
                {
                  "partition": "7",
                  "price": 58424.9,
                  "volume": 14.584170899999991,
                  "count": "424",
                  "underlyingTrade": {
                    "volume": 0.3655928,
                    "exchange": "cbse",
                    "id": "679499080",
                    "datetime": "2024-08-12T13:52:44.216425Z"
                  }
                },
                {
                  "partition": "8",
                  "price": 58425.63,
                  "volume": 6.909352779999999,
                  "count": "305",
                  "underlyingTrade": {
                    "volume": 0.19652022,
                    "exchange": "cbse",
                    "id": "679499321",
                    "datetime": "2024-08-12T13:53:09.097614Z"
                  }
                },
                {
                  "partition": "4",
                  "price": 58507.6,
                  "volume": 11.486490139999999,
                  "count": "442",
                  "underlyingTrade": {
                    "volume": 0.11795193,
                    "exchange": "cbse",
                    "id": "679497509",
                    "datetime": "2024-08-12T13:51:02.354315Z"
                  }
                },
                {
                  "partition": "5",
                  "price": 58617.97,
                  "volume": 22.758717719999996,
                  "count": "612",
                  "underlyingTrade": {
                    "volume": 0.30000007,
                    "exchange": "cbse",
                    "id": "679498150",
                    "datetime": "2024-08-12T13:51:40.171679Z"
                  }
                },
                {
                  "partition": "9",
                  "price": 58403.7,
                  "volume": 51.51317158000001,
                  "count": "535",
                  "underlyingTrade": {
                    "volume": 4.52337977,
                    "exchange": "krkn",
                    "id": "72810698",
                    "datetime": "2024-08-12T13:53:30.437555Z"
                  }
                }
              ]
            }
          ]
        }
      ],
      "tsEvent": "2024-08-12T13:53:45.417622358Z",
      "sequenceId": "cqt17qfvavm6rm0ghh8g",
      "lastIngestTime": "2024-08-12T13:53:42.855990657Z"
    }
    curl -X GET "https://us.market-api.kaiko.io/v2/data/index.v1/digital_asset_rates_price/KK_BRR_BTCUSD_LDN" \
      -H "X-API-KEY: $KAIKO_API_KEY" \
      -H "accept: application/json" \
      -G \
      --data-urlencode "start_time=2024-10-27T00:00:00.000Z" \
      --data-urlencode "end_time=2024-10-28T00:00:00.000Z" \
      --data-urlencode "parameters=True" \
      --data-urlencode "detail=True"
    https://us.market-api.kaiko.io/v2/data/index.v1/digital_asset_rates_price/{index_code}

    detail

    No

    boolean. If true, returns the underlying partition data for each publication Default: false

    page_size

    No

    (min: 1, default: 100, max: 5000). See Pagination

    Automatically included in continuation tokens.

    continuation_token

    No

    See Pagination

    sort

    No

    Return the data in ascending (asc) or descending (desc) order. Default desc

    Automatically included in continuation tokens.

    detail

    Underlying partition data for each publication including price, volume, trade count and underlying data of the trade selected from the partition.

    'partition': 0,

    'price': 67678,

    'volume': 5.14445852,

    'count': 125,

    'underlying_trade': {'datetime': '2024-10-27T15:55:17.334Z',

    'exchange': 'stmp',

    'volume': 0.20137745,

    'id': '366038625'}

    sequence_id

    Yes

    List of publication ID to explore. A publication is defined by event occurring on a specific instrument at a given point in time. Publication IDs can be retrieved from your index response.

    cmrqt2dugrtbh9jbhlk0,cmt40b74tfbpmrtbk180

    sort

    No

    If asc, sort time-series in ascending. If desc, sort time-series in descending.

    asc

    page_size

    No

    See Min: 1 Max: 100 Default: 10

    index_code

    Ticker identifying the rate.

    KK_PR_BTCUSD

    index_type

    Type of publication: real-time or fixings.

    SIC_REAL_TIME

    sequenceID

    The publication ID to explore. A publication is defined by event occurring on a specific instrument at a given point in time. Publication IDs can be retrieved from publication stream response.

    cnb0k3vvavm8ib6863qg

    underlying_data

    List of links to specific pre-filtered queries on the Rest API trades endpoint for the selected SequenceID.

    [ "https://us.market-api.kaiko.io/v3/data/trades.v1/exchanges/bfnx/spot/btc-usd/trades?start_time=2024-02-21T14:29:55.000Z&end_time=2024-02-21T14:34:55.000Z&index_inserted_at=2024-02-21T14:34:50.863ZZ&sort=asc", "https://us.market-api.kaiko.io/v3/data/trades.v1/exchanges/cbse/spot/btc-usd/trades?start_time=2024-02-21T14:29:55.000Z&end_time=2024-02-21T14:34:55.000Z&index_inserted_at=2024-02-21T14:34:50.863ZZ&sort=asc"]

    100

    https://us.market-api.kaiko.io/v1/data/index_replication.v1/rates
    curl --compressed \
      -H 'Accept: application/json' \
      -H 'X-Api-Key: <client-api-key>' \
      'https://us.market-api.kaiko.io/v1/data/index_replication.v1/rates?sequence_id=csibfhkth8ejovmc3fcg'
    import http.client
    import json
    
    # Enter your Kaiko API Key
    api_key = "KAIKO_API_KEY"
    api_host = "us.market-api.kaiko.io"
    api_base_endpoint = "/v1/data/index_replication.v1/rates"
    # Start of mandatory parameter configuration
    mandatory_params = {
        "sequence_id": "csibfhkth8ejovmc3fcg",
    }
    # End of mandatory parameter configuration
    # Start of optional parameter configuration
    optional_params = {
            "sort": "asc",
    }
    # End of optional parameter configuration
    conn = http.client.HTTPSConnection(api_host)
    headers = {
        "X-Api-Key": api_key,
        "Accept": "application/json"
    }
    
    all_params = {**mandatory_params, **optional_params}
    
    url_params = []
    for param, value in all_params.items():
        url_params.append(f"{param}={value}")
    url_params = '&'.join(url_params)
    
    endpoint_with_params = f"{api_base_endpoint}?{url_params}"
    
    # Pagination for next pages
    all_data = []
    next_url = endpoint_with_params
    while next_url:
        conn.request("GET", next_url, headers=headers)
        response = conn.getresponse()
        data = json.loads(response.read().decode("utf-8"))
        all_data.extend(data.get("data", []))
        print(f"Fetched {len(data.get('data', []))} datapoints. Total: {len(all_data)}")
        next_url = data.get("next_url", "").replace("https://us.market-api.kaiko.io", "")
        if not next_url:
            break
    conn.close()
    print(f" datapoints fetched: {(all_data)}")
    {
        "time": "2024-11-01T11:18:09.931Z",
        "timestamp": 1730459889931,
        "data": [
            {
                "index_code": "KK_BRR_BTCUSD",
                "index_type": "SIC_REAL_TIME",
                "sequence_id": "csibfhkth8ejovmc3fcg",
                "underlying_data": [
                    "https://us.market-api.kaiko.io/v3/data/trades.v1/exchanges/cbse/spot/btc-usd/trades?start_time=2024-11-01T11:12:55Z&end_time=2024-11-01T11:13:10Z&index_inserted_at=2024-11-01T11:13:09.839473378Z&sort=asc",
                    "https://us.market-api.kaiko.io/v3/data/trades.v1/exchanges/gmni/spot/btc-usd/trades?start_time=2024-11-01T11:12:55Z&end_time=2024-11-01T11:13:10Z&index_inserted_at=2024-11-01T11:13:09.839473378Z&sort=asc",
                    "https://us.market-api.kaiko.io/v3/data/trades.v1/exchanges/krkn/spot/btc-usd/trades?start_time=2024-11-01T11:12:55Z&end_time=2024-11-01T11:13:10Z&index_inserted_at=2024-11-01T11:13:09.839473378Z&sort=asc",
                    "https://us.market-api.kaiko.io/v3/data/trades.v1/exchanges/lmax/spot/btc-usd/trades?start_time=2024-11-01T11:12:55Z&end_time=2024-11-01T11:13:10Z&index_inserted_at=2024-11-01T11:13:09.839473378Z&sort=asc",
                    "https://us.market-api.kaiko.io/v3/data/trades.v1/exchanges/stmp/spot/btc-usd/trades?start_time=2024-11-01T11:12:55Z&end_time=2024-11-01T11:13:10Z&index_inserted_at=2024-11-01T11:13:09.839473378Z&sort=asc"
                ]
            }
        ],
        "result": "success",
        "continuation_token": "",
        "next_url": "",
        "access": {
            "access_range": {
                "start_timestamp": 1454284800000,
                "end_timestamp": null
            },
            "data_range": {
                "start_timestamp": null,
                "end_timestamp": null
            }
        }
    }

    Subscribe

    How to configure a Kaiko multi-asset rate stream.

    What is this endpoint for?

    Monitor the overall performance of specific buckets of assets. The indices combine several data sources to summarize market performance. They can be used to aid the issuance of derivatives contracts or investment vehicles by providing pricing for settlement. You can see our full list of indices here and learn more about their performance in our factsheet.

    Endpoints

    Request parameters

    Parameter
    Description
    Examples

    Requesting multiple tickers at the same time To configure multiple tickers in the same stream, provide the indexCode as a comma-separated list eg KT5,KT10NYC Alternatively, use a wildcard by entering a * and you'll receive all tickers you have as part of your Kaiko subscription.

    Response fields

    Field
    Description

    Request examples

    This example demonstrates how to request historical data using replay. The maximum amount of data you can request for one replay cannot exceed a total of 24 hours in hours, seconds, and minutes. Replay data is available on a 72-hour rolling basis and should only be used to retrieve missed data. If full history is required, please use Rest API or CSV deployment methods.

    cURL requests are intended for testing purposes only.

    For more advanced users, you can access our full SDK , where you'll find more coding languages, examples and guidance.

    Response Example

    Valour - CDF Index

    What is this endpoint for?

    This endpoint is a customized index made specifically for Valour, a Kaiko Indices client. It's designed to serve as an underlying price feed for leveraged financial instruments. The price is calculated by measuring the performance of live futures contracts with a constant time to expiry to effectively reflect a price, mitigating the volatility caused by rollovers.

    You can find out more about our Customized Indices .

    • base

    The base asset for the used Reference Rate.

    • quote

    The quote asset for the used Reference Rate

    • Exchanges

    The exchanges used to calculate the Reference Rate.

    • insturmentInterval

    The startTime and endTime of the calculation period for the specific Reference Rate.

    • tsEvent

    The time the rate was published by Kaiko.

    price

    Information on the pricing for the index.

    • indexValue

    The value for the index publication.

    pairs

    The pricing details of the underlying Kaiko Reference Rates used in the calculation.

    • underlyingPrice

    The published price of the Reference Rate.

    • weightingFactor

    The weighting of the Reference Rate to the index.

    • cappingFactor

    The capping of the Reference Rate to the index.

    • currencyConversionFactor

    The conversion factor used in the Reference Rate for the index.

    tsEvent

    The theoretical time of price publication

    tsCompute

    The exact time of price computation.

    index_code

    The Indices ticker. You can find a full list of our tickers here.

    KT5

    indexCode

    The ticker identifying the index.

    commodity

    The type of publication. Either real-time or fixings

    interval

    The time period in which transaction data are considered for the calculation of the index. If an index's calculation methodology has an interval of 15 seconds, startTime and endTime will be separated by 15s.

    mainQuote

    is the quote asset used for the index denomination.

    compositions

    The list of underlying data used to calculate the index price.

    • underlyingInstrument

    The ticker for the Kaiko Reference Rate(s) used to calculate the multi-asset index.

    gateway-v0-grpc.kaiko.ovh
    gateway-v0-http.kaiko.ovh
    https://gateway-v0-http.kaiko.ovh/api/stream/index_multi_assets_v1
    here
    Endpoints
    gateway-v0-grpc.kaiko.ovh
    gateway-v0-http.kaiko.ovh
    https://gateway-v0-http.kaiko.ovh/api/stream/constant_duration_indices_v1

    Parameters

    Parameter
    Description
    Examples

    index_code

    The Kaiko CDF Index tickers

    KAIKO_CDF_BTCUSDT

    See the methodology for a full list of tickers.

    Requesting multiple tickers at the same time To configure multiple tickers in the same stream, provide the indexCode as a comma separated list eg KAIKO_CDF_BTCUSDT,KAIKO_CDF_ETHUSDT Alternatively, use a wildcard by entering a * and you'll receive all tickers you have as part of you Kaiko subscription.

    Fields

    Field
    Description

    commodity

    The type of publication. Either real-time or fixings

    indexCode

    The ticker identifying the rate.

    base

    Base asset of futures

    quote

    Quote asset of futures

    computedCdf

    Price of CDF index

    exchange

    The exchange code for underlying futures trade. Please find for a full name of exchange.

    Request examples

    Make sure to read our Python quick-start guide before starting.

    cURL requests are intended for testing purposes only.

    For more advanced users, you can access our full SDK here, where you'll find more coding languages, examples and guidance.

    Response Example

    here
    curl -X POST "https://gateway-v0-http.kaiko.ovh/api/stream/index_multi_assets_v1" -H "accept: application/json" -H "X-Api-Key: $KAIKO_API_KEY" -H "Content-Type: application/json" -d "{\"indexCode\": \"KT5\"}"
    {
      "commodity": "SIC_REAL_TIME",
      "indexCode": "KT5",
      "interval": {
        "startTime": "2024-08-12T14:23:55Z",
        "endTime": "2024-08-12T14:29:00Z"
      },
      "mainQuote": "usd",
      "compositions": [
        {
          "underlyingInstrument": "KK_RFR_AVAXUSD",
          "base": "avax",
          "quote": "usd",
          "exchanges": [
            "bfnx",
            "cbse",
            "krkn",
            "stmp"
          ],
          "instrumentInterval": {
            "startTime": "2024-08-12T14:23:55Z",
            "endTime": "2024-08-12T14:28:55Z"
          },
          "currencyConversion": "none",
          "tsEvent": "2024-08-12T14:28:56.074863348Z"
        },
        {
          "underlyingInstrument": "KK_RFR_BTCUSD",
          "base": "btc",
          "quote": "usd",
          "exchanges": [
            "bfnx",
            "cbse",
            "krkn",
            "lmax",
            "stmp"
          ],
          "instrumentInterval": {
            "startTime": "2024-08-12T14:24:00Z",
            "endTime": "2024-08-12T14:29:00Z"
          },
          "currencyConversion": "none",
          "tsEvent": "2024-08-12T14:29:01.087284434Z"
        },
        {
          "underlyingInstrument": "KK_RFR_ETHUSD",
          "base": "eth",
          "quote": "usd",
          "exchanges": [
            "bfnx",
            "cbse",
            "krkn",
            "lmax",
            "stmp"
          ],
          "instrumentInterval": {
            "startTime": "2024-08-12T14:23:55Z",
            "endTime": "2024-08-12T14:28:55Z"
          },
          "currencyConversion": "none",
          "tsEvent": "2024-08-12T14:28:56.142347541Z"
        },
        {
          "underlyingInstrument": "KK_RFR_SOLUSD",
          "base": "sol",
          "quote": "usd",
          "exchanges": [
            "bfnx",
            "cbse",
            "gmni",
            "krkn",
            "stmp"
          ],
          "instrumentInterval": {
            "startTime": "2024-08-12T14:24:00Z",
            "endTime": "2024-08-12T14:29:00Z"
          },
          "currencyConversion": "none",
          "tsEvent": "2024-08-12T14:29:00.784958075Z"
        },
        {
          "underlyingInstrument": "KK_RFR_XRPUSD",
          "base": "xrp",
          "quote": "usd",
          "exchanges": [
            "cbse",
            "indr",
            "krkn",
            "lmax",
            "stmp"
          ],
          "instrumentInterval": {
            "startTime": "2024-08-12T14:23:55Z",
            "endTime": "2024-08-12T14:28:55Z"
          },
          "currencyConversion": "none",
          "tsEvent": "2024-08-12T14:28:55.988918370Z"
        }
      ],
      "price": {
        "indexValue": 334.99947165068875,
        "divisor": 26979870988.68237,
        "pairs": [
          {
            "underlyingInstrument": "KK_RFR_AVAXUSD",
            "underlyingPrice": 21.333163636363636,
            "weightingFactor": 17278580619.32558,
            "cappingFactor": 1.0,
            "currencyConversionFactor": 1.0
          },
          {
            "underlyingInstrument": "KK_RFR_BTCUSD",
            "underlyingPrice": 59699.73163636363,
            "weightingFactor": 390312772.9127332,
            "cappingFactor": 0.119856816159272,
            "currencyConversionFactor": 1.0
          },
          {
            "underlyingInstrument": "KK_RFR_ETHUSD",
            "underlyingPrice": 2680.1494545454543,
            "weightingFactor": 2288124768.3108406,
            "cappingFactor": 0.373375636405882,
            "currencyConversionFactor": 1.0
          },
          {
            "underlyingInstrument": "KK_RFR_SOLUSD",
            "underlyingPrice": 147.37236363636362,
            "weightingFactor": 17542805404.323048,
            "cappingFactor": 1.0,
            "currencyConversionFactor": 1.0
          },
          {
            "underlyingInstrument": "KK_RFR_XRPUSD",
            "underlyingPrice": 0.5706330909090909,
            "weightingFactor": 1755466226611.777,
            "cappingFactor": 1.0,
            "currencyConversionFactor": 1.0
          }
        ]
      },
      "tsEvent": "2024-08-12T14:29:00Z",
      "tsCompute": "2024-08-12T14:29:05.210675561Z"
    }
     # This is a code example. Configure your parameters below #
    
    from __future__ import print_function
    from datetime import datetime, timedelta
    import logging
    import os
    from google.protobuf.timestamp_pb2 import Timestamp
    import grpc
    from google.protobuf.json_format import MessageToJson
    from kaikosdk import sdk_pb2_grpc
    from kaikosdk.stream.constant_duration_indices_v1 import request_pb2 as pb_constant_duration_indices
    
    def constant_duration_indices_v1_request(channel: grpc.Channel):
        try:
            with channel:
                stub = sdk_pb2_grpc.StreamConstantDurationIndicesServiceV1Stub(channel)
    
                responses = stub.Subscribe(pb_constant_duration_indices.StreamConstantDurationIndicesServiceRequestV1(
                    index_code = "KAIKO_CDF_BTCUSDT"
                ))
                for response in responses:
                    print("Received message %s" % (MessageToJson(response, including_default_value_fields = True)))
        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)
        constant_duration_indices_v1_request(channel)
    
    if __name__ == '__main__':
        logging.basicConfig()
        run()
    # This is a code example. Configure your parameters below #
    
    from __future__ import print_function
    from datetime import datetime, timedelta
    import logging
    import os
    from google.protobuf.timestamp_pb2 import Timestamp
    import grpc
    from google.protobuf.json_format import MessageToJson
    from kaikosdk import sdk_pb2_grpc
    from kaikosdk.stream.constant_duration_indices_v1 import request_pb2 as pb_constant_duration_indices
    
    def constant_duration_indices_v1_request(channel: grpc.Channel):
        try:
            # start of date configuration #
            start = Timestamp()
            start.FromDatetime(datetime.utcnow() - timedelta(days=2))
            end = Timestamp()
            end.FromDatetime(datetime.utcnow() - timedelta(days=1))
            # end of date configuration #
            
            stub = sdk_pb2_grpc.StreamConstantDurationIndicesServiceV1Stub(channel)
    
            responses = stub.Subscribe(pb_constant_duration_indices.StreamConstantDurationIndicesServiceRequestV1(
                index_code = "KAIKO_CDF_BTCUSDT",
                interval={
                    'start_time': start,
                    'end_time': end
                }
            ))
            for response in responses:
                print("Received message %s" % (MessageToJson(response, including_default_value_fields = True)))
        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)
        constant_duration_indices_v1_request(channel)
    
    if __name__ == '__main__':
        logging.basicConfig()
        run()
    curl -X POST "https://gateway-v0-http.kaiko.ovh/api/stream/constant_duration_indices_v1" -H "accept: application/json" -H "X-Api-Key: $KAIKO_API_KEY" -H "Content-Type: application/json" -d '{ "indexCode": "KAIKO_CDF_BTCUSDT", "interval": {"startTime": "2025-04-24T15:30:00.000Z", "endTime": "2025-04-24T15:31:00.000Z" } }'
    {
       "result":{
          "commodity":"SIC_REAL_TIME",
          "indexCode":"KAIKO_CDF_BTCUSDT",
          "composition":{
             "base":"btc",
             "quote":"usdt",
             "data":[
                {
                   "computedCdf":95024.52103689784,
                   "exchange":"binc",
                   "frontFuture":{
                      "symbol":"btcusdt_250627",
                      "price":94481.42295081966,
                      "expiry":"2025-06-27T08:00:00Z",
                      "timestamp":"2025-04-25T09:31:00Z",
                      "weight":0.6813186813186813
                   },
                   "backFuture":{
                      "symbol":"btcusdt_250926",
                      "price":96096.2,
                      "expiry":"2025-09-26T08:00:00Z",
                      "timestamp":"2025-04-25T09:29:41.131Z",
                      "weight":0.31868131868131866
                   },
                   "constantDuration":91,
                   "status":"CDF_SUCCESS",
                   "rateQuoteConversion":{
                      "index":"KK_RFR_USDTUSD",
                      "value":1.0003,
                      "timestamp":"2025-04-25T09:31:00Z"
                   }
                }
             ]
          },
          "startTime":"2025-04-25T09:30:00Z",
          "endTime":"2025-04-25T09:31:00Z",
          "tsEvent":"2025-04-25T09:31:05.247126935Z"
       }
    }

    frontFuture

    A nested object containing:

    • symbol

    Instrument code of front future. Please find instrument explorer for detailed information.

    • price

    1-min VWAP of front future (Relevant doc of VWAP can be found here.) If it's not available, last traded price

    • expiry

    The timestamp of expiration of front future

    • timestamp

    The timestamp of the price of front future. If price is 1-min VWAP, endTime of the calculation if price is from the last trade, the timestamp of the trade

    • weight

    Applied weight to the price of front future

    backFuture

    A nested object containing:

    • symbol

    Instrument code of back future. Please find instrument explorer for detailed information.

    • price

    1-min VWAP of back future (Relevant doc of VWAP can be found here.) If it's not available, last traded price

    • expiry

    The timestamp of expiration of back future

    • timestamp

    The timestamp of the price of back future. If price is 1-min VWAP, endTime of the calculation if price is from the last trade, the timestamp of the trade

    • weight

    Applied weight to the price of back future

    constantDuration

    Constant Duration

    status

    Status of the publication CDF_SUCCESS : Calculation succeeded

    CDF_NO_FUTURE : Cannot find the relevant front or back future

    CDF_NO_PRICE : Futures are available but prices are not available

    rateQuoteConversion

    A nested object containing:

    • index

    Kaiko Reference Rate that is used to convert the currency. Detailed methodology of Kaiko Reference rate can be found here

    • value

    Price of rateQuoteConversion / index

    • timestamp

    Timestamp of rateQuoteConversion / index

    interval_startTime

    The start time for the interval.

    interval_endTime

    The end time for the interval.

    tsEvent

    The exact time of the publication.

    instrument explorer
    Kaiko Stream
    here
    Tick-Level Trades
    here
    # This is a code example. Configure your parameters below #
    
    from __future__ import print_function
    from datetime import datetime, timedelta
    import logging
    import os
    from google.protobuf.timestamp_pb2 import Timestamp
    import grpc
    from google.protobuf.json_format import MessageToJson
    from kaikosdk import sdk_pb2_grpc
    from kaikosdk.stream.index_v1 import request_pb2 as pb_index
    
    def index_rate_request(channel: grpc.Channel):
        try:
            # start of date configuration #
            start = Timestamp()
            start.FromDatetime(datetime.utcnow() - timedelta(days=2))
            end = Timestamp()
            end.FromDatetime(datetime.utcnow() - timedelta(days=1))
            # end of date configuration #
            
            stub = sdk_pb2_grpc.StreamIndexServiceV1Stub(channel)
            responses = stub.Subscribe(pb_index.StreamIndexServiceRequestV1(
                index_code = "KK_BRR_BTCUSD",
                interval={
                    'start_time': start,
                    'end_time': end
                }
            ))
            for response in responses:
                # for debug purpose only, don't use MessageToJson in the reading loop in production
                print("Received message %s" % (MessageToJson(response, including_default_value_fields = True)))
        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)
        index_rate_request(channel)
    
    if __name__ == '__main__':
        logging.basicConfig()
        run()
    # This is a code example. Configure your parameters below #
    
    from __future__ import print_function
    from datetime import datetime, timedelta
    import logging
    import os
    from google.protobuf.timestamp_pb2 import Timestamp
    import grpc
    from google.protobuf.json_format import MessageToJson
    from kaikosdk import sdk_pb2_grpc
    from kaikosdk.stream.index_v1 import request_pb2 as pb_index
    
    def index_rate_request(channel: grpc.Channel):
        try:
            with channel:
                stub = sdk_pb2_grpc.StreamIndexServiceV1Stub(channel)
                responses = stub.Subscribe(pb_index.StreamIndexServiceRequestV1(
                    index_code = "KK_BRR_BTCUSD"
                ))
                for response in responses:
                    # for debug purpose only, don't use MessageToJson in the reading loop in production
                    print("Received message %s" % (MessageToJson(response, including_default_value_fields = True)))
        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)
        index_rate_request(channel)
    
    if __name__ == '__main__':
        logging.basicConfig()
        run()
    # This is a code example. Configure your parameters below #
    
    from __future__ import print_function
    from datetime import datetime, timedelta
    import logging
    import os
    from google.protobuf.timestamp_pb2 import Timestamp
    import grpc
    from google.protobuf.json_format import MessageToJson
    from kaikosdk import sdk_pb2_grpc
    from kaikosdk.stream.index_forex_rate_v1 import request_pb2 as pb_index_forex_rate
    
    def index_forex_rate(channel: grpc.Channel):
        try:
            with channel:
                stub = sdk_pb2_grpc.StreamIndexForexRateServiceV1Stub(channel)
                responses = stub.Subscribe(pb_index_forex_rate.StreamIndexForexRateServiceRequestV1(
                    index_code = "KK_BRR_BTCUSD_EUR"
                ))
                for response in responses:
                    # for debug purpose only, don't use MessageToJson in the reading loop in production
                    print("Received message %s" % (MessageToJson(response, including_default_value_fields = True)))
        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)
        index_forex_rate(channel)
    
    if __name__ == '__main__':
        logging.basicConfig()
        run()
    # This is a code example. Configure your parameters below #
    
    from __future__ import print_function
    from datetime import datetime, timedelta
    import logging
    import os
    from google.protobuf.timestamp_pb2 import Timestamp
    import grpc
    from google.protobuf.json_format import MessageToJson
    from kaikosdk import sdk_pb2_grpc
    from kaikosdk.stream.index_multi_assets_v1 import request_pb2 as pb_index_multi_assets
    
    def index_multi_asset(channel: grpc.Channel):
        try:
            with channel:
                stub = sdk_pb2_grpc.StreamIndexMultiAssetsServiceV1Stub(channel)
                responses = stub.Subscribe(pb_index_multi_assets.StreamIndexMultiAssetsServiceRequestV1(
                    index_code = "KT15"
                ))
                for response in responses:
                    # for debug purpose only, don't use MessageToJson in the reading loop in production
                    print("Received message %s" % (MessageToJson(response, including_default_value_fields = True)))
        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)
        index_multi_asset(channel)
    
    if __name__ == '__main__':
        logging.basicConfig()
        run()
    # This is a code example. Configure your parameters below #
    
    from __future__ import print_function
    from datetime import datetime, timedelta
    import logging
    import os
    from google.protobuf.timestamp_pb2 import Timestamp
    import grpc
    from google.protobuf.json_format import MessageToJson
    from kaikosdk import sdk_pb2_grpc
    from kaikosdk.stream.index_multi_assets_v1 import request_pb2 as pb_index_multi_assets
    
    def index_multi_asset(channel: grpc.Channel):
        try:
            # start of date configuration #
            start = Timestamp()
            start.FromDatetime(datetime.utcnow() - timedelta(days=2))
            end = Timestamp()
            end.FromDatetime(datetime.utcnow() - timedelta(days=1))
            # end of date configuration #
            
            stub = sdk_pb2_grpc.StreamIndexMultiAssetsServiceV1Stub(channel)
            responses = stub.Subscribe(pb_index_multi_assets.StreamIndexMultiAssetsServiceRequestV1(
                index_code = "KT15",
                interval={
                    'start_time': start,
                    'end_time': end
                }
            ))
            for response in responses:
                # for debug purpose only, don't use MessageToJson in the reading loop in production
                print("Received message %s" % (MessageToJson(response, including_default_value_fields = True)))
        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)
        index_multi_asset(channel)
    
    if __name__ == '__main__':
        logging.basicConfig()
        run()