Only this pageAll pages
Powered by GitBook
1 of 41

Stream

General

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Data Feeds

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Analytics Solutions

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Legacy endpoints

Loading...

Loading...

Loading...

Loading...

Loading...

BETA ENDPOINTS

Loading...

API Key

To make any request, you'll need an API Key from Kaiko. Contact [email protected] if you don't have yours. There's a placeholder for the API Key in all code examples. The parameter to be passed in the header is X-Api-Key.

Rate limiting

Our Stream service is limited to 3000 subscriptions per API key per minute as standard. If you exceed this threshold, a 429 an error message will occur. A "subscription" refers to a live data stream, regardless of the amount of data received by each. If you'd like to discuss rate-limiting, please contact [email protected].

Level 1 Aggregations

Reference Data

Level 1 Tick-Level

Emerging assets

General information

Level 1 & Level 2 Data

Kaiko Fair Market Value

Introduction

A little about Kaiko Stream.

The fastest way to consume Kaiko data.

Kaiko Stream is designed for those that need our data in the fastest way possible. Once connected to a stream, you'll get constant updates for the parameters you have initially configured. This provides true real-time data, and allows you to get insights on several exchanges or instruments from one connection.

✔ Real-time updates delivered instantly with no need to call an API each time ✔ Data on multiple exchanges or instruments simultaneously in one stream ✔ gRPC technology for the best data delivery and uptime ✔ Customizable calculations, frequencies, and channels ✔ Limited historical data available on replay

Let's get started .

Response codes

Here is a summary of our general response codes.

Quick-Start: cURL

Making a request with cURL is extremely straightforward. cURL is only designed for testing purposes, and should not be used for production. Here are the steps to get started:

Parameter patterns

Cartesian Product of Patterns

If the params lists contain more than one element, the resulting pattern will be constructed as a cartesian product of each element of the lists, i.e:

pattern = exchange1,exchange2:instrument_class:instrument1,instrument2

will be equivalent to the union of 4 patterns:

Introduction

Basic information about Kaiko Market Data.

About our Market Data Solutions

Our Market Data products offer insight into over 100 centralized spot and derivatives exchanges, providing a detailed view of the trades taking place, the state of the order books, and insight into open derivatives contracts. Track the real-time and historical performance and monitor current market trends. Each endpoint provides different information on market data.

Get started with the menu on the left.

⬅️ ⬅️ ⬅️

  • .... and that's it! You'll now receive updates in real-time as per your configuration.

    pattern1 = exchange1:instrument_class:instrument1
  • pattern2 = exchange1:instrument_class:instrument2

  • pattern3 = exchange2:instrument_class:instrument1

  • pattern4 = exchange2:instrument_class:instrument

  • Union of Patterns

    Multiple patterns can also be combined with the + operator: where:

    pattern = pattern1+pattern2

    • pattern1 = <exchange1>:<instrument_class1>:<instrument1>

    • pattern2 = <exchange2>:<instrument_class2>:<instrument2>

    here

    Kaiko Derivatives Risk Indicators

    Established assets

    Level 2 Tick-Level

    Default

    An unexpected error response.

    200

    OK

    A successful response.(streaming responses)

    Inline

    403

    Forbidden

    Returned when the user does not have permission to access the resource.

    Inline

    404

    Not Found

    Returned when the resource does not exist.

    string

    default

    Quick-Start: Python

    Get started with Kaiko Stream and Python

    Before implementing Kaiko Stream in your Python environment, ensure you meet the following technical requirements.

    System requirements

    • Python Version: Minimum Python 3.7+ (recommended: 3.9+)

    • Operating System: Cross-platform (Windows, macOS, Linux)

    • Network: Stable internet connection for gRPC streaming

    Core files

    File
    Purpose
    Link

    Checklist

    .... and that's it! You'll now receive updates in real-time as per your configuration.

    This guide is intended to get you started with Stream and Python. You can also access our full SDK , where you'll find more coding languages, examples and guidance.

    VWAP (v1)

    This endpoint has been deprecated. Please use the new VWAP endpoint instead. Please contact [email protected] if you have any questions about migrating.

    Subscribe

    Retrieve ongoing Volume Weighted Average Price updates. Supported intervals are 1s, 1m and 1h.

    Run your script

    Requirements

    This file contains the minimum requirements for the script to run.

    https://raw.githubusercontent.com/kaikodata/kaiko-sdk-examples/master/python/requirements.txt

    Pipfile

    This file contains important PIP information for your Python script to run.

    https://raw.githubusercontent.com/kaikodata/kaiko-sdk-examples/master/python/Pipfile

    Pipfile.lock

    This file contains additional PIP information for your Python script to run.

    https://raw.githubusercontent.com/kaikodata/kaiko-sdk-examples/master/python/Pipfile.lock

    Resubscribe

    This tells Python what to do in the instance you lose connection with Kaiko Stream.

    https://raw.githubusercontent.com/kaikodata/kaiko-sdk-examples/master/python/resubscribe.py

    here
    here
    rpcStatus
    POST /api/stream/aggregates_vwap_v1

    Parameters

    Name
    In
    Type
    Required
    Description

    body

    body

    kaikosdkStreamAggregatesVWAPRequestV1

    true

    none

    Responses

    Status
    Meaning
    Description
    Schema

    200

    A successful response.(streaming responses)

    Inline

    403

    Returned when the user does not have permission to access the resource.

    Inline

    404

    Returned when the resource does not exist.

    Response Schema

    Status Code 200

    Stream result of kaikosdkStreamAggregatesVWAPResponseV1

    Name
    Type
    Required
    Restrictions
    Description

    » result

    false

    none

    none

    VWAP

    VWAP

    What is this endpoint for?

    This endpoint delivers VWAP (volume-weighted average price) for an instrument on an exchange in real time.

    Endpoints

    gateway-v0-grpc.kaiko.ovh

    Request parameters

    Parameter
    Description
    Examples

    Configuring a wildcard

    A wildcard allows you to request all information we have on a specific instrument, class, or exchange in the same stream. Use a * in place of the relevant exchange, instrument, or class parameter.

    For example, the configuration below would deliver trades for BTC/USD across all exchanges where it’s supported:

    Response fields

    Field
    Description

    Request examples

    cURL requests are intended for testing purposes only.

    Information from this endpoint can be accessed through Google BigQuery. To get started, read our .

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

    Response Example

    string

    default

    Default

    An unexpected error response.

    rpcStatus

    OK
    Forbidden
    Not Found
    kaikosdkStreamAggregatesVWAPResponseV1
    exchange: * class: spot instrument: btc-usd

    uid

    The unique ID for this delivery.

    volume

    Volume traded in interval. 0 when no trades reported.

    sequenceId

    Not applicable. Null

    aggregate

    The period you would like the VWAP aggregation to be calculated over.

    1m

    instrumentCriteria

    A nested object to configure following properties for your stream:

    • exchange (String) - The code(s) for the exchange(s)

    • instrument_class (String) - The class(es) of the instrument(s) .

    • code (String) - The Kaiko code for the instrument.

    Explore instruments, codes and exchanges in the or .

    cbse

    spot

    btc-usd

    aggregate

    The period of calculation.

    class

    The class of instrument.

    code

    The instrument code.

    price

    The price for the peirod (USD).

    exchange

    The exchange the VWAP is referencing.

    tsEvent

    The timestamp for the interval.

    gateway-v0-http.kaiko.ovh
    https://gateway-v0-http.kaiko.ovh/api/stream/aggregates_vwap_v1
    here

    Kaiko Best Execution

    What is this endpoint for?

    Get a market-representative execution benchmark that’s ideal for reporting and demonstrating execution efficiency to clients. The exchanges used in this calculation are vetted, meaning only those that are part of the Kaiko Exchange Ranking are included. The best bids are aggregated over 10-second intervals and delivered every second. This means you receive the best bids and asks from the previous 10 seconds, updated every second.

    Note that Kaiko Exchange Ranking is updated every quarter, so the exchanges used in the calculation may change.

    Endpoints

    Request parameters

    Parameter
    Description
    Examples
    Mandatory?

    Configuring multiple instruments

    To configure multiple instruments in the same stream, provide the code as a comma separated list eg btc-usd,eth-usd.

    Response fields

    Field
    Description

    Request examples

    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

    OHLCV Candles (v1)

    This endpoint has been deprecated. Please use the new OHLCV Candlesticks endpoint instead. OHLCV Please contact [email protected] if you have any questions about migrating.

    Subscribe

    Retrieve ongoing Open-High-Low-Close-Volume candle updates. Supported intervals are 1s, 1m and 1h.

    Event Sending Rate

    Please note that an event is not sent for every trades on the feed for a given exchange/instrument. Feed consumers should treat each event update as an absolute representation, indicating the precise values of data aggregation at the time it is sent. Each update represents an accurate aggregation at a specific point in time. This implies that there must be at least one tick between two consecutive events for a given exchange/symbol, though there may be more.

    Duplicate Events

    For OHLCV/VWAP, duplicate events may be sent due to the way data is aggregated in our centralized datastore. This means that for two consecutive events for a given exchange/code, the first event might contain an aggregated result that includes ticks inserted before we sent an update message. This can result in duplicates for the subsequent update since it has already been accounted for in the aggregation of the first event. It is important to note that this does not indicate inaccurate data, as we consistently provide accurate real-time information. Instead, it represents high trading volume being ingested rapidly, which is actually a positive aspect, as it keeps you up-to-date with the latest developments on the exchanges. In some instances, our updates may even be faster.

    Parameters

    Name
    In
    Type
    Required
    Description

    Responses

    Status
    Meaning
    Description
    Schema

    Response Schema

    Status Code 200

    Stream result of kaikosdkStreamAggregatesOHLCVResponseV1

    Name
    Type
    Required
    Restrictions
    Description

    State price

    What is this endpoint for?

    This endpoint should be used when there isn’t enough liquidity to produce a direct or synthetic price. Especially useful for DeFi-only assets, state price derives a price by analyzing the real-time state of liquidity pools for the selected asset, inspecting the pools’ reserves, balances, and recent flow to infer a-price consistent with current market conditions. The data includes the calculated state price and the trading volume from the associated block within each pool, expressed in USD. Pool eligibility depends on the pairing: non-LST tokens must be paired with USDT, USDC, or wETH, while LST tokens must be paired with wETH.

    Endpoint

    Parameters

    Parameter
    Description
    Examples
    Mandatory?

    Fields

    Field
    Description

    Request examples

    Make sure to read our before starting.

    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

    Aggregated Quotes (v1)

    This endpoint is deprecated and will be removed in future release. Please use Aggregated Quotes instead. Kaiko Best Execution Please contact [email protected] if you have any questions about migrating.

    Subscribe

    Retrieve ongoing Top Of Book (Ask or Bid) average price updates accross a selection of exchanges, for a given instrument.

    Wildcard (*) is not supported, but you can provide a comma separated list of instruments codes (for example: “btc-usd,eth-usd” as code field).

    An empty value can be returned when there are no changes on best ask or best bid across exchanges where the requested instrument is listed. This allows checking that the service is working as expected even though no meaningful update is sent.

    The update frequency is 5s.

    Parameters

    Name
    In
    Type
    Required
    Description

    Responses

    Status
    Meaning
    Description
    Schema

    Response Schema

    Status Code 200

    Stream result of kaikosdkStreamAggregatedPriceResponseV1

    Name
    Type
    Required
    Restrictions
    Description

    Enumerated Values

    Property
    Value

    Trades (v1)

    This endpoint has been deprecated. Please use the new Tick-Level Trades endpoint instead. All trades Please contact [email protected] if you have any questions about migrating.

    Subscribe

    Retrieve an ongoing stream of tick-by-tick trades for any selection of instruments or exchanges.

    POST /api/stream/trades_v1

    Parameters

    Name
    In
    Type
    Required
    Description

    Responses

    Status
    Meaning
    Description
    Schema

    Response Schema

    Status Code 200

    Stream result of kaikosdkStreamTradesResponseV1

    Name
    Type
    Required
    Restrictions
    Description

    Enumerated Values

    Property
    Value

    All trades

    What is this endpoint for?

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

    OHLCV

    What is this endpoint for?

    This Stream delivers the OHLCV for an instrument on an exchange in real-time.

    Endpoints

    curl -X POST "https://gateway-v0-http.kaiko.ovh/api/stream/aggregates_vwap_v1" -H "accept: application/json" -H "X-Api-Key: $KAIKO_API_KEY" -H "Content-Type: application/json" -d "{ \"instrumentCriteria\": {  \"exchange\": \"binc\",  \"instrumentClass\": \"spot\",  \"code\": \"eth-usdt\" }, \"aggregate\": \"1m\"}"
    "aggregate": "1s",
      "class": "spot",
      "code": "eth-usdt",
      "exchange": "binc",
      "price": 2591.3221372276307,
      "tsEvent": "2024-08-09T13:47:20.689338450Z",
      "uid": "2024-08-09T13:47:19Z",
      "sequenceId": ""
    

    volume

    • When BEST-BID: The quantity of the base asset that the buyer is willing to purchase

    • When BEST-ASK: The quantity of the base asset the seller has available for sale

    instrument_class

    The class of the instrument(s) . Explore instruments, codes and exchanges in the Instrument Explorer or .

    spot

    code

    The Kaiko code for the instrument(s). The class of the instrument(s) . Explore instruments, codes and exchanges in the Instrument Explorer or .

    btc-usd

    includeUnvettedPrice

    This parameter is set to false by default and not included in the code example. Setting this field to true includes best bids and asks from exchanges that are not included in the Kaiko Exchange Ranking. This parameter is helpful when an instrument you need is not covered by any exchange on the Kaiko Exchange ranking. It also serves as a backup for instruments covered by only one exchange, ensuring you still receive a price in case that exchange drops off the ranking when it's updated. If you set this parameter true, the calculation will include all exchanges covered by Kaiko and this price will appear in a separate unvetted section of the response.

    "includeUnvettedPrice": true

    aggregate

    The time period over which the best bid or ask was calculated. This is always 10s.

    instrumentClass

    The class of the instrument.

    code

    The instrument code.

    eventType

    BEST_BID - The best bid from the period BEST_ASK - The best ask from the period

    tsEvent

    The timestamp the data became available in the Kaiko system.

    price

    When BEST-BID: The price per unit of the base that the buyer is willing to pay in the quote asset, represented as a scientific notation

    Example: btc-usd

    • base asset = btc

    • quote asset = usd price: 60555.00271626198

    For each unit of btc, the buyer is willing to pay 60555.00271626198 USD.

    When BEST-ASK: The price per unit of the base that the seller is willing to accept in the quote asset, represented as a scientific notation

    Example: btc-usd

    • base asset = btc

    • quote asset = usd price: 60556.00224312413

    For each unit of btc, the buyer is willing to accept 60556.00224312413 USD.

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

    default

    Default

    An unexpected error response.

    body

    body

    kaikosdkStreamAggregatesOHLCVRequestV1

    true

    none

    200

    OK

    A successful response.(streaming responses)

    Inline

    403

    Forbidden

    Returned when the user does not have permission to access the resource.

    Inline

    404

    Not Found

    Returned when the resource does not exist.

    » result

    kaikosdkStreamAggregatesOHLCVResponseV1

    false

    none

    none

    string

    default

    Default

    An unexpected error response.

    body

    body

    kaikosdkStreamAggregatedPriceRequestV1

    true

    none

    200

    OK

    A successful response.(streaming responses)

    Inline

    403

    Forbidden

    Returned when the user does not have permission to access the resource.

    Inline

    404

    Not Found

    Returned when the resource does not exist.

    » result

    kaikosdkStreamAggregatedPriceResponseV1

    false

    none

    none

    eventType

    UNKNOWN

    eventType

    BEST_ASK

    eventType

    BEST_BID

    string

    default

    Default

    An unexpected error response.

    body

    body

    kaikosdkStreamTradesRequestV1

    true

    none

    200

    OK

    A successful response.(streaming responses)

    Inline

    403

    Forbidden

    Returned when the user does not have permission to access the resource.

    Inline

    404

    Not Found

    Returned when the resource does not exist.

    » result

    kaikosdkStreamTradesResponseV1

    false

    none

    none

    side

    UNKNOWN

    side

    BUY

    side

    SELL

    string

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

    Request parameters

    Parameter
    Description
    Examples

    instrumentCriteria

    A nested object to configure following properties for your stream:

    • exchange (String) - The code(s) for the exchange(s)

    • instrument_class (String) - The class(es) of the instrument(s) .

    • code (String) - The Kaiko code for the instrument.

    cbse

    spot

    btc-usd

    commodities

    Must always be [pb_commodity.SMUC_TRADE]

    [pb_commodity.SMUC_TRADE]

    interval

    For accessing 72h replay data only. See the replay code example.

    start_time end_time

    Configuring a wildcard

    A wildcard allows you to request all information we have on a specific instrument, class, or exchange in the same stream. Use a * in place of the relevant exchange, instrument, or class parameter.

    For example, the configuration below would deliver trades for BTC/USD across all exchanges where it’s supported:

    exchange: * class: spot instrument: btc-usd

    Response fields

    Field
    Description

    additionalProperties

    Additional properties, specific to the exchange.

    amount

    Quantity of asset bought or sold (can be in base_asset, quote_asset or the number of contracts).

    class

    Instrument class, empty when not mapped.

    code

    Instrument code, empty when not mapped.

    exchange

    Instrument exchange code.

    sequenceId

    Sequence ID for event. Sortable in lexicographic order.

    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 here, where you'll find more coding languages, examples and guidance.

    Response Example

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

    Request parameters

    Parameter
    Description
    Examples

    aggregate

    The period you would like the OHLCV aggregation to be calculated over.

    1m

    instrumentCriteria

    A nested object to configure following properties for your stream:

    • exchange (String) - The code(s) for the exchange(s)

    • instrument_class (String) - The class(es) of the instrument(s) .

    • code (String) - The Kaiko code for the instrument.

    cbse

    spot

    btc-usd

    Configuring a wildcard

    A wildcard allows you to request all information we have on a specific instrument, class, or exchange in the same stream. Use a * in place of the relevant exchange, instrument, or class parameter.

    For example, the configuration below would deliver trades for BTC/USD across all exchanges where it’s supported:

    exchange: * class: spot instrument: btc-usd

    Response fields

    Field
    Description

    aggregate

    The period of calculation.

    class

    The class of instrument.

    close

    Closing price of interval. null when no trades reported.

    exchange

    The exchange the OHLCV is referencing.

    high

    Closing price of interval. null when no trades reported.

    low

    Lowest price during interval. null when no trades reported.

    Request examples

    cURL requests are intended for testing purposes only.

    Information from this endpoint can be accessed through Google BigQuery. To get started, read our .

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

    Response Example

    gateway-v0-grpc.kaiko.ovh

    asset

    The asset name you would like to get data for. To retrieve data for all eligible assets at once, simply enter * in the asset parameter field.

    ageur,wsteth

    datetime

    Timestamp at which the data has been processed. One data point per second will be published.

    base

    Base asset requested.

    aggregatedPriceUsd

    State price aggregated over multiple pools, denominated in USD.

    aggregatedPriceEth

    State price aggregated over multiple pools, denominated in ETH. This field will return empty for LST tokens.

    tsEvent

    Date of the publication.

    lstQuote

    LST quote token if relevant, otherwise will return empty.

    gateway-v0-grpc.kaiko.ovh
    gateway-v0-http.kaiko.ovh
    https://gateway-v0-http.kaiko.ovh/api/stream/aggregatedstateprice
    Python quick-start guide
    here
    Instrument Explorer

    Best bids and asks (top of book)

    What is this endpoint for?

    Top-of-Book is also known as best bids and asks. It offers the best bid and best asks on an order book, provided in real-time.

    Endpoints

    Implied Volatility SVI (Closed Beta)

    This is a closed beta. Please contact your account manager if you'd like to be included in the program.

    What is this endpoint for?

    IV SVI stands for Implied Volatility Surface for Vanilla Instruments. This endpoint distributes the raw data we use to calculate our solution.

    curl -X POST "https://gateway-v0-http.kaiko.ovh/api/stream/aggregated_quote_v2" -H "accept: application/json" -H "X-Api-Key: $KAIKO_API_KEY" -H "Content-Type: application/json" -d "{\"instrumentClass\":\"spot\", \"code\": \"btc-usd\"}"
     "aggregate": "10s",
      "instrumentClass": "spot",
      "code": "btc-usd",
      "eventType": "BEST_ASK",
      "tsEvent": "2024-08-09T23:15:18.087882038Z",
      "vetted": {
        "price": "60556.00224312413",
        "volume": "0.2699806"
    curl -X POST "https://gateway-v0-http.kaiko.ovh/api/stream/market_update_v1" -H "accept: application/json" -H "X-Api-Key: $KAIKO_API_KEY" -H "Content-Type: application/json" -d "{ \"instrumentCriteria\": {  \"exchange\": \"cbse\",  \"instrumentClass\": \"spot\",  \"code\": \"*\" }, \"commodities\": [\"SMUC_TRADE\"]}"
    {
        "result": {
            "additionalProperties": {
                "sequence": "85453949096"
            },
            "amount": 0.31157787,
            "class": "spot",
            "code": "btc-usd",
            "exchange": "cbse",
            "sequenceId": "cqpo618mna6i5t62gp4g",
            "id": "677226346",
            "price": 56510,
            "side": "SELL",
            "tsExchange": {
                "value": "2024-08-07T14:21:57.046442Z"
            },
            "tsCollection": {
                "value": "2024-08-07T14:21:57.131157967Z"
            },
            "tsEvent": "2024-08-07T14:21:57.329633824Z"
        }
    }
    curl -X POST "https://gateway-v0-http.kaiko.ovh/api/stream/aggregates_ohlcv_v1" -H "accept: application/json" -H "X-Api-Key: $your_key" -H "Content-Type: application/json" -d "{ \"instrumentCriteria\": { \"exchange\": \"cbse\", \"instrumentClass\": \"spot\", \"code\": \"btc-usd\" }, \"aggregate\": \"1m\"}"
     {"aggregate": "1s",
      "class": "spot",
      "close": "60521.02",
      "exchange": "cbse",
      "high": "60528.91",
      "low": "60521.02",
      "open": "60528.91",
      "code": "btc-usd",
      "timestamp": "2024-08-09T13:13:14.347471354Z",
      "uid": "2024-08-09T13:13:13Z",
      "volume": "0.00028618000000000003",
      "sequenceId": "" }
    curl -X POST "https://gateway-v0-http.kaiko.ovh/api/stream/aggregatedstateprice" -H "accept: application/json" -H "X-Api-Key: $KAIKO_API_KEY" -H "Content-Type: application/json" -d "{ \"asset\": \"wsteth\", \"start_time\": \"2025-01-07T10:48:59.528Z\", \"end_time\": \"2025-01-08T10:48:59.528Z\" }"
    {
    	"result": {
    		"datetime": "2024-10-23T09:45:13.000964543Z",
    		"base": "wsteth",
    		"aggregatedPriceUsd": "3036.2060425401045987863569203955",
    		"aggregatedPriceEth": "1.1822171670279031",
    		"tsEvent": "2024-10-23T09:45:13.447941047Z",
    		"lstQuote": "weth"
    	}
    }
    rpcStatus
    rpcStatus
    rpcStatus

    Explore instruments, codes and exchanges in the Instrument Explorer or .

    id

    Trade ID, empty string when not present.

    price

    Price for the trade.

    tsExchange

    The timestamp provided by the exchange for the transaction.

    tsCollection

    The timestamp for when Kaiko received the trade from the exchange.

    tsEvent

    The timestamp the data became available in the Kaiko system.

    side

    - UNKNOWN: Unknown side (not specified). - BUY: Buy side. - SELL: Sell side. See "taker_side_sell" Explained

    Explore instruments, codes and exchanges in the Instrument Explorer or .

    open

    Opening price of interval. null when no trades reported.

    code

    The instrument code.

    timestamp

    The timestamp for the interval.

    uid

    The unique ID for this delivery.

    volume

    Volume traded in interval. 0 when no trades reported.

    sequenceId

    Not applicable. Null

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

    Request parameters

    Parameter
    Description
    Examples

    instrumentCriteria

    A nested object to configure following properties for your stream:

    • exchange (String) - The code(s) for the exchange(s)

    • instrument_class (String) - The class(es) of the instrument(s) .

    • code (String) - The Kaiko code for the instrument.

    cbse

    spot

    algo-btc

    Configuring a wildcard

    A wildcard allows you to request all information we have on a specific instrument, class, or exchange in the same stream. Use a * in place of the relevant exchange, instrument, or class parameter.

    For example, the configuration below would deliver trades for BTC/USD across all exchanges where it’s supported:

    exchange: * class: spot instrument: btc-usd

    Response fields

    Field
    Description

    amount

    • When BEST-BID: The quantity of the base asset that the buyer is willing to purchase

    • When BEST-ASK: The quantity of the base asset the seller has available for sale

    class

    Instrument class, empty when not mapped.

    code

    Instrument code, empty when not mapped.

    exchange

    Instrument exchange code.

    sequenceId

    Sequence ID for event. Sortable in lexicographic order.

    price

    When BEST-BID: The price per unit of the base that the buyer is willing to pay in the quote asset, represented as a scientific notation

    Example: algo-btc

    • base asset = algo

    • quote asset = btc price: 1.96e-06

    For each unit of Algo, the buyer is willing to pay 1.96e-06

    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 here, where you'll find more coding languages, examples and guidance.

    Response Example

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

    Parameters

    Parameter
    Description
    Examples

    assets

    A nested object to configure following properties for your stream:

    • base (String) - The desired base as the underlying of the options.

    • quote (String) - The desired quote as the underlying of the options.

    Explore codes and exchanges in the or by using the endpoint.

    btc

    usd

    exchanges

    The desired exchange as source of options data.

    Explore codes and exchanges in the or by using the endpoint.

    drbt

    Fields

    Field
    Description

    dataStartTime

    Start time of the calculation window used.

    dataEndTime

    End time of the calculation window used.

    expiry

    Expiry date of the instrument.

    exchanges

    Exchanges included.

    timeToExpiry

    Time to expiry.

    atmImpliedVariance

    ATM implied variance.

    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

    Direct price

    What is this endpoint for?

    This endpoint returns a price calculation for a specific pair by aggregating prices from our trading data. The computation works as follows:

    1. Listen to trades from all selected exchanges where the instrument is actively traded.

    2. Compute RWM price. The computation is based on two principles:

      • A robust aggregation of prices (derived from a weighted median methodology: full details available here)

      • An incremental increase of the estimation window seeking for sufficient dataset to compute a robust price (e.g. number of trades under a certain threshold)

    At the end of the computation, in case there are still no trades, a null value will be returned. In this instance, we'd reccomend using .

    Endpoints

    Parameters

    Parameter
    Description
    Examples
    Mandatory?

    Exchanges that send their trades late may not be captured in the given sliding window.

    Fields

    Field
    Description

    Request examples

    Make sure to read our before starting.

    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

    Synthetic price

    What is this endpoint for?

    This endpoint calculates a synthetic price when there is less liquidity (historic trades) between two assets. The methodology is developed with global tax and accounting standards in mind. Additionally, our robust price aggregation method reduces the impact of outliers in terms of volume and price, meaning you can trust the price returned.

    The calculation works as follows:

    1. Retrieve the last available optimal liquidity path

    2. Listen to trades for all intermediary pairs from all covered exchanges where the instrument is actively traded

    3. Compute RWM price for each intermediary pair

    4. Compute the product of intermediary pairs based on the liquidity path

    The calculation considers all instruments traded across all exchanges covered by Kaiko.

    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 .

    Endpoints

    Parameters

    Parameter
    Description
    Examples
    Mandatory?

    Exchanges that send their trades late may not be captured in the given sliding window.

    Fields

    Field
    Description

    Request examples

    Make sure to read our before starting.

    cURL requests are intended for testing purposes only.

    Information from this endpoint can be accessed through Google BigQuery. To get started, read our .

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

    Response Example

    Quick-Start Guides

    The prerequisites for setting up your Kaiko Stream

    Let's get started setting up your first stream by using one of our Quick-Start Guides below.

    Quick-Start Guides

    Note, Kaiko Stream also supports several other coding languages that we do not have quick-start guides for. For C++, C#, Go, Java, Node, Python, Rust, Scala languages, you can find the SDK examples in our Github .

    curl -X POST "https://gateway-v0-http.kaiko.ovh/api/stream/market_update_v1" -H "accept: application/json" -H "X-Api-Key: $KAIKO_API_KEY" -H "Content-Type: application/json" -d "{ \"instrumentCriteria\": {  \"exchange\": \"cbse\",  \"instrumentClass\": \"spot",  \"code\": \"btx-usd\" }, \"commodities\": [\"SMUC_TOP_OF_BOOK\"]}"
    {
      "commodity": "SMUC_TOP_OF_BOOK",
      "amount": 6.835e-05,
      "class": "spot",
      "code": "btc-usd",
      "exchange": "cbse",
      "sequenceId": "cqr9icumv1b0afe4cg50",
      "price": 60763.73,
      "tsExchange": {
        "value": "2024-08-09T22:33:23.902971Z"
      },
      "tsCollection": {
        "value": "2024-08-09T22:33:23.916224545Z"
      },
      "tsEvent": "2024-08-09T22:33:23.978211823Z",
      "updateType": "BEST_BID",
      "id": "",
      "additionalProperties": {}
    }
    
    # This is a code example. Configure your parameters in the parameter configuration section #
    
    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
    from kaikosdk.stream.index_v1 import request_pb2 as pb_index
    from kaikosdk.stream.index_multi_assets_v1 import request_pb2 as pb_index_multi_assets
    from kaikosdk.stream.index_forex_rate_v1 import request_pb2 as pb_index_forex_rate
    from kaikosdk.stream.aggregated_quote_v2 import request_pb2 as pb_aggregated_quote
    from kaikosdk.stream.aggregates_spot_exchange_rate_v2 import request_pb2 as pb_spot_exchange_rate
    from kaikosdk.stream.aggregates_direct_exchange_rate_v2 import request_pb2 as pb_direct_exchange_rate
    from kaikosdk.stream.derivatives_instrument_metrics_v1 import request_pb2 as pb_derivatives_instrument_metrics
    from kaikosdk.stream.iv_svi_parameters_v1 import request_pb2 as pb_iv_svi_parameters
    
    
    def iv_svi_parameters_v1_request(channel: grpc.Channel):
        try:
            with channel:
                stub = sdk_pb2_grpc.StreamIvSviParametersServiceV1Stub(channel)
    
                responses = stub.Subscribe(pb_iv_svi_parameters.StreamIvSviParametersRequestV1(
                    assets = assets_pb2.Assets(
                        base = "btc",
                        quote = "usd"
                    ),
                    exchanges = "drbt"
                ))
                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)
    
        iv_svi_parameters_v1_request(channel)
    
    if __name__ == '__main__':
        logging.basicConfig()
        run()
    
    curl --request POST \
      --url https://gateway-v0-http.kaiko.ovh/api/stream/iv_svi_parameters_v1 \
      --header 'Accept: application/json' \
      --header 'Content-Type: application/json' \
      --header 'X-Api-Key: API_KEY' \
      --data '{"assets":{"base":"btc","quote":"usd"},"exchanges":"drbt"}'
    here
    Quick-Start: Python
    Quick-Start: cURL

    extrapolate_missing_values

    This parameter is set to false by default. Setting it to true means that if there is no trade price available from the calculation window you configured, the last available price (from outside the window) will be used.

    false

    window

    The window on which you would like your Cross Price to be calculated. Available windows: 1s, 5s, 15s, 30s, 60s, 300s

    5s

    update_frequency

    How regularly you would like to receive your pricing updates. Available frequencies: 1s, 5s, 10s, 30s, and 1m

    2s

    assets

    A nested object to configure following properties for your stream:

    • base - the base asset you'd like your price to be based on

    • quote - the asset you'd like the price to be quoted in

    Explore instruments, codes and exchanges in the Instrument Explorer or .

    btc usd

    assets

    The base and quote assets as configured above.

    price

    The calculated Cross Price.

    timestamp

    The time the Cross Price was calculated.

    window

    A nested object containing the following fields:

    • startTime - The start of the calculation window for this Cross Price

    • endTime - The end of the calculation window for this Cross Price

    • Duration - The window as configured above

    noTrade

    If false a price was able to be calculated within the window provided. If true the extrapolate_missing_values parameter was needed to calculate a price.

    Cross Prices
    gateway-v0-grpc.kaiko.ovh
    gateway-v0-http.kaiko.ovh
    https://gateway-v0-http.kaiko.ovh/api/stream/aggregates_spot_direct_exchange_rate_v2
    Python quick-start guide
    here

    extrapolate_missing_values

    This parameter is set to false by default. Setting it to true means that if there is no trade price available from the calculation window you configured, the last available price (from outside the window) will be used.

    false

    window

    The window on which you would like your Cross Price to be calculated. Available windows: 1s, 5s, 15s, 30s, 60s, 300s

    15s

    update_frequency

    How regularly you would like to receive your pricing updates. Available frequencies: 1s, 5s, 10s, 30s, and 1m

    1s

    assets

    A nested object to configure following properties for your stream:

    • base - the base asset you'd like your price to be based on

    • quote - the asset you'd like the price to be quoted in

    Explore instruments, codes and exchanges in the Instrument Explorer or .

    btc eur

    assets

    The base and quote assets as configured above.

    price

    The calculated Cross Price.

    timestamp

    The time the Cross Price was calculated.

    window

    A nested object containing the following fields:

    • startTime - The start of the calculation window for this Cross Price

    • endTime - The end of the calculation window for this Cross Price

    • Duration - The window as configured above

    noTrade

    If false a price was able to be calculated within the window provided. If true the extrapolate_missing_values parameter was needed to calculate a price.

    Oanda FX Rates add-on
    gateway-v0-grpc.kaiko.ovh
    gateway-v0-http.kaiko.ovh
    https://gateway-v0-http.kaiko.ovh/api/stream/aggregates_spot_exchange_rate_v2
    Python quick-start guide
    here

    Explore instruments, codes and exchanges in the Instrument Explorer or .

    BTC, equal to 0.00000196 when converted to a decimal number

    When BEST-ASK: The price per unit of the base that the seller is willing to accept in the quote asset, represented as a scientific notation

    Example: algo-btc

    • base asset = algo

    • quote asset = btc price: 1.97e-06

    For each unit of Algo, the buyer is willing to accept 1.97e-06 BTC, equal to 0.00000197 when converted to a decimal number

    tsExchange

    The timestamp provided by the exchange for the data. Where exchanges do not provide this data, we fill this with tsCollection. This applies to the following exchanges:

    • Bitfinex (bfnx) perpetual-future & spot

    • Binance US (bnus) spot

    • Bitvavo (bvav) spot

    tsCollection

    The timestamp for when Kaiko received the data from the exchange.

    tsEvent

    The timestamp the data became available in the Kaiko system.

    updateType

    BEST_BID - The current best bid BEST_ASK - The current best ask

    additionalProperties

    N/A. Always null

    id

    N/A. Always null

    atmSkew

    ATM skew.

    leftSlope

    Left slope of IV smile.

    rightSlope

    Right slope of IV smile.

    minImpliedVariance

    Min implied variance.

    currentSpot

    Current spot.

    interestRate

    Interest rate.

    tsEvent

    Event generation timestamp (event created by Kaiko), after normalization.

    Instrument Explorer
    Instrument Explorer

    Bids and asks

    What is this endpoint for?

    All bids and asks on an exchange's order book. Use Kaiko Stream for real-time tick-level updates, or CSV for backdated information. When you connect, you first receive a full snapshot of the current order book with every bid and ask, followed by continuous real-time updates for every change ("delta") that takes place.

    When you subscribe, you'll initially receive a full snapshot within a few seconds, followed by all subsequent tick-level updates. If you receive another full snapshot, replace your local snapshot with the new one. This should happen infrequently and only occurs if we detect a consistency issue, such as a lost connection to the exchange or the exchange being down for some time.

    If you receive an update with an amount of 0, you should remove the corresponding price level from your local order book. You'll occasionally receive a 0 message for a price level that doesn't exist in your local order book - this can be safely ignored and is due to various exchange limitations.

    The order book should not be considered valid until all updates with the same tsExchange have been applied to your local order book, meaning all potential messages from the same update batch have been processed.

    Endpoints

    Request parameters

    Parameter
    Description
    Examples

    Configuring a wildcard

    A wildcard allows you to request all information we have on a specific instrument, class, or exchange in the same stream. Use a * in place of the relevant exchange, instrument, or class parameter.

    For example, the configuration below would deliver trades for BTC/USD across all exchanges where it’s supported:

    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

    Derivatives pricing

    Derivatives price endpoint.

    What is this endpoint for?

    This endpoint can be used to get pricing information related to derivatives contracts.

    Endpoints

    gateway-v0-grpc.kaiko.ovh

    Request parameters

    Parameter
    Description
    Examples

    Configuring a wildcard

    A wildcard allows you to request all information we have on a specific instrument or exchange in the same stream. Use a * in place of the relevant exchange or class parameter.

    For example, the configuration below would deliver all perpetual future contracts on OkEX. exchange: okex class: perpetual-future instrument: *

    Response fields

    Field
    Description
    Example

    Request examples

    cURL requests are intended for testing purposes only.

    Information from this endpoint can be accessed through Google BigQuery. To get started, read our .

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

    Response Example

     # This is a code example. Configure your parameters in the parameter configuration section #
    
    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
    from kaikosdk.stream.index_v1 import request_pb2 as pb_index
    from kaikosdk.stream.index_multi_assets_v1 import request_pb2 as pb_index_multi_assets
    from kaikosdk.stream.index_forex_rate_v1 import request_pb2 as pb_index_forex_rate
    from kaikosdk.stream.aggregated_quote_v2 import request_pb2 as pb_aggregated_quote
    from kaikosdk.stream.aggregates_spot_exchange_rate_v2 import request_pb2 as pb_spot_exchange_rate
    from kaikosdk.stream.aggregates_direct_exchange_rate_v2 import request_pb2 as pb_direct_exchange_rate
    
    def aggregates_direct_exchange_rate_request(channel: grpc.Channel):
        try:
            with channel:
                stub = sdk_pb2_grpc.StreamAggregatesSpotDirectExchangeRateV2ServiceV1Stub(channel)
    
    ##Configure your window and frequency ##
                window = duration_pb2.Duration()
                window.FromSeconds(5)
    
                update_frequency = duration_pb2.Duration()
                update_frequency.FromSeconds(2)
    
                responses = stub.Subscribe(pb_direct_exchange_rate.StreamAggregatesDirectExchangeRateV2RequestV1(
    
    ##Configure your assets##
                    assets = assets_pb2.Assets(
                        base = "btc",
                        quote = "usd"
                    ),
                    window = window,
                    update_frequency = update_frequency
                ))
                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)
    
        aggregates_direct_exchange_rate_request(channel)
    
    if __name__ == '__main__':
        logging.basicConfig()
        run()
    
    curl -X POST "https://gateway-v0-http.kaiko.ovh/api/stream/aggregates_spot_direct_exchange_rate_v2" -H "accept: application/json" -H "X-Api-Key: $KAIKO_API_KEY" -H "Content-Type: application/json" -d "{ \"assets\": { \"base\": \"btc\", \"quote\": \"usd\" }, \"window\": \"10s\"}"
     "assets": {
        "base": "btc",
        "quote": "usd"
      },
      "price": 59394.87,
      "timestamp": "2024-08-12T11:14:58.022023572Z",
      "window": {
        "startTime": "2024-08-12T11:14:48Z",
        "endTime": "2024-08-12T11:14:58Z",
        "duration": "10s"
      },
      "noTrade": false
    }
    
     # This is a code example. Configure your parameters in the parameter configuration section #
    
    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
    from kaikosdk.stream.index_v1 import request_pb2 as pb_index
    from kaikosdk.stream.index_multi_assets_v1 import request_pb2 as pb_index_multi_assets
    from kaikosdk.stream.index_forex_rate_v1 import request_pb2 as pb_index_forex_rate
    from kaikosdk.stream.aggregated_quote_v2 import request_pb2 as pb_aggregated_quote
    from kaikosdk.stream.aggregates_spot_exchange_rate_v2 import request_pb2 as pb_spot_exchange_rate
    from kaikosdk.stream.aggregates_direct_exchange_rate_v2 import request_pb2 as pb_direct_exchange_rate
    
    def aggregates_spot_exchange_rate_request(channel: grpc.Channel):
        try:
            with channel:
                stub = sdk_pb2_grpc.StreamAggregatesSpotExchangeRateV2ServiceV1Stub(channel)
     # confiugure your window and frequency #
                window = duration_pb2.Duration()
                window.FromSeconds(10)
    
                update_frequency = duration_pb2.Duration()
                update_frequency.FromSeconds(2)
    
                responses = stub.Subscribe(pb_spot_exchange_rate.StreamAggregatesSpotExchangeRateV2RequestV1(
     # confiugure your assets #
                    assets = assets_pb2.Assets(
                        base = "eth",
                        quote = "usd"
                    ),
                    
                   # End of parameter configuration#
                    window = window,
                    update_frequency = update_frequency
                ))
                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)
    
        aggregates_spot_exchange_rate_request(channel)
    
    if __name__ == '__main__':
        logging.basicConfig()
        run()
    curl -X POST "https://gateway-v0-http.kaiko.ovh/api/stream/aggregates_spot_exchange_rate_v2" -H "accept: application/json" -H "X-Api-Key: $KAIKO_API_KEY" -H "Content-Type: application/json" -d "{ \"assets\": { \"base\": \"eth\", \"quote\": \"usd\" }, \"window\": \"5s\"}"
    {
      "assets": {
        "base": "eth",
        "quote": "usd"
      },
      "price": 2629.972960779576,
      "timestamp": "2024-08-12T10:35:06.026554200Z",
      "window": {
        "startTime": "2024-08-12T10:34:56Z",
        "endTime": "2024-08-12T10:35:06Z",
        "duration": "10s"
      },
      "noTrade": false
    }
    
    exchange: * class: spot instrument: btc-usd

    bids

    Represents buy orders.

    amount: the quantity of the base asset the buyer is willing to purchase

    price: the price per unit of the base that the buyer is willing to pay in the quote asset, represented as a scientific notation Example: algo-btc

    • base asset = algo

    • quote asset = btc amount : 80569.0

    tsExchange

    The timestamp provided by the exchange for the data. Where exchanges do not provide this data, we fill this with tsCollection. This applies to the following exchanges:

    • Bitfinex (bfnx)

    • Bitflyer (bfly)

    • CEX.io (cexi)

    tsCollection

    The timestamp for when Kaiko received the data from the exchange.

    tsEvent

    The timestamp the data became available in the Kaiko system.

    instrumentCriteria

    A nested object to configure following properties for your stream:

    • exchange (String) - The code(s) for the exchange(s)

    • instrument_class (String) - The class(es) of the instrument(s) .

    • code (String) - The Kaiko code for the instrument.

    Explore instruments, codes and exchanges in the or .

    cbse

    spot

    algo-btc

    class

    Instrument class, empty when not mapped.

    code

    Instrument code, empty when not mapped.

    exchange

    Instrument exchange code.

    sequenceId

    Sequence ID for event. Sortable in lexicographic order.

    updateType

    SNAPSHOT - A new Snapshot of the order book UPDATED- A new batch of bids & asks since the snapshot

    asks

    Represents sell orders

    amount: the quantity of the base asset available for sale

    price: the price per unit of the base that the seller is willing to accept in the quote asset, represented as a scientific notation Example: algo-btc

    • base asset = algo

    • quote asset = btc amount : 42656.0 price: 1.97e-06

    • The asker has 42656.0 Algo available

    • For each unit of Algo, the buyer is willing to accept 1.97e-06 BTC, equal to 0.00000197 when converted to a decimal number

    gateway-v0-grpc.kaiko.ovh
    gateway-v0-http.kaiko.ovh
    https://gateway-v0-http.kaiko.ovh/api/stream/orderbookl2_v1
    https://gateway-v0-http.kaiko.ovh/api/stream/orderbookl2_replay_v1
    here

    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.

    mark_price

    Most recent traded price of derivative contract.

    price

    commodityKind

    Always SDICK_PRICE

    SDICK_PRICE

    tsCollection

    The timestamp for when Kaiko received the trade from the exchange.

    2024-08-30T10:19:38.044166107Z

    tsEvent

    The timestamp for the interval.

    2024-08-30T10:19:39.206955912Z

    instrumentCriteria

    A nested object to configure following properties for your stream:

    • exchange (String) - The code(s) for the exchange(s)

    • instrument_class (String) - The class(es) of the instrument(s) . The instrument must be a derivative class.

    • code (String) - The Kaiko code for the instrument.

    Explore instruments, codes and exchanges in the or via API.

    cbse

    option

    algo-btc

    commodities

    AlwaysSDICK_PRICE

    SDICK_PRICE

    value

    The value for the commodity (price, 24 hour volume etc) received in the message.

    59583.2

    legacySymbol

    Exchange assigned Instrument identifier

    btcusdcperpetual

    exchange

    Supported Exchanges

    binc

    commodity

    The price of the underlying index, often as a weighted average across multiple exchanges' spot prices

    index_price

    gateway-v0-http.kaiko.ovh
    https://gateway-v0-http.kaiko.ovh/api/stream/derivatives_instrument_metrics_v1
    here

    While Fair Market Value Pricing includes fiat conversions, our endpoint ensures IFRS-compliant, auditable conversions for non-USD fiat currencies.

    #Live
    
    curl -X POST "https://gateway-v0-http.kaiko.ovh/api/stream/orderbookl2_v1" -H "accept: application/json" -H "X-Api-Key: $KAIKO_API_KEY" -H "Content-Type: application/json" -d "{ \"instrumentCriteria\": { \"exchange\": \"cbse\", \"instrumentClass\": \"spot\", \"code\": \"algo-btc\"}}"
    
    
    #Replay/Historical Data
    
    curl -X POST "https://gateway-v0-http.kaiko.ovh/api/stream/orderbookl2_replay_v1" -H "accept: application/json" -H "X-Api-Key: $KAIKO_API_KEY" -H "Content-Type: application/json" -d "{ \"instrumentCriteria\": {  \"exchange\": \"cbse\",  \"instrumentClass\": \"spot\",  \"code\": \"algo-btc\" }, \"interval\": { \"startTime\": \"2025-01-14T12:00:00.000Z\", \"endTime\": \"2025-01-14T18:00:00.000Z\" }}"
    Received message {"class":"spot",
    "code":"bch-eur",
    "exchange":"cbse",
    "sequenceId":"cu2o2sokocas72q8rkq0",
    "updateType":"SNAPSHOT",
    "asks":[
      {
        "amount":0.02778327,
        "price":414.07
      },
      {
        "amount":0.4,
        "price":414.08
      }
    ],
    "bids":[
      {
        "amount":0.4,
        "price":413.93
      },
      {
        "amount":0.0277962,
        "price":413.85
      } ],
    "tsExchange":{
      "value":"2025-01-13T21:11:15.064Z"
    },
    "tsCollection":{
      "value":"2025-01-13T21:11:15.064284559Z"
    },
    "tsEvent":"2025-01-13T21:11:15.260258142Z",
    "additionalProperties":{}
    }
    
    Received message {"class":"spot",
    "code":"bch-eur",
    "exchange":"cbse",
    "sequenceId":"cu2o2sokocas72q8rla0",
    "updateType":"UPDATE",
    "asks":[
      {
        "amount":4,
        "price":414.42
      }
      ],
    "bids":[],
    "tsExchange":{
      "value":"2025-01-13T21:11:15.016291Z"
    },
    "tsCollection":{
      "value":"2025-01-13T21:11:15.086529551Z"
    },
    "tsEvent":"2025-01-13T21:11:15.277722255Z",
    "additionalProperties":{}
    }
    
    Received message {"class":"spot",
    "code":"bch-eur",
    "exchange":"cbse",
    "sequenceId":"cu2o2sokocas72q8t9q0",
    "updateType":"UPDATE",
    "asks":[],
    "bids":[
      {
        "amount":0,
        "price":413.85
      },
      {
        "amount":0.02779016,
        "price":413.94
      }
      ],
    "tsExchange":{
      "value":"2025-01-13T21:11:15.235251Z"
      },
    "tsCollection":{
      "value":"2025-01-13T21:11:15.248921649Z"
      },
    "tsEvent":"2025-01-13T21:11:15.635226002Z",
    "additionalProperties":{}
    }
    
    # This is a code example. Configure your parameters in the parameter configuration section #
    
    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
    from kaikosdk.stream.index_v1 import request_pb2 as pb_index
    from kaikosdk.stream.index_multi_assets_v1 import request_pb2 as pb_index_multi_assets
    from kaikosdk.stream.index_forex_rate_v1 import request_pb2 as pb_index_forex_rate
    from kaikosdk.stream.aggregated_quote_v2 import request_pb2 as pb_aggregated_quote
    from kaikosdk.stream.aggregates_spot_exchange_rate_v2 import request_pb2 as pb_spot_exchange_rate
    from kaikosdk.stream.aggregates_direct_exchange_rate_v2 import request_pb2 as pb_direct_exchange_rate
    from kaikosdk.stream.derivatives_instrument_metrics_v1 import request_pb2 as pb_derivatives_instrument_metrics
    from kaikosdk.stream.iv_svi_parameters_v1 import request_pb2 as pb_iv_svi_parameters
    
    
    
    def derivatives_instrument_metrics_request(channel: grpc.Channel):
        try:
            with channel:
                stub = sdk_pb2_grpc.StreamDerivativesInstrumentMetricsServiceV1Stub(channel)
    
                responses = stub.Subscribe(pb_derivatives_instrument_metrics.StreamDerivativesInstrumentMetricsRequestV1(
                    instrument_criteria = instrument_criteria_pb2.InstrumentCriteria(
                    # Start of parameter configuration #
                        exchange = "okex",
                        instrument_class = "perpetual-future",
                        code = "btc-usdt"
                    ),
                    commodities = [
                    "SDICK_PRICE"
                ]
                ))
                    # End of parameter configuration #
                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)
    
        derivatives_instrument_metrics_request(channel)
    
    if __name__ == '__main__':
        logging.basicConfig()
        run()
    
    ``
    curl -X POST "https://gateway-v0-http.kaiko.ovh/api/stream/derivatives_instrument_metrics_v1" \
    -H "accept: application/json" \
    -H "X-Api-Key: $kaiko_api_key" \
    -H "Content-Type: application/json" \
    -d "{ \"instrumentCriteria\": {  \"exchange\": \"okex\",  \"instrumentClass\": \"perpetual-future\",  \"code\": \"btc-usdt\" }}"
    {
      "value": "104741.3",
      "legacySymbol": "btcusdtswap",
      "exchange": "okex",
      "commodity": "index_price",
      "commodityKind": "SDICK_PRICE",
      "tsCollection": "2024-12-18T12:57:14.310736661Z",
      "tsEvent": "2024-12-18T12:57:15.598328558Z"
    }
    {
      "value": "104780.2",
      "legacySymbol": "btcusdtswap",
      "exchange": "okex",
      "commodity": "mark_price",
      "commodityKind": "SDICK_PRICE",
      "tsCollection": "2024-12-18T12:57:14.293738809Z",
      "tsEvent": "2024-12-18T12:57:15.599742192Z"
    }
    {
      "value": "104778.6",
      "legacySymbol": "btcusdtswap",
      "exchange": "okex",
      "commodity": "price",
      "commodityKind": "SDICK_PRICE",
      "tsCollection": "2024-12-18T12:57:14.322458748Z",
      "tsEvent": "2024-12-18T12:57:15.610571665Z"
    }
    
    price
    :
    1.96e-06
  • The buyer will purchase up to 80569.0 Algo

  • For each unit of Algo, the buyer is willing to pay 1.96e-06 BTC, equal to 0.00000196 when converted to a decimal number

  • Instrument Explorer
    Instrument Explorer

    Bids and asks: Market Update

    *Legacy version of Market Update: Full Order Book will be supported until February 17th, 2025

    What is this endpoint for?

    All bids and asks on an exchange's order books. Use Kaiko Stream for real-time tick-level updates, or Rest API for snapshots at 30-second intervals. When you connect, you first receive a snapshot of the current order book, followed by continuous real-time updates for every change ("delta") that takes place.

    When you subscribe, you'll initially receive a full snapshot within a few seconds, followed by all subsequent tick-level updates. If you receive another full snapshot, replace your local snapshot with the new one. This should happen infrequently and only occurs if we detect a consistency issue, such as a lost connection to the exchange or the exchange being down for some time.

    If you receive an update with an amount of 0, you should remove the corresponding price level from your local order book. You'll occasionally receive a 0 message for a price level that doesn't exist in your local order book - this can be safely ignored and is due to various exchange limitations.

    The order book should not be considered valid until all updates with the same tsExchange have been applied to your local order book, meaning all potential messages from the same update batch have been processed.

    Endpoints

    Parameters

    Parameter
    Description
    Examples

    Configuring a wildcard

    A wildcard allows you to request all information we have on a specific instrument, class, or exchange in the same stream. Use a * in place of the relevant exchange, instrument, or class parameter.

    For example, the configuration below would deliver trades for BTC/USD across all exchanges where it’s supported:

    Fields

    Field
    Description

    Request examples

    Make sure to read our before starting.

    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.

    Response Example

    Exchange-provided metrics

    Available in the "basic" pack of Derivatives Risk Indicators.

    What is this endpoint for?

    This endpoint is part of . It can be used to get risk information such as greeks and IV in real-time.

    Endpoints

    Reference API
    Reference API
    exchange: * class: spot instrument: btc-usd

    tsEvent

    The timestamp the data became available in the Kaiko system.

    updateType

    SNAPSHOT - A new Snapshot of the order book UPDATED_BID - A new bid since the snapshot

    UPDATED_ASK - A new ask since the snapshot

    asks

    Represents sell orders

    amount: the quantity of the base asset available for sale

    price: the price per unit of the base that the seller is willing to accept in the quote asset, represented as a scientific notation Example: algo-btc

    • base asset = algo

    • quote asset = btc amount : 42656.0

    bids

    Represents buy orders.

    amount: the quantity of the base asset the buyer is willing to purchase

    price: the price per unit of the base that the buyer is willing to pay in the quote asset, represented as a scientific notation Example: algo-btc

    • base asset = algo

    • quote asset = btc amount : 80569.0

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

    instrumentCriteria

    A nested object to configure following properties for your stream:

    • exchange (String) - The code(s) for the exchange(s)

    • instrument_class (String) - The class(es) of the instrument(s) .

    • code (String) - The Kaiko code for the instrument.

    Explore instruments, codes and exchanges in the or by using the endpoint.

    cbse

    spot

    algo-btc

    class

    Instrument class, empty when not mapped.

    code

    Instrument code, empty when not mapped.

    exchange

    Instrument exchange code.

    sequenceId

    Sequence ID for event. Sortable in lexicographic order.

    tsExchange

    The timestamp provided by the exchange for the data.

    tsCollection

    The timestamp for when Kaiko received the data from the exchange.

    gateway-v0-grpc.kaiko.ovh
    gateway-v0-http.kaiko.ovh
    https://gateway-v0-http.kaiko.ovh/api/stream/market_update_v1
    Python quick-start guide
    gateway-v0-grpc.kaiko.ovh
    gateway-v0-http.kaiko.ovh
    https://gateway-v0-http.kaiko.ovh/api/stream/derivatives_instrument_metrics_v1

    Parameters

    Parameter
    Description
    Examples

    instrumentCriteria

    A nested object to configure following properties for your stream:

    • exchange (String) - The code(s) for the exchange(s)

    • instrument_class (String) - The class(es) of the instrument(s) . The instrument must be a derivative class.

    • code (String) -

    cbse

    option

    algo-btc

    commodities

    AlwaysSDICK_RISK

    SDICK_RISK

    Configuring a wildcard

    A wildcard allows you to request all information we have on a specific instrument or exchange in the same stream. Use a * in place of the relevant exchange or class parameter.

    For example, the configuration below would deliver all perpetual future contracts on OkEX. exchange: okex class: perpetual-future instrument: *

    Fields: Perpetual Future

    Field
    Description
    Example

    Value

    The value for the commodity in the received message. eg: 24h_volume or price

    59583.2

    legacySymbol

    Exchange assigned instrument identifier

    BTCUSDC_PERP

    exchange

    binc

    commodityKind

    Always SDICK_RISK

    SDICK_RISK

    Fields: Future

    Field
    Description
    Example

    Value

    The value for the commodity in the received message. eg: 24h_volume or price

    59583.2

    commodityKind

    Always SDICK_RISK

    SDICK_RISK

    tsCollection

    The timestamp for when Kaiko received the trade from the exchange.

    2024-08-30T10:19:38.044166107Z

    tsEvent

    The timestamp for the interval.

    2024-08-30T10:19:39.206955912Z

    Fields: Option

    Field
    Description
    Example

    Value

    The value for the commodity (price, 24 hour volume etc) received in the message.

    59583.2

    commodityKind

    Always SDICK_RISK

    SDICK_RISK

    tsCollection

    The timestamp for when Kaiko received the trade from the exchange.

    2024-08-30T10:19:38.044166107Z

    tsEvent

    The timestamp for the interval.

    2024-08-30T10:19:39.206955912Z

    Request examples

    cURL requests are intended for testing purposes only.

    Information from this endpoint can be accessed through Google BigQuery. To get started, read our .

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

    Response Example

    Derivatives Risk Indicators
    # This is a code example. Configure your parameters in the parameter configuration section #
    
    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
    from kaikosdk.stream.index_v1 import request_pb2 as pb_index
    from kaikosdk.stream.index_multi_assets_v1 import request_pb2 as pb_index_multi_assets
    from kaikosdk.stream.index_forex_rate_v1 import request_pb2 as pb_index_forex_rate
    from kaikosdk.stream.aggregated_quote_v2 import request_pb2 as pb_aggregated_quote
    from kaikosdk.stream.aggregates_spot_exchange_rate_v2 import request_pb2 as pb_spot_exchange_rate
    from kaikosdk.stream.aggregates_direct_exchange_rate_v2 import request_pb2 as pb_direct_exchange_rate
    
    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 = "cbse",
                        instrument_class = "spot",
                        code = "algo-btc"
                    ),
                      # end of parameter configuration # 
                    commodities=[pb_commodity.SMUC_FULL_ORDER_BOOK]
                ))
                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()
    # This is a code example. Configure your parameters and dates in each section #
    
    from __future__ import print_function
    import logging
    import grpc
    import os
    
    from google.protobuf.json_format import MessageToJson
    from google.protobuf.timestamp_pb2 import Timestamp
    import grpc
    from google.protobuf.json_format import MessageToJson
    from google.protobuf.timestamp_pb2 import Timestamp
    
    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
    from kaikosdk.stream.index_v1 import request_pb2 as pb_index
    from kaikosdk.stream.index_multi_assets_v1 import request_pb2 as pb_index_multi_assets
    from kaikosdk.stream.index_forex_rate_v1 import request_pb2 as pb_index_forex_rate
    from kaikosdk.stream.aggregated_quote_v2 import request_pb2 as pb_aggregated_quote
    from kaikosdk.stream.aggregates_spot_exchange_rate_v2 import request_pb2 as pb_spot_exchange_rate
    from kaikosdk.stream.aggregates_direct_exchange_rate_v2 import request_pb2 as pb_direct_exchange_rate
    
    def market_update_request(channel: grpc.Channel):
        try:
             # start of date configuration #
            start = Timestamp()
            start.FromJsonString('2024-09-25T05:00:00Z')
            end = Timestamp()
            end.FromJsonString('2024-09-26T06:00:00Z')
            # end of date configuration #
    
            stub = sdk_pb2_grpc.StreamMarketUpdateServiceV1Stub(channel)
            responses = stub.Subscribe(pb_market_update.StreamMarketUpdateRequestV1(
                instrument_criteria = instrument_criteria_pb2.InstrumentCriteria(
                         # start of parameter configuration #
                        exchange = "cbse",
                        instrument_class = "spot",
                        code = "algo-btc"),
                         # end of parameter configuration #
                interval={
                    'start_time': start,
                    'end_time' : end
                }
            ))
            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)
    
        res = market_update_request(channel)
        print("Response: %s" % res)
        channel.close()
    
    if __name__ == '__main__':
        logging.basicConfig()
        run()
    curl -X POST "https://gateway-v0-http.kaiko.ovh/api/stream/market_update_v1" -H "accept: application/json" -H "X-Api-Key: $KAIKO_API_KEY" -H "Content-Type: application/json" -d "{ \"instrumentCriteria\": {  \"exchange\": \"cbse\",  \"instrumentClass\": \"spot\",  \"code\": \"algo-btc\" }, \"commodities\": [\"SMUC_FULL_ORDER_BOOK\"]}"
      Received message {"commodity": "SMUC_FULL_ORDER_BOOK",
      "class": "spot",
      "code": "bch-eur",
      "exchange": "cbse",
      "sequenceId": "cqr4creaghi85rh762vg",
      "tsExchange": {
        "value": "2024-08-09T16:40:11.514371Z"
      },
      "tsCollection": {
        "value": "2024-08-09T16:40:13.920904647Z"
      },
      "tsEvent": "2024-08-09T16:40:13.988430052Z",
      "updateType": "SNAPSHOT",
      "snapshot": {
         "asks": [
          {
            "amount": 42656.0,
            "price": 1.97e-06
          },
         "bids": [
          {
            "amount": 80569.0,
            "price": 1.96e-06
          },
          {
            "amount": 30569.0,
            "price": 1.95e-06
          }, ]
    Received message {
    "commodity": "SMUC_FULL_ORDER_BOOK",
      "class": "spot",
      "code": "bch-eur",
      "exchange": "cbse",
      "sequenceId": "cqr4crmaghi85rh7688g",
      "price": 317.67,
      "tsExchange": {
        "value": "2024-08-09T16:40:14.020Z"
      },
      "tsCollection": {
        "value": "2024-08-09T16:40:14.020618238Z"
      },
      "tsEvent": "2024-08-09T16:40:14.227194837Z",
      "updateType": "UPDATED_BID",
      "amount": 0.0,
      "id": "",
      "additionalProperties": {}
    }Received message {
      "commodity": "SMUC_FULL_ORDER_BOOK",
      "class": "spot",
      "code": "bch-eur",
      "exchange": "cbse",
      "sequenceId": "cqr4crmaghi85rh7682g",
      "price": 318.07,
      "tsExchange": {
        "value": "2024-08-09T16:40:14.020Z"
      },
      "tsCollection": {
        "value": "2024-08-09T16:40:14.020432858Z"
      },
      "tsEvent": "2024-08-09T16:40:14.227070681Z",
      "updateType": "UPDATED_ASK",
      "amount": 0.0,
      "id": "",
      "additionalProperties": {}
    }
    
    
    
    # This is a code example. Configure your parameters in the parameter configuration section #
    
    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
    from kaikosdk.stream.index_v1 import request_pb2 as pb_index
    from kaikosdk.stream.index_multi_assets_v1 import request_pb2 as pb_index_multi_assets
    from kaikosdk.stream.index_forex_rate_v1 import request_pb2 as pb_index_forex_rate
    from kaikosdk.stream.aggregated_quote_v2 import request_pb2 as pb_aggregated_quote
    from kaikosdk.stream.aggregates_spot_exchange_rate_v2 import request_pb2 as pb_spot_exchange_rate
    from kaikosdk.stream.aggregates_direct_exchange_rate_v2 import request_pb2 as pb_direct_exchange_rate
    from kaikosdk.stream.derivatives_instrument_metrics_v1 import request_pb2 as pb_derivatives_instrument_metrics
    from kaikosdk.stream.iv_svi_parameters_v1 import request_pb2 as pb_iv_svi_parameters
    
    
    
    def derivatives_instrument_metrics_request(channel: grpc.Channel):
        try:
            with channel:
                stub = sdk_pb2_grpc.StreamDerivativesInstrumentMetricsServiceV1Stub(channel)
    
                responses = stub.Subscribe(pb_derivatives_instrument_metrics.StreamDerivativesInstrumentMetricsRequestV1(
                    instrument_criteria = instrument_criteria_pb2.InstrumentCriteria(
                    # Start of parameter configuration #
                        exchange = "okex",
                        instrument_class = "perpetual-future",
                        code = "btc-usdt"
                    ),
                    commodities = [
                    "SDICK_RISK"
                ]
                ))
                    # End of parameter configuration #
                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)
    
        derivatives_instrument_metrics_request(channel)
    
    if __name__ == '__main__':
        logging.basicConfig()
        run()
    
    curl -X POST "https://gateway-v0-http.kaiko.ovh/api/stream/derivatives_instrument_metrics_v1" \
    -H "accept: application/json" \
    -H "X-Api-Key: $kaiko_api_key" \
    -H "Content-Type: application/json" \
    -d "{ \"instrumentCriteria\": {  \"exchange\": \"okex\",  \"instrumentClass\": \"perpetual-future\",  \"code\": \"btc-usdt\" }}"
    {
      "value": "-0.0000345359072087",
      "legacySymbol": "btcusdtswap",
      "exchange": "okex",
      "commodity": "funding_rate",
      "commodityKind": "SDICK_RISK",
      "tsCollection": "2024-12-18T13:15:43.861660474Z",
      "tsEvent": "2024-12-18T13:15:45.456011570Z"
    }
    
    price
    :
    1.97e-06
    • The asker has 42656.0 Algo available

    • For each unit of Algo, the buyer is willing to accept 1.97e-06 BTC, equal to 0.00000197 when converted to a decimal number

    price
    :
    1.96e-06
    • The buyer will purchase up to 80569.0 Algo

    • For each unit of Algo, the buyer is willing to pay 1.96e-06 BTC, equal to 0.00000196 when converted to a decimal number

    Instrument Explorer
    Reference API
    The Kaiko code for the instrument.

    Explore instruments, codes and exchanges in the Instrument Explorer or .

    tsCollection

    The timestamp for when Kaiko received the trade from the exchange.

    2024-08-30T10:19:38.044166107Z

    tsEvent

    The timestamp for the interval.

    2024-08-30T10:19:39.206955912Z

    commodity:funding rate

    The current funding rate.

    -0.0000756735759807

    comodity: predicted_funding_rate

    The predicted funding rate for the next period.

    -0.0000845044644161

    commodity: ask

    The best ask price from the order book at the time of funding rate calculation.

    101937.0

    commodity: ask_amount

    The size of the best ask order from the order book at the time of funding rate calculation.

    0.552

    commodity: bid

    The best bid price from the order book at the time of the funding rate calculation.

    101936.0

    commodity: bid_amount

    The size of the best bid order from the order book at the time of funding rate calculation.

    0.396

    commodity: 24h_volume

    The volume of the trades executed in the last 24 hours (can be in base_asset, quote_asset or the number of contracts)

    140.235

    commodity: open_interest

    The total outstanding number of contracts (units in which open interest metrics are quoted vary by exchange)

    144.817

    commodity: time_to_expiry

    The number of minutes remaining before expiry.

    41504

    commodity: nearby

    The soonest expiring contract with the same base & quote asset on the specified exchange

    boolean value

    commodity: quarterly_nearby

    The soonest expiring quarterly contract with the same base & quote asset on the specified exchange

    boolean value

    commodity: expiry

    Expiration date of the contract

    1737072000000000000

    commodity: 24h_volume

    The volume of the trades executed in the last 24 hours (can be in base_asset, quote_asset or the number of contracts)

    2047.3

    commodity: open_interest

    The total outstanding number of contracts (units in which open interest metrics are quoted vary by exchange)

    6813.4

    commodity: ask

    The price level of the best ask order from the order book at the time of message receipt.

    97890.1

    commodity: ask_amount

    The size of the best ask order from the order book at the time of the message.

    0.552

    commodity: bid

    The price level of the best bid order from the order book at the time of message receipt.

    97878.4

    commodity: bid_amount

    The size of the best bid order from the order book at the time of the message.

    0.396

    commodity: time_to_expiry

    The number of minutes remaining before expiry.

    41504

    commodity: nearby

    The soonest expiring contract with the same base & quote asset on the specified exchange

    boolean value

    commodity: quarterly_nearby

    The soonest expiring quarterly contract with the same base & quote asset on the specified exchange

    boolean value

    commodity: ask_iv

    Implied volatility for the best ask.

    0.8166587

    commodity: bid_iv

    Implied volatility for the best bid.

    0.6817713

    commodity: mark_iv

    The implied volatility for the mark price.

    0.7418202

    commodity: delta

    The delta value for the option.

    -1.6532715362206545

    commodity: gamma

    The gamma value for the option.

    3.7235607858486044

    commodity: rho

    The rho value for the option.

    16.74149

    commodity: theta

    The theta value for the option.

    0.0002888

    commodity: vega

    The vega value for the option.

    0.0006550

    commodity: strike_price

    The strike price of the contract in USD

    90000

    commodity: underlying_index

    Name of the underlying index

    BTC-31JAN25

    commodity: kind

    Put or Call

    C

    commodity: expiry

    Expiry

    1738281600000000000

    Supported Exchanges
    guide
    guide
    guide
    guide
    guide
    # 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.core import instrument_criteria_pb2
    from kaikosdk.stream.aggregates_vwap_v1 import request_pb2 as pb_vwap
    
    def vwap_request(channel: grpc.Channel):
        try:
            with channel:
                stub = sdk_pb2_grpc.StreamAggregatesVWAPServiceV1Stub(channel)
                responses = stub.Subscribe(pb_vwap.StreamAggregatesVWAPRequestV1(
                    aggregate='1s',
                    instrument_criteria = instrument_criteria_pb2.InstrumentCriteria(
                        exchange = "binc",
                        instrument_class = "spot",
                        code = "eth-usdt"
                    )
                ))
                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)
        vwap_request(channel)
    
    if __name__ == '__main__':
        logging.basicConfig()
        run()
    Reference Data
    IV Smile
    Reference Data
    Reference Data
    Reference Data
    Oanda FX Rates add-on
    Reference Data
    Reference Data
    Reference Data
    # 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.aggregated_quote_v2 import request_pb2 as pb_aggregated_quote
    
    def aggregated_quote_request(channel: grpc.Channel):
        try:
            with channel:
                stub = sdk_pb2_grpc.StreamAggregatedQuoteServiceV2Stub(channel)
                # Globbing patterns are also supported on all fields. See http://sdk.kaiko.com/#instrument-selection for all supported patterns
                responses = stub.Subscribe(pb_aggregated_quote.StreamAggregatedQuoteRequestV2(
                    instrument_class = "spot",
                    code = "btc-usd"
                ))
                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)
        aggregated_quote_request(channel)
    
    if __name__ == '__main__':
        logging.basicConfig()
        run()
    Reference Data
    Reference Data
    Reference Data
    Reference Data
    # 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.core import instrument_criteria_pb2
    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
    
    def market_update_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.StreamMarketUpdateServiceV1Stub(channel)
            # Globbing patterns are also supported on all fields. See http://sdk.kaiko.com/#instrument-selection for all supported patterns
            responses = stub.Subscribe(pb_market_update.StreamMarketUpdateRequestV1(
                instrument_criteria = instrument_criteria_pb2.InstrumentCriteria(
                    exchange = "cbse",
                    instrument_class = "spot",
                    code = "*"
                ),
                    commodities=[pb_commodity.SMUC_TRADE],
                    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)
        market_update_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.aggregated_state_price_v1 import request_pb2 as pb_aggregated_state_price
    
    def aggregated_state_price_v1_request(channel: grpc.Channel):
        try:
            with channel:
                stub = sdk_pb2_grpc.StreamAggregatedStatePriceServiceV1Stub(channel)
    
                responses = stub.Subscribe(pb_aggregated_state_price.StreamAggregatedStatePriceRequestV1(
                	# Globbing patterns are also supported: ["*"] will subscribe to all assets
                    assets = ["ageur", "wsteth"]
                ))
                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)
        aggregated_state_price_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.core import instrument_criteria_pb2
    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
    
    def market_update_request(channel: grpc.Channel):
        try:
            with channel:
                stub = sdk_pb2_grpc.StreamMarketUpdateServiceV1Stub(channel)
                # Globbing patterns are also supported on all fields. See http://sdk.kaiko.com/#instrument-selection for all supported patterns
                responses = stub.Subscribe(pb_market_update.StreamMarketUpdateRequestV1(
                    instrument_criteria = instrument_criteria_pb2.InstrumentCriteria(
                        exchange = "cbse",
                        instrument_class = "spot",
                        code = "*"
                    ),
                    commodities=[pb_commodity.SMUC_TRADE]
                ))
                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)
        market_update_request(channel)
    
    if __name__ == '__main__':
        logging.basicConfig()
        run()
    # This is a code example. Configure your parameters below #
    # Last update - 2025-06-26 #
    
    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.core import instrument_criteria_pb2
    from kaikosdk.stream.aggregates_ohlcv_v1 import request_pb2 as pb_ohlcv
    
    def ohlcv_request(channel: grpc.Channel):
        try:
            with channel:
                stub = sdk_pb2_grpc.StreamAggregatesOHLCVServiceV1Stub(channel)
                responses = stub.Subscribe(pb_ohlcv.StreamAggregatesOHLCVRequestV1(
                    aggregate='1s',
                    instrument_criteria = instrument_criteria_pb2.InstrumentCriteria(
                        exchange = "cbse",
                        instrument_class = "spot",
                        code = "btc-usd"
                    )
                ))
                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)))
                    # 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)
        ohlcv_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.core import instrument_criteria_pb2
    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
    
    def market_update_request(channel: grpc.Channel):
        try:
            with channel:
                stub = sdk_pb2_grpc.StreamMarketUpdateServiceV1Stub(channel)
                # Globbing patterns are also supported on all fields. See http://sdk.kaiko.com/#instrument-selection for all supported patterns
                responses = stub.Subscribe(pb_market_update.StreamMarketUpdateRequestV1(
                    instrument_criteria = instrument_criteria_pb2.InstrumentCriteria(
                        exchange = "cbse",
                        instrument_class = "spot",
                        code = "*"
                    ),
                    commodities=[pb_commodity.SMUC_TOP_OF_BOOK]
                ))
                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)
        market_update_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.core import instrument_criteria_pb2
    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
    
    def market_update_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.StreamMarketUpdateServiceV1Stub(channel)
            # Globbing patterns are also supported on all fields. See http://sdk.kaiko.com/#instrument-selection for all supported patterns
            responses = stub.Subscribe(pb_market_update.StreamMarketUpdateRequestV1(
                instrument_criteria = instrument_criteria_pb2.InstrumentCriteria(
                    exchange = "cbse",
                    instrument_class = "spot",
                    code = "*"
                ),
                    commodities=[pb_commodity.SMUC_TOP_OF_BOOK],
                    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)
        market_update_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
    from google.protobuf.json_format import MessageToJson
    import grpc
    from kaikosdk import sdk_pb2_grpc
    from kaikosdk.core import instrument_criteria_pb2
    from kaikosdk.stream.orderbookl2_v1 import request_pb2 as pb_orderbookl2
    
    
    def orderbookl2_v1_request(channel: grpc.Channel):
        try:
            with channel:
                stub = sdk_pb2_grpc.StreamOrderbookL2ServiceV1Stub(channel)
    
                responses = stub.Subscribe(
                    pb_orderbookl2.StreamOrderBookL2RequestV1(
                        instrument_criteria=instrument_criteria_pb2.InstrumentCriteria(
                            exchange="cbse", instrument_class="spot", code="*"
                        ),
                    )
                )
    
                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)
        orderbookl2_v1_request(channel)
    
    
    if __name__ == "__main__":
        logging.basicConfig()
        run()
    
    https://github.com/kaikodata/kaiko-sdk-examples/blob/master/python/code-example/orderbookl2_v1_replay_request.py
    # This is a code example. Configure your parameters below #
    
    from __future__ import print_function
    from datetime import datetime, timedelta, timezone
    import logging
    import os
    from google.protobuf.timestamp_pb2 import Timestamp
    from google.protobuf.json_format import MessageToJson
    import grpc
    from kaikosdk import sdk_pb2_grpc
    from kaikosdk.core import instrument_criteria_pb2
    from kaikosdk.stream.orderbookl2_v1 import request_pb2 as pb_orderbookl2
    
    
    def orderbookl2replay_v1_request(channel: grpc.Channel):
        try:
            with channel:
                # start of date configuration #
                start = Timestamp()
                start.FromDatetime(datetime.now(timezone.utc) - timedelta(days=2))
                end = Timestamp()
                end.FromDatetime(datetime.now(timezone.utc) - timedelta(days=1))
                # end of date configuration #
                stub = sdk_pb2_grpc.StreamOrderbookL2ReplayServiceV1Stub(channel)
    
                responses = stub.Subscribe(
                    pb_orderbookl2.StreamOrderBookL2ReplayRequestV1(
                        instrument_criteria=instrument_criteria_pb2.InstrumentCriteria(
                            exchange="cbse", instrument_class="spot", code="*"
                        ),
                        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)
        orderbookl2replay_v1_request(channel)
    
    
    if __name__ == "__main__":
        logging.basicConfig()
        run()