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.5.tar.gz (39.2 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.5-py3-none-any.whl (37.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: yfin-0.1.5.tar.gz
  • Upload date:
  • Size: 39.2 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.5.tar.gz
Algorithm Hash digest
SHA256 80af60c8df9077193dc3b060634a3e3a86419fd2887b133e675a425fa7eecea5
MD5 386dfc498625c03b5bd31895e07de64d
BLAKE2b-256 80f1d6ebbf546ec6c6ef21863bf9cda973e40d2125541fd8769cdda04e31e119

See more details on using hashes here.

Provenance

The following attestation bundles were made for yfin-0.1.5.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.5-py3-none-any.whl.

File metadata

  • Download URL: yfin-0.1.5-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.5-py3-none-any.whl
Algorithm Hash digest
SHA256 ccacc6c82561b1b3aca943ccfee82bd4a6834baa7c00bde35df3a3780d0c36ff
MD5 72f5f53eb15aeafc05b5e152e34bb277
BLAKE2b-256 73a367b71602b51ad2b8395802671bc8edd36210adeb754b08835219a2ee40c0

See more details on using hashes here.

Provenance

The following attestation bundles were made for yfin-0.1.5-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