pilwon / node-yahoo-finance

Yahoo Finance historical quotes and snapshot data downloader written in Node.js
495 stars 123 forks source link

Non-browsers blocked #67

Closed thilomaurer closed 4 years ago

thilomaurer commented 4 years ago

Getting exception for quote with price

yahooFinance.quote({
    symbol: "X",
    modules: [ 'price' ]
})

https://query2.finance.yahoo.com/v10/finance/quoteSummary/X?modules=price

33 X stockQuote Error Failed to download data (404 - {"description":"NotFoundException: HTTP 404 Not Found","detail":{"content":["NotFoundException: HTTP 404 Not Found"]},"uri":"http://yahoo.com","lang":"en-US"}) Error: Failed to download data (404 - {"description":"NotFoundException: HTTP 404 Not Found","detail":{"content":["NotFoundException: HTTP 404 Not Found"]},"uri":"http://yahoo.com","lang":"en-US"})

same via curl:

$ curl 'https://query2.finance.yahoo.com/v10/finance/quoteSummary/X?modules=price'
{"description":"NotFoundException: HTTP 404 Not Found","detail":{"content":["NotFoundException: HTTP 404 Not Found"]},"uri":"http://yahoo.com","lang":"en-US"}

may be solved by adding User-Agent Header

$ curl 'https://query2.finance.yahoo.com/v10/finance/quoteSummary/X?modules=price' -H 'user-agent: Mozilla/5.0'
{"quoteSummary":{"result":[{"price":{"maxAge":1,"preMarketChangePercent .......

Seems that yahoo blocks non-browsers....

thilomaurer commented 4 years ago

Well, no seems that did only work for a short amount of time. Now it does not even work in the browser itself.

thilomaurer commented 4 years ago

Yes, even yahoo's own website throws errors. Maybe this can be closed tomorrow.

gadicc commented 4 years ago

Thanks for following up, @thilomaurer! Yes, it seems many of the errors reported here relate back to transient errors on Yahoo's CDN which resolve themselves in short order.