YouTube · JavaScript
const params = new URLSearchParams({
"engine": "youtube",
"gl": "US",
"hl": "en",
"q": "pulling an espresso shot",
});
const response = await fetch(`https://www.searchapi.io/api/v1/search?${params}`, {
headers: { Authorization: `Bearer ${process.env.SEARCHAPI_API_KEY}` },
});
console.log(await response.json());
const params = new URLSearchParams({
"engine": "youtube",
"gl": "US",
"hl": "en",
"q": "pulling an espresso shot",
});
const response = await fetch(`https://www.searchapi.io/api/v1/search?${params}`, {
headers: { Authorization: `Bearer ${process.env.SEARCHAPI_API_KEY}` },
});
console.log(await response.json());
The key is read from SEARCHAPI_API_KEY and sent as a Bearer token.