Python SDK
Package: yfin on PyPI
pip install yfin
yfinance-Compatible Import
Use this path when you want existing yfinance-style code to keep its shape.
import yfin as yf
history = ticker.history(period="1mo", interval="1d")
fast_info = dict(ticker.fast_info)
info = ticker.info
chain = ticker.option_chain()
Common supported calls include Ticker, download, history, fast_info,
info, options, option_chain, corporate actions, financial statements,
analyst data, holders, insider data, calendar data, SEC filings, sustainability,
shares, valuation, and live quote helpers.
For a migration table, see Migrate from yfinance. For data behavior, see Symbols, Historical Prices, and Missing Data.
Return Shapes
The compatibility layer returns Python objects that existing yfinance code
usually expects: pandas DataFrame and Series objects for tabular/time-series
data, dictionaries for quote and metadata objects, and lists for collection
responses such as news.
The low-level Client returns JSON-compatible Python dictionaries that match
the REST API response bodies.
Low-Level Client
Use Client when you want direct access to the hosted REST API from Python.
import yfin
quote = client.quote(["AAPL", "MSFT"])
history = client.history("NVDA", range="5d", interval="1h")
fundamentals = client.fundamentals("AAPL", modules=["price", "summaryDetail"])
Configuration
Pass configuration directly:
client = yfin.Client(
api_key="yfin_...",
timeout=10,
)
Or use environment variables:
export [email protected]
export YFIN_API_KEY=yfin_...
export YFIN_BASE_URL=https://api.yfin.dev
YFIN_BASE_URL is useful for tests and alternate API origins.
Errors
The SDK raises YfinRateLimitError for HTTP 429 and YfinError for other API
or transport failures.
import yfin
from yfin import YfinRateLimitError
try:
print(client.history("AAPL", range="1mo", interval="1d"))
except YfinRateLimitError as exc:
print("rate limited", exc)
Live Quotes
The Python package also exposes yfinance-style live quote helpers:
import yfin as yf
ws = yf.WebSocket()
ws.subscribe(["AAPL", "MSFT"])
For direct REST endpoint shapes, use the API Reference.