Skip to main content

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)

Metadata

Release files for yfin 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for yfin 0.2.0
File Size Uploaded Provenance Actions
yfin-0.2.0.tar.gz 15.6 kB With provenance Details for yfin-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for yfin 0.2.0
File Interpreter ABI Platform Actions
yfin-0.2.0-py3-none-any.whl Python 3 none any Details for yfin-0.2.0-py3-none-any.whl

Total release size: 28.6 kB

Release files / yfin-0.2.0.tar.gz

Download URL yfin-0.2.0.tar.gz
Size 15.6 kB
Tags Source
SHA-256 checksum
How to use checksums
88306f1cb6cda1fcc616534d06f1eee0ad114a0d291d1b6791d1a0e0de01f5a3
BLAKE2b-256 checksum
How to use checksums
300a770a8560ffb6a360ac49c20dee5cbf38ded0816f199aaaee1b2aa0066459
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 27, 2026.

Transparency log

Release files / yfin-0.2.0-py3-none-any.whl

Download URL yfin-0.2.0-py3-none-any.whl
Size 13.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e1a4cdda985c0bd120e8c798f966ca30252f84a9ce1807261f96a89147e438c1
BLAKE2b-256 checksum
How to use checksums
e9833c63d35476485238c4a66298ab138b5fb588407ed9b86488c2f7f4fe5eb9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 27, 2026.

Transparency log

Security for yfin 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for yfin-0.2.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 27, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page