DEX trades
Last updated
Was this helpful?
Was this helpful?
curl --compressed -H 'Accept: application/json' -H 'X-Api-Key: <client-api-key>' \
'https://us.market-api.kaiko.io/v3/data/trades.v1/dexs/ethereum/0xcd5fe23c85820f7b72d0926fc9b05b43e359b7ee'##### 1. Import dependencies #####
import requests
import pandas as pd
##### 2. Choose the value of the query's parameters #####
# ---- Required parameters ---- #
blockchain = "ethereum"
asset_address = "0xcd5fe23c85820f7b72d0926fc9b05b43e359b7ee"
# ---- Optional parameters ---- #
sort = "desc"
page_size = "100"
start_time= "2025-01-01T00:00:00Z"
end_time= "2025-01-01T00:03:00Z"
# ---- API key configuration ---- #
api_key = "YOUR_API_KEY"
##### 3. Get the data #####
# ---- Function to run an API call ---- #
# Get the data in a dataframe --------- #
def get_kaiko_data(api_key: str, exchange: str, pair: str, instrument_class: str, start_time: str, end_time: str, sort: str, page_size: int):
headers = {'Accept': 'application/json', 'X-Api-Key': api_key}
url = f'https://us.market-api.kaiko.io/v3/data/trades.v1/dexs/{blockchain}/{asset_address}'
params = {
"start_time": start_time,
"end_time": end_time,
"sort": sort,
"page_size": page_size
}
try:
res = requests.get(url, headers=headers, params=params)
res.raise_for_status()
data = res.json()
if 'data' not in data:
print("No data returned.")
return pd.DataFrame()
df = pd.DataFrame(data['data'])
# Handle pagination with continuation token
while 'next_url' in data:
next_url = data['next_url']
if next_url is None:
break
res = requests.get(next_url, headers=headers)
res.raise_for_status()
data = res.json()
if 'data' in data:
df = pd.concat([df, pd.DataFrame(data['data'])], ignore_index=True)
return df
except requests.exceptions.RequestException as e:
print(f"API request error: {e}")
return pd.DataFrame()
# ---- Get the data ---- #
df = get_kaiko_data(api_key=api_key, exchange=exchange, pair=pair, instrument_class=instrument_class, start_time=start_time, end_time=end_time ,sort=sort, page_size=int(page_size)){
"query":
{
"start_time": "2010-01-01T00:00:00.000Z",
"page_size": 100,
"exchange": "*",
"instrument_class": "*",
"instrument": "*",
"sort": "desc",
"data_version": "v1",
"commodity": "dex_trades",
"request_time": "2026-06-18T17:48:43.355Z",
"start_timestamp": 1262304000000,
"live": "True"
},
"time": "2026-06-18T17:48:43.355Z",
"timestamp": 1781804923355,
"access":
{
"access_range":
{
"start_timestamp": 1073001600000,
"end_timestamp": 1861830000000
},
"data_range":
{
"start_timestamp": "None",
"end_timestamp": 1861830000000
}
},
"data":
[
{
"timestamp": 1781804435000,
"trade_id": "ethereum-u4-0x373d4a1b17f68ef3e7a35fa7069301d8dd0491b1345a3e2c1987449c894a3d43-0x19b-0x7b2df9aa55101bb4251bb0a3d48ca08deedf3eefc39899d9fea1192e751b5bcf",
"price": "0.9115886885456722",
"token1_address": "0x0000000000000000000000000000000000000000",
"token2_address": "0xcd5fe23c85820f7b72d0926fc9b05b43e359b7ee",
"amount": "0.05",
"taker_side_sell": "False",
"blockchain": "ethereum",
"transaction_hash": "0x373d4a1b17f68ef3e7a35fa7069301d8dd0491b1345a3e2c1987449c894a3d43",
"log_index": 411,
"pool_address": "0x8fab936c814e050b67f4ff50c73bd35561f0c7e8855c7f6aaa38f6762d3520f2",
"user_address": "0xba8d1c4fce49bcc8aa5146bccdeaf8d032697613",
"block_number": 25346002
},
/* MORE ROWS */
],
"result": "success",
"continuation_token": "xxx",
"next_url": "https://eu.market-api.kaiko.io/v3/data/trades.v1/dexs/ethereum/0xcd5fe23c85820f7b72d0926fc9b05b43e359b7ee?continuation_token=xxx"
}