yfinance: Edge: Too Many Requests, response code = 429
Mod edit: only reply if yf.__version__ prints latest version. Ignore PIP Conda etc
Describe bug
I am using both Tickers.download and ticker.history. No data is returned via either method. in particular it seems to be getting a JSONDecodeError. I was having issues on evening of 19/2/2025 (GMT) and there was a notice saying the service was down. The morning after on the 19th i get the error described below in the logs. I have updated to latest version 0.2.54.
My device is a 2019 MBP, running Intel Core i5 and on OS 13.5.
Simple code that reproduces your problem
print("test 1 - download")
symbols = ["BRNL.L", "MSFT", "AMZN", "GOOGL"]
tickers = Tickers(symbols)
data = tickers.download()
print(data)
brnl= tickers.filter(data, "BRNL.L")
print(brnl)
print("test 2 - history")
dat = yf.Ticker("MSFT")
hist = dat.history(period="1d")
print(hist)
Debug log
test 1 - download
DEBUG Entering download()
DEBUG Disabling multithreading because DEBUG logging enabled
DEBUG Entering history()
DEBUG Entering history()
DEBUG AMZN: Yahoo GET parameters: {‘period1’: ‘1926-03-15 19:00:00-05:00’, ‘period2’: ‘2025-02-19 02:19:10-05:00’, ‘interval’: ‘1d’, ‘includePrePost’: False, ‘events’: ‘div,splits,capitalGains’}
DEBUG Entering get()
DEBUG url=https://query2.finance.yahoo.com/v8/finance/chart/AMZN
DEBUG params={‘period1’: -1382140800, ‘period2’: 1739949550, ‘interval’: ‘1d’, ‘includePrePost’: False, ‘events’: ‘div,splits,capitalGains’}
DEBUG Entering _get_cookie_and_crumb()
DEBUG cookie_mode = ‘basic’
DEBUG Entering _get_cookie_and_crumb_basic()
DEBUG loaded persistent cookie
DEBUG reusing cookie
DEBUG crumb = ‘Edge: Too Many Requests’
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 loaded persistent cookie
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 loaded persistent cookie
DEBUG reusing cookie
DEBUG crumb = ‘Edge: Too Many Requests’
DEBUG Exiting _get_cookie_and_crumb_basic()
DEBUG Exiting _get_cookie_and_crumb()
DEBUG response code=429
DEBUG Exiting get()
DEBUG Entering history()
DEBUG Entering history()
DEBUG MSFT: Yahoo GET parameters: {‘period1’: ‘1926-03-15 19:00:00-05:00’, ‘period2’: ‘2025-02-19 02:19:11-05:00’, ‘interval’: ‘1d’, ‘includePrePost’: False, ‘events’: ‘div,splits,capitalGains’}
DEBUG Entering get()
DEBUG url=https://query2.finance.yahoo.com/v8/finance/chart/MSFT
DEBUG params={‘period1’: -1382140800, ‘period2’: 1739949551, ‘interval’: ‘1d’, ‘includePrePost’: False, ‘events’: ‘div,splits,capitalGains’}
DEBUG Entering _get_cookie_and_crumb()
DEBUG cookie_mode = ‘basic’
DEBUG Entering _get_cookie_and_crumb_basic()
DEBUG reusing cookie
DEBUG reusing crumb
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 loaded persistent cookie
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 loaded persistent cookie
DEBUG reusing cookie
DEBUG crumb = ‘Edge: Too Many Requests’
DEBUG Exiting _get_cookie_and_crumb_basic()
DEBUG Exiting _get_cookie_and_crumb()
DEBUG response code=429
DEBUG Exiting get()
DEBUG Entering history()
DEBUG Entering history()
DEBUG GOOGL: Yahoo GET parameters: {‘period1’: ‘1926-03-15 19:00:00-05:00’, ‘period2’: ‘2025-02-19 02:19:13-05:00’, ‘interval’: ‘1d’, ‘includePrePost’: False, ‘events’: ‘div,splits,capitalGains’}
DEBUG Entering get()
DEBUG url=https://query2.finance.yahoo.com/v8/finance/chart/GOOGL
DEBUG params={‘period1’: -1382140800, ‘period2’: 1739949553, ‘interval’: ‘1d’, ‘includePrePost’: False, ‘events’: ‘div,splits,capitalGains’}
DEBUG Entering _get_cookie_and_crumb()
DEBUG cookie_mode = ‘basic’
DEBUG Entering _get_cookie_and_crumb_basic()
DEBUG reusing cookie
DEBUG reusing crumb
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 loaded persistent cookie
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 loaded persistent cookie
DEBUG reusing cookie
DEBUG crumb = ‘Edge: Too Many Requests’
DEBUG Exiting _get_cookie_and_crumb_basic()
DEBUG Exiting _get_cookie_and_crumb()
DEBUG response code=429
DEBUG Exiting get()
DEBUG Entering history()
DEBUG Entering history()
DEBUG BRNL.L: Yahoo GET parameters: {‘period1’: ‘1926-03-16 00:00:00+00:00’, ‘period2’: ‘2025-02-19 07:19:14+00:00’, ‘interval’: ‘1d’, ‘includePrePost’: False, ‘events’: ‘div,splits,capitalGains’}
DEBUG Entering get()
DEBUG url=https://query2.finance.yahoo.com/v8/finance/chart/BRNL.L
DEBUG params={‘period1’: -1382140800, ‘period2’: 1739949554, ‘interval’: ‘1d’, ‘includePrePost’: False, ‘events’: ‘div,splits,capitalGains’}
DEBUG Entering _get_cookie_and_crumb()
DEBUG cookie_mode = ‘basic’
DEBUG Entering _get_cookie_and_crumb_basic()
DEBUG reusing cookie
DEBUG reusing crumb
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 loaded persistent cookie
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 loaded persistent cookie
DEBUG reusing cookie
DEBUG crumb = ‘Edge: Too Many Requests’
DEBUG Exiting _get_cookie_and_crumb_basic()
DEBUG Exiting _get_cookie_and_crumb()
DEBUG response code=429
DEBUG Exiting get()
ERROR
4 Failed downloads:
ERROR [‘AMZN’, ‘MSFT’, ‘GOOGL’, ‘BRNL.L’]: JSONDecodeError(‘Expecting value: line 1 column 1 (char 0)’)
DEBUG [‘AMZN’, ‘MSFT’, ‘GOOGL’, ‘BRNL.L’]: Traceback (most recent call last):
File “/Users/williambennett/anaconda3/lib/python3.11/site-packages/requests/models.py”, line 971, in json
return complexjson.loads(self.text, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/Users/williambennett/anaconda3/lib/python3.11/json/init.py”, line 346, in loads
return _default_decoder.decode(s)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/Users/williambennett/anaconda3/lib/python3.11/json/decoder.py”, line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/Users/williambennett/anaconda3/lib/python3.11/json/decoder.py”, line 355, in raw_decode
raise JSONDecodeError(“Expecting value”, s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/williambennett/anaconda3/lib/python3.11/site-packages/yfinance/multi.py", line 268, in _download_one
data = Ticker(ticker).history(
^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/williambennett/anaconda3/lib/python3.11/site-packages/yfinance/utils.py", line 104, in wrapper
result = func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/Users/williambennett/anaconda3/lib/python3.11/site-packages/yfinance/base.py", line 78, in history
return self._lazy_load_price_history().history(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/williambennett/anaconda3/lib/python3.11/site-packages/yfinance/utils.py", line 104, in wrapper
result = func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/Users/williambennett/anaconda3/lib/python3.11/site-packages/yfinance/scrapers/history.py", line 151, in history
data = data.json()
^^^^^^^^^^^
File "/Users/williambennett/anaconda3/lib/python3.11/site-packages/requests/models.py", line 975, in json
raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
DEBUG Exiting download() Series([], Name: Adj Close, dtype: float64) Empty DataFrame Columns: [Close] Index: [] test 2 - history DEBUG Entering history() DEBUG Entering history() DEBUG MSFT: Yahoo GET parameters: {‘range’: ‘1d’, ‘interval’: ‘1d’, ‘includePrePost’: False, ‘events’: ‘div,splits,capitalGains’} DEBUG Entering get() DEBUG url=https://query2.finance.yahoo.com/v8/finance/chart/MSFT DEBUG params={‘range’: ‘1d’, ‘interval’: ‘1d’, ‘includePrePost’: False, ‘events’: ‘div,splits,capitalGains’} DEBUG Entering _get_cookie_and_crumb() DEBUG cookie_mode = ‘basic’ DEBUG Entering _get_cookie_and_crumb_basic() DEBUG reusing cookie DEBUG reusing crumb 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 loaded persistent cookie 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 loaded persistent cookie DEBUG reusing cookie DEBUG crumb = ‘Edge: Too Many Requests’ DEBUG Exiting _get_cookie_and_crumb_basic() DEBUG Exiting _get_cookie_and_crumb() DEBUG response code=429 DEBUG Exiting get() ERROR $MSFT: possibly delisted; No price data found (period=1d) DEBUG Exiting history() DEBUG Exiting history() Empty DataFrame Columns: [Open, High, Low, Close, Adj Close, Volume] Index: []
Bad data proof
yfinance version
0.2.54
Python version
3.11.5
Operating system
OS 13.5
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 5
- Comments: 26 (2 by maintainers)
I was facing this bug with Google Colab. After upgrade the yf version to 0.2.54, the bug stoped (untill now). PS: even after the upgrade, the colab enviroment stilled tied in 0.2.52 version… only after a couple of minutes, the upgrade really apear in the “print(yf.version)” command.
Copying my message from a Issue #2291 thread to here Hello all, I’ve found that the date that breaks the download function for a ticker such as ^PUT is 2021-10-02, is there any significance to this date? Also notice that it doesn’t matter if the start or end date is a market trade date or not, it seems to be significant with 2021-10-02 for some reason.
Can also confirm that I am running on the version 0.2.54 of yfinance: