> ## 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 market OHLCV

> Get OHLCV candles for one pool, priced as the USD price of the pool's base token.

Returns open, high, low, close and volume candles for a single pool, oldest first.

* `address` must be a **pool** address or a 32-byte pool id. There is no token fallback: a token address returns `404 POOL_NOT_FOUND`. For candles of a token across its best pool, use [Get token OHLCV](https://sonar-cf3aeac7.mintlify.site/api-reference/token/get-token-ohlcv.md).
* Prices are the **USD price of the pool's base token** (the pool's default base, or `token0` if it has none). There is no `baseToken` parameter on this endpoint. Use [Get market details](https://sonar-cf3aeac7.mintlify.site/api-reference/market/get-market-details.md) to see which token is the base.
* The `period`, `from`, `to`, `limit` and `fill` parameters work exactly as on [Get token OHLCV](https://sonar-cf3aeac7.mintlify.site/api-reference/token/get-token-ohlcv.md).

## Query parameters

**address** `string` *required*

Pool address (`0x` + 40 hex) or 32-byte pool id (`0x` + 64 hex). Case-insensitive.

**chain** `string` *required*

Chain id, as a number (`1`) or with the `evm:` prefix (`evm:1`). See [Chains and identifiers](https://sonar-cf3aeac7.mintlify.site/concepts/chains-and-identifiers.md).

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

Candle size. One of `1s`, `5s`, `15s`, `30s`, `1m`, `5m`, `15m`, `30m`, `1h`, `4h`, `6h`, `12h`, `1d`, `1w`, `1M`. Case matters: `1m` is one minute and `1M` is one month. See [Periods](#periods).

**from** `integer`

Start of the window, Unix epoch **milliseconds**. Must be less than or equal to `to`. Defaults to `to − limit × period`.

**to** `integer`

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

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

Maximum number of candles, from 1 to 2000.

**fill** `string` (default: false)

`true` to insert flat candles for empty buckets between returned candles. Only the exact strings `true` and `false` are accepted.

> [!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: an empty `from=` or `to=` is read as `0`.

## Periods

| `period` | Candle size |
| - | - |
| `1s`, `5s`, `15s`, `30s` | 1, 5, 15 or 30 seconds |
| `1m`, `5m`, `15m`, `30m` | 1, 5, 15 or 30 minutes |
| `1h`, `4h`, `6h`, `12h` | 1, 4, 6 or 12 hours |
| `1d` | 1 day (UTC) |
| `1w` | 7 days, starting Monday 00:00 UTC |
| `1M` | 1 calendar month (UTC). For the default `from`, a month counts as 31 days. |

Candle times are bucket start times in UTC.

## How candles are built

**Which trades count.** Only trades are included; liquidity adds and removals, MEV and bonding events are not. A trade moves the price only if its price is above 0 and below 1,000,000,000 USD and its USD value is at least 0.10. Smaller trades still count toward volume `v`. A bucket with no priced trade has no candle.

**The window and `limit`.** Candles cover every bucket from the one that contains `from` to the one that contains `to`, inclusive. The bucket that contains `to` is included in full, so with the default `to` (now) the last candle is the current, still-open candle.

If the window holds more than `limit` candles, the **most recent `limit`** are returned. For the sub-minute periods (`1s` to `30s`) the window is also capped at `limit × period` before `to`, whatever `from` says.

**Paging back in time.** Take the first (oldest) candle of the page and request again with `to = first.t - 1`, keeping the same `period` and `limit`:

```javascript theme={null}
const older = await getCandles({ ...params, to: candles[0].t - 1 });
```

An empty array means there are no earlier trades in that window.

**Joined candles.** Within each response, every candle's `o` is set to the previous candle's close `c`, and `h`/`l` are widened to include that open if needed. Candles therefore connect without gaps. The first candle in the response keeps its own open, so it may differ slightly from the close of the last candle of the previous page.

**`fill=true`.** Empty buckets **between** two returned candles are filled with flat candles (`o = h = l = c` = the previous close, `v = 0`). Nothing is added before the first candle or after the last one, so a pool with no recent trades does not get filler up to now. Filled candles count toward `limit`, and the most recent `limit` candles are kept. Without `fill`, empty buckets are simply missing.

## Response

**status** `"success"`

Always `success` for a 2xx response.

**data** `OhlcvCandle[]`

Candles sorted by time, **oldest first**. Prices are USD prices of the pool's base token and `v` is the pool's USD trading volume in the bucket. An empty array when there are no trades 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_ADDRESS` | `address` is malformed (`address: must be a valid token address or pool id`). |
| 400 | `INVALID_PARAMETERS` | Any other validation failure: bad `chain`, unknown `period`, `limit` outside 1 to 2000, `fill` not `true`/`false`, or `from` after `to` (`from: from must be before to`). |
| 404 | `POOL_NOT_FOUND` | No pool with this address on `chain`, including when `address` is a token. Message: `Pool not found`. |
| 500 | `INTERNAL_ERROR` | Unexpected server error. |

```bash cURL theme={null}
curl "https://api.example.com/api/v1/market/ohlcv?address=0x88e6a0c2ddd26feeb64f039a2c41296fcb3f5640&chain=1&period=1h&limit=3&fill=true"
```

```javascript JavaScript theme={null}
const params = new URLSearchParams({
  address: "0x88e6a0c2ddd26feeb64f039a2c41296fcb3f5640",
  chain: "1",
  period: "1h",
  limit: "3",
  fill: "true",
});

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

for (const { t, o, h, l, c, v } of body.data) {
  console.log(new Date(t).toISOString(), o, h, l, c, v);
}
```

```json 200 theme={null}
{
  "status": "success",
  "data": [
    { "t": 1796292000000, "o": 3498.2, "h": 3510.0, "l": 3490.1, "c": 3505.6, "v": 8200040.4 },
    { "t": 1796295600000, "o": 3505.6, "h": 3515.3, "l": 3501.0, "c": 3512.0, "v": 9100000.0 },
    { "t": 1796299200000, "o": 3512.0, "h": 3514.9, "l": 3509.8, "c": 3512.4, "v": 1200070.7 }
  ]
}
```

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

```json 400 theme={null}
{
  "status": "error",
  "statusCode": 400,
  "code": "INVALID_PARAMETERS",
  "message": "from: from must be before to",
  "details": [
    { "field": "from", "message": "from must be before to" }
  ]
}
```


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