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.
Endpoints
gateway-v0-grpc.kaiko.ovhgateway-v0-http.kaiko.ovhhttps://gateway-v0-http.kaiko.ovh/api/stream/market_update_v1Request parameters
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 Instrument Explorer or Reference Data.
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
Response fields
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.
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
Request examples
# This is a code example. Configure your parameters below #
from __future__ import print_function
from datetime import datetime, timedelta
import logging
import os
from google.protobuf.timestamp_pb2 import Timestamp
import grpc
from google.protobuf.json_format import MessageToJson
from kaikosdk import sdk_pb2_grpc
from kaikosdk.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 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.
# 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()cURL requests are intended for testing purposes only.
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\"]}"For more advanced users, you can access our full SDK here, where you'll find more coding languages, examples and guidance.
Response Example
{
"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"
}
}Last updated
Was this helpful?
