yahoo_finance 0.1.1
yahoo_finance: ^0.1.1 copied to clipboard
A Yahoo Finance client for Flutter — the Dart equivalent of Python's yfinance. Fetch quotes, historical prices, and ticker metadata with browser-grade TLS fingerprinting to avoid Yahoo's rate limits.
yahoo_finance #
A Yahoo Finance client for Flutter — the Dart equivalent of Python's yfinance. Same API shape, same endpoints, same battle-tested workarounds for Yahoo's bot protection.
import 'package:yahoo_finance/yahoo_finance.dart';
final ticker = Ticker('AAPL');
final quote = await ticker.quote();
print(quote.regularMarketPrice);
final bars = await ticker.history(
period: Period.threeMonths,
interval: Interval.oneDay,
);
final info = await ticker.info();
print('${info.longName} — analyst target ${info.targetMeanPrice}');
final income = await ticker.incomeStatement();
print('Revenue: ${income.latest('TotalRevenue')}');
// Market-wide calendars (not symbol-scoped)
final earnings = await Calendars().earningsCalendar(limit: 50);
Features #
| Area | API |
|---|---|
| Snapshot quote | quote() |
| Company info, key stats, analyst targets | info() · fastInfo() |
| Historical OHLCV bars | history(period, interval, start, end) |
| Dividends, splits, capital gains | actions() |
| Financial statements (annual/quarterly/TTM) | incomeStatement() · balanceSheet() · cashFlow() |
| Options expirations & chains | options() · optionChain() |
| News | news() |
| Earnings & dividend dates | calendar() |
| Analyst recommendations & rating changes | recommendations() · upgradesDowngrades() |
| Market-wide calendars (earnings, IPOs, economic events, splits) | Calendars().earningsCalendar() etc. |
Missing vs yfinance: holders/insiders, analyst estimate tables,
sustainability, fundsData, multi-symbol batching, symbol search.
Why it needs its own HTTP stack #
Yahoo rate-limits and blocks plain HTTP clients (401/429) and
fingerprints TLS handshakes. Like yfinance (which uses curl_cffi's
browser impersonation), this package routes traffic through real
browser network stacks:
- iOS / macOS → URLSession (
cupertino_http, Safari TLS fingerprint) - Android → Cronet (
cronet_http, Chrome TLS fingerprint) - Linux / Windows →
dart:iofallback with realistic browser headers
On top of that, a shared YahooHttpClient manages the cookie + crumb
session, retries once on auth failures, and rotates the session
periodically. Disable impersonation with the
YAHOOFIN_DISABLE_IMPERSONATION env var (mirrors yfinance's
YF_DISABLE_CURL_CFFI).
Flutter Web is not supported — Yahoo blocks cross-origin browser requests (CORS).
Install #
flutter pub add yahoo_finance
Example app #
example/ is a runnable feature tester: pick a symbol and
tap through every API (history with period/interval pickers, financials
with statement/frequency pickers, options chains, market calendars…).
cd example
flutter run -d macos # or an iOS/Android device
Development #
flutter pub get # root AND example/
dart analyze # covers both
flutter test # package tests (offline, fixture-based)
cd example && flutter test
Tests never hit the network — they parse recorded Yahoo responses from
test/fixtures/.
Disclaimer #
Unofficial library, not affiliated with Yahoo. Data is provided by Yahoo Finance for personal, non-commercial use — review Yahoo's terms of service before using it in a product.