LogoLogo
  • Kaiko Knowledge Hub
  • General
    • 👋Introduction
    • 🏎️Getting Started
      • API input
      • API output
        • "taker_side_sell" Explained
        • Market open and close
        • Timestamp
      • Authentication
      • Data versioning
      • Envelope
      • Error codes
      • Pagination
      • Rate limiting
  • Data Feeds
    • Introduction
    • Level 1 & Level 2 Data
      • Level 1 Aggregations
        • Trade Count, OHLCV, & VWAP
          • OHLCV only
          • VWAP only
      • Level 1 Tick-Level
        • All trades
        • Derivative liquidation events
        • Borrows, repayments, liquidations, and withdrawals
      • Level 2 Aggregations
        • Market depth (snapshot)
        • Market depth (aggregation)
        • Price slippage (snapshot)
        • Price slippage (aggregation)
        • Bid-ask spread (aggregation)
        • Tokens in a liquidity pool
          • Tokens in a liquidity pool (Uniswap v3)
        • Interest rates, borrowed and deposited amounts
        • Raw order book snapshot
          • Raw order book snapshot + market depth, bid/ask spread & price slippage
      • Level 2 Tick-Level
        • Mints and burns
    • Reference Data
      • Free tier
        • Asset codes
        • Exchange codes
        • Exchange trading pair codes (instruments)
        • Lending protocol codes
        • Blockchain codes
      • Advanced tier
        • Derivatives contract details
        • Derivatives price details
      • Premium tier
        • Market capitalization and circulating supply (BETA)
  • ANALYTICS Solutions
    • Introduction
    • Kaiko Fair Market Value
      • Kaiko Fair Market Value (Direct prices for high liquidity pairs)
      • Kaiko Fair Market Value (Synthetic prices for low liquidity pairs)
        • Convert with Oanda FX Rates
    • Kaiko Derivatives Risk Indicators
      • Exchange-provided metrics
      • Token-level liquidation volumes
      • Implied volatility calculation - smile
      • Implied volatility calculation - surface
    • Kaiko Portfolio Risk & Performance
      • Value at risk calculation
      • Custom valuation
  • Monitoring Solutions
    • Kaiko Market Explorer
      • Assets
      • Exchanges
    • Kaiko Blockchain Monitoring
      • Ethereum Wallets
        • Balances and transactions
      • Bitcoin Wallets
        • Balances
        • Transaction
      • Solana Wallets
        • Balances and transactions
      • Provenance Wallets
        • Balances and transactions
  • Misc & Legacy endpoints
    • CME
Powered by GitBook
On this page
  • What is this endpoint for?
  • Endpoint
  • Path parameters
  • Query parameters
  • Fields
  • Request examples
  • Response example

Was this helpful?

Export as PDF
  1. ANALYTICS Solutions
  2. Kaiko Fair Market Value

Kaiko Fair Market Value (Direct prices for high liquidity pairs)

PreviousKaiko Fair Market ValueNextKaiko Fair Market Value (Synthetic prices for low liquidity pairs)

Last updated 2 months ago

Was this helpful?

What is this endpoint for?

This endpoint returns a price calculation for a specific pair by aggregating prices from our Trade Data. Read the to learn about the calculation process.

If a null value is returned, it means there are not enough trades to calculate a direct price. In this case, use Kaiko Fair Market Value (Synthetic prices for low liquidity pairs) instead.

Endpoint

https://<eu|us>.market-api.kaiko.io/v2/data/trades.v1/robust_pair_price/{base_asset}/{quote_asset}

Path parameters

Parameter
Required
Description

base_asset

Yes

quote_asset

Yes

sort

No

Return the data in ascending (asc) or descending (desc) order. Default is desc.

Query parameters

Parameter
Required
Description

interval

Yes

The interval parameter is suffixed with s, m, h or d to specify seconds, minutes, hours or days, respectively. Any arbitrary value between one second and one day can be used, as long as it sums up to a maximum of 1 day. The suffixes are s (second), m (minute), h (hour) and d (day). Default 24h.

start_time

No

Starting time in ISO 8601 (inclusive). Automatically included in continuation tokens.

end_time

No

Ending time in ISO 8601 (exclusive) Automatically included in continuation tokens.

page_size

No

  • Less than or equal to 1m Default: 10, Max: 100

  • 1m to 1h Default: 4, Max: 10

  • More than 1h Default: 1, Max: 4

Automatically included in continuation tokens.

sort

No

Return the data in ascending (asc) or descending (desc) order. Default is desc.

include_exchanges

No

exclude_exchanges

No

extrapolate_missing_values

No

When true, if there are any null (missing) prices for the calculation, they will be filled in using the last available price from the window requested. This is useful for assets that don't have a lot of trades or for data that is collected very frequently. However, if the parameter is set to true and no prices were available in that window, a null value will still be returned.

Fields

Field
Description

timestamp

Timestamp at which the interval begins.

price

volume

Total volume in base asset traded in the interval.

0 when no trades are reported, except if extrapolate_missing_values is true.

count

Total amount of trades reported during the interval. 0 when no trades are reported, except if extrapolate_missing_values is true.

extrapolate_missing_values

true if the value has been extrapolated from the last computed value available, false if not.

Request examples

curl --compressed -H 'Accept: application/json' -H 'X-Api-Key: <client-api-key>' \
  'https://us.market-api.kaiko.io/v2/data/trades.v1/robust_pair_price/btc/eth?interval=1m&extrapolate_missing_values=true&start_time=2023-05-03T00:01:00.000Z&end_time=2023-05-04T00:00:00.000Z'
##### 1. Import dependencies #####
import requests
import pandas as pd

##### 2. Choose the value of the query's parameters #####
# ---- Required parameters ---- #
base_asset = "btc"
quote_asset = "usd"
interval = "1h"

# ---- Optional parameters ---- #
sort = "desc"
page_size = 4
start_time= "2023-01-01T00:00:00Z"
end_time= "2023-01-01T23:59:59Z"
include_exchanges = None
exclude_exchanges = None
extrapolate_missing_values = None

# ---- 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, base_asset: str, quote_asset: str, interval: str, start_time: str, end_time: str, sort: str, page_size: int, include_exchanges: list = None, exclude_exchanges: list = None, extrapolate_missing_values: bool = None):
    headers = {'Accept': 'application/json', 'X-Api-Key': api_key}
    
    url = f'https://us.market-api.kaiko.io/v2/data/trades.v1/robust_pair_price/{base_asset}/{quote_asset}'
    params = {
        "start_time": start_time,
        "end_time": end_time,
        "sort": sort,
        "page_size": page_size,
        "interval": interval,
        "include_exchanges": include_exchanges,
        "exclude_exchanges": exclude_exchanges,
        "extrapolate_missing_values": extrapolate_missing_values
    }

    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, base_asset=base_asset, quote_asset=quote_asset, interval=interval, start_time=start_time, end_time=end_time, sort=sort, page_size=page_size, include_exchanges=include_exchanges, exclude_exchanges=exclude_exchanges, extrapolate_missing_values=extrapolate_missing_values)
print (df)

Response example

{
  "query": {
    "start_time": "2023-05-03T23:50:00Z",
    "end_time": "2023-05-04T00:00:00Z",
    "base_asset": "btc",
    "quote_asset": "eth",
    "interval": "1m",
    "sort": "desc",
    "sources": false,
    "page_size": 10,
    "include_exchanges": [],
    "exclude_exchanges": [],
    "request_time": "2024-07-11T07:39:11.34695219Z",
    "data_version": "v1",
    "commodity": "trades",
    "extrapolate_missing_values": true,
    "instruments": [
      "bbsp:spot:eth-btc",
      "bfly:spot:eth-btc",
      "bfnx:spot:eth-btc",
      "bgon:spot:eth-btc",
      "binc:spot:eth-btc",
      "bnus:spot:eth-btc",
      "bull:spot:eth-btc",
      "cbse:spot:eth-btc",
      "cnex:spot:eth-btc",
      "kcon:spot:eth-btc",
      "krkn:spot:eth-btc",
      "lmax:spot:eth-btc",
      "okex:spot:eth-btc",
      "stmp:spot:eth-btc",
      "yobt:spot:eth-btc"
    ]
  },
  "time": "2024-07-11T07:39:11.430101692Z",
  "timestamp": 1720683551,
  "data": [
    {
      "timestamp": 1683158340000,
      "price": "15.236109727862226",
      "volume": "10.661977267122458",
      "count": 263,
      "extrapolate_missing_values": false
    },
    {
      "timestamp": 1683158280000,
      "price": "15.226897227981592",
      "volume": "26.42011153624422",
      "count": 184,
      "extrapolate_missing_values": false
    },
		/*...*/
	],  
	"result": "success",
  "continuation_token": "V7Dxo9XotwyC1qQtT6Dkaq3fhY8jFqzmgjwkALFWdZQ4JHWoUQFrDaTw8Zc4yCY4Cf863uPBY4phumdqcjoL4imnx5amnLJCZP3rr7dDBw2EC33kpYtsRPsmx1sVW2tfp5pUh72fP9gYrhHzzQpGAz5PKFFwiTuHT921xT1ajG8EV9aRibXxs69PLGwnfH6WD5iw4SAc58c7ZF8PafYgb34APyYC1",
  "next_url": "https://us.market-api.kaiko.io/v2/data/trades.v1/robust_pair_price/btc/eth?continuation_token=V7Dxo9XotwyC1qQtT6Dkaq3fhY8jFqzmgjwkALFWdZQ4JHWoUQFrDaTw8Zc4yCY4Cf863uPBY4phumdqcjoL4imnx5amnLJCZP3rr7dDBw2EC33kpYtsRPsmx1sVW2tfp5pUh72fP9gYrhHzzQpGAz5PKFFwiTuHT921xT1ajG8EV9aRibXxs69PLGwnfH6WD5iw4SAc58c7ZF8PafYgb34APyYC1",
  "access": {
    "access_range": {
      "start_timestamp": 1262995200000,
      "end_timestamp": 2186006399000
    },
    "data_range": {
      "start_timestamp": null,
      "end_timestamp": null
    }
  }
}

The desired base asset code. See

The desired quote asset code. See

See Page size limits differ by the interval selected:

List of exchanges' code to include in the calculation. Default is all exchanges. Automatically included in continuation tokens.

List of exchanges' code to exclude in the calculation. Automatically included in continuation tokens.

. null when no trades reported, except if extrapolate_missing_values is true

methodology
Asset codes
Asset codes
Pagination
Exchange codes
RWM Robust Weighted Median