sstrickx / yahoofinance-api

Java Client API for Yahoo Finance
MIT License
492 stars 217 forks source link

Error Code 401 #226

Open ahmzd21 opened 1 month ago

ahmzd21 commented 1 month ago

Output: SLF4J(I): Connected with provider of type [org.slf4j.simple.SimpleServiceProvider] [main] INFO yahoofinance.quotes.query1v7.QuotesRequest - Sending request: https://query1.finance.yahoo.com/v7/finance/quote?symbols=INTC Error retrieving stock data: Server returned HTTP response code: 401 for URL: https://query1.finance.yahoo.com/v7/finance/quote?symbols=INTC

I was just running a simple code given below:

import yahoofinance.Stock; import yahoofinance.YahooFinance; import java.io.IOException; import java.math.BigDecimal;

public class StockMarket { public static void main(String[] args) { try { Stock stock = YahooFinance.get("INTC");

          BigDecimal price = stock.getQuote().getPrice();
          BigDecimal change = stock.getQuote().getChangeInPercent();
          BigDecimal peg = stock.getStats().getPeg();
          BigDecimal dividend = stock.getDividend().getAnnualYieldPercent();

          stock.print();
      } catch (IOException e) {
          System.out.println("Error retrieving stock data: " + e.getMessage());
      }
  }

}

ahmzd21 commented 1 month ago

Anyone knows how to fix this?