Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
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.
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].
A little about Kaiko Stream.
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
Here is a summary of our general response codes.
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:
Basic information about Kaiko Market Data.
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:instrument1pattern2 = exchange1:instrument_class:instrument2
pattern3 = exchange2:instrument_class:instrument1
pattern4 = exchange2:instrument_class:instrument
Multiple patterns can also be combined with the + operator:
where:
pattern = pattern1+pattern2
pattern1 = <exchange1>:<instrument_class1>:<instrument1>
pattern2 = <exchange2>:<instrument_class2>:<instrument2>
Default
An unexpected error response.
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.
string
default
Get started with Kaiko Stream and Python
Before implementing Kaiko Stream in your Python environment, ensure you meet the following technical requirements.
Python Version: Minimum Python 3.7+ (recommended: 3.9+)
Operating System: Cross-platform (Windows, macOS, Linux)
Network: Stable internet connection for gRPC streaming
.... and that's it! You'll now receive updates in real-time as per your configuration.
This endpoint has been deprecated. Please use the new VWAP endpoint instead. Please contact [email protected] if you have any questions about migrating.
Retrieve ongoing Volume Weighted Average Price updates. Supported intervals are 1s, 1m and 1h.
Requirements
This file contains the minimum requirements for the script to run.
Pipfile
This file contains important PIP information for your Python script to run.
Pipfile.lock
This file contains additional PIP information for your Python script to run.
Resubscribe
This tells Python what to do in the instance you lose connection with Kaiko Stream.
body
body
kaikosdkStreamAggregatesVWAPRequestV1
true
none
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.
Status Code 200
Stream result of kaikosdkStreamAggregatesVWAPResponseV1
» result
false
none
none
This endpoint delivers VWAP (volume-weighted average price) for an instrument on an exchange in real time.
gateway-v0-grpc.kaiko.ovhcURL 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.
string
default
Default
An unexpected error response.
exchange: *
class: spot
instrument: btc-usduid
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.ovhhttps://gateway-v0-http.kaiko.ovh/api/stream/aggregates_vwap_v1Get 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.
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.
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.
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.
Status Code 200
Stream result of kaikosdkStreamAggregatesOHLCVResponseV1
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.
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.
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.
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.
Status Code 200
Stream result of kaikosdkStreamAggregatedPriceResponseV1
Enumerated Values
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.
Retrieve an ongoing stream of tick-by-tick trades for any selection of instruments or exchanges.
POST /api/stream/trades_v1
Status Code 200
Stream result of kaikosdkStreamTradesResponseV1
Enumerated Values
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.
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.ovhgateway-v0-http.kaiko.ovhhttps://gateway-v0-http.kaiko.ovh/api/stream/aggregated_quote_v2default
Default
An unexpected error response.
body
body
true
none
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.
» result
false
none
none
string
default
Default
An unexpected error response.
body
body
kaikosdkStreamAggregatedPriceRequestV1
true
none
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.
» result
false
none
none
eventType
UNKNOWN
eventType
BEST_ASK
eventType
BEST_BID
string
default
Default
An unexpected error response.
body
body
kaikosdkStreamTradesRequestV1
true
none
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.
» result
false
none
none
side
UNKNOWN
side
BUY
side
SELL
string
gateway-v0-grpc.kaiko.ovhgateway-v0-http.kaiko.ovhhttps://gateway-v0-http.kaiko.ovh/api/stream/market_update_v1instrumentCriteria
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
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.
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.
gateway-v0-http.kaiko.ovhhttps://gateway-v0-http.kaiko.ovh/api/stream/aggregates_ohlcv_v1aggregate
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
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.
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.
gateway-v0-grpc.kaiko.ovhasset
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.ovhgateway-v0-http.kaiko.ovhhttps://gateway-v0-http.kaiko.ovh/api/stream/aggregatedstatepricecurl -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"
}
}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.ovhhttps://gateway-v0-http.kaiko.ovh/api/stream/market_update_v1instrumentCriteria
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
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
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.
gateway-v0-grpc.kaiko.ovhgateway-v0-grpc.kaiko.ovhgateway-v0-http.kaiko.ovhhttps://gateway-v0-http.kaiko.ovh/api/stream/iv_svi_parameters_v1assets
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
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.
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.
This endpoint returns a price calculation for a specific pair by aggregating prices from our trading data. The computation works as follows:
Listen to trades from all selected exchanges where the instrument is actively traded.
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 .
Exchanges that send their trades late may not be captured in the given sliding window.
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.
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:
Retrieve the last available optimal liquidity path
Listen to trades for all intermediary pairs from all covered exchanges where the instrument is actively traded
Compute RWM price for each intermediary pair
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 .
Exchanges that send their trades late may not be captured in the given sliding window.
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.
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"}'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.
gateway-v0-grpc.kaiko.ovhgateway-v0-http.kaiko.ovhhttps://gateway-v0-http.kaiko.ovh/api/stream/aggregates_spot_direct_exchange_rate_v2extrapolate_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.
gateway-v0-grpc.kaiko.ovhgateway-v0-http.kaiko.ovhhttps://gateway-v0-http.kaiko.ovh/api/stream/aggregates_spot_exchange_rate_v2Explore instruments, codes and exchanges in the Instrument Explorer or .
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.
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.
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.
Derivatives price endpoint.
This endpoint can be used to get pricing information related to derivatives contracts.
gateway-v0-grpc.kaiko.ovhcURL 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.
# 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-usdbids
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.ovhgateway-v0-http.kaiko.ovhhttps://gateway-v0-http.kaiko.ovh/api/stream/orderbookl2_v1
https://gateway-v0-http.kaiko.ovh/api/stream/orderbookl2_replay_v1
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
binc
commodity
The price of the underlying index, often as a weighted average across multiple exchanges' spot prices
index_price
gateway-v0-http.kaiko.ovhhttps://gateway-v0-http.kaiko.ovh/api/stream/derivatives_instrument_metrics_v1#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"
}
price1.96e-06The 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
*Legacy version of Market Update: Full Order Book will be supported until February 17th, 2025
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.
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.
exchange: *
class: spot
instrument: btc-usdtsEvent
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
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.ovhgateway-v0-http.kaiko.ovhhttps://gateway-v0-http.kaiko.ovh/api/stream/market_update_v1gateway-v0-grpc.kaiko.ovhgateway-v0-http.kaiko.ovhhttps://gateway-v0-http.kaiko.ovh/api/stream/derivatives_instrument_metrics_v1instrumentCriteria
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
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
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
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
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.
# 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"
}
price1.97e-06The 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
price1.96e-06The 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
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
# 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()# 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()# 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()
# 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()