Airsc miễn phí cho tất cả. Nếu nó giúp bạn, hãy ủng hộ $2–$20.

Ủng hộ
MCP serverCẩn thậnKết nối & tự động hoáCần cài đặt chút

yahoo-finance2

gadicc · gadicc/yahoo-finance2

Một API không chính thức cho Yahoo Finance, cung cấp các kỹ năng agent và một MCP server để các AI agent truy cập dữ liệu thị trường tài chính.

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

802 sao108Giấy phép: MITCập nhật 14 ngày trước0 lượt mở

Xem trước

▍

Bạn có thể làm gì với nó

  • Nhận báo giá chứng khoán thời gian thực và dữ liệu lịch sử để phân tích tài chính trong AI agent của bạn.
  • Xây dựng một AI agent theo dõi tin tức công ty cụ thể và các chỉ số tài chính bằng cách sử dụng Yahoo Finance.
  • Tự động hóa việc thu thập dữ liệu tài chính để theo dõi danh mục đầu tư hoặc nghiên cứu thị trường thông qua một agent.

Kiểm tra an toàn

Cẩn thận

Dùng được, nhưng nên đọc ghi chú trước.

  • ●Có câu lệnh cố ghi đè chỉ dẫn của agent hoặc giấu hành động khỏi bạn..agents/skills/improve/SKILL.md

Quét tự động các file trong repo. Luôn xem lại code trước khi chạy.

Trích từ 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.

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

Xem mã nguồn trên GitHub