I keep getting an error that says I’m not subscribed to the API even though I have the correct API key setup. Here’s my configuration:
import fetch from 'node-fetch';
const API_BASE = 'https://video-search-v2.p.rapidapi.com';
const requestConfig = {
method: 'GET',
headers: {
'X-RapidAPI-Key': process.env.REACT_APP_API_TOKEN,
'X-RapidAPI-Host': 'video-search-v2.p.rapidapi.com'
}
};
export const getAPIData = async(endpoint) => {
const response = await fetch(`${API_BASE}/${endpoint}`, requestConfig);
const result = await response.json();
return result;
}
And here’s how I call it:
import { getAPIData } from '../helpers/apiService';
const Dashboard = () => {
const [activeFilter, setActiveFilter] = useState('Popular');
const [contentList, setContentList] = useState([]);
useEffect(() => {
getAPIData(`videos?type=search&query=${activeFilter}&limit=25`)
.then((response) => setContentList(response.results))
.catch(err => {
console.error('API Error:', err.message);
});
}, [activeFilter]);
I put my API key in the environment file but still get the “You are not subscribed to this API” error. What could be causing this issue?
I’ve hit this exact same issue - super frustrating. It’s usually not your code, it’s something wonky with your RapidAPI account. Check your dashboard and make sure you’re actually subscribed to that specific endpoint. Even with free APIs, you sometimes have to explicitly hit the subscribe button. Also verify your subscription hasn’t expired. One thing that got me was using the wrong API key - if you’ve got multiple RapidAPI accounts, double-check you’re using the right key. Your code looks solid, so it’s probably just an account setup thing on RapidAPI’s end.
Same thing happened to me last month - turned out to be billing. RapidAPI has this weird payment verification thing even for free tiers, and they don’t explain it well. Check your billing section in the dashboard - you might need to add a payment method even for free plans. Also, rate limiting can look like subscription errors. Try one manual test request through their interface first to see if you get different error messages. If that works but your code doesn’t, it’s definitely an auth issue with how you’re passing the key.
make sure your env vars are loaded right. try console.logging(process.env.REACT_APP_API_TOKEN) to check if it’s undefined. oh, and restart your dev server after any changes to the env file, that can help!