Choose a Free Crypto OHLCV API
for Candles and Backtests选择适合图表与回测的
免费加密货币 K线 API
Compare free candle data by coverage, intervals, history, limits, and provenance—then request and normalize OHLCV safely.
按币种覆盖、K线周期、历史范围、调用限制与来源比较免费数据,
再安全请求并标准化 OHLCV。
Free crypto OHLCV API: quick answer免费加密货币 K线 API:快速结论
Timestamped open, high, low, close, and volume candles for a symbol, interval, and time range.
Free tiers differ in API keys, rate limits, historical depth, asset coverage, granularity, and commercial-use terms.
Check whether candles represent an exchange pair, an aggregate, or on-chain liquidity—and whether volume units are base or quote currency.
Choose the source that matches your market, interval, history, and refresh needs; normalize before charting or backtesting.
按交易对、周期和时间范围返回带时间戳的开、高、低、收与成交量 K线。
不同免费层在 API Key、频率限制、历史深度、币种覆盖、粒度与商用条款上差异明显。
数据究竟来自单一交易所、聚合市场还是链上流动性池,并确认成交量使用基础币还是计价币。
按市场、周期、历史范围与刷新需求选源,并在制图或回测前统一字段与时间戳。
What developers need from a cryptocurrency candle data API开发者需要数字货币历史行情 API 完成什么任务
Treat candle construction as the primary data contract把 K线构造规则作为首要数据契约
This page is for charting, indicators, and backtests that consume open, high, low, close, and volume. The provider must define whether candles are built from trades, quotes, an index, or a derivative mark; whether the timestamp marks interval open or close; which timezone anchors boundaries; and whether the final still-forming candle is included. Two APIs can use the same symbol and interval yet produce different, internally valid bars.
本页服务于使用开高低收和成交量的图表、指标与回测。供应商必须说明 K线来自成交、报价、指数还是衍生品标记价,时间戳代表周期开始还是结束,边界按哪个时区对齐,以及是否包含仍在形成的最后一根 K线。即使代码和周期相同,两个 API 也可能生成不同但各自有效的 K线。
Validate OHLCV invariants before strategy results. For a completed candle, high should be at least open and close, low should be no greater than them, volume should be non-negative, and timestamps should advance exactly one interval unless a documented no-trade rule applies.
先校验 OHLCV 不变量,再看策略结果。已完成 K线的最高价应不低于开盘和收盘,最低价应不高于两者,成交量不能为负;除非明确规定无成交时省略,否则时间戳应按周期连续推进。
Three candle-construction models三种 K线构造模型
Aggregate executed trades from one market. Confirm trade corrections, late trades, zero-trade intervals, base volume, quote volume, and whether bars can be revised.
聚合一个市场的实际成交。应确认成交更正、迟到成交、零成交周期、基础币量、计价币额,以及 K线是否会修订。
Combine several venues or an index. Review contributor weights, outlier removal, venue outages, rebalance rules, and how volume is aggregated.
组合多个场所或指数。应检查贡献权重、异常值剔除、场所故障、重平衡规则和成交量聚合方法。
Build bars from swaps in one pool. Token decimals, price direction, pool migrations, fee tiers, low liquidity, and chain reorgs affect results.
根据一个池子的兑换构造 K线。代币精度、价格方向、池迁移、费率层级、低流动性和链重组都会影响结果。
Create candles from a retained trade stream when provider bars do not match the strategy boundary. Version the aggregation code and raw trade snapshot.
当供应商 K线边界不符合策略时,可从保存的成交流自行聚合,并为聚合代码和原始成交快照设置版本。
Understand the candle before comparing prices比较价格前先弄清一根 K线的定义
- Time boundary: determine whether the timestamp marks candle open or close and whether intervals align to UTC.
- Price basis: distinguish exchange trades, volume-weighted aggregates, index prices, mark prices, and DEX swap prices.
- Volume basis: identify base-asset volume, quote-currency volume, trade count, or provider-calculated volume.
- Incomplete candles: decide whether to exclude the current still-forming candle from indicators and backtests.
- 时间边界:确认时间戳代表 K线开始还是结束,以及周期是否按 UTC 对齐。
- 价格口径:区分交易所成交价、成交量加权聚合价、指数价格、标记价格和 DEX 兑换价格。
- 成交量口径:确认是基础币成交量、计价币成交额、成交笔数,还是供应商计算值。
- 未完成 K线:技术指标与回测通常应排除仍在形成的当前 K线。
Suppose one venue's BTC/USD hourly candle closes at $60,000 after 100 BTC of trades, so quote notional is about $6 million. A second source reports BTC/USDT at 60,120 with 140 BTC of base volume, while an aggregate index closes at 60,050 and publishes no trade volume. These are three valid but different observations. Converting the 140 BTC volume to “USD volume” by multiplying by 60,120 silently assumes one USDT equals one U.S. dollar and uses the closing price rather than each trade price. Store venue, instrument ID, base and quote assets, product type, candle method, base volume, quote notional, contributor set, and conversion rule before comparing or merging bars.
假设某交易所 BTC/USD 的小时 K线收于 60,000 美元,成交量为 100 BTC,对应计价成交额约 600 万美元;第二个来源的 BTC/USDT 收于 60,120,基础币成交量为 140 BTC;另一个综合指数收于 60,050,却不提供成交量。这三组数据都可能有效,但含义完全不同。如果直接用 140 × 60,120 换算“美元成交额”,就同时假设 1 USDT 恒等于 1 美元,并用收盘价替代了每笔成交价。比较或合并前,应保存交易场所、工具 ID、基础币与计价币、产品类型、K线方法、基础币量、计价成交额、贡献市场和换算规则。
Keep USDT, USDC, USD and other quote currencies distinct. If analysis needs one currency, apply a timestamped FX or stablecoin conversion and preserve the unconverted source bar.
A provider may omit a no-trade interval, emit OHLC equal to the prior close with zero volume, or return a gap during an outage. Normalize these as different states; never manufacture liquidity.
Track listing, suspension, delisting, symbol reuse, contract migration, pool migration, and exchange history by stable instrument ID and effective time rather than joining on display symbols alone.
USDT、USDC、USD 和其他计价币应分别保存。若分析必须统一币种,应使用带时间戳的汇率或稳定币换算,并保留未经转换的原始 K线。
供应商可能省略无成交周期,也可能沿用前收盘价并给出零成交量;接口故障同样会产生缺口。三者必须保留为不同状态,不能人为制造流动性。
用稳定工具 ID 和生效时间跟踪上线、停牌、下线、代码复用、合约迁移、资金池迁移和交易所历史,不能只按展示符号拼接数据。
How to compare free cryptocurrency OHLCV data APIs如何比较免费加密货币 OHLCV 数据 API
| Decision判断项 | Check检查内容 | Why it matters为何重要 |
|---|---|---|
| Market coverage市场覆盖 | Exchange pair, aggregate, or DEX pool交易所交易对、聚合价格或 DEX 池 | The same symbol can represent different markets.相同符号可能代表不同市场。 |
| GranularityK线粒度 | 1m, 5m, 1h, 1d and custom intervals1分钟、5分钟、1小时、日线与自定义周期 | Free plans may restrict intraday candles.免费层常限制分钟级数据。 |
| Historical depth历史深度 | Earliest candle, per-request window, pagination最早K线、单次窗口与分页方式 | A long backtest may need many calls or a paid tier.长周期回测可能需要多次调用或付费层。 |
| Limits and terms限制与条款 | Key, requests, attribution, caching, commercial use密钥、请求数、署名、缓存与商用 | “Free” does not always permit production use.“免费”不一定允许生产或商业使用。 |
| Freshness更新时效 | Current candle delay, cache duration, finalization time当前 K线延迟、缓存时长与最终确认时间 | A chart can tolerate more delay than an alerting system.行情图通常比预警系统更能容忍延迟。 |
| Data quality数据质量 | Gaps, duplicates, corrections, status page, provenance缺口、重复、修订、状态页与来源说明 | Backtests can silently change when data is repaired.数据修复可能让历史回测结果静默变化。 |
| Delivery交付方式 | REST, WebSocket, CSV, bulk downloadREST、WebSocket、CSV 与批量下载 | Historical loading and live updates need different paths.历史回填与实时更新通常需要不同通道。 |
A practical free-tier selection checklist免费层选型检查清单
Record asset, quote currency, venue, spot or derivative, interval, earliest date, acceptable delay, and expected daily request count.
写清币种、计价币、交易场所、现货或衍生品、K线周期、最早日期、可接受延迟和预计日请求量。
Request a liquid pair and a thinly traded pair. Test maximum rows, pagination boundaries, missing periods, response headers, and rate-limit behavior.
分别请求高流动性和低流动性交易对,测试最大返回条数、分页边界、缺失周期、响应头和触发限频后的行为。
Check commercial use, attribution, retention, redistribution, derived-data, and display requirements instead of assuming public access means unrestricted use.
检查商用、署名、保存期限、再分发、衍生数据和展示要求,不要把“公开可访问”等同于“可无限制使用”。
Store provider, endpoint, market, request time, interval, timezone, schema version, and ingestion status with each dataset.
随数据保存供应商、端点、市场、请求时间、周期、时区、字段版本和摄取状态,便于切换与追溯。
How to get historical crypto OHLCV data in Python如何用 Python 获取加密货币历史 K线数据
A provider-neutral request and validation workflow与供应商无关的请求与校验流程
import requests
import pandas as pd
params = {"symbol": "BTC-USD", "interval": "1h",
"start": "2026-07-01", "end": "2026-07-07"}
rows = requests.get(API_URL, params=params, timeout=20).json()
df = pd.DataFrame(rows)
df["timestamp"] = pd.to_datetime(df["timestamp"], utc=True)
df = df.sort_values("timestamp").drop_duplicates("timestamp")
assert {"open", "high", "low", "close", "volume"} <= set(df.columns)Confirm whether it expects a coin ID, exchange symbol, base/quote pair, contract address, or pool address.
Use explicit UTC boundaries and a supported interval; paginate without overlapping or skipping candles.
Rename fields, parse timestamps, sort, deduplicate, inspect gaps, and record the provider and market provenance.
确认接口使用币种 ID、交易所符号、基础币/计价币、合约地址还是流动性池地址。
使用 UTC 边界和受支持的周期,分页时避免 K线重复或跳过。
统一字段、解析时间戳、排序、去重、检查缺口,并记录供应商与市场来源。
Pagination, rate limits, and retry safety分页、限频与安全重试
Historical endpoints often cap the number of candles returned per call. Advance the next request from the last confirmed timestamp, use the provider’s documented inclusive or exclusive boundary, and deduplicate after concatenation. For 429 and temporary 5xx responses, respect Retry-After, apply bounded exponential backoff, and never retry invalid parameters indefinitely.
历史接口通常限制单次返回的 K线数量。下一页应从最后一个已确认时间戳继续,并按文档区分包含或不包含边界;拼接后再次按时间戳去重。遇到 429 或临时 5xx 时,应遵循 Retry-After、使用有上限的指数退避,且不要无限重试错误参数。
Quality checks before charting or backtesting制图或回测前的数据质量检查
| Check检查项 | Expected rule预期规则 | Typical failure常见问题 |
|---|---|---|
| Price bounds价格边界 | low ≤ open/close ≤ high | Malformed fields or inconsistent adjustment字段错位或调整口径不一致 |
| Interval continuity周期连续性 | Timestamp difference equals the requested interval相邻时间戳差值等于请求周期 | Maintenance, illiquidity, or pagination gaps维护、低流动性或分页缺口 |
| Uniqueness唯一性 | One row per market and candle-open time每个市场与 K线开始时间仅一行 | Inclusive pagination duplicates包含边界的分页产生重复 |
| Completeness完整性 | No null OHLC; volume rule documentedOHLC 无空值;成交量规则有记录 | Empty candles encoded as zero or null空 K线被编码为零或空值 |
| Final candle最后一根 K线 | Closed before indicator or backtest use进入指标或回测前已经收盘 | Look-ahead or changing values未来函数或数值持续变化 |
Backtest warning: OHLCV bars do not contain tick order inside the candle. If both a stop and target fall within the same bar, bar data alone cannot prove which executed first. Use conservative execution rules or finer-grained data.
回测提醒:OHLCV K线不包含周期内逐笔成交的先后顺序。如果止损价与止盈价同时落在一根 K线范围内,仅靠该 K线无法判断哪个先成交,应使用保守成交规则或更细粒度数据。
How QVeris helps find a free crypto OHLCV APIQVeris 如何帮助查找免费数字货币 K线 API
QVeris helps agents and developers discover and inspect callable capabilities. Open the QVeris tool details to review its available tools, inputs, and outputs, and connect the selected capability through the documented QVeris workflow.
QVeris 帮助 Agent 与开发者发现并检查可调用能力。可先使用 QVeris tool details 查找行情数据工具,核对输入输出,再按 QVeris 文档接入选定能力。
QVeris does not make a provider’s free tier unlimited or guarantee data quality. Verify the underlying source, limits, licensing, and candle semantics before production use.
QVeris 不会把供应商免费层变成无限调用,也不保证底层数据质量。生产使用前仍需核实来源、限制、许可与 K线定义。
Free crypto OHLCV API FAQ免费加密货币 K线 API 常见问题
It summarizes a market’s open, high, low, close, and traded volume for each candle interval.
Some public endpoints are keyless, but coverage, history, rate limits, stability, and usage terms still vary.
Exchange APIs and market-data providers both do. Choose based on whether you need venue-specific or aggregated candles.
Yes when the history, granularity, license, and quality fit your test. Inspect gaps, survivorship, market changes, and look-ahead bias.
Call a supported candle endpoint with the BTC pair, interval, and time range; parse JSON into a dataframe and validate timestamps and fields.
No. Exchange candles represent trades on one venue, while aggregated candles combine or derive prices under a provider-specific methodology.
Usually no. Preserve the gap first. If your model requires a regular index, document any forward-fill or zero-volume synthetic candle explicitly.
REST is convenient for history and recovery; WebSocket is useful for live updates. Production systems commonly use both.
它按每个 K线周期汇总开盘价、最高价、最低价、收盘价与成交量。
部分公共接口无需密钥,但币种覆盖、历史范围、限频、稳定性与使用条款仍各不相同。
交易所 API 与行情数据供应商都可提供,应按单一场所数据或聚合行情的需求选择。
可以,但需确认历史深度、粒度、许可与质量,并检查缺口、幸存者偏差和未来函数。
向支持的接口传入 BTC 交易对、周期与时间范围,把 JSON 转为数据表后校验时间戳与字段。
不同。交易所 K线代表单一场所成交,聚合 K线则按供应商自己的方法组合或计算多个市场价格。
通常不应该。先保留缺口;如果模型要求规则时间索引,应明确记录前向填充或零成交量合成 K线。
REST 适合历史回填与故障恢复,WebSocket 适合实时更新,生产系统通常会同时使用两者。
