scheb / yahoo-finance-api

PHP client for Yahoo Finance API 📈
MIT License
280 stars 56 forks source link

429 Too Many Requests #42

Closed yasinaslan16 closed 1 year ago

yasinaslan16 commented 1 year ago

We get the same error from two different servers. Error 429 Too Many Requests returns when pulling data..

No problem on link: https://query1.finance.yahoo.com/v1/test/getcrumb

Fatal error: Uncaught GuzzleHttp\Exception\ClientException: Client error: GET https://query2.finance.yahoo.com/v1/test/getcrumb resulted in a 429 Too Many Requests response: Too Many Requests in /home/mytrnuwm/public_html/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php:113 Stack trace: #0 /home/mytrnuwm/public_html/vendor/guzzlehttp/guzzle/src/Middleware.php(65): GuzzleHttp\Exception\RequestException::create(Object(GuzzleHttp\Psr7\Request), Object(GuzzleHttp\Psr7\Response)) #1 /home/mytrnuwm/public_html/vendor/guzzlehttp/promises/src/Promise.php(204): GuzzleHttp\Middleware::GuzzleHttp{closure}(Object(GuzzleHttp\Psr7\Response)) #2 /home/mytrnuwm/public_html/vendor/guzzlehttp/promises/src/Promise.php(153): GuzzleHttp\Promise\Promise::callHandler(1, Object(GuzzleHttp\Psr7\Response), NULL) #3 /home/mytrnuwm/public_html/vendor/guzzlehttp/promises/src/TaskQueue.php(48): GuzzleHttp\Promise\Promise::GuzzleHttp\Promise{closure}() #4 /home/mytrnuwm/public_html/vendor/guzzlehttp/promises/src/Promise.php(248): Gu in /home/mytrnuwm/public_html/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php on line 113

brightq commented 1 year ago

We have exactly same issue.

scheb commented 1 year ago

Seem to be rate-limiting or even blocking scripted user-agents (such as curl or the Guzzle client) more restrictively now. Not sure why the tests on Github are working fine, maybe it's a special treatment for certain networks 🤷. Randomizing the user agent seems to do the job for now -> Release 4.8.0