Skip to content

New rate-limiting #2128

Description

@capoveur

Describe bug

I have used yfinance for the last year to pull 7 day, 1 minute granularity data on 7000 equity stocks at the end of each market day. This has always worked fine, and the rate limits have never been a problem. On Wednesday 13/11/24, everything changed [when the fire nation attacked]. Now, it pulls data for about 950 tickers, then gives me 429 (rate limit error) responses after that. Has Yahoo started to crack down on free API users? On the API documentation it says there are no more than 360 requests per hour, which 950 goes over anyway. Why were there no problems before? What has suddenly changed?

Simple code that reproduces your problem

import yfinance as yf

tick_string = "A AAPL TSLA ALAB"     # example. This actually has 7000 tickers in it

data = yf.download(tick_string, period='7d', interval='1m', threads=True, keepna=True, prepost=False)

Debug log

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 _make_request()
DEBUG Exiting get()
DEBUG Entering history()
DEBUG Entering history()
DEBUG XNET: Yahoo GET parameters: {'range': '7d', 'interval': '1m', 'includePrePost': False, 'events': 'div,splits,capitalGains'}
DEBUG Entering get()
DEBUG Entering _make_request()
DEBUG url=https://query2.finance.yahoo.com/v8/finance/chart/XNET
DEBUG params={'range': '7d', 'interval': '1m', '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

Bad data proof

No response

yfinance version

0.2.49

Python version

No response

Operating system

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions