> For the complete documentation index, see [llms.txt](https://docs.nexus.xyz/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.nexus.xyz/api-reference/candles/fetch-o-h-l-c-v.md).

# GET /markets/{market\_id}/candles

Get OHLCV candles

Get OHLCV candles.

`operationId`: `fetchOHLCV` · CCXT method: `fetchOHLCV`

**Authentication:** none — this operation is public.

Returns candlestick data as arrays: \[timestamp, open, high, low, close, volume], ascending by timestamp. Optionally bounded by `startTime` / `endTime`; unbounded, it returns the latest `limit` bars.

**`startTime` sets the paging direction.** With `startTime` given, the **earliest** `limit` bars at or after it are returned, so the standard `ccxt.fetchOHLCV` loop that advances `since` progresses: each request starts where the last one ended. Without `startTime` — the unbounded or `endTime`-only case — the **most recent** `limit` bars in the window are returned, which is what "the latest bars" means above and is unchanged. To reconstruct a long history, pass `startTime` and advance it by the timestamp after the last bar received. This operation has no pagination cursor.

## Parameters

| Name        | In    | Type                                           | Required | Default | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| ----------- | ----- | ---------------------------------------------- | -------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `market_id` | path  | `string`                                       | Yes      | —       | Market identifier (e.g. BTC-USDX-PERP, ETH-USDX-PERP). Uppercase ASCII alphanumeric segments joined by single hyphens, at most 64 characters. A value outside that set is rejected with `400` (`INVALID_MARKET_ID`) before any store is read — it cannot name a market, so an empty result would assert that nothing traded rather than that the question was malformed. A well-formed identifier that names no listed market is a `404`, not a `400`.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| `timeframe` | query | `string` — one of `1s` \| `1m` \| `5m` \| `1h` | No       | `"1m"`  | —                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| `startTime` | query | `integer`                                      | No       | —       | Inclusive lower bound of the window, Unix milliseconds UTC, compared against each candle's bucket start. Omit for no lower bound. **Supplying `startTime` also sets the paging direction.** With it, the response begins AT this bound and runs forward, so a capped page is the OLDEST bars in the window and its last bar is where the next request resumes — `ccxt.fetchOHLCV`'s `since`, whose standard loop advances from the last bar it was handed. Without it, the response is the NEWEST bars in the window, which is what `fetchOHLCV` with no `since` means. This is a correctness property, not a preference: served newest-first, a `since` deep in history would return the bars adjacent to now, the caller's cursor would jump to now, and the loop would exit after one page — reporting a complete history with everything in between missing. No error and no empty page, just a gap shaped like an answer. Must be strictly before `endTime` when both are given; an inverted window is rejected with `400` (`INVALID_RANGE`) rather than normalised, so a nonsensical window never reads back as an empty one. A negative value is rejected with `400` (`INVALID_TIME`). Spelled in camelCase rather than the snake\_case used elsewhere in this API, deliberately: `ccxt.fetchOHLCV` and the Binance and Hyperliquid kline contracts all use these names. |
| `endTime`   | query | `integer`                                      | No       | —       | Inclusive upper bound of the window, Unix milliseconds UTC, compared against each candle's bucket start. Omit to read up to now. With no `startTime`, the operation returns the newest bars in the window, so a long history can be walked by moving `endTime` backwards. Prefer paging forward on `startTime` instead — that is the direction `ccxt.fetchOHLCV` pages in, and see that parameter for why. `endTime` alone does not change the direction. See `startTime` for the rejection rules and for why both are camelCase.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| `limit`     | query | `integer`                                      | No       | `200`   | Maximum number of bars to return. A value above the maximum is clamped rather than rejected. The maximum is what the server accepts, not a promise of how many bars exist: the effective ceiling depends on the history available for that market and timeframe, so a response may hold fewer bars than requested. Read `x-nexus-candles-truncated` to tell a capped page from a complete one.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |

## Responses

| Status | Body                     | Meaning                       |
| ------ | ------------------------ | ----------------------------- |
| `200`  | array of array of —      | OHLCV candles for the market. |
| `400`  | — *(no schema declared)* | —                             |
| `429`  | — *(no schema declared)* | —                             |

## Example

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

```bash
curl -X GET 'https://exchange.nexus.xyz/api/exchange/markets/BTC-USDX-PERP/candles'
```

{% endtab %}

{% tab title="Python" %}

```python
import requests


response = requests.get("https://exchange.nexus.xyz/api/exchange/markets/BTC-USDX-PERP/candles")
response.raise_for_status()
print(response.json())
```

{% endtab %}

{% tab title="TypeScript" %}

```typescript
const response = await fetch("https://exchange.nexus.xyz/api/exchange/markets/BTC-USDX-PERP/candles", {
  method: "GET",
});
if (!response.ok) throw new Error(`${response.status} ${await response.text()}`);
console.log(await response.json());
```

{% endtab %}
{% endtabs %}

***

<sub>Generated from</sub> <sub></sub><sub>`eng/apps/exchange/api/openapi.json`</sub> <sub></sub><sub>(spec</sub> <sub></sub><sub>`0.9.73`</sub><sub>). Do not edit by hand — regenerate with</sub> <sub></sub><sub>`python3 product/docs/tools/api-reference/generate.py`</sub><sub>. Hand-authored context lives in the Guides pages.</sub>


---

# 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.nexus.xyz/api-reference/candles/fetch-o-h-l-c-v.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.
