---
title: "Get Klines"
method: GET
path: "/api/v1/backtesting/klines"
tags: ["Backtesting"]
---

# Get Klines

`GET /api/v1/backtesting/klines`

## Request

- Base URL: `https://cryptodataapi.com`
- URL: `https://cryptodataapi.com/api/v1/backtesting/klines`
- Auth: API key in header `X-API-Key`

Query historical OHLCV klines for backtesting.

The archive stores closed 1-minute bars. ``interval`` (1m default, or 5m, 15m, 30m,
1h, 4h, 1d) aggregates them per request on the UTC grid: ``t`` is the bar open, and
``n`` says how many 1-minute bars went into it, so a bar with a gap, or one still
forming at ``end``, is visible. ``start`` is floored to the interval. Until 2026-10-10
``interval`` was not read at all and every call returned 1m bars.

``grain`` says what a row is, ``coverage`` where local rows start and stop for this
symbol, and ``next_cursor`` / ``has_more`` page the window without re-fetching a
boundary bar. An aggregated page scans at most ~278 days of 1m rows, so a long 1d
request pages early. An unrecognised query parameter is a 400.

## Query parameters

- `symbol` string, required: Trading pair, e.g. BTCUSDT (Binance) or BTC (Hyperliquid)
- `exchange` string: binance or hyperliquid
- `interval` string: Bar width: 1m (as stored), or 5m, 15m, 30m, 1h, 4h, 1d, aggregated from the 1m bars on the UTC grid
- `start` string, required: Start time (ISO 8601 or unix ms)
- `end` string: End time (ISO 8601 or unix ms, defaults to now). EXCLUSIVE — the range is [start, end), so consecutive windows do not repeat a boundary row.
- `bounds` string: Interval convention for `start`/`end`. `half-open` (default) is [start, end) — `end` is EXCLUSIVE, so consecutive windows tile without repeating a boundary row. `closed` is [start, end] — `end` INCLUSIVE, the pre-2026-08-08 behaviour; use it only to keep an existing integration byte-identical.
- `limit` integer
- `cursor` string, nullable: Opaque page cursor — the `next_cursor` of the previous response, verbatim. Resumes strictly after the last row served, keyed on the table's full primary key, so a page boundary inside a same-millisecond burst loses nothing (unlike `start = last.time + 1`). `start` / `end` still bound the window.
- `format` string: json or csv. CSV has no envelope: paging state travels in the `X-Has-More` / `X-Next-Cursor` response headers.

## Response `200`

Successful Response

- BacktestKlinesResponse
  - `grain` GrainDescriptor: What ONE ROW of a series is, stated on the payload so it cannot be mis-summed. ``kind``: ``event`` (one fill), ``bar`` (a closed bucket), ``rate_snapshot`` (the live rate sampled on a timer), ``rolling_window`` (a trailing total sampled on a timer), ``settled_payment`` (one settlement print). ``sum_ok`` — adding rows across time is meaningful. ``is_cumulative`` — a row already contains its predecessors' flow. ``settlements_per_day`` is set for funding series only.
    - `kind` string, required
    - `cadence` string, nullable
    - `is_cumulative` boolean
    - `sum_ok` boolean
    - `window` string, nullable
    - `settlements_per_day` integer, nullable
    - `note` string, required
  - `coverage` CoverageInfo: Local retention bounds (ms) for the queried scope. ``archive_hint`` is set when the window starts before ``local_first`` — those rows are not missing, they live in the daily Parquet archive.
    - `local_first` integer, nullable
    - `local_last` integer, nullable
    - `archive_hint` string, nullable
  - `next_cursor` string, nullable
  - `has_more` boolean
  - `symbol` string, required
  - `exchange` string, required
  - `interval` string, required
  - `count` integer, required
  - `klines` BacktestKline[], required
    - `t` integer, required
    - `o` number, required
    - `h` number, required
    - `l` number, required
    - `c` number, required
    - `v` number, required
    - `qv` number, nullable
    - `n` integer, nullable

## Other responses

- `422`: Validation Error

---

[API](https://skmtc.dev/cryptodataapi/apis/crypto-data-api.md) · [All operations](https://skmtc.dev/cryptodataapi/apis/crypto-data-api/llms.txt) · [OpenAPI document](https://skmtc.dev/cryptodataapi/apis/crypto-data-api/revisions/8628b754ca81?raw)
