Lightweight Python SDK for yfin: hosted Yahoo Finance quotes, history, options, fundamentals, screeners, and search.
Project description
yfin
Lightweight Python SDK for yfin, a hosted Yahoo Finance data API for builders.
yfin gives you access to Yahoo Finance market data without running your own scraper stack: quotes, historical prices, options chains, fundamentals, screeners, symbol search, and market context through product-native namespaces. Use it for dashboards, agents, notebooks, research tools, watchlists, prototyping, and app backends.
This SDK is intentionally straightforward: plain dict responses, typed
errors, automatic retries, a symbol-scoped ticker workbench, and sync/async
streaming clients.
Docs: https://docs.yfin.dev/python-sdk
pip install yfin
Quick Use
import yfin
client = yfin.Client()
apple = client.ticker("AAPL")
# Current quote snapshots
quotes = client.quotes.batch(["AAPL", "MSFT"])
# Historical chart data
history = apple.history(range="5d", interval="1h")
# Options chain data
chain = apple.option_chain()
print(quotes["data"], history["data"], chain["data"])
Common Calls
client.quotes.batch(["AAPL", "MSFT"])
client.prices.history("AAPL", range="1mo", interval="1d", events="div,splits,capitalGains")
client.options.chain("AAPL", date="2026-01-16")
client.fundamentals.get("AAPL", modules=["price", "summaryDetail"])
client.symbols.search("apple")
client.screeners.default(count=25)
client.screeners.run({
"size": 10,
"query": {"operator": "EQ", "operands": ["sector", "Technology"]},
})
The client is organized around yfin product areas: quotes, prices,
options, fundamentals, financials, symbols, screeners, market,
calendar, events, research, and reference. Use client.ticker("AAPL")
for symbol-scoped quote, history, options, fundamentals, financials, metadata,
and research calls.
Runtime Support
Configuration can come from constructor options or environment variables:
| Option | Environment | Purpose |
|---|---|---|
base_url |
YFIN_BASE_URL |
Override https://api.yfin.dev; must be http or https |
contact |
YFIN_CONTACT |
Send optional support metadata |
api_key |
YFIN_API_KEY |
Send email-verified API credentials |
management_token |
YFIN_MANAGEMENT_TOKEN |
Manage API keys after email verification |
api_key is sent as Authorization: Bearer <key> by default. Pass
api_key_header="x-yfin-key" to use X-Yfin-Key instead.
The SDK retries transient 429, 502, 503, and 504 responses by default.
Use max_retries, retry_statuses, backoff_factor, max_backoff, and
backoff_jitter when you need tighter control, or set max_retries=0.
Keep API keys on a server when you do not control the runtime.
Auth Helpers
client = yfin.Client()
client.management.request_auth_otp("you@example.com")
verified = client.management.verify_auth_otp("you@example.com", "123456", label="agent")
api_key = verified["data"]["api_key"]
management_token = verified["data"]["management_token"]
authed = yfin.Client(api_key=api_key)
authed.management.request_limit_increase(
requested_rps=25,
use_case="production agent workload",
message="Short traffic description.",
)
managed = yfin.Client(management_token=management_token)
keys = managed.management.keys.list()
created = managed.management.keys.create(label="batch job")
managed.management.keys.rotate(created["data"]["key"]["id"])
Custom-limit requests are limited to 1 per minute per API key. You can also
email sam@yfin.dev.
All successful calls return the hosted yfin envelope:
{
"data": {},
"meta": {
"provider": "yahoo_finance",
"generated_at": "2026-01-01T00:00:00Z",
"route": "/v1/quote",
},
}
Errors
HTTP errors raise YfinError. HTTP 429 raises YfinRateLimitError; HTTP 503
raises YfinServiceBusyError after retry exhaustion. Error objects include
retry_after, status, code, response, and response headers.
try:
yfin.Client().quotes.get("AAPL")
except yfin.YfinRateLimitError as error:
print(error.retry_after)
except yfin.YfinServiceBusyError as error:
print("service busy", error.retry_after)
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file yfin-0.2.0.tar.gz.
File metadata
- Download URL: yfin-0.2.0.tar.gz
- Upload date:
- Size: 15.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
88306f1cb6cda1fcc616534d06f1eee0ad114a0d291d1b6791d1a0e0de01f5a3
|
|
| MD5 |
da5a7f2a6580480f2adad1dd5aaa39d8
|
|
| BLAKE2b-256 |
300a770a8560ffb6a360ac49c20dee5cbf38ded0816f199aaaee1b2aa0066459
|
Provenance
The following attestation bundles were made for yfin-0.2.0.tar.gz:
Publisher:
publish-yfin-python.yml on bluefin-ai/fin-services
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
yfin-0.2.0.tar.gz -
Subject digest:
88306f1cb6cda1fcc616534d06f1eee0ad114a0d291d1b6791d1a0e0de01f5a3 - Sigstore transparency entry: 1646869817
- Sigstore integration time:
-
Permalink:
bluefin-ai/fin-services@df702f644aaed2ac44e4e51ed76ea3f4808e24ec -
Branch / Tag:
refs/tags/yfin-python-v0.2.0 - Owner: https://github.com/bluefin-ai
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-yfin-python.yml@df702f644aaed2ac44e4e51ed76ea3f4808e24ec -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file yfin-0.2.0-py3-none-any.whl.
File metadata
- Download URL: yfin-0.2.0-py3-none-any.whl
- Upload date:
- Size: 13.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e1a4cdda985c0bd120e8c798f966ca30252f84a9ce1807261f96a89147e438c1
|
|
| MD5 |
bf86f449f690e37fac77849f90d5ac5d
|
|
| BLAKE2b-256 |
e9833c63d35476485238c4a66298ab138b5fb588407ed9b86488c2f7f4fe5eb9
|
Provenance
The following attestation bundles were made for yfin-0.2.0-py3-none-any.whl:
Publisher:
publish-yfin-python.yml on bluefin-ai/fin-services
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
yfin-0.2.0-py3-none-any.whl -
Subject digest:
e1a4cdda985c0bd120e8c798f966ca30252f84a9ce1807261f96a89147e438c1 - Sigstore transparency entry: 1646869828
- Sigstore integration time:
-
Permalink:
bluefin-ai/fin-services@df702f644aaed2ac44e4e51ed76ea3f4808e24ec -
Branch / Tag:
refs/tags/yfin-python-v0.2.0 - Owner: https://github.com/bluefin-ai
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-yfin-python.yml@df702f644aaed2ac44e4e51ed76ea3f4808e24ec -
Trigger Event:
workflow_dispatch
-
Statement type: