Convert with Oanda FX Rates
What is this endpoint for?
This add-on endpoint ensures IFRS-compliant currency conversions for over 70 fiat pairs when a synthetic price is used in Kaiko Fair Market Value. While synthetic prices can be generated in any fiat currency, this endpoint guarantees compliance for non-USD currencies. In low-liquidity cases, users request a synthetic price quoted in USD, then convert it into their desired fiat currency using this endpoint.
HTTP Request
https://us.market-api.kaiko.io/v2/data/analytics.{data_version}/oanda_fx_ratesPath parameters
quote
Yes
The quote fiat currency. Automatically included in continuation tokens.
base
Yes
The base fiat currency. Automatically included in continuation tokens.
Query parameters
end_time
No
Ending time in ISO 8601 (exclusive). Automatically included in continuation tokens.
interval
No
The interval parameter is suffixed with m, h or d to specify seconds, minutes, hours or days, respectively.
Any arbitrary value between one minute and one day can be used, as long as it sums up to a maximum of 1 day. The suffixes are m (minute), h (hour) and d (day).
Default 1h.
For each interval, the resulting FX rate is an average of all available FX rates over that period.
Automatically included in continuation tokens.
page_size
No
start_time
No
Starting time in ISO 8601 (inclusive). Automatically included in continuation tokens.
sort
No
Return the data in ascending (asc) or descending (desc) order. Default is desc.
Automatically included in continuation tokens.
Fields
timestamp
Timestamp at which the interval ends.
fx_rate
Average fx rate over the interval.
Request examples
curl --compressed -H 'Accept: application/json' -H 'X-Api-Key: <client-api-key>' \
'https://us.market-api.kaiko.io/v2/data/analytics.v2/oanda_fx_rates?base=eur&page_size=2&sort=desc&interval=1d"e=jpy'##### 1. Import dependencies #####
import requests
import pandas as pd
##### 2. Choose the value of the query's parameters #####
# ---- Required parameters ---- #
quote = "usd"
base = "jpy"
# ---- Optional parameters ---- #
interval = "1h"
sort = "desc"
page_size = 100
start_time= "2025-01-01T00:00:00.000Z"
end_time= "2025-01-31T00:00:00.000Z"
# ---- 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, quote: str, base: str, start_time: str, end_time: str, interval: str, sort: str, page_size: int):
headers = {'Accept': 'application/json', 'X-Api-Key': api_key}
url = f'https://us.market-api.kaiko.io/v2/data/analytics.v2/oanda_fx_rates'
params = {
"start_time": start_time,
"end_time": end_time,
"sort": sort,
"page_size": page_size,
"interval": interval,
"quote": quote,
"base": base
}
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, quote=quote, base=base, interval=interval, start_time=start_time, end_time=end_time, sort=sort, page_size=page_size)
print (df)Response examples
{
"query": {
"base": "eur",
"quote": "jpy",
"interval": "1d",
"page_size": "2",
"sort": "desc",
"start_time": "null",
"end_time": "2022-08-31T08:38:25.883Z"
},
"time": "2022-08-31T08:38:25.905Z",
"timestamp": 1661935105,
"data": [
{
"timestamp": 1660780800000,
"fx_rate": "137.38630485436903"
},
{
"timestamp": 1660694400000,
"fx_rate": "137.15155641205303"
}
],
"continuation_token": "4tvMKJPYA6ESWsE7s87P2ujFvr6XRNvegzst2eg1EpdyQEPKWpuNic5XPGrhz47RzbbqC598E3XusLo34Hivgw4sYrrvdmYxL7WQVtebjtYVMUPPd97vqo2VjL22A6cTSNojTQsvHh8T6MPRjuJAMfx5LWyVZQWYyzLrSE",
"next_url": "https://us.market-api.kaiko.io/v2/data/analytics.v2/oanda_fx_rates?continuation_token=4tvMKJPYA6ESWsE7s87P2ujFvr6XRNvegzst2eg1EpdyQEPKWpuNic5XPGrhz47RzbbqC598E3XusLo34Hivgw4sYrrvdmYxL7WQVtebjtYVMUPPd97vqo2VjL22A6cTSNojTQsvHh8T6MPRjuJAMfx5LWyVZQWYyzLrSE"
}Last updated
Was this helpful?
