# Yahoo Finance API & yfinance Alternative for Python

> Replace unofficial yfinance scrapers, 429 rate-limit blocks, and 4-quarter statement caps with QuantSet's documented REST, CSV, Python DataFrame, and MCP API.

Canonical URL: https://quantset.dev/docs/switch/yfinance
Full LLM API Contract: https://api.quantset.dev/llms-full.txt

> ## For AI agents
> The QuantSet API is at https://api.quantset.dev. Send the key in the `X-API-Key` header. The sandbox key `mw_demo` needs no signup and reads the sample listings.
> No key yet? An agent can open an account on its own: https://api.quantset.dev/skill.md
> Connect an MCP client to https://api.quantset.dev/mcp. Client setup is at https://api.quantset.dev/agents.md.
> Start with https://api.quantset.dev/llms.txt or read the full reference at https://api.quantset.dev/llms-full.txt. The OpenAPI file is https://api.quantset.dev/openapi.json. Add `.md` to any docs URL to get that page as Markdown.

Yahoo shut down its official public developer API years ago. Open-source scrapers like `yfinance` parse undocumented web endpoints that trigger `429 Too Many Requests`, rotate session crumbs without warning, and return only 4–5 periods of restated financials. QuantSet gives Python workflows a documented REST, CSV, and MCP contract with deterministic pagination and SEC XBRL provenance.
          

          

## Why yfinance breaks in backtests and cron jobs

          

`yfinance` is great for a quick notebook plot, but teams running scheduled pipelines, factor backtests, or AI agents hit the same four failure modes:
          
            
- **Undocumented `429 Too Many Requests` & crumb blocks:** Cloud and CI runner IPs (GitHub Actions, AWS, GCP, Fly.io) regularly hit Yahoo cookie/crumb blocks or silent empty DataFrames with no `Retry-After` contract.
            
- **Shallow, silently restated fundamentals:** Scraped web tables typically expose only the last 4 annual or 4–5 quarterly statements—with no SEC accession numbers, no filing dates for point-in-time checks, and silent schema renames in `Ticker.info`.
            
- **Opaque `Adj Close` math:** When a reverse split or special dividend lands, scraped series frequently double-adjust or lag by days without exposing whether split and dividend factors reconciled.
            
- **Zero snapshot isolation:** Paginating across hundreds of tickers while daily bars update mid-run produces inconsistent cross-sectional dates.
          

          

## yfinance vs. QuantSet at a glance

          
            
              
                
| Capability | yfinance (unofficial scraper) | QuantSet API & Python SDK |
              
              
                
| **Official contract** | Scrapes internal web JSON / HTML crumbs | Versioned `/api/v1` OpenAPI + deterministic JSON & CSV |
                
| **Rate-limit transparency** | Unannounced IP bans / `429` HTML challenges | Explicit `X-RateLimit-Remaining` & `Retry-After` headers |
                
| **US equity price history** | Varies by symbol; unflagged split breaks | Back to 1962 (up to 20,000 bars in one call) + cross-checked `adj_close` |
                
| **Financial statements** | ~4 years / 5 quarters, no filing metadata | Multi-decade SEC XBRL with `available_at` & accession provenance |
                
| **Missing values** | Mixed `NaN`, `0`, or missing dict keys | Strict `null` when unverified—never coerced to `0` |
                
| **AI / MCP integration** | Breaks mid-prompt when rate-limited | Native hosted Streamable HTTP MCP (`/mcp`) + `@quantset/mcp` |
              
            
          

          

## Side-by-side Python migration

          

Replace brittle `yf.Ticker(...).history()` and `.financials` calls with either `pip install quantset` or plain `httpx` / `requests`:
          
            
```
# Before: unofficial Yahoo scraper (breaks on cloud IPs & 4-year statement cap)
# import yfinance as yf
# df = yf.Ticker("NVDA").history(start="2015-01-01")
# inc = yf.Ticker("NVDA").income_stmt

# After: QuantSet Python SDK (deterministic snapshot + DataFrame conversion)
import quantset as qs

bars = qs.prices("NVDA", start="2015-01-01").to_df()
income = qs.income(["NVDA"], period="quarterly", limit_per_instrument=12).to_df()
print(bars.tail(3)[["date", "close", "adj_close", "adjustment"]])
```

          

          

## OHLCV bars with verified adjusted close

          

Copy the daily bars request into your client to use the free `mw_demo` sandbox key. Notice how every bar explicitly reports its currency, volume unit, and split/dividend verification status—and up to 20,000 daily bars return in a single HTTP call.
          
            
```
curl "https://api.quantset.dev/api/v1/prices?ticker=NVDA&limit=5" -H "X-API-Key: mw_demo"
```

          
          

Global listings use explicit exchange suffixes under the `global:` namespace (for example `global:SHEL.L` in London, `global:1301.T` in Tokyo, or `global:RELIANCE.NS` in India) so tickers never collide across countries:
          
            
```
curl "https://api.quantset.dev/api/v1/prices?ticker=SHEL.L&limit=5" -H "X-API-Key: mw_demo"
```

          

          

## SEC XBRL income statements beyond four quarters

          

Unlike scraped summary tables that truncate after four periods, QuantSet normalizes U.S. SEC EDGAR filings into standardized `income`, `balance_sheet`, and `cash_flow` rows—preserving discrete quarterly cash flows (never unlabelled 6M/9M YTD totals) alongside filing dates.
          
            
```
curl "https://api.quantset.dev/api/v1/financial-statements/income?tickers=us:NVDA&period=quarterly&limit_per_instrument=4" -H "X-API-Key: mw_demo"
```

          

          

## Batch 100 tickers in 1 call (zero rate-limit anxiety)

          

Instead of looping `yf.Ticker(sym)` 100 times and triggering a `429` ban, pass up to 100 comma-separated instruments across US equities, global equities, and crypto in a single request—counted as **1 API call**:
          
            
```
curl "https://api.quantset.dev/api/v1/quotes?tickers=us:NVDA,us:AAPL,us:MSFT,global:SHEL.L,crypto:BTCUSDT" -H "X-API-Key: mw_demo"
```

          

          

## Common questions about Yahoo Finance API alternatives

          

### Does Yahoo Finance still have an official free API?

          

No. Yahoo retired its official YQL and public finance APIs in 2017. Packages such as `yfinance` and `yahooquery` scrape undocumented frontend endpoints intended for web browsers, while third-party wrappers on API marketplaces resell those same scraped endpoints without upstream SLAs.
          

### Can I test QuantSet in Python before buying a key?

          

Yes. Every endpoint above works immediately with `X-API-Key: mw_demo` (no signup or credit card) across nine benchmark US, global, ETF, index, and crypto instruments at 30 requests per minute. When you are ready for the full 90,000+ symbol universe, [Developer plans start at $39/month](/pricing) (6,000 credits per month).

---

## QuantSet Ecosystem & Integrations (https://quantset.dev/integrations)

- **MCP Clients & 7 Skills:** `npx quantset init` & `npx skills add quantset/skills` (Claude, Claude Code, Cursor, ChatGPT, Codex, Hermes, OpenClaw, Block Goose, Cline, Docker MCP Toolkit — `https://api.quantset.dev/mcp`)
- **Python SDK & Agent Frameworks:** `pip install "quantset[pandas]"` · `from quantset.tools import build_agent_functions, langchain_tools, crewai_tools` (PydanticAI, LangGraph, LangChain, CrewAI, Agno, AutoGen, Google ADK, OpenAI Agents SDK)
- **TypeScript SDK & Vercel AI / Mastra:** `npm install quantset` · `import { createQuantsetTools } from "quantset/tools"` (Node 20+, Bun, Deno, Cloudflare Workers, Vercel Edge)
- **Spreadsheets & Workspaces:** Google Sheets (`=QUANTSET()` & `=IMPORTDATA()`), Microsoft Excel Power Query (`?format=csv`), Notion MCP & n8n/Make webhooks (`https://quantset.dev/docs/guides/google-sheets-excel-notion-stock-templates`)
- **Drop-In Migrations & Machine Payments:** FMP `/stable/*` & `/v3/*` adapter (`https://quantset.dev/docs/switch/fmp`), `yfinance` migration (`https://quantset.dev/docs/switch/yfinance`), autonomous signup (`https://api.quantset.dev/skill.md`), and `x402` Base USDC.
