Axios request to Yahoo Finance API through RapidAPI fails with 500 error

I’m having trouble with the Yahoo Finance API on RapidAPI. My axios request keeps failing with a 500 error. Here’s what I’m trying:

const apiKey = 'my_secret_key'
const apiHost = 'finance-data-provider.p.rapidapi.com'

const config = {
  headers: {
    'x-rapidapi-key': apiKey,
    'x-rapidapi-host': apiHost
  }
}

axios.get(`https://${apiHost}/stock/AAPL`, config)
  .then(res => console.log(res.data))
  .catch(err => console.error(err.message))

I’m pretty sure my API key is correct. Any ideas why this might be happening? I’ve double-checked the endpoint and headers. Could it be a problem on RapidAPI’s end? Or am I missing something obvious in my code? Thanks for any help!

hey, i had similar probs with yahoo finance api. try using ‘yh-finance.p.rapidapi.com’ instead of ur current endpoint. also, double-check ur API key and make sure u didn’t hit any usage limits. if it still doesn’t work, maybe contact rapidapi support? they might know whats up.

I’ve worked extensively with the Yahoo Finance API through RapidAPI, and I can offer some insights. First, ensure you’re using the correct endpoint: ‘yh-finance.p.rapidapi.com’. The one in your code seems incorrect. Additionally, the path for stock data should be more specific. Try this:

axios.get(https://yh-finance.p.rapidapi.com/stock/v2/get-summary?symbol=AAPL, config)

If you’re still getting a 500 error, it could be a temporary issue with the API. In my experience, waiting a bit and trying again often resolves it. Also, check your RapidAPI dashboard for any account issues or usage limits. If the problem persists, don’t hesitate to contact RapidAPI support - they’re usually quite helpful with these matters.

I’ve encountered similar issues with the Yahoo Finance API through RapidAPI before. In my experience, the problem often lies with the API endpoint itself. The one you’re using (finance-data-provider.p.rapidapi.com) doesn’t seem familiar to me.

Have you tried using the official Yahoo Finance API endpoint? It should be yh-finance.p.rapidapi.com. Also, make sure you’re using the correct path for stock data. Try this:

const apiHost = 'yh-finance.p.rapidapi.com'
axios.get(`https://${apiHost}/stock/v2/get-summary?symbol=AAPL`, config)

If that doesn’t work, it might be worth checking your RapidAPI dashboard to ensure your subscription is active and you haven’t hit any usage limits. Sometimes, a 500 error can indicate issues on their end, so if the problem persists, reaching out to RapidAPI support might be your best bet.

Lastly, don’t forget to handle the error more specifically in your catch block. You might get more informative error messages that way.