$git clone https://github.com/gadicc/yahoo-finance2Unofficial API for Yahoo Finance with CLI, MCP and Agent Skill.
| 1 | # yahoo-finance2 |
| 2 | |
| 3 | Unofficial API for Yahoo Finance with CLI, MCP and Agent Skill. |
| 4 | |
| 5 | Copyright (c) 2021 by Gadi Cohen and Pilwon Huh. [MIT licensed](./LICENSE). |
| 6 | |
| 7 | [](https://www.npmjs.com/package/yahoo-finance2) |
| 8 | [](https://github.com/gadicc/yahoo-finance2/actions/workflows/release.yaml) |
| 9 | [](https://codecov.io/gh/gadicc/yahoo-finance2) |
| 10 | [](https://github.com/semantic-release/semantic-release) |
| 11 | [](http://www.typescriptlang.org/) |
| 12 | [](./LICENSE) |
| 13 | |
| 14 | You are reading the docs for **v4**, the current major version published as |
| 15 | `yahoo-finance2@latest`. For the older **v3 docs**, click |
| 16 | [here](https://github.com/gadicc/yahoo-finance2/tree/3.x). Upgrading? See |
| 17 | [UPGRADING](./docs/UPGRADING.md). |
| 18 | |
| 19 | [Live Demo on CodeSandbox](https://codesandbox.io/p/devbox/gxvftx) (Updated |
| 20 | 2024-06-17; NextJS with both RSC and Hook-Relay examples) |
| 21 | |
| 22 | NB: Recently **the repo was renamed** from `node-yahoo-finance2` to |
| 23 | `yahoo-finance2`, and the following **branches were named**, `master` to `main`, |
| 24 | and `devel` to `dev`. See [UPGRADING.md#dev](./docs/UPGRADING.md#dev) for the |
| 25 | git commands to update your local installation. |
| 26 | |
| 27 | ## Supported runtimes: |
| 28 | |
| 29 | - **Bun**: v1+. |
| 30 | - **Cloudflare**: Modern releases, tested in CI via Workers Vitest under |
| 31 | `nodejs_compat`. |
| 32 | - **Deno**: v2+. |
| 33 | - **Node**: v22+; v22 until 2027-04-30, v24 until 2028-04-30. Supported releases |
| 34 | follow the [Node.js release schedule](https://endoflife.date/nodejs). |
| 35 | |
| 36 | ## Unofficial API |
| 37 | |
| 38 | This project is neither created nor endorsed by Yahoo Inc. Yahoo does not |
| 39 | provide any official API to developers, nor makes any guarantees regarding |
| 40 | service availability or API consistency. In practice however, the open source |
| 41 | community has kept this project (and it's predecessor) working well since 2013. |
| 42 | |
| 43 | Nevertheless, we make no guarantees and you use this package at your own risk. |
| 44 | The developers (and obviously Yahoo) cannot be held responsible for any losses |
| 45 | you may incur as a result of using this service. Use of this package is |
| 46 | considered acknowledgement and acceptance of these terms and of its license. |
| 47 | |
| 48 | ## Quickstart |
| 49 | |
| 50 | **CLI** (Command line interface) |
| 51 | |
| 52 | ```bash |
| 53 | $ npx yahoo-finance2 --help |
| 54 | $ npx yahoo-finance2 search AMZN |
| 55 | $ npx yahoo-finance2 quoteSummary GOOGL |
| 56 | $ npx yahoo-finance2 quoteSummary NVDA '{"modules":["assetProfile", "secFilings"]}' |
| 57 | |
| 58 | # or install it |
| 59 | $ npm install -g yahoo-finance2 |
| 60 | $ yahoo-finance search MSFT '{ "someOption": true }' |
| 61 | ``` |
| 62 | |
| 63 | See the [CLI docs](./docs/cli.md) for stdout/stderr behavior and exit codes. |
| 64 | |
| 65 | See the [MCP docs](./docs/mcp.md) to expose yahoo-finance2 tools to MCP clients |
| 66 | such as Codex, Claude, Cursor, and VS Code. |
| 67 | |
| 68 | **Importing** |
| 69 | |
| 70 | ```ts |
| 71 | // or: const YahooFinance = require("yahoo-finance2").default; |
| 72 | import YahooFinance from "yahoo-finance2"; |
| 73 | |
| 74 | const yahooFinance = new YahooFinance(); |
| 75 | |
| 76 | const results = await yahooFinance.search("Apple"); |
| 77 | |
| 78 | const quote = await yahooFinance.quote('AAPL'); |
| 79 | const { regularMarketPrice as price, currency } = quote; |
| 80 | ``` |
| 81 | |
| 82 | Available modules: |
| 83 | [`chart`](https://jsr.io/@gadicc/yahoo-finance2/doc/modules/chart), |
| 84 | [`fundamentalsTimeSeries`](https://jsr.io/@gadicc/yahoo-finance2/doc/modules/fundamentalsTimeSeries), |
| 85 | [`historical`](https://jsr.io/@gadicc/yahoo-finance2/doc/modules/historical), |
| 86 | [`insights`](https://jsr.io/@gadicc/yahoo-finance2/doc/modules/insights), |
| 87 | [`options`](https://jsr.io/@gadicc/yahoo-finance2/doc/modules/options), |
| 88 | [`quote`](https://jsr.io/@gadicc/yahoo-finance2/doc/modules/quote), |
| 89 | [`quoteSummary`](https://jsr.io/@gadicc/yahoo-finance2/doc/modules/quoteSummary) |
| 90 | (submodules: assetProfile, balanceSheetHistory, balanceS |