Google Search · JavaScript
const params = new URLSearchParams({
"engine": "google",
"q": "best brazilian footballer",
});
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": "google",
"q": "best brazilian footballer",
});
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());
Fetch AI Overview · JavaScript
const params = new URLSearchParams({
"engine": "google_ai_overview",
"page_token": "PASTE_FROM_PREVIOUS_RESPONSE",
});
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": "google_ai_overview",
"page_token": "PASTE_FROM_PREVIOUS_RESPONSE",
});
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());
Replace PASTE_FROM_PREVIOUS_RESPONSE with ai_overview.page_token from the response before it. It is valid for a few minutes.
The key is read from SEARCHAPI_API_KEY and sent as a Bearer token.