Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error fetching stock price for AAPL: Error: Failed to get crumb, status 403, statusText: Forbidden #784

Open
minsixhao opened this issue Jun 21, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@minsixhao
Copy link

Bug Report

I was very surprised to discover this project and then started using it. After downloading the package, I began running the test code and found errors, which made me very sad.

How do I solve this problem?

Vision

"yahoo-finance2": "^2.11.3"

Code

import yahooFinance from 'yahoo-finance2';

async function getStockPrice(symbol) {
  try {
    console.log(symbol);
    const quote = await yahooFinance.quoteSummary(symbol);
    console.log(quote);
  } catch (error) {
    console.error(`Error fetching stock price for ${symbol}:`, error);
  }
}
getStockPrice('AAPL');

Console Output:


AAPL
Please consider completing the survey at https://bit.ly/yahoo-finance-api-feedback if you haven't already; for more info see https://github.com/gadicc/node-yahoo-finance2/issues/764#issuecomment-2056623851.
Fetching crumb and cookies from https://finance.yahoo.com/quote/AAPL...
Success. Cookie expires on Sun Jun 22 2025 01:34:13 GMT+0800 (中国标准时间)
fetch https://query1.finance.yahoo.com/v1/test/getcrumb
Error fetching stock price for AAPL: Error: Failed to get crumb, status 403, statusText: Forbidden
    at _getCrumb (###/node_modules/yahoo-finance2/dist/esm/src/lib/getCrumb.js:204:15)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Object.yahooFinanceFetch [as _fetch] (file:###/yahoo-finance2/dist/esm/src/lib/yahooFinanceFetch.js:53:23)
    at async Object.moduleExec [as _moduleExec] (file:###/node_modules/yahoo-finance2/dist/esm/src/lib/moduleExec.js:52:18)
    at async getStockPrice (file:###/yahoo/api.js:6:19)
@minsixhao minsixhao added the bug Something isn't working label Jun 21, 2024
@glaucoheitor
Copy link
Contributor

Check to see if you're able to manually go to https://query1.finance.yahoo.com/v1/test/getcrumb on the browser.

@hidaviddong
Copy link

same

@StrongerLph
Copy link

I had the same problem。I'm using a vpn and I can access this address https://query1.finance.yahoo.com/v1/test/getcrumb

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants