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: Perpetual-Future
  • Fields: Future
  • Fields: Option
  • Request examples
  • Response example

Was this helpful?

Export as PDF
  1. Data Feeds
  2. Reference Data
  3. Advanced tier

Derivatives price details

Derivatives price endpoint

What is this endpoint for?

This endpoint shows the mark price, index price, and price (last traded price) of a derivative.

Endpoint

https://eu.market-api.kaiko.io/v2/data/derivatives.v2/price

Path Parameters

Parameter
Required?
Example

region

Yes

Choose between eu and us.

Query Parameters

Parameter
Required
Description
Example

exchange

Yes

Should be one of the exchanges currently supported

okex

instrument_class

Yes

future, perpetual-future, or option

future

instrument

Yes

btcusdt250117

interval

No

Interval period (can be one of 1m, 1h, 4h, and 1d). Default 1m When you query data using aninterval greater than one minute, we'll return the data from the last minute of that time period. For example, if you query data for 09:00 with the interval set at 1h, we'll return data from 09:59 (since that's the last minute of the 09:00-10:00 hour period).

1h

page_size

No

10

sort

No

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

asc

start_time

No

Starting time in ISO 8601 (inclusive).

2025-01-01T00:00:00.000Z

end_time

No

Ending time in ISO 8601 (exclusive).

2025-01-04T00:00:00.000Z

Fields: Perpetual-Future

Field
Description
Example

timestamp

Timestamp at which the interval begins. In milliseconds.

1650441900000

index_price

The price of the underlying index, often as a weighted average across multiple exchanges' spot prices

39713.3

mark_price

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.

39745.9

price

Most recent traded price of derivative contract

39767

Fields: Future

Field
Description
Example

timestamp

Timestamp at which the interval begins. In milliseconds.

1735850520000

index_price

The price of the underlying index, often as a weighted average across multiple exchanges' spot prices

97353.8

mark_price

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.

104276.62

price

Most recent traded price of derivative contract

104293.8

Fields: Option

Field
Description
Example

timestamp

Timestamp at which the interval begins. In milliseconds.

1735850520000

index_price

The price of the underlying index, often as a weighted average across multiple exchanges' spot prices

97508.58

mark_price

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.

0.0061

price

Most recent traded price of derivative contract

0.0065

Request examples

curl --compressed -H 'Accept: application/json' -H 'X-Api-Key: <client-api-key>' \
  'https://eu.market-api.kaiko.io/v2/data/derivatives.v2/price?exchange=okex&instrument_class=perpetual-future&instrument=btc-usdt&page_size=2'
##### 1. Import dependencies #####
import requests
import pandas as pd

##### 2. Choose the value of the query's parameters #####
# ---- Required parameters ---- #
exchange = "okex"
instrument_class = "perpetual-future"
instrument = "btc-usdt"

# ---- Optional parameters ---- #
interval = "1h"
page_size = 10
sort = "asc"
start_time = None
end_time = 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, exchange: str, instrument_class: str, instrument: str, interval: str, page_size: int, sort: str, start_time: str, end_time: str):
    headers = {'Accept': 'application/json', 'X-Api-Key': api_key}
    
    url = f'https://eu.market-api.kaiko.io/v2/data/derivatives.v2/price'
    params = {
        "exchange": exchange,
        "instrument_class": instrument_class,
        "instrument": instrument,
        "interval": interval,
        "page_size": page_size,
        "sort": sort,
        "start_time": start_time,
        "end_time": end_time
    }

    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, instrument_class=instrument_class, instrument=instrument, interval=interval, page_size=page_size, sort=sort, start_time=start_time, end_time=end_time)
print (df)

Response example

{
    "query": {
        "exchange": "okex",
        "instrument_class": "perpetual-future",
        "instrument": "btc-usdt",
        "interval": "1m",
        "page_size": 2,
        "sort": "desc",
        "data_version": "v2",
        "commodity": "derivatives",
        "request_time": "2022-04-28T12:36:34.981Z"
    },
    "time": "2022-04-28T12:36:37.166Z",
    "timestamp": 1651149397166,
    "data": [
        {
            "timestamp": 1651149360000,
            "index_price": null,
            "mark_price": "39707.8",
            "price": "39709.7"
        },
        {
            "timestamp": 1651149300000,
            "index_price": "39713.3",
            "mark_price": "39745.9",
            "price": "39767"
        }
    ],

    /*---*/

    "access": {
        "access_range": {
            "start_timestamp": 1646006400000,
            "end_timestamp": null
        },
        "data_range": {
            "start_timestamp": null,
            "end_timestamp": null
        }
    }
}
PreviousDerivatives contract detailsNextPremium tier

Last updated 2 months ago

Was this helpful?

Instrument code. See One instrument returned per query.

Number of snapshots to return data for. (default: 100, min: 1, max: 1000). See

Information from this endpoint can be accessed through Google BigQuery. To get started, read our .

Pagination
guide