
yahoo-finance2
CLIYahoo Finance 的非官方数据工具,自带 yahoo-finance 命令行、MCP 服务和 Agent Skill,可查股票报价、历史行情、财报、期权链与分析师评级。需要 Node.js 22+,无需 API Key;接口非官方可能变动,数据仅供研究参考,投资决策需专业人员复核。
yahoo-finance2
Unofficial API for Yahoo Finance with CLI, MCP and Agent Skill.
Copyright (c) 2021 by Gadi Cohen and Pilwon Huh. MIT licensed.
You are reading the docs for v4, the current major version published as
yahoo-finance2@latest. For the older v3 docs, click
here. Upgrading? See
UPGRADING.
Live Demo on CodeSandbox (Updated 2024-06-17; NextJS with both RSC and Hook-Relay examples)
NB: Recently the repo was renamed from node-yahoo-finance2 to
yahoo-finance2, and the following branches were named, master to main,
and devel to dev. See UPGRADING.md#dev for the
git commands to update your local installation.
Supported runtimes:
- Bun: v1+.
- Cloudflare: Modern releases, tested in CI via Workers Vitest under
nodejs_compat. - Deno: v2+.
- Node: v22+; v22 until 2027-04-30, v24 until 2028-04-30. Supported releases follow the Node.js release schedule.
Unofficial API
This project is neither created nor endorsed by Yahoo Inc. Yahoo does not provide any official API to developers, nor makes any guarantees regarding service availability or API consistency. In practice however, the open source community has kept this project (and it's predecessor) working well since 2013.
Nevertheless, we make no guarantees and you use this package at your own risk. The developers (and obviously Yahoo) cannot be held responsible for any losses you may incur as a result of using this service. Use of this package is considered acknowledgement and acceptance of these terms and of its license.
Quickstart
CLI (Command line interface)
$ npx yahoo-finance2 --help
$ npx yahoo-finance2 search AMZN
$ npx yahoo-finance2 quoteSummary GOOGL
$ npx yahoo-finance2 quoteSummary NVDA '{"modules":["assetProfile", "secFilings"]}'
# or install it
$ npm install -g yahoo-finance2
$ yahoo-finance search MSFT '{ "someOption": true }'
See the CLI docs for stdout/stderr behavior and exit codes.
See the MCP docs to expose yahoo-finance2 tools to MCP clients such as Codex, Claude, Cursor, and VS Code.
Importing
// or: const YahooFinance = require("yahoo-finance2").default;
import YahooFinance from "yahoo-finance2";
const yahooFinance = new YahooFinance();
const results = await yahooFinance.search("Apple");
const quote = await yahooFinance.quote('AAPL');
const { regularMarketPrice as price, currency } = quote;
Available modules:
chart,
fundamentalsTimeSeries,
historical,
insights,
options,
quote,
quoteSummary
(submodules: assetProfile, balanceSheetHistory, balanceSheetHistoryQuarterly,
calendarEvents, cashflowStatementHistory, cashflowStatementHistoryQuarterly,
defaultKeyStatistics, earnings, earningsHistory, earningsTrend, financialData,
fundOwnership, fundPerformance, fundProfile, incomeStatementHistory,
incomeStatementHistoryQuarterly, indexTrend, industryTrend, insiderHolders,
insiderTransactions, institutionOwnership, majorDirectHolders,
majorHoldersBreakdown, netSharePurchaseActivity, price, quoteType,
recommendationTrend, secFilings, sectorTrend, summaryDetail, summaryProfile,
symbol, topHoldings, upgradeDowngradeHistory),
recommendationsBySymbol,
screener,
search,
trendingSymbols.
Extras:
quoteCombine.
See the Explanatatory Documentation and Full API Documentation.
Particularly, make sure to read the notes there on ERROR HANDLING. Be aware that if a stock gets delisted, Yahoo removes all related data, including historical (and chart) data from periods before the delisting occurred (i.e. queries that worked before will start failing, and there is no way to retrieve this data again).
Agent Skill
This repo ships an Agent Skills-compatible skill at
skills/yahoo-finance2. Install it for
compatible agents with:
npx skills add gadicc/yahoo-finance2
The npm package also includes the skill under skills/yahoo-finance2 for tools
that sync skills from installed packages.
(Optional) TypeScript Love
Working with yahoo-finance2 is a joy if you're using TypeScript (but you don't
have to), with type checking and auto completion:

Try it yourself on our Live CodeSandbox.
Using in the Browser
It's not possible to run this in the browser, due to CORS and cookie issues. You should execute calls on a server or in a serverless or edge function, and pass this data to the browser as required. See the CodeSandbox above for examples. Use React Server Components, trpc, or other strategies to maintain types.
Related Projects
-
📈 Ghostfolio - mature, open-source Wealth Management & longtime supporter.
-
🛠️ StockQuotes.MCP - AI MCP Server to fetch real time financial data.
-
⚡ live-quotes - Demo to showcase running yahoo-finance2 in cloudflare workers with live quotes.
-
🦊 Foliofox - Open-source portfolio tracker with an AI financial advisor.
Want your project listed? Open a PR to add it here.
Contributing
Pull Requests welcome! Read CONTRIBUTING.md and join our list of heroes:
Credits
-
Massive thanks to @pilwon for the original node-yahoo-finance and for all our prior collaborations on this and other projects 🙏
-
Special mention goes out to pudgereyem and PythonCreator27 who made significant contributions in the very early days of this project.
相关资源

OpenBB Platform CLI
CLIOpenBB 开源投资研究平台的命令行版,在终端查询股票行情、财报、宏观经济等金融数据,可用 Routine 脚本批量自动取数。官方维护,部分数据源需自备 API Key。
OpenBB-finance/OpenBB75.9k
hithink-finance CLI(同花顺金融数据)
CLI同花顺官方金融数据命令行:查询 A 股行情、财务报表、估值、公募基金与期货期权数据,可把全市场历史行情同步到本地 DuckDB 用 SQL 分析。需要 Node.js 22+ 和在同花顺金融数据服务官网申请的 API Key;数据仅供研究,投资决策需专业人员复核。
HiThink-Tech/Financial-API4.7k
Yahoo Finance MCP Server (yfmcp)
MCP通过 yfinance 免费获取雅虎财经数据:公司资料、财报、分析师预期、新闻、期权链、基金持仓与板块排行,还能生成 K 线图。无需 API Key,装好 uv 即可运行;数据可能延迟,投资结论需专业人员复核。
narumiruna/yfinance-mcp213
Finance Toolkit MCP
MCPFinanceToolkit 开源库作者出品的 MCP,用 500 多种公式透明的方法计算财务比率、估值、风险与宏观指标,适合公司对比与尽调初稿。托管版免安装,首次连接时填入 Financial Modeling Prep API Key(免费档仅限美股、近 5 年数据);结果需专业人员复核。
JerBouma/FinanceToolkit5.6k
hithink-finance(同花顺金融数据服务)
Skill同花顺官方金融取数技能:用自然语言查询 A 股行情、财报、估值、指数板块、公募基金与期货期权数据,自动选用 CLI、MCP 或 REST 接口,大批量结果落盘到本地。需在同花顺金融数据服务官网用同花顺 App 扫码登录并创建 API Key;分析结果不构成投资建议,需专业人员复核。
HiThink-Tech/Financial-API4.7k
同花顺金融数据服务
MCP同花顺官方的 A 股数据服务,提供托管 MCP,让 agent 查询 A 股行情、财务报表、估值、涨跌停与龙虎榜;指数板块、公募基金、期货期权另有独立服务,可按同样方式添加。需在官网注册并创建 API Key;不含港美股和分钟级行情,分析结论不构成投资建议。
HiThink-Tech/Financial-API4.7k