# OHLCV

## What is this endpoint for? <a href="#what-is-this-endpoint-for" id="what-is-this-endpoint-for"></a>

This Stream delivers the OHLCV for an instrument on an exchange in real-time.

## Endpoints

{% tabs %}
{% tab title="gRPC" %}

```url
gateway-v0-grpc.kaiko.ovh
```

{% endtab %}

{% tab title="http" %}

```url
gateway-v0-http.kaiko.ovh
```

{% endtab %}

{% tab title="API (testing)" %}

```url
https://gateway-v0-http.kaiko.ovh/api/stream/aggregates_ohlcv_v1
```

{% endtab %}
{% endtabs %}

## Request parameters

<table><thead><tr><th width="184">Parameter</th><th width="387">Description</th><th>Examples</th></tr></thead><tbody><tr><td><code>aggregate</code></td><td>The period you would like the OHLCV aggregation to be calculated over.</td><td><code>1m</code></td></tr><tr><td><code>instrumentCriteria</code></td><td><p>A <strong>nested object</strong> to configure following properties for your stream: </p><ul><li><code>exchange</code> (String) - The code(s) for the exchange(s)</li><li><code>instrument_class</code> (String) - The class(es) of the instrument(s) .</li><li><code>code (String) -</code> The Kaiko code for the instrument.</li></ul><p>Explore instruments, codes and exchanges in the <a href="https://instruments.kaiko.com/#/instruments">Instrument Explorer</a> or <a data-mention href="/spaces/ltAbhvgBfrAWlpUnC7ys/pages/ypeWZ4XSK6XHt2hrySeK">/spaces/ltAbhvgBfrAWlpUnC7ys/pages/ypeWZ4XSK6XHt2hrySeK</a>. </p></td><td><p><code>cbse</code></p><p></p><p><code>spot</code></p><p></p><p><code>btc-usd</code><br><br></p></td></tr></tbody></table>

{% hint style="info" %}
**Configuring a wildcard**

A wildcard allows you to request all information we have on a specific instrument, class, or exchange in the same stream.\
\
Use a `*` in place of the relevant `exchange`, `instrument`, or `class` parameter. <br>

For example, the configuration below would deliver trades for BTC/USD across all exchanges where it’s supported:

`exchange: *`\
`class: spot`\
`instrument: btc-usd`
{% endhint %}

## Response fields

<table><thead><tr><th width="223">Field</th><th width="537">Description</th></tr></thead><tbody><tr><td><code>aggregate</code></td><td>The period of calculation.</td></tr><tr><td><code>class</code></td><td>The class of instrument.</td></tr><tr><td><code>close</code></td><td>Closing price of interval. <code>null</code> when no trades reported.</td></tr><tr><td><code>exchange</code></td><td>The exchange the OHLCV is referencing.</td></tr><tr><td><code>high</code> </td><td>Closing price of interval. <code>null</code> when no trades reported.</td></tr><tr><td><code>low</code></td><td>Lowest price during interval. <code>null</code> when no trades reported.</td></tr><tr><td><code>open</code></td><td>Opening price of interval. <code>null</code> when no trades reported.</td></tr><tr><td><code>code</code></td><td>The instrument code.</td></tr><tr><td><code>timestamp</code></td><td>The timestamp for the interval.</td></tr><tr><td><code>uid</code></td><td>The unique ID for this delivery.</td></tr><tr><td><code>volume</code></td><td>Volume traded in interval. 0 when no trades reported.</td></tr><tr><td><code>sequenceId</code></td><td>Not applicable. <code>Null</code></td></tr></tbody></table>

## Request examples

{% tabs %}
{% tab title="Python" %}
{% @github-files/github-code-block url="<https://github.com/kaikodata/kaiko-sdk-examples/blob/master/python/code-example/ohlcv_request.py>" visible="false" fullWidth="true" %}
{% endtab %}

{% tab title="cURL" %}
**cURL requests are intended for testing purposes only.**

{% code overflow="wrap" %}

```url
curl -X POST "https://gateway-v0-http.kaiko.ovh/api/stream/aggregates_ohlcv_v1" -H "accept: application/json" -H "X-Api-Key: $your_key" -H "Content-Type: application/json" -d "{ \"instrumentCriteria\": { \"exchange\": \"cbse\", \"instrumentClass\": \"spot\", \"code\": \"btc-usd\" }, \"aggregate\": \"1m\"}"
```

{% 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 %}

{% tab title="Other examples" %}
For more advanced users, you can access our full SDK [here](https://github.com/kaikodata/kaiko-sdk-examples/tree/master), where you'll find more coding languages, examples and guidance.
{% endtab %}
{% endtabs %}

## Response Example

```json
 {"aggregate": "1s",
  "class": "spot",
  "close": "60521.02",
  "exchange": "cbse",
  "high": "60528.91",
  "low": "60521.02",
  "open": "60528.91",
  "code": "btc-usd",
  "timestamp": "2024-08-09T13:13:14.347471354Z",
  "uid": "2024-08-09T13:13:13Z",
  "volume": "0.00028618000000000003",
  "sequenceId": "" }
```


---

# 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/stream/data-feeds/level-1-and-level-2-data/level-1-aggregations/ohlcv.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.
