> ## Documentation Index
> Fetch the complete documentation index at: https://sonar-cf3aeac7.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Get asset OHLCV

> Get OHLCV candles for a cross-chain asset, built from the asset's sampled USD price.

## What is an asset?

An **asset** is a cross-chain price identity. It groups the tokens that represent the same thing on different chains (for example USDC on Ethereum and USDC on Base) under one numeric id, with one USD price series.

You get an asset id from:

* `assetId` in [token details](https://sonar-cf3aeac7.mintlify.site/api-reference/token/get-token.md), in `base`/`quote` of [market details](https://sonar-cf3aeac7.mintlify.site/api-reference/market/get-market-details.md), and in `token` of [wallet holdings](https://sonar-cf3aeac7.mintlify.site/api-reference/wallet/get-wallet-holdings.md).
* `id` in [search](https://sonar-cf3aeac7.mintlify.site/api-reference/search/search.md) results with `type=assets`.

Not every token is linked to an asset; in that case `assetId` is `null`. Use [Get token OHLCV](https://sonar-cf3aeac7.mintlify.site/api-reference/token/get-token-ohlcv.md) or [Get market OHLCV](https://sonar-cf3aeac7.mintlify.site/api-reference/market/get-market-ohlcv.md) for those tokens.

## How asset candles differ from pool candles

Asset candles come from periodic samples of the asset's USD price, not from individual trades:

* **Periods:** `1m` and longer only. Sub-minute periods (`1s` to `30s`) are rejected with `400`.
* **No `chain` parameter:** an asset is not tied to one chain.
* **No `fill` parameter:** it is ignored if sent.
* **Not joined or gap-filled:** each candle's `o` is the first price sample in that bucket (not the previous candle's close), and buckets with no samples are missing.
* **Sampling:** prices are currently sampled about every 5 minutes, so `1m` candles are sparse and short periods may have gaps.
* **Partial oldest bucket:** only samples between `from` and `to` are used. When `from` falls inside a bucket, the oldest candle covers only part of that bucket.
* **Volume:** `v` is the asset's USD volume in the bucket, summed across its tokens on all chains, or `0`.

## Query parameters

**id** `integer` *required*

Asset id. A positive integer, at most 2147483647.

**period** `string` (default: 1h)

Candle size. One of `1m`, `5m`, `15m`, `30m`, `1h`, `4h`, `6h`, `12h`, `1d`, `1w`, `1M`. `1m` is one minute and `1M` is one calendar month (UTC).

**from** `integer`

Start of the window, Unix epoch **milliseconds**. Must be less than or equal to `to`. Defaults to `to − limit × period` (a month counts as 31 days).

**to** `integer`

End of the window, Unix epoch **milliseconds**. Defaults to now.

**limit** `integer` (default: 500)

Maximum number of candles, from 1 to 2000. If more buckets have data, the **most recent `limit`** are returned.

> [!WARNING]
>
> `from` and `to` are in **milliseconds**. A value in seconds is accepted but is read as a date in January 1970. Leave out parameters you don't use rather than sending them empty.

To page back in time, request again with `to = first.t - 1`, where `first` is the oldest candle of the current page.

## Response

**status** `"success"`

Always `success` for a 2xx response.

**data** `OhlcvCandle[]`

Candles sorted by time, **oldest first**. Prices are the asset's USD price. An empty array when there are no samples in the window.

**OhlcvCandle**

**t** `number`

Bucket start time in Unix epoch **milliseconds** (UTC).

**o** `number`

Open price in USD.

**h** `number`

High price in USD.

**l** `number`

Low price in USD.

**c** `number`

Close price in USD.

**v** `number`

Volume in USD. `0` when the bucket has no volume.

## Errors

| Status | `code` | When |
| - | - | - |
| 400 | `INVALID_PARAMETERS` | `id` missing, not a positive integer or too large; `period` not in the list (including `1s` to `30s`); `limit` outside 1 to 2000; or `from` after `to` (`from: from must be before to`). |
| 404 | `ASSET_NOT_FOUND` | No asset with this `id`. Message: `Asset not found`. |
| 500 | `INTERNAL_ERROR` | Unexpected server error. |

```bash cURL theme={null}
curl "https://api.example.com/api/v1/asset/ohlcv?id=2534&period=1h&limit=3"
```

```javascript JavaScript theme={null}
const params = new URLSearchParams({ id: "2534", period: "1h", limit: "3" });

const res = await fetch(`https://api.example.com/api/v1/asset/ohlcv?${params}`);
const body = await res.json();
if (body.status !== "success") throw new Error(`${body.code}: ${body.message}`);

console.log(body.data);
```

```json 200 theme={null}
{
  "status": "success",
  "data": [
    { "t": 1796292000000, "o": 3499.1, "h": 3509.4, "l": 3492.8, "c": 3505.2, "v": 61840220.5 },
    { "t": 1796295600000, "o": 3504.9, "h": 3516.0, "l": 3500.2, "c": 3511.8, "v": 54000310.2 },
    { "t": 1796299200000, "o": 3511.9, "h": 3514.1, "l": 3509.0, "c": 3512.3, "v": 6100045.9 }
  ]
}
```

```json 404 theme={null}
{
  "status": "error",
  "statusCode": 404,
  "code": "ASSET_NOT_FOUND",
  "message": "Asset not found"
}
```

```json 400 theme={null}
{
  "status": "error",
  "statusCode": 400,
  "code": "INVALID_PARAMETERS",
  "message": "period: Invalid option: expected one of \"1m\"|\"5m\"|\"15m\"|\"30m\"|\"1h\"|\"4h\"|\"6h\"|\"12h\"|\"1d\"|\"1w\"|\"1M\"",
  "details": [
    {
      "field": "period",
      "message": "Invalid option: expected one of \"1m\"|\"5m\"|\"15m\"|\"30m\"|\"1h\"|\"4h\"|\"6h\"|\"12h\"|\"1d\"|\"1w\"|\"1M\""
    }
  ]
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.