yfinance: [0.2.59] YFRateLimitError: Too Many Requests. Rate limited.
Describe bug
YFRateLimitError: Too Many Requests. Rate limited. Try after a while.
This bug is still here, 0.2.59/0.2.58/0.2.57.
Simple code that reproduces your problem
import yfinance as yf
stock = yf.Ticker(‘SPY’) stock.info
Debug log from yf.enable_debug_mode()
DEBUG get_raw_json(): https://query2.finance.yahoo.com/v10/finance/quoteSummary/SPY DEBUG Entering get() DEBUG Entering _make_request() DEBUG url=https://query2.finance.yahoo.com/v10/finance/quoteSummary/SPY DEBUG params={‘modules’: ‘financialData,quoteType,defaultKeyStatistics,assetProfile,summaryDetail’, ‘corsDomain’: ‘finance.yahoo.com’, ‘formatted’: ‘false’, ‘symbol’: ‘SPY’} DEBUG Entering _get_cookie_and_crumb() DEBUG cookie_mode = ‘basic’ DEBUG Entering _get_cookie_and_crumb_basic() DEBUG crumb = '<!DOCTYPE html> <html lang="zh">
</body></html>
'
DEBUG Exiting _get_cookie_and_crumb_basic() DEBUG Exiting _get_cookie_and_crumb() DEBUG response code=429 DEBUG toggling cookie strategy basic -> csrf DEBUG Entering _get_cookie_and_crumb() DEBUG cookie_mode = ‘csrf’ DEBUG Entering _get_crumb_csrf() DEBUG Failed to find “csrfToken” in response DEBUG Exiting _get_crumb_csrf() DEBUG toggling cookie strategy csrf -> basic DEBUG Entering _get_cookie_and_crumb_basic() DEBUG crumb = '<!DOCTYPE html> <html lang="zh">
</body></html>
'
DEBUG Exiting _get_cookie_and_crumb_basic() DEBUG Exiting _get_cookie_and_crumb() DEBUG response code=429
Bad data proof
yfinance version
0.2.59
Python version
3.10.16/3.13.3
Operating system
OSX
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 4
- Comments: 38
Commits related to this issue
- Fix for rate limit during getting crumb. Address #2441, #2480 — committed to vsukhoml/yfinance by vsukhoml 2 years ago
- Fix for rate limit during getting crumb. Address #2441, #2480 Don't check for cached crumb to be wrong since this shall not happen with a new flow. — committed to vsukhoml/yfinance by vsukhoml 2 years ago
- Fix for rate limit during getting crumb. Address #2441, #2480 Don't check for cached crumb to be wrong since this shall not happen with a new flow. — committed to vsukhoml/yfinance by vsukhoml 2 years ago
- Fix for rate limit during getting crumb. Address #2441, #2480 Don't check for cached crumb to be wrong since this shall not happen with a new flow. — committed to ranaroussi/yfinance by vsukhoml 2 years ago
Does #2483 help?
MAC m1 macos 15.2 Python 3.13 yfinance 0.2.61
yfinance.exceptions.YFRateLimitError: Too Many Requests. Rate limited. Try after a while.
I’ve upgrade to latest 0.2.61, still the same problem.
I’ve upgraded and have the latest version, but still : YFRateLimitError('Too Many Requests. Rate limited. Try after a while.) To be clear, I’ve developped a tool that leverages multiple fallback processes in case this happens, using user-agent randomization, session cooling, batch or individual downloads, but none of these solutions seem to escape this issue anymore.
Have you tried not using a vpn or proxy?
No, It does not work. I’ve tried it.
but it failed again, and the error is still here.
Yes, I’ve had this issue for a few days and #2483 fixes it for me, thanks for your work debugging @ValueRaider!
I’ve checked the issues and it appears that yfinance versions below 0.2.58 are affected by this. Perhaps you need to update it first.