yfin vs yfinance
yfinance is the default Python library many developers start with. yfin keeps the useful yfinance-style Python surface, then adds the pieces teams and agents usually have to build themselves: hosted HTTP endpoints, OpenAPI schemas, multi-language SDKs, explicit rate limits, and documented error responses.
Comparison
| Area | yfin | yfinance |
|---|---|---|
| Public requests/minute | 1,200 anonymous, 6,000 with X-Yfin-Contact, 30,000 with an API key | No managed API tier or published service quota |
| Public requests/second | 40 anonymous, 200 with X-Yfin-Contact, 2,000 with an API key | No hosted service limit |
| Public REST endpoints | 22 named routes for quotes, history, options, fundamentals, search, screeners, market summaries, sectors, industries, and research data | None |
| REST contract coverage | 45 shipped REST contracts behind the public API | Python calls only |
| OpenAPI | Full API reference with schemas, examples, and error bodies | Not available |
| AI-native use | Agents can read the docs, inspect OpenAPI, and call stable HTTP URLs from any runtime | Agents need Python execution or a custom wrapper |
| SDKs | Python plus TypeScript/JavaScript | Python |
| Python migration | import yfin as yf supports common yfinance-shaped calls | Already yfinance |
| Service identity | Optional contact header and API keys for higher-volume apps | No service identity model |
| Error handling | Documented JSON errors, Retry-After, SDK error classes | Library/runtime exceptions vary by call path |
Why It Matters
For a notebook, yfinance can be enough. For a product, backend job, hosted tool, or AI agent, yfin is the stronger shape: it gives you a real API boundary, clear request limits, schema-backed docs, and SDKs for more than one runtime.
The practical difference is that yfin can be called from Python, JavaScript, curl, serverless functions, browsers, and LLM tools using the same documented HTTP surface.
Migration Path
Most Python migrations start with the import:
- import yfinance as yf
+ import yfin as yf
import yfin as yf
ticker = yf.Ticker("AAPL", contact="you@example.com")
history = ticker.history(period="5d", interval="1d")
fast_info = ticker.fast_info
For a compatibility map of common yfinance calls, see Migrate from yfinance.
API Example
curl "https://api.yfin.dev/v1/quote?symbols=AAPL,MSFT" \
-H "X-Yfin-Contact: you@example.com"
curl "https://api.yfin.dev/v1/history?symbol=AAPL&period=5d&interval=1d"
Use the API Reference for response fields, examples, and error shapes.