> For the complete documentation index, see [llms.txt](https://docs.swivel.finance/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.swivel.finance/swivel-v3.0.0/developers/exchange/get/ohclv-candles.md).

# OHCLV (Candles)

## Get OHCLV

<mark style="color:blue;">`GET`</mark> `https://api.swivel.exchange/v2/samples?underlying=x&maturity=y&protocol=p&start=z&end=e&interval=f&type=g`

This endpoint allows you to request OHLCV points for the given period.\
\
Returns OHLCV points with each containing its OHLCV data at the given timestamp.

#### Query Parameters

| Name                                         | Type    | Description                                                                                                                                                                                                                                                                                                                                                                                                                       |
| -------------------------------------------- | ------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| interval<mark style="color:red;">\*</mark>   | string  | The time between datapoints in minutes dividable by 5. E.g. 5, 15, 30, 60, ...                                                                                                                                                                                                                                                                                                                                                    |
| maturity<mark style="color:red;">\*</mark>   | string  | The maturity of market in unix seconds.                                                                                                                                                                                                                                                                                                                                                                                           |
| underlying<mark style="color:red;">\*</mark> | string  | The underlying token contract being transacted. E.g. USDC, DAI, etc.,                                                                                                                                                                                                                                                                                                                                                             |
| start<mark style="color:red;">\*</mark>      | number  | Start of of the period in seconds                                                                                                                                                                                                                                                                                                                                                                                                 |
| end<mark style="color:red;">\*</mark>        | number  | End of the period in seconds                                                                                                                                                                                                                                                                                                                                                                                                      |
| type<mark style="color:red;">\*</mark>       | string  | Sampling type e.g. OHLCV                                                                                                                                                                                                                                                                                                                                                                                                          |
| protocol<mark style="color:red;">\*</mark>   | integer | <p>A pointer that refers to a given yield bearing market like Lido or Compound.</p><p></p><p>The protocol enum values:</p><p></p><p><code>enum Protocols {</code></p><p>  <code>Erc4626 = 0,</code> </p><p>  <code>Compound = 1,</code> </p><p>  <code>Rari = 2,</code> </p><p>  <code>Yearn = 3,</code> </p><p>  <code>Aave = 4,</code> </p><p>  <code>Euler = 5,</code> </p><p>  <code>Lido = 6</code></p><p><code>}</code></p> |

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

```
[
    {
        "timestamp": 1638472500,
        "data": {
            "open": "0.0499",
            "high": "0.0499",
            "low": "0.0499",
            "close": "0.0499",
            "volume": "252275019238957087498"
        }
    },
    {
        "timestamp": 1638473400,
        "data": {
            "open": "0.0499",
            "high": "0.05",
            "low": "0.0499",
            "close": "0.05",
            "volume": "170000000000000000000"
        }
    },
...
]
```

{% endtab %}

{% tab title="400: Bad Request E.g. Invalid maturity" %}

```javascript
{
    "error": {
        "message": "invalid maturity"
    }
}
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.swivel.finance/swivel-v3.0.0/developers/exchange/get/ohclv-candles.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
