Sandbox
@gadicc/yahoo-finance2

Yahoo Finance API, CLI, and MCP server

This package wraps Yahoo Finance data in a reusable API, a command-line tool, and an MCP server. It also ships a skill so compatible agents can use the same finance actions without you rewriting prompts or tools by hand.

795 starsโ€ข106 forksโ€ขHTMLโ€ขUpdated 1mo ago
Who it's for

Builders who want Claude Code, Codex, or Cursor to look up market data and company details from Yahoo Finance.

What it delivers

You can ask an agent or CLI to search symbols, fetch quotes, screen markets, and inspect company data without building the data layer yourself.

What it does

CLI for finance queries

Run `search`, `quoteSummary`, and other Yahoo Finance actions from the terminal.

MCP server

Expose Yahoo Finance tools to MCP clients such as Codex, Claude, Cursor, and VS Code.

Agent skill

Ship the repo as an Agent Skills-compatible skill under `skills/yahoo-finance2`.

TypeScript API

Import `yahoo-finance2` in code and call modules like `search`, `quote`, `quoteSummary`, `historical`, and `screener`.

Docs and upgrade notes

Use the API docs, CLI docs, MCP docs, and upgrading guide to set it up and handle errors.

How to get it

  1. 1CLI (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 }'

README

yahoo-finance2

Unofficial API for Yahoo Finance with CLI, MCP and Agent Skill.

Copyright (c) 2021 by Gadi Cohen and Pilwon Huh. MIT licensed.

npm CI coverage semantic-release TypeScript MIT License

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:

Types Animation

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:

contributors badge

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.

Files in the repo

Repository payloadโ€ข23 top-level entries
  • .agents
  • .claude
  • .github
  • .vscode
  • bin
  • docs
  • plans
  • scripts
  • skills
  • src
  • tests
  • .editorconfig
  • .gitignore
  • AGENTS.md
  • CONTRIBUTING.md
  • deno.json
  • deno.lock
  • LICENSE
  • README.md
  • release.config.mjs
  • renovate.json
  • SECURITY.md
  • skills-lock.json

Discussion (0)

Ask about usage, or say what you built with it

Sign in to join the discussion.

No comments yet. Be the first to say what this is good for.

More tools

JuliusBrussee/
caveman

๐Ÿชจ why use many token when few token do trick โ€” Claude Code skill that cuts 65% of tokens by talking like caveman

105k
1 add
MemPalace/
mempalace

The best-benchmarked open-source AI memory system. And it's free.

59k
stablyai/
orca

Orca is the ADE for working with a fleet of parallel agents. Run any coding agent with your own subscription. Available on desktop, mobile and remote runtime.

66k

A cross-platform desktop All-in-One assistant for Claude Code, Codex, OpenCode, OpenClaw, Grok Build & Hermes Agent. Only official website: ccswitch.io

132k

Never stop coding. Free MIT AI gateway: one endpoint, 352 providers (150+ free), 1200+ models Kimi, Claude, GPT, Gemini, GLM, DeepSeek, MiniMax. Works with Claude Code, Codex, Cursor, OpenCode, Cline & Copilot. Quota-aware auto-fallback, RTK+Caveman compression saves 15-95% tokens, MCP/A2A, Desktop/PWA. Built by 550+ contributors

64k
headroomlabs-ai/
headroom

Compress tool outputs, logs, files, and RAG chunks before they reach the LLM. 20% fewer tokens for coding agents, 60-95% fewer tokens for JSON, same answers. Library, proxy, MCP server.

71k