yahoo-finance2 is an actively maintained JavaScript and TypeScript client library for accessing the unofficial Yahoo Finance API. Currently at stable version 3.14.0, it provides programmatic access to various financial data points including historical prices, real-time quotes, company fundamentals, and search capabilities. The project maintains a regular release cadence, with multiple minor and patch updates occurring monthly, ensuring responsiveness to changes in Yahoo Finance's underlying API. Key differentiators include its comprehensive TypeScript support, broad runtime compatibility (Node.js v20+, Bun, Deno, Cloudflare Workers), and a command-line interface for quick data retrieval. As an unofficial API client, it does not come with guarantees from Yahoo Inc., emphasizing its community-driven nature and the importance of using it at one's own risk for financial applications.
npm install yahoo-finance2Verified import paths — ran on the pinned version, not inferred.
Demonstrates instantiating the YahooFinance client and using both instance methods (search) and directly imported functions (quote, historical) to fetch financial data.
Consult the `UPGRADING.md` document in the repository for detailed migration steps from v2 to v3. Update import statements and API call patterns as necessary.
Update your local Git remote URLs and branch tracking. Refer to `UPGRADING.md#dev` for specific `git` commands to update your repository clone.
Implement robust error handling, consider rate-limiting, and validate data against other sources if using for critical applications. Be prepared for potential API changes that may require library updates.
Ensure your Node.js environment is updated to version 20.0.0 or newer. Check the `engines.node` field in `package.json` for current requirements.
For CommonJS, use `const YahooFinance = require("yahoo-finance2").default;`. For ESM, ensure `import YahooFinance from "yahoo-finance2";` is used for the class, or `import { someFunction } from "yahoo-finance2";` for named exports.Ensure you are on the latest stable version of `yahoo-finance2` (>=3.11.1). If issues persist, consider implementing retry mechanisms, rate-limiting, or explicitly setting `fetchOptions.userAgent` if the default is causing problems.
Upgrade to `yahoo-finance2@^3.13.2` or later to ensure correct processing of search results and access to the `typeDisp` property.
No dependency data recorded yet.