How to Choose a Free Stock API
and Build Reliably如何选择免费股票 API
并可靠接入
Compare free stock APIs for quotes, history, and fundamentals—then test coverage, latency, limits, licensing, and failure behavior before launch.
比较提供行情、历史数据和基本面数据的免费股票 API,
并在上线前测试覆盖范围、延迟、调用限额、授权条款与故障处理表现。
Quick Summary快速摘要
Free stock APIs commonly expose delayed quotes, daily OHLCV history, symbol search, company profiles, and selected fundamentals.
Compare exchange coverage, latency, adjustment rules, request quotas, uptime, documentation, and commercial-use terms.
Keep the provider response raw, normalize it into your own schema, cache stable data, and validate timestamps before use.
A free stock API may be delayed or rate-limited. Do not assume it supports live trading, public display, or redistribution.
免费股票 API 通常提供延迟行情、日线 OHLCV、代码搜索、公司资料与部分基本面。
比较交易所覆盖、延迟、复权规则、调用额度、稳定性、文档与商业使用条款。
保留原始响应,统一为自有字段结构,缓存稳定数据,并在使用前验证时间戳。
免费 API 可能延迟或限流,也不一定允许实时交易、公开展示或再分发。
Define your free stock API requirements先定义免费股票 API 需求
Start with the decision or product you are building. A watchlist needs current quotes; a backtest needs adjusted history; a screener needs fundamentals; an agent workflow needs stable schemas and source metadata.
先明确你的决策或产品目标。自选股需要当前行情,回测需要复权历史数据,选股器需要基本面,Agent 工作流则需要稳定字段与来源元数据。
The phrase free stock data covers several products that behave very differently. A quote endpoint may return only the latest traded price, while an end-of-day dataset can provide years of bars but no intraday updates. Fundamental feeds often follow company reporting cycles, and regulatory filings may arrive as documents rather than tidy rows. Define the market, asset class, frequency, history depth, and acceptable delay before comparing providers.
“免费股票数据”并不是单一产品。行情接口可能只返回最新成交价,日线数据集可以覆盖多年,却没有盘中更新;基本面数据通常跟随公司财报周期,监管申报则可能以文档而非整齐表格提供。因此在比较供应商之前,应先写清市场范围、资产类别、数据频率、历史深度以及可接受的延迟。
For research, price fields alone are rarely enough. You may also need trading calendars, symbol changes, delistings, currency, exchange identifiers, and corporate actions. These reference fields prevent survivorship bias and make it possible to join prices with fundamentals correctly. A smaller dataset with explicit lineage and consistent identifiers is often more useful than a larger feed whose origin and adjustment rules are unclear.
对于研究任务,只有价格字段通常不够。你还可能需要交易日历、代码变更、退市记录、币种、交易所标识和公司行动。这些参考字段能减少幸存者偏差,也能让价格与基本面正确关联。来源清楚、标识一致的小型数据集,往往比来源不明、复权规则模糊的大型数据源更有价值。
Last price, change, bid/ask, session status, and timestamp. Confirm whether values are real-time, delayed, indicative, or end-of-day.
Open, high, low, close, and volume by interval. For return calculations, verify splits, dividends, and adjusted-close methodology.
Income statements, balance sheets, cash flow, ratios, and company facts. Check reporting periods, currencies, and restatements.
Ticker mappings, exchanges, time zones, data lineage, and provider identity make downstream results easier to explain and audit.
最新价、涨跌、买卖价、交易状态和时间戳。务必确认数据是实时行情、延迟行情、参考报价还是日终数据。
按周期提供开高低收和成交量。计算收益率前,要核对拆股、分红与复权收盘价的方法。
利润表、资产负债表、现金流、比率和公司资料。注意报告期、币种以及后续重述。
代码映射、交易所、时区、数据血缘和供应商身份,让结果更容易解释与审计。
How to compare free stock API options如何比较免费股票 API 方案
No single source is best for every workflow. Exchanges and regulators are closest to primary records, but their files may require more cleaning. Market-data APIs make common fields easier to query, although free plans usually trade convenience for lower request limits, delayed prices, shorter history, or narrower exchange coverage. Broker feeds can be useful for personal execution workflows, while downloadable files are efficient for reproducible analysis.
没有一种来源适合所有工作流。交易所和监管机构最接近一手记录,但文件往往需要更多清洗;市场数据 API 查询方便,不过免费套餐通常以较低调用限额、延迟行情、较短历史或较窄市场覆盖来换取便利。券商数据适合个人交易流程,而可下载文件更适合可重复的研究分析。
| Source来源 | What it offers提供内容 | Best for适合场景 | Watch for注意事项 |
|---|---|---|---|
| Exchange or regulator交易所或监管机构 | Authoritative listings, notices, and filings.权威的上市信息、公告与申报文件。 | Verification and primary-source research.核验与一手资料研究。 | May be fragmented or not API-friendly.可能分散,且不一定便于 API 调用。 |
| Free market-data API免费市场数据 API | Normalized quotes, history, and fundamentals.标准化的行情、历史与基本面。 | Apps, agents, prototypes, and repeatable research.应用、Agent、原型与可重复研究。 | Rate limits, delays, and license restrictions.有调用限额、延迟和授权限制。 |
| Broker data券商数据 | Account-linked quotes and trading context.与账户关联的行情和交易上下文。 | Personal portfolio and execution workflows.个人投资组合与交易执行流程。 | Access may require an eligible account.可能要求符合条件的账户。 |
| CSV or bulk datasetCSV 或批量数据集 | Portable files for analysis and archival.便于分析与归档的可移植文件。 | Spreadsheets, notebooks, and backtests.表格、Notebook 与回测。 | Often less current than a live API.通常不如实时 API 更新及时。 |
Compare sources with the same small test set rather than relying on feature lists. Request a liquid stock, a thinly traded security, a symbol that changed, and a date containing a split or dividend. Compare timestamps, missing records, precision, adjustment behavior, and error messages. This test quickly reveals whether two providers use different sessions or definitions even when their column names look identical.
不要只看功能清单,最好用同一组小样本横向测试:选择一只高流动性股票、一只成交稀疏的证券、一个曾更换代码的标的,以及包含拆股或分红的日期。对比时间戳、缺失记录、数值精度、复权方式和错误信息。即使字段名称相同,这种测试也能快速发现不同供应商对交易时段和指标定义的差异。
Compare providers with verified limits and source roles结合已核验的限制与数据角色比较供应商
Provider names are less important than the exact job each source performs. Alpha Vantage offers a free API key and states that most datasets on its free service allow up to 25 requests per day; its support page also says real-time and 15-minute delayed U.S. stock data are premium-only. Financial Modeling Prep requires an API key and exposes normalized endpoints for quotes, historical prices, company profiles, statements, and corporate actions. Massive (formerly Polygon.io) documents U.S. stock data sourced through exchanges, SIPs, FINRA facilities, and OTC markets, with actual access determined by the selected plan and entitlement. These products are convenient application feeds, but their free boundaries and licenses should be checked again on the day you integrate.
与供应商名称相比,更重要的是明确它在工作流中承担的任务。Alpha Vantage 提供免费 API Key,并说明其免费服务中的大多数数据集每天最多可调用 25 次;其支持页面同时说明,美国股票实时数据和 15 分钟延迟数据属于付费能力。Financial Modeling Prep 要求 API Key,提供行情、历史价格、公司资料、财务报表和公司行动等标准化端点。Massive(原 Polygon.io)的文档说明,其美国股票数据来自交易所、SIP、FINRA 设施及 OTC 市场,实际可用范围由套餐与授权决定。这些服务适合作为应用数据源,但免费范围和许可条款应在接入当天重新核验。
SEC EDGAR serves a different purpose. Its submissions and XBRL company-facts APIs are keyless, updated throughout the day, and useful for primary-source filing and fundamental data—not live stock prices. The SEC asks automated clients to declare a descriptive User-Agent and stay within its fair-access limit of ten requests per second. A robust research stack may therefore combine a market-data API for prices, EDGAR for filings, and issuer or exchange records for final verification instead of asking one provider to do everything.
SEC EDGAR 承担的是另一类任务。它的申报记录与 XBRL 公司事实 API 无需密钥、会在日内更新,适合获取一手申报和基本面信息,但不是实时股价源。SEC 要求自动化客户端声明可识别的 User-Agent,并遵守每秒不超过 10 次请求的公平访问限制。因此,一个稳健的研究数据栈可以用市场数据 API 获取价格、用 EDGAR 获取申报,再用公司或交易所记录完成关键核验,而不是强求一家供应商覆盖所有任务。
| Candidate候选来源 | Useful role适合角色 | Verified boundary已核验边界 | Test before adoption接入前测试 |
|---|---|---|---|
| Alpha Vantage | Prototypes, daily time series, indicators, and selected fundamentals.原型、日线、指标及部分基本面。 | Most free datasets: up to 25 requests/day; U.S. real-time and 15-minute delayed data are premium.多数免费数据集每天最多 25 次;美国实时与 15 分钟延迟数据为付费能力。 | Endpoint quota, history depth, adjustment fields, and commercial terms.端点限额、历史深度、复权字段与商用条款。 |
| Financial Modeling Prep | Normalized quotes, company profiles, statements, and corporate actions.标准化行情、公司资料、财报与公司行动。 | An API key is required; endpoint availability depends on the current plan.必须使用 API Key;端点是否可用取决于当前套餐。 | Exchange coverage, delay, period definitions, revisions, and redistribution rights.交易所覆盖、延迟、报告期定义、修订与再分发权利。 |
| Massive / Polygon.io | Detailed U.S. quote, trade, aggregate, and reference workflows.美国报价、成交、聚合行情与参考数据工作流。 | Plan and market-data entitlement determine accessible feeds and recency.可访问的数据流与时效由套餐和市场数据授权决定。 | SIP versus venue coverage, WebSocket behavior, session handling, and display rights.SIP 与场所覆盖、WebSocket 行为、交易时段及展示权。 |
| SEC EDGAR | Primary filings, submissions, and structured XBRL company facts.一手申报、提交记录和结构化 XBRL 公司事实。 | No key; identify the client and remain at or below 10 requests/second.无需密钥;需标识客户端且每秒不超过 10 次请求。 | CIK mapping, taxonomy changes, units, filing periods, amendments, and restatements.CIK 映射、分类标准变化、单位、申报期、修订与重述。 |
Treat a ticker as a label, not a permanent identifier把股票代码视为标签,而不是永久标识
Ticker strings can be reused, changed after reorganizations, or differ across venues and share classes. Store the provider symbol together with exchange or MIC, currency, security name, and an effective date range. Where available, retain stable identifiers such as CIK, FIGI, or ISIN as additional join keys. Never join a decade of prices to today’s company table by ticker alone: that can silently attach old observations to the wrong issuer or discard delisted securities.
股票代码可能被重复使用,也可能因重组而变更,并且会因交易场所和股份类别而不同。应把供应商代码与交易所或 MIC、币种、证券名称和生效日期范围一起保存;若来源提供 CIK、FIGI 或 ISIN,也应作为额外关联键保留。不要只按今天的股票代码把十年价格连接到当前公司表,否则可能把旧记录错误地归给另一发行人,或悄悄丢掉已经退市的证券。
Raw prices, adjusted prices, and point-in-time truth原始价格、复权价格与历史时点可得数据
A historical endpoint is not analysis-ready until its adjustment policy is explicit. Raw OHLC fields reflect prices observed in each session. An adjusted series may restate earlier prices for splits, cash dividends, special dividends, or other actions so returns are easier to compare through time. Providers can use different factors and revision schedules. Preserve the original fields, adjusted fields, adjustment factor, corporate-action event, provider, retrieval time, and methodology version rather than overwriting one series with the other.
历史行情端点只有在复权规则明确后才适合分析。原始 OHLC 反映每个交易时段实际观察到的价格;复权序列可能根据拆股、现金分红、特别分红或其他公司行动回写早期价格,使跨期收益更便于比较。不同供应商可能采用不同因子和修订周期。应同时保留原始字段、复权字段、复权因子、公司行动事件、供应商、抓取时间和方法版本,而不是用一个序列覆盖另一个。
If an endpoint already returns adjusted bars, applying a second split or dividend factor corrupts returns. Test a known corporate-action date and document which fields are adjusted.
Backtests should know which securities existed on each historical date. Include listings, delistings, symbol changes, and membership dates to reduce survivorship and look-ahead bias.
Keep the market event timestamp, provider publication timestamp, and ingestion timestamp. This shows what was actually knowable when a model or decision ran.
如果端点已经返回复权 K 线,再次应用拆股或分红因子会破坏收益率。选择一个已知公司行动日期做测试,并记录哪些字段已经复权。
回测需要知道每个历史日期当时有哪些证券存在。应纳入上市、退市、代码变更和指数成分生效日期,以减少幸存者偏差与前视偏差。
分别保存市场事件时间、供应商发布时间和系统入库时间,才能判断模型或决策运行当时真正可以获得哪些信息。
A production-minded API integration workflow面向生产环境的 API 接入流程
A reliable workflow separates discovery from production use. First inspect the provider documentation and a sample response. Then make a small request, save the raw payload, and transform it into your own stable schema. Add validation before the data enters a chart, model, spreadsheet, or agent. This makes it easier to replace a source later without rewriting the rest of the product.
可靠的工作流会把“发现数据源”和“正式使用”分开。先查看供应商文档与示例响应,再发起小规模请求,保存原始返回,并转换为自己的稳定字段结构。数据进入图表、模型、表格或 Agent 之前应先经过验证。这样未来更换数据源时,无需重写整个产品。
Start with a ticker and the required dataset: quote, history, fundamentals, corporate actions, or filings. Avoid choosing a provider before you define the need.
Review schema, exchange coverage, delay, sample response, request cost, limits, source lineage, and commercial-use rules.
Send the symbol, interval, start and end dates, adjustment mode, and output format. Store the provider timestamp with every result.
Check missing sessions, duplicates, time zones, split adjustments, null values, and unexpected schema changes before analysis.
先确定股票代码和数据类型:行情、历史、基本面、公司行动或监管申报文件,不要在需求明确前锁定供应商。
检查字段结构、交易所覆盖、延迟、示例响应、调用成本、限额、来源与商业使用规则。
传入代码、周期、起止日期、复权模式和输出格式,并保存每条结果对应的供应商时间戳。
分析前检查缺失交易日、重复记录、时区、拆股复权、空值和意外的字段变化。
For API access, cache responses that do not need second-by-second freshness, apply exponential backoff to temporary failures, and log the request time, parameters, status code, and provider timestamp. For CSV, preserve the original file separately from the cleaned table and record its download date, delimiter, encoding, and time zone. Both approaches need a repeatable update policy so old and new observations are not silently mixed.
使用 API 时,应缓存不要求秒级更新的结果,对临时失败采用指数退避,并记录请求时间、参数、状态码和供应商时间戳。使用 CSV 时,应把原始文件与清洗后的表格分开保存,同时记录下载日期、分隔符、编码和时区。两种方式都需要可重复的更新策略,避免新旧数据在无提示的情况下混合。
A real, keyless SEC company-facts request一个真实且无需密钥的 SEC 公司事实请求
The request below retrieves Apple’s structured company facts from SEC EDGAR. It deliberately inspects available taxonomy keys instead of assuming that every issuer exposes the same revenue tag. Replace the example contact information with a real project name and monitored email address. This endpoint demonstrates primary-source fundamentals; it does not return a current stock quote.
下面的请求从 SEC EDGAR 获取苹果公司的结构化公司事实。示例先检查可用分类标准字段,而不是假设每家公司都使用同一个收入标签。请把示例联系信息替换为真实项目名称和有人维护的邮箱。该端点演示的是一手基本面数据,不会返回当前股票报价。
import requests
url = "https://data.sec.gov/api/xbrl/companyfacts/CIK0000320193.json"
headers = {"User-Agent": "ResearchApp ops@example.com"}
response = requests.get(url, headers=headers, timeout=20)
response.raise_for_status()
payload = response.json()
print(payload["entityName"])
print(sorted(payload["facts"].get("us-gaap", {}).keys())[:10])
In production, place the raw response in immutable storage, record the URL and retrieval time, then normalize only the facts required by the task. Validate units and fiscal periods, distinguish filed values from derived metrics, and retain amendment metadata. For QVeris workflows, use capability discovery to locate an appropriate quote, history, filing, or fundamental source; inspect its input and provenance; call it with explicit parameters; and preserve the provider response beside the normalized result. QVeris helps route and structure the workflow, but it does not replace market-data entitlements or guarantee a provider’s accuracy or license.
在生产环境中,应把原始响应写入不可变存储,记录 URL 和获取时间,再只标准化任务需要的事实字段。需要核验单位与财务期间,区分申报值和衍生指标,并保留修订信息。使用 QVeris 时,可以先查找适合的行情、历史、申报或基本面数据能力,检查输入要求和来源信息,再用明确参数调用,并把供应商原始响应与标准化结果并存。QVeris 可以帮助组织和调用这些能力,但不能替代市场数据授权,也不保证供应商的数据或许可信息一定正确。
Free stock API reliability checklist免费股票 API 可靠性检查清单
A useful source makes coverage, freshness, provider identity, request limits, pricing, and licensing visible before you depend on it.
可靠的数据源会在你正式依赖它之前,清楚展示覆盖范围、更新时间、供应商身份、请求限额、价格与授权条款。
Data quality is not only about whether a number looks plausible. Confirm that every observation refers to the intended venue, session, currency, and time zone. Check whether timestamps represent trade time, bar close, or provider delivery time. When building indicators or backtests, document how missing sessions, zero volume, duplicate rows, outliers, splits, dividends, and restated fundamentals are handled.
数据质量不只是判断一个数字“看起来是否合理”。每条记录都应对应正确的交易场所、交易时段、币种和时区,还要确认时间戳表示成交时间、K 线结束时间,还是供应商发送时间。构建指标或回测时,应记录如何处理缺失交易日、零成交量、重复行、异常值、拆股、分红以及重述后的财务数据。
- Confirm the market, exchange, asset class, interval, and historical depth.
- Record whether prices are raw or adjusted and how corporate actions are handled.
- Preserve source, timestamp, currency, time zone, and request parameters with every result.
- 确认市场、交易所、资产类别、周期和历史深度。
- 记录价格是否复权,以及拆股和分红等公司行动的处理方式。
- 为每条结果保留来源、时间戳、币种、时区和请求参数。
Finally, read the license as carefully as the schema. Free access may permit personal analysis but restrict public display, redistribution, automated extraction, model training, or commercial products. Keep a link or copy of the applicable terms with the project and review them when the provider changes plans. If the data supports trading, compliance, or customer-facing decisions, validate critical values against an authoritative source.
最后,许可证应当和字段说明一样认真阅读。免费访问可能允许个人分析,却限制公开展示、再分发、自动抓取、模型训练或商业产品。建议在项目中保存适用条款的链接或副本,并在供应商调整套餐时重新检查。如果数据用于交易、合规或面向客户的决策,关键数值还应与权威来源交叉核验。
FAQ常见问题
Yes. Many market-data providers offer free tiers for quotes, daily history, symbol search, or fundamentals, usually with request and coverage limits.
Some are, but many return delayed or end-of-day data or cover only specific venues. Check timestamps, entitlements, and exchange notes.
Many providers support CSV export. Verify the interval, time zone, missing sessions, and whether close prices are adjusted.
It depends on the license. API access does not automatically grant display, redistribution, derived-data, or commercial rights.
JSON is usually easier for applications that request data repeatedly and need structured metadata. CSV is simpler for spreadsheets, bulk downloads, notebooks, and portable archives. Choose based on the workflow, then normalize field names and data types before combining files or providers.
Test several symbols and dates against an exchange, regulator, issuer filing, or another independent source. Check timestamps, decimal precision, corporate actions, missing sessions, and update frequency. Accuracy should be monitored continuously because provider coverage and schemas can change.
有。许多市场数据供应商提供行情、日线历史、代码搜索或基本面的免费套餐,但通常存在调用与覆盖限制。
部分是实时的,但很多返回延迟或日终数据,或只覆盖特定市场。务必检查时间戳、授权与交易所说明。
许多供应商支持 CSV。下载后要核对周期、时区、缺失交易日以及收盘价是否复权。
取决于许可证。能够调用 API 不代表自动拥有展示、再分发、衍生数据或商业使用权。
JSON 更适合需要重复请求并保留结构化元数据的应用;CSV 更适合电子表格、批量下载、Notebook 和便携归档。无论选择哪种格式,在合并多个文件或供应商之前,都应统一字段名称、日期格式、数值类型和空值规则。
选择多个股票代码和历史日期,与交易所、监管机构、上市公司申报文件或另一独立来源进行对照。重点检查时间戳、小数精度、公司行动、缺失交易日与更新频率。供应商的覆盖范围和字段结构可能变化,因此准确性检查应持续进行,而不是只在首次接入时完成。
