Skip to main content

Python SDK for the hosted yfin Yahoo Finance API, with yfinance-compatible data access.

Project description

yfin Python SDK

PyPI Python CI OpenAPI Warm benchmark

yfin is a yfinance-compatible Python SDK backed by the hosted api.yfin.dev Yahoo Finance API. The hosted API handles Yahoo Finance contracts, crumb bootstrap, caching, request coalescing, and origin budgets. The SDK adds pandas/yfinance-shaped access on top.

Use yfinance for a mature local-only notebook dependency. Use yfin when you want the same Python shape plus a hosted REST API, shared caching, OpenAPI, explicit rate limits, and infrastructure that absorbs Yahoo cookie/crumb/TLS and rate-limit churn.

pip install yfin

Quickstart

import yfin as yf

aapl = yf.Ticker("AAPL")

print(aapl.history(period="5d", interval="1d"))
print(aapl.fast_info)
print(aapl.info)
print(aapl.option_chain())
print(aapl.funds_data.top_holdings)
print(aapl.valuation)
print(yf.download(["AAPL", "MSFT"], period="5d"))

ws = yf.WebSocket(verbose=False)
ws.subscribe("BTC-USD")

Low-Level Hosted API Client

import yfin

client = yfin.Client(contact="you@example.com")
print(client.quote(["AAPL", "MSFT"]))
print(client.history("NVDA", range="5d", interval="1h"))

Set YFIN_BASE_URL to override the hosted API URL.

What yfin Ships

  • yfinance-compatible Ticker, Tickers, download, WebSocket, and AsyncWebSocket APIs.
  • 45 CP2-confirmed Yahoo REST contracts behind https://api.yfin.dev.
  • OpenAPI schema at https://api.yfin.dev/v1/openapi.json.
  • Machine-readable endpoint manifest at https://api.yfin.dev/v1/endpoints.
  • Cache metadata and explicit typed rate-limit errors.

Honest Performance Position

yfin is not guaranteed to beat yfinance on cold one-off notebook calls. A cold miss goes through yfin and then Yahoo. The hosted path is designed to win when requests are repeated, concurrent, cacheable, or run from services/agents that benefit from managed Yahoo access.

Recent live checks:

Probe Result
Anonymous forced history misses 25/25 HTTP 200, no 429
17 forced history misses 1.4s wall time
Same 17 warm hosted reads 117ms wall time, 76ms median
Python SDK 17-accessor warm pass 637ms wall time
Local yfinance matching 16-accessor pass 1330ms wall time

See the benchmark notes.

Trust And Docs

Rate Limits

Identity Total requests/minute Yahoo-origin misses/minute
Anonymous IP 1200 120
X-Yfin-Contact / SDK contact= 6000 600
Manual API key 30000 3000

High-volume users can email sam@yfin.dev for an API key.

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

yfin-0.1.4.tar.gz (38.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

yfin-0.1.4-py3-none-any.whl (37.4 kB view details)

Uploaded Python 3

File details

Details for the file yfin-0.1.4.tar.gz.

File metadata

  • Download URL: yfin-0.1.4.tar.gz
  • Upload date:
  • Size: 38.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for yfin-0.1.4.tar.gz
Algorithm Hash digest
SHA256 42d6fe402727f10e36de925f578e7bf81e7399dd6e4d05a105a526ecc48ed79f
MD5 3128ed6378cf3b7cc2c1fc980afebe5f
BLAKE2b-256 0b0c75dea9834022154bb3b8e68bb0a679d35653ba380a4e43a575b5aa66edcf

See more details on using hashes here.

Provenance

The following attestation bundles were made for yfin-0.1.4.tar.gz:

Publisher: publish-yfin-python.yml on bluedoor-ai/yfin

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file yfin-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: yfin-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 37.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for yfin-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 c76539c5135bac858384aefe5eb7544562ad2bfdff5321945c040081bf897203
MD5 ec9c0043e395d13a4d3f15b2d9d33efe
BLAKE2b-256 382acfc566ae21b6770c2b0abcb42cbcd78735e496504a361d2ba8fa2aeaf6a9

See more details on using hashes here.

Provenance

The following attestation bundles were made for yfin-0.1.4-py3-none-any.whl:

Publisher: publish-yfin-python.yml on bluedoor-ai/yfin

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page