
yfinance Alternative for AI Agents: An Official Stock API Your Agent Sets Up Itself
A yfinance alternative for AI agents: an official stock market API with published limits, SDKs and MCP, and a key your coding agent gets with no signup. What yfinance is, when it is still the right tool, and what SentiSense adds: sentiment, insider, congressional, 13F, options and earnings data, with every yfinance claim read from its README, GitHub tracker and Yahoo's terms on October 17, 2026.
A yfinance alternative for an AI agent is an official, keyed market data API with published rate limits, docs the agent can read, and a key the agent can get without a browser step. SentiSense treats the agent as a user in its own right: it can try the API in the same turn it chooses it, and the person it works for decides what to keep. npx sentisense init returns a working temporary API key with no signup, the agent uses it right away, and the person keeps the same key on a free account later. The API covers the most-watched US stocks and ETFs with prices, fundamentals and chart history, plus the data yfinance does not carry: per-stock sentiment and the SentiSense Score, insider Form 4 trades, congressional trades, 13F institutional flows, end-of-day options analytics, analyst ratings, earnings analysis and company KPIs.
This post states what a data service should offer an agent and how SentiSense does it; covers what yfinance is and where it breaks, with every claim read from the library's own README, its GitHub tracker or Yahoo's terms on October 17, 2026; and compares the two in code. For a wider comparison of general stock data APIs, see the best stock data APIs in 2026.
What should a data service offer an agent?
A growing share of the work that used to begin with a person reading docs in a browser now begins with an agent: it picks a data source, writes the client, runs it and reports back. A service built for that reader does four things, and each one pays the person as much as the agent.
- It lets the agent try first. A key the agent can obtain in one command, with no form in the middle, means the dashboard runs in the same turn instead of stopping at "please sign up and paste a secret".
- It publishes its limits. Requests a minute, requests a day, what a free key returns and where the full record begins, so the agent designs around real numbers rather than discovering them in a 429.
- It describes itself in a form the agent reads. An
llms.txtindex atsentisense.ai/llms.txt, a single-file reference atsentisense.ai/skill.md, installable agent skills and an MCP connector, so the agent learns the API from the source rather than from a tutorial written against last year's version. - It leaves the person in control. The agent provisions; the person decides what is kept, under which account and at which tier. A key no person has kept cannot reach billing or account settings.
Neon, Prisma and Vercel already run this pattern for databases and deployments: the agent provisions, a person claims. SentiSense's temporary key is the same contract for market data, and the rest of this post works through it.
What is yfinance, and why do people look for an alternative?
yfinance is an open-source Python library, distributed under the Apache 2.0 license, that reads Yahoo Finance's publicly available web endpoints. It is popular for good reasons: one pip install, no key, no account, a Ticker object that returns price history, fundamentals, option chains, insider transactions, top institutional holders, analyst recommendations, earnings dates and news, and a maintainer base that shipped version 1.7.0 on August 26, 2026, with the GitHub project past 25,000 stars.
The library's README is also clear about what it is not. It states that yfinance is "not affiliated, endorsed, or vetted by Yahoo, Inc.", that it is intended for research and educational purposes, that the Yahoo Finance API is intended for personal use, and that Yahoo's terms govern your rights to the data it downloads. Yahoo's own Terms of Service, last updated August 4, 2026, prohibit collecting data from its services by automated means and reusing them for commercial purposes, and Yahoo Finance's data page says the information it displays must not be redistributed.
The practical consequence is that the library depends on endpoints Yahoo built for its own website, and it breaks when those change. Three episodes from the project's GitHub tracker:
- Late 2022 to June 2023. Yahoo began encrypting responses. Issue 1407, "yfinance failed to decrypt Yahoo data response", collected 96 comments and 284 reactions before the June 2023 release removed the decryption code.
- October to November 2023. The
.infoendpoint returned 404 on every ticker (issue 1729, 147 comments, 65 reactions), a month after the library had adopted Yahoo's cookie-and-crumb request flow. - February to May 2025. A wave of
YFRateLimitError: Too Many Requestsreports. Issue 2422 alone ran to 141 comments, with users reporting the limit held across different IP addresses; a user-agent change in February (issue 2276) and several crumb-handling fixes followed.
Each was fixed in a later release. Each also stalled every script and pipeline built on the version before it, on Yahoo's schedule rather than the builder's. There is no published rate limit to design around, because there is no published API.
What does SentiSense offer instead?
SentiSense is a documented REST API with a key on every call, published limits, and the same data reachable from Python, Node, a CLI, an MCP connector and installable agent skills. Prices are delayed 15 minutes; options data is end of day. The table reads each row against what yfinance's Ticker reference lists.
| Data | yfinance | SentiSense |
|---|---|---|
| Prices and OHLCV history | Yahoo's history, any period | 15-minute delayed quotes; daily bars up to about 26 years, split- and dividend-adjusted on the longest ranges |
| Fundamentals | Statements and key stats | Statements as filed, up to 40 quarters or 20 years of history |
| Options | Raw chain per expiry | End-of-day analytics ranked against each stock's own history: IV rank, put/call percentile, 25-delta skew, open-interest walls, max pain, unusual contracts; no raw chain |
| Analyst ratings | Recommendations, upgrades and downgrades, price targets | Consensus and targets, upgrade and downgrade actions, estimates and surprise history, per-analyst call records (free preview, full on PRO) |
| Insider trades | Insider transactions table | SEC Form 4 buys, sells, awards and exercises, with cluster-buy detection (free preview, full on PRO) |
| Institutional ownership | Top holders table | 13F flows by quarter, holders per stock, activist positions, institution profiles (free preview, full on PRO) |
| Congressional trades | None | STOCK Act disclosures by member or by ticker (free preview, full on PRO) |
| Sentiment | None | Per-stock sentiment, the SentiSense Score, mentions by source, the Market Mood index (free) |
| Earnings | Dates and calendar | Calendar plus per-quarter earnings analysis, SEC risk-factor diffs and the price reaction to each of the last 12 reports (free preview, full on PRO) |
| Company KPIs | None | Segment and operating metrics from filings, by fiscal period (PRO) |
| Access | Unofficial endpoints, no key, no published limits | Keyed REST API, 30 requests a minute and 1,000 a month free, 300 a minute and unlimited on PRO; Python and Node SDKs, CLI, MCP connector, 21 agent skills |
Free previews return the top rows of a response and say so in the payload, so an agent can tell a free slice from the full record. The full API reference is at sentisense.ai/docs/api/, the sentiment endpoints on the stock sentiment API page.
How does a coding agent get a key with no signup?
In a terminal, or from inside Claude Code, Codex, Cursor or any agent that can run a command:
npx sentisense init
It prints SENTISENSE_API_KEY=<key>, when the key expires, the keep link, the limits and where the agent docs are. It writes no files into the project: the key goes wherever the project already keeps secrets. The same call without the CLI is one keyless POST:
curl -X POST https://app.sentisense.ai/api/v1/keys/provision
Until the key is kept, it is temporary and runs at tighter limits than a free account, and every data endpoint answers it the way it answers a Free key. Account endpoints (keys, billing, account settings) stay closed. The first call is the usual header:
curl -H "X-SentiSense-API-Key: $SENTISENSE_API_KEY" \
"https://app.sentisense.ai/api/v1/stocks/NVDA/sentiment"
The keep link works for 14 days from the moment the key was made, including after the key has stopped. The agent hands it to the person it works for; that person opens it, signs in or creates a free account, and confirms. The same key string moves onto their account at the Free tier's limits, so the project keeps running with nothing to change. If the person has an API key already, the page asks which one to keep. Details, response fields and error codes are on the keys for coding agents page; a person who prefers to sign up first gets a free key at app.sentisense.ai/get-api-key.
yfinance and SentiSense, side by side in Python
The yfinance call most scripts start with, and its SentiSense equivalent, then the call yfinance has no equivalent for.
# yfinance: last close over one month
import yfinance as yf
aapl = yf.Ticker("AAPL")
hist = aapl.history(period="1mo")
print(hist["Close"].iloc[-1])
# SentiSense: the same bar, then the sentiment read
import os
from sentisense import SentiSenseClient # pip install sentisense
client = SentiSenseClient(api_key=os.environ["SENTISENSE_API_KEY"])
bars = client.get_stock_chart("AAPL", timeframe="1M") # OHLCV dicts, oldest first
print(bars[-1]["close"])
s = client.get_stock_sentiment("AAPL").data
print(s["direction"], s["scoreLabel"], s["mentions"]) # 30-day read, Score band, mentions today
The Node SDK and CLI expose the same calls (npx sentisense sentiment AAPL), the MCP connector serves them as tools to Claude, ChatGPT, Codex and Grok, and the published skills give an agent the patterns without writing the script. More Python, including whether a mention spike is good or bad news, is in five Python stock sentiment examples.
When is yfinance still the right tool?
For a notebook, a class project or a one-off backtest over Yahoo's history, where a stall costs an afternoon and nothing else, and you want no account of any kind. For global tickers: SentiSense covers US stocks and ETFs. For raw option chains by expiry, which SentiSense does not serve; it returns end-of-day analytics on the chain instead. For a batch of fundamentals on a ticker outside the most-watched US names, which SentiSense may not track.
For anything that must run tomorrow, that an agent sets up on its own, or that needs the layer between headlines and price, start with the temporary key and keep it when it earns its place.
FAQ
Is yfinance an official Yahoo Finance API? No. yfinance is an open-source Python library under the Apache 2.0 license that reads Yahoo Finance's publicly available endpoints. Its own README says it is not affiliated with, endorsed or vetted by Yahoo, that it is intended for research and educational purposes, and that Yahoo's terms govern the data. Yahoo publishes no official finance API for third parties, so there is no published rate limit, no key and no contract.
Why does yfinance stop working or return Too Many Requests? Because it depends on endpoints Yahoo built for its own website. When Yahoo changes them, the library breaks until its maintainers catch up: response encryption in late 2022, 404s on the info endpoint in October 2023, and the rate limiting that produced a 141-comment YFRateLimitError thread in April and May 2025 are the largest cases in the project's GitHub tracker. Each was fixed in a later release, and each one stalled every pipeline built on the version before it.
What is the best yfinance alternative for an AI agent? One the agent can set up and call without a human step in the middle: a keyed API with published limits, docs it can read (llms.txt, a skill file or an MCP server), a key it can obtain itself, and a person who decides what is kept. SentiSense does this with npx sentisense init, which returns a working temporary key with no signup; the person the agent works for keeps the same key on a free account later. It covers the most-watched US stocks and ETFs with prices, fundamentals, sentiment, insider, congressional, 13F, options, analyst and earnings data.
How does a temporary SentiSense key work? npx sentisense init, or one POST to /api/v1/keys/provision, returns a key and a keep link. Until it is kept, the key is temporary, runs at tighter limits than a free account and cannot reach account endpoints. The keep link works for 14 days: open it, sign in or create a free account, and the same key string moves onto that account at the Free tier's limits, so nothing in the project changes.
When is yfinance still the right choice? For a notebook, a class project or a one-off backtest where a stall costs nothing and you want no account of any kind. It also covers global tickers and returns raw option chains per expiry, which SentiSense does not: SentiSense covers US stocks and ETFs and serves end-of-day options analytics rather than chains.
yfinance facts were read from the library's README, its GitHub issue tracker and PyPI, and Yahoo's terms from Yahoo's own pages, on October 17, 2026. SentiSense limits are as published on its docs that day. Prices on SentiSense are delayed 15 minutes and options data is end of day. This article is educational and is not investment advice.