Complex Template · Historical Crypto Price Data

Use case 3: Historical Crypto Price Data

Pull a kline window for charts, backtests, or indicators.

Use this template when
  • Need history, not just the latest price
  • Backtest or compute MA / RSI / volatility
  • Embed a kline chart in your product
Audience: Quants, charting products, research teams
Output previewStatic sample · not live
BTC · 1h · 100 bars68,412 → 69,120
OHLCV · missing points: 0

Sign in to load a live response. Static sample is shown until then.


API / MCP

The same template supports REST, Python, and MCP Prompt. Pick the entry you know.

import requests

url = "https://api.gatedata.ai/api/v1/markets/kline?query=BTC&market=crypto&venue=gate&market_type=spot&quote=USDT&timeframe=1h&limit=100"
r = requests.get(url, headers={"Authorization": "Bearer gd_live_…"}, timeout=30)
r.raise_for_status()
bars = r.json().get("bars", [])
print(len(bars), bars[-1] if bars else None)

Inputs

Changing parameters updates the code samples and request URL. Defaults are one-click runnable for live templates.

GET/api/v1/markets/kline?query=BTC&market=crypto&venue=gate&market_type=spot&quote=USDT&timeframe=1h&limit=100

Output & interpretation

Static sample responseStatic sample · not live
{
  "asset": "BTC",
  "venue": "gate",
  "timeframe": "1h",
  "bars": [
    { "ts": 1751803200000, "o": 68120.1, "h": 68450.0, "l": 68010.5, "c": 68412.5, "v": 1523.4 }
  ],
  "missing_points": 0,
  "data_status": "ok",
  "metadata": {
    "data_status": "ready",
    "updated_at": "2026-07-06T12:00:00Z",
    "object_refs": [
      {
        "type": "asset",
        "id": "asset_btc",
        "asset_id": "asset_btc",
        "resolved_from": "params",
        "resolution_confidence": "explicit"
      },
      {
        "type": "listing",
        "id": "listing_gate_BTC_USDT_spot",
        "asset_id": "asset_btc",
        "instrument_id": "instrument_btc_usdt_spot",
        "listing_id": "listing_gate_BTC_USDT_spot",
        "venue_id": "venue_gate",
        "resolved_from": "params",
        "resolution_confidence": "explicit"
      }
    ]
  }
}
Field notes
  • timeframestring
    Bar size, e.g. 1h
  • bars[]array
    OHLCV ascending by time
  • bars[].o | h | l | c | vnumber
    Open/high/low/close/volume
  • missing_pointsnumber
    Missing candles; >0 means gaps
  • data_statusstring
    ok / partial / stale
  • metadata.object_refs[]object[]
    Unified object references
  • object_refs[].typestring
    Object reference type
  • object_refs[].idstring
    Canonical object identifier
  • object_refs[].asset_idstring
    Canonical asset identifier
  • object_refs[].resolved_fromstring
    Input used to resolve the object
  • object_refs[].resolution_confidencestring
    Object resolution confidence
How to read results
  • Check missing_points before charting
  • Iterate bars ascending — no look-ahead
  • Align timeframe and timestamps across venues

Boundaries & next steps

Do NOT use for
  • Not for ms streaming — use WebSocket
  • No order book
Common boundaries & status
  • Free tier covers recent history; longer windows / exports need paid plans
  • Thin markets may return partial