I am using Yahoo Finance’s API at https://query1.finance.yahoo.com/v8/finance/chart/Ticker with php’s file_get_contents and getting "failed to open stream: HTTP request failed! HTTP/1.0 429 Too Many Requests" but when I use curl to the same URL from the command line of the server I get an actual response! I verified that both of the requests are coming from the same IP.
I am not sending many requests – I sent maybe 40 get requests last night and then my first request today failed. My question is – has anyone seen the same type of problem? I read that the limit was 100 requests per hour – which I was well under!
Any advice would be appreciated.
2
Answers
Since you noticed that curl works, try adding a user agent to your request to mimic curl.
I was running into the same issue in Rust and adding a similar user-agent to the request fixed it. You can also try a browser user agent such as
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36
.I have the same issue today with yahoo, but I get similar when I’m just browsing GitHub.
On GitHub:
On Yahoo: