Get Klines
GET/v1/cryptodata/backtesting/klines
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.
Price
$0.01/ callEdge cache
Off
Uptime 24h
100.00%
p95
1.86s
Parameters
| Name | In | Type | Description |
|---|---|---|---|
| symbol* | query | string | Trading pair, e.g. BTCUSDT (Binance) or BTC (Hyperliquid) |
| exchange | query | string = binance | binance or hyperliquid |
| interval | query | string = 1m | Bar width: 1m (as stored), or 5m, 15m, 30m, 1h, 4h, 1d, aggregated from the 1m bars on the UTC grid |
| start* | query | string | Start time (ISO 8601 or unix ms) |
| end | query | 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 | query | string = half-open | 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 | query | integer = 1000 | |
| cursor | query | string | 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 | query | string = json | json or csv. CSV has no envelope: paging state travels in the `X-Has-More` / `X-Next-Cursor` response headers. |
Code
# 1. No key, no payment: the gateway answers 402 with the price
curl -i "https://api.realtimeapi.ai/v1/cryptodata/backtesting/klines?symbol=BTCUSDT&start=2026-10-28"
# 2. Pay: retry with a signed x402 payment (any x402 client builds this header)
curl "https://api.realtimeapi.ai/v1/cryptodata/backtesting/klines?symbol=BTCUSDT&start=2026-10-28" -H "PAYMENT-SIGNATURE: $X402_PAYMENT"// npm i @x402/fetch @x402/core @x402/evm viem
import { wrapFetchWithPayment } from "@x402/fetch";
import { x402Client } from "@x402/core/client";
import { ExactEvmScheme } from "@x402/evm/exact/client";
import { privateKeyToAccount } from "viem/accounts";
const client = x402Client.fromConfig({ schemes: [{ network: "eip155:8453", client: new ExactEvmScheme(privateKeyToAccount(PRIVATE_KEY)) }] });
const pay = wrapFetchWithPayment(fetch, client);
const data = await (await pay("https://api.realtimeapi.ai/v1/cryptodata/backtesting/klines?symbol=BTCUSDT&start=2026-10-28")).json();
console.log(data);# pip install x402 eth-account requests
from eth_account import Account
from x402.clients.requests import x402_requests
session = x402_requests(Account.from_key(PRIVATE_KEY))
print(session.get("https://api.realtimeapi.ai/v1/cryptodata/backtesting/klines?symbol=BTCUSDT&start=2026-10-28").json())curl "https://api.realtimeapi.ai/v1/cryptodata/backtesting/klines?symbol=BTCUSDT&start=2026-10-28" -H "X-API-Key: $RTAPI_KEY"Frequently asked questions
How do I get get klines from CryptoDataAPI?
Send GET https://api.realtimeapi.ai/v1/cryptodata/backtesting/klines. Pay $0.01 per request with x402, or send an X-API-Key header.
What does GET /backtesting/klines cost?
$0.01 per successful request in USDC on Base. Failed requests are never charged.
Can I call this endpoint from an MCP client?
Yes. Connect any MCP client to the RealtimeAPI server and use call_feed with this endpoint's URL, or get_quote to check the price first.