# Replication data

## What is this endpoint for?

Kaiko Reference Rates are available exclusively through our [Stream](https://app.gitbook.com/o/w3tnmhy33x0ccB3jdxr3/s/v5MrdvtFK4Vl0U5hpSQz/) Service. This helps you identify the underlying trades used to calculate each publication. Simply take the `sequence_id` field from any published rate you receive via Stream, and query this endpoint. The endpoint then generates a URL to query our [Tick-Level Trades](https://app.gitbook.com/s/ltAbhvgBfrAWlpUnC7ys/data-feeds/level-1-and-level-2-data/level-1-tick-level/all-trades) endpoint where you'll see all the trades.

{% hint style="warning" %}
We support publications for up to 72 hours using this endpoint. If you require the trades for a rate published more than 72 hours ago, contact our operations team.
{% endhint %}

### Endpoint

{% code overflow="wrap" %}

```http
https://us.market-api.kaiko.io/v1/data/index_replication.v1/rates
```

{% endcode %}

### Request parameters

<table><thead><tr><th width="170">Parameter</th><th width="131">Required</th><th width="356">Description</th><th>Example</th></tr></thead><tbody><tr><td><code>sequence_id</code></td><td>Yes</td><td>List of publication ID to explore. A publication is defined by event occurring on a specific instrument at a given point in time. <br><br>Publication IDs can be retrieved from your index response. </td><td><code>cmrqt2dugrtbh9jbhlk0,cmt40b74tfbpmrtbk180</code></td></tr><tr><td><code>sort</code></td><td>No</td><td>If asc, sort time-series in ascending. If desc, sort time-series in descending.</td><td><code>asc</code></td></tr><tr><td><code>page_size</code></td><td>No</td><td><p>See <a href="https://docs.kaiko.com/kaiko-rest-api/general/getting-started/pagination">pagination</a> <br></p><p>Min: <code>1</code><br>Max: <code>100</code><br>Default: <code>10</code></p></td><td><code>100</code></td></tr></tbody></table>

### Response fields

<table><thead><tr><th width="183">Field</th><th width="316">Description</th><th>Example</th></tr></thead><tbody><tr><td><code>index_code</code></td><td>Ticker identifying the rate.</td><td><code>KK_PR_BTCUSD</code></td></tr><tr><td><code>index_type</code></td><td>Type of publication: real-time or fixings.</td><td><code>SIC_REAL_TIME</code></td></tr><tr><td><code>sequenceID</code></td><td>The publication ID to explore. A publication is defined by event occurring on a specific instrument at a given point in time. Publication IDs can be retrieved from <a href="https://sdk.kaiko.com/#tocS_kaikosdkStreamIndexServiceResponseV1">publication stream</a> response.</td><td><code>cnb0k3vvavm8ib6863qg</code></td></tr><tr><td><code>underlying_data</code></td><td>List of links to specific pre-filtered queries on the Rest API trades endpoint for the selected SequenceID.</td><td><code>[</code><br><code>"https://us.market-api.kaiko.io/v3/data/trades.v1/exchanges/bfnx/spot/btc-usd/trades?start_time=2024-02-21T14:29:55.000Z&#x26;end_time=2024-02-21T14:34:55.000Z&#x26;index_inserted_at=2024-02-21T14:34:50.863ZZ&#x26;sort=asc",</code><br><code>"https://us.market-api.kaiko.io/v3/data/trades.v1/exchanges/cbse/spot/btc-usd/trades?start_time=2024-02-21T14:29:55.000Z&#x26;end_time=2024-02-21T14:34:55.000Z&#x26;index_inserted_at=2024-02-21T14:34:50.863ZZ&#x26;sort=asc"]</code></td></tr></tbody></table>

### Request example

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

```url
curl --compressed \
  -H 'Accept: application/json' \
  -H 'X-Api-Key: <client-api-key>' \
  'https://us.market-api.kaiko.io/v1/data/index_replication.v1/rates?sequence_id=csibfhkth8ejovmc3fcg'
```

{% endcode %}
{% endtab %}

{% tab title="Python" %}

```python
import http.client
import json

# Enter your Kaiko API Key
api_key = "KAIKO_API_KEY"
api_host = "us.market-api.kaiko.io"
api_base_endpoint = "/v1/data/index_replication.v1/rates"
# Start of mandatory parameter configuration
mandatory_params = {
    "sequence_id": "csibfhkth8ejovmc3fcg",
}
# End of mandatory parameter configuration
# Start of optional parameter configuration
optional_params = {
        "sort": "asc",
}
# End of optional parameter configuration
conn = http.client.HTTPSConnection(api_host)
headers = {
    "X-Api-Key": api_key,
    "Accept": "application/json"
}

all_params = {**mandatory_params, **optional_params}

url_params = []
for param, value in all_params.items():
    url_params.append(f"{param}={value}")
url_params = '&'.join(url_params)

endpoint_with_params = f"{api_base_endpoint}?{url_params}"

# Pagination for next pages
all_data = []
next_url = endpoint_with_params
while next_url:
    conn.request("GET", next_url, headers=headers)
    response = conn.getresponse()
    data = json.loads(response.read().decode("utf-8"))
    all_data.extend(data.get("data", []))
    print(f"Fetched {len(data.get('data', []))} datapoints. Total: {len(all_data)}")
    next_url = data.get("next_url", "").replace("https://us.market-api.kaiko.io", "")
    if not next_url:
        break
conn.close()
print(f" datapoints fetched: {(all_data)}")
```

{% endtab %}
{% endtabs %}

### Response example

{% code overflow="wrap" %}

```json
{
    "time": "2024-11-01T11:18:09.931Z",
    "timestamp": 1730459889931,
    "data": [
        {
            "index_code": "KK_BRR_BTCUSD",
            "index_type": "SIC_REAL_TIME",
            "sequence_id": "csibfhkth8ejovmc3fcg",
            "underlying_data": [
                "https://us.market-api.kaiko.io/v3/data/trades.v1/exchanges/cbse/spot/btc-usd/trades?start_time=2024-11-01T11:12:55Z&end_time=2024-11-01T11:13:10Z&index_inserted_at=2024-11-01T11:13:09.839473378Z&sort=asc",
                "https://us.market-api.kaiko.io/v3/data/trades.v1/exchanges/gmni/spot/btc-usd/trades?start_time=2024-11-01T11:12:55Z&end_time=2024-11-01T11:13:10Z&index_inserted_at=2024-11-01T11:13:09.839473378Z&sort=asc",
                "https://us.market-api.kaiko.io/v3/data/trades.v1/exchanges/krkn/spot/btc-usd/trades?start_time=2024-11-01T11:12:55Z&end_time=2024-11-01T11:13:10Z&index_inserted_at=2024-11-01T11:13:09.839473378Z&sort=asc",
                "https://us.market-api.kaiko.io/v3/data/trades.v1/exchanges/lmax/spot/btc-usd/trades?start_time=2024-11-01T11:12:55Z&end_time=2024-11-01T11:13:10Z&index_inserted_at=2024-11-01T11:13:09.839473378Z&sort=asc",
                "https://us.market-api.kaiko.io/v3/data/trades.v1/exchanges/stmp/spot/btc-usd/trades?start_time=2024-11-01T11:12:55Z&end_time=2024-11-01T11:13:10Z&index_inserted_at=2024-11-01T11:13:09.839473378Z&sort=asc"
            ]
        }
    ],
    "result": "success",
    "continuation_token": "",
    "next_url": "",
    "access": {
        "access_range": {
            "start_timestamp": 1454284800000,
            "end_timestamp": null
        },
        "data_range": {
            "start_timestamp": null,
            "end_timestamp": null
        }
    }
}
```

{% endcode %}
