sstrickx / yahoofinance-api

Java Client API for Yahoo Finance
MIT License
498 stars 219 forks source link

v3.17 is working? #197

Open emidesy opened 1 year ago

emidesy commented 1 year ago

Hi! i use the last version, but a few days its not working. I proof single stock in a clean code and nothing.

Thanks!

StefanLober commented 1 year ago

Hello, what environment did you use to get the stock data? I have used this API v3.17 in an Android app and noticed that it stopped working a few days ago. There is always this error:

java.io.FileNotFoundException: https://query1.finance.yahoo.com/v7/finance/quote?symbols=AMD.DE
        at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:251)
        at com.android.okhttp.internal.huc.DelegatingHttpsURLConnection.getInputStream(DelegatingHttpsURLConnection.java:210)
        at com.android.okhttp.internal.huc.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:26)
        at yahoofinance.quotes.query1v7.QuotesRequest.getResult(QuotesRequest.java:74)
        at yahoofinance.YahooFinance.getQuotes(YahooFinance.java:381)
        at yahoofinance.YahooFinance.get(YahooFinance.java:98)
        at yahoofinance.YahooFinance.get(YahooFinance.java:82)

However, using the URL in a browser works fine and testing the API v3.17 getting the same symbol in a simple command line Java project on Windows also works.

RamitPahwa commented 1 year ago

Any WorkAround for this in Android ? Need this for a prototype @StefanLober @sstrickx

emidesy commented 1 year ago

Hi! Exactly the same error for me, with android app, @StefanLober

El sáb, 12 de nov. de 2022 06:09, Stefan Lober @.***> escribió:

Hello, what environment did you use to get the stock data? I have use this API v3.17 in an Android app and noticed that it sopped working a few days ago. There is always this error: java.io.FileNotFoundException: https://query1.finance.yahoo.com/v7/finance/quote?symbols=AMD.DE

However, using the URL in a browser works fine and testing the API v3.17 getting the same symbol in a simple command line Java project on Windows also works.

— Reply to this email directly, view it on GitHub https://github.com/sstrickx/yahoofinance-api/issues/197#issuecomment-1312419838, or unsubscribe https://github.com/notifications/unsubscribe-auth/ATP53X4AC4DRGXV2PRNK4BLWH5NFNANCNFSM6AAAAAARTGPBTU . You are receiving this because you authored the thread.Message ID: @.***>

emidesy commented 1 year ago

There is a fork of this project, https://github.com/sfuhrm/yahoofinance-api But it doesnt work to me,

StefanLober commented 1 year ago

Setting a User-Agent with setRequestProperty fixes the problem on Android. It seems that the Android implementation of HttpURLConnection does not set this property, while the default Java implementation does set it. Propably, Yahoo has made a change in the recent past, so that requests without User-Agent no longer work.

emidesy commented 1 year ago

Thanks!! its work,

I add this line: System.setProperty("http.agent", "");