Subscribe

How to configure a Kaiko mono-asset rate stream.

What is this endpoint for?

Single-asset benchmarks 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

gateway-v0-grpc.kaiko.ovh

Request parameters

Parameter
Description
Examples

index_code

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

KK_BRR_BTCUSD

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

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.

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.

Request examples

# 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()

Response Example

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

Last updated

Was this helpful?