I read several forum posts and watched a couple tutorial videos but I still don’t understand how to properly format a Web API call that requires a key.
Here’s the format I started with:
I’ve tried replacing ?key with &key, I’ve tried adding headers with “key” or “api_key” or “Authorization” but any of these attempts results in a message that says a key is required.
What is the correct format for using a key? Does it matter what type of key? I obviously don’t know very much about Web APIs despite my reading!
Here’s an example of an API I was trying to access that required a key:
var unirest = require("unirest");
var req = unirest("GET", "https://omgvamp-hearthstone-v1.p.rapidapi.com/info");
req.headers({
"x-rapidapi-host": "omgvamp-hearthstone-v1.p.rapidapi.com",
"x-rapidapi-key": "871a5d996emsh391e0aee1fb8b16p17d7e9jsn4b44613f5c20"
});
as I mentioned before, you have to check the documentation of the API provider that you want to work with because there is no way of authentication / access that will work with ANY API. From what I could find with a few minutes of research you have to add these two headers at least:
Of course you will also have to replace xxxx with your API key and set the proper API URL (I guess the “https://apiurl?..” in your blocks was just an example? because it can’t work like that).