# Derivatives price details

## What is this endpoint for?

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

### Endpoint

```http
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

<table><thead><tr><th width="189">Parameter</th><th width="128">Required</th><th width="324">Description</th><th>Example</th></tr></thead><tbody><tr><td><code>exchange</code></td><td>Yes</td><td>Should be one of the exchanges currently supported</td><td><code>okex</code></td></tr><tr><td><code>instrument_class</code></td><td>Yes</td><td><code>future</code>, <code>perpetual-future</code>, or <code>option</code></td><td><code>future</code></td></tr><tr><td><code>instrument</code></td><td>Yes</td><td>Instrument <code>code</code>. <br><br>See <a data-mention href="/spaces/bvJkzmxJbcDMceEJsq2K/pages/o4ZunsQ4PYoKpO528Uxw">/spaces/bvJkzmxJbcDMceEJsq2K/pages/o4ZunsQ4PYoKpO528Uxw</a><br><br>One instrument returned per query.</td><td><code>btcusdt250117</code></td></tr><tr><td><code>interval</code></td><td>No</td><td>Interval period (can be one of <code>1m</code>, <code>1h</code>, <code>4h</code>, and <code>1d</code>). Default <code>1m</code><br><br>When you query data using an<code>interval</code> greater than one minute, we'll return the data from the last minute of that time period. For example, if you query data for <code>09:00</code> with the <code>interval</code> set at <code>1h</code>, we'll return data from <code>09:59</code> (since that's the last minute of the 09:00-10:00 hour period). </td><td><code>1h</code></td></tr><tr><td><code>page_size</code></td><td>No</td><td>Number of snapshots to return data for. (default: 100, min: 1, max: 1000). <br><br>See <a data-mention href="/pages/mP3amLsYqKTsrRBoblxX">/pages/mP3amLsYqKTsrRBoblxX</a></td><td><code>10</code></td></tr><tr><td><code>sort</code></td><td>No</td><td>Return the data in ascending (<code>asc</code>) or descending (<code>desc</code>) order. Default <code>desc</code></td><td><code>asc</code></td></tr><tr><td><code>start_time</code></td><td>No</td><td>Starting time in ISO 8601 (inclusive).</td><td><code>2025-01-01T00:00:00.000Z</code></td></tr><tr><td><code>end_time</code></td><td>No</td><td>Ending time in ISO 8601 (exclusive).</td><td><code>2025-01-04T00:00:00.000Z</code></td></tr></tbody></table>

### Fields: Perpetual-Future

<table><thead><tr><th width="189">Field</th><th width="341">Description</th><th>Example</th></tr></thead><tbody><tr><td><code>timestamp</code></td><td>Timestamp at which the interval begins. In milliseconds.</td><td><code>1650441900000</code></td></tr><tr><td><code>index_price</code></td><td>The price of the underlying index, often as a weighted average across multiple exchanges' spot prices</td><td><code>39713.3</code></td></tr><tr><td><code>mark_price</code></td><td>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.</td><td><code>39745.9</code></td></tr><tr><td><code>price</code></td><td>Most recent traded price of derivative contract</td><td><code>39767</code></td></tr></tbody></table>

### Fields: Future

<table><thead><tr><th width="189">Field</th><th width="341">Description</th><th>Example</th></tr></thead><tbody><tr><td><code>timestamp</code></td><td>Timestamp at which the interval begins. In milliseconds.</td><td><code>1735850520000</code></td></tr><tr><td><code>index_price</code></td><td>The price of the underlying index, often as a weighted average across multiple exchanges' spot prices</td><td><code>97353.8</code></td></tr><tr><td><code>mark_price</code></td><td>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.</td><td><code>104276.62</code></td></tr><tr><td><code>price</code></td><td>Most recent traded price of derivative contract</td><td><code>104293.8</code></td></tr></tbody></table>

### Fields: Option

<table><thead><tr><th width="189">Field</th><th width="341">Description</th><th>Example</th></tr></thead><tbody><tr><td><code>timestamp</code></td><td>Timestamp at which the interval begins. In milliseconds.</td><td><code>1735850520000</code></td></tr><tr><td><code>index_price</code></td><td>The price of the underlying index, often as a weighted average across multiple exchanges' spot prices</td><td><code>97508.58</code></td></tr><tr><td><code>mark_price</code></td><td>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.</td><td><code>0.0061</code></td></tr><tr><td><code>price</code></td><td>Most recent traded price of derivative contract</td><td><code>0.0065</code></td></tr></tbody></table>

### Request examples

{% tabs %}
{% tab title="cURL" %}
{% code overflow="wrap" %}

```url
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'
```

{% endcode %}
{% endtab %}

{% tab title="Python" %}
{% code overflow="wrap" %}

```python
##### 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)
```

{% endcode %}
{% endtab %}

{% tab title="BigQuery" %}
Information from this endpoint can be accessed through Google BigQuery. \
\
To get started, read our [guide](broken://spaces/zwO3AMVXsp37KK2FngVc/pages/LFIZ1UwRtOxTg308jneZ).
{% endtab %}
{% endtabs %}

### Response example

{% code overflow="wrap" %}

```json
{
    "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
        }
    }
}
```

{% endcode %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.kaiko.com/rest-api/data-feeds/reference-data/advanced-tier/derivatives-price-details.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
