Trends · JavaScript
const params = new URLSearchParams({
"engine": "google_trends",
"geo": "US",
"q": "heat pump, air conditioner",
"time": "today 12-m",
});
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_trends",
"geo": "US",
"q": "heat pump, air conditioner",
"time": "today 12-m",
});
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());
Interest by region · JavaScript
const params = new URLSearchParams({
"engine": "google_trends",
"data_type": "GEO_MAP",
"geo": "US",
"q": "heat pump, air conditioner",
"time": "today 12-m",
});
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_trends",
"data_type": "GEO_MAP",
"geo": "US",
"q": "heat pump, air conditioner",
"time": "today 12-m",
});
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());
Related queries · JavaScript
const params = new URLSearchParams({
"engine": "google_trends",
"data_type": "RELATED_QUERIES",
"geo": "US",
"q": "heat pump",
"time": "today 12-m",
});
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_trends",
"data_type": "RELATED_QUERIES",
"geo": "US",
"q": "heat pump",
"time": "today 12-m",
});
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.