Google Trends API
Stay on top of the market by scraping Google Trends in real time.
To enable this engine, set the engine=google_trends parameter.
Google trends is a tool that returns data about the popularity of search queries. Being able to scrape Google Trends can give you an advantage over your competition or can be used in various marketing campaigns.
Scrape Google Trends Page
We will use following URL as an example for this request:
https://serpapi.webscrapingapi.com/v1?engine=google_trends&api_key=<YOUR_API_KEY>&geo=US&q=american%20football&date=2021-01-01%202022-01-01
cURL
NodeJS
Python
PHP
Go
Java
.NET
Ruby
curl --request GET --url "https://serpapi.webscrapingapi.com/v1?engine=google_trends&api_key=YOUR_API_KEY&geo=US&q=american%20football&date=2021-01-01%202022-01-01"
const http = require("https");
const options = {
"method": "GET",
"hostname": "serpapi.webscrapingapi.com",
"port": null,
"path": "/v1?engine=google_trends&api_key=YOUR_API_KEY&geo=US&q=american%20football&date=2021-01-01%202022-01-01",
"headers": {}
};
const req = http.request(options, function (res) {
const chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
const body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.end();
import http.client
conn = http.client.HTTPSConnection("serpapi.webscrapingapi.com")
conn.request("GET", "/v1?engine=google_trends&api_key=YOUR_API_KEY&geo=US&q=american%20football&date=2021-01-01%202022-01-01")
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://serpapi.webscrapingapi.com/v1?engine=google_trends&api_key=YOUR_API_KEY&geo=US&q=american%20football&date=2021-01-01%202022-01-01",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
package main
import (
"fmt"
"net/http"
"io/ioutil"
)
func main() {
url := "https://serpapi.webscrapingapi.com/v1?engine=google_trends&api_key=YOUR_API_KEY&geo=US&q=american%20football&date=2021-01-01%202022-01-01"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
HttpResponse<String> response = Unirest.get("https://serpapi.webscrapingapi.com/v1?engine=google_trends&api_key=YOUR_API_KEY&geo=US&q=american%20football&date=2021-01-01%202022-01-01")
.asString();
var client = new RestClient("https://serpapi.webscrapingapi.com/v1?engine=google_trends&api_key=YOUR_API_KEY&geo=US&q=american%20football&date=2021-01-01%202022-01-01");
var request = new RestRequest(Method.GET);
IRestResponse response = client.Execute(request);
require 'uri'
require 'net/http'
require 'openssl'
url = URI("https://serpapi.webscrapingapi.com/v1?engine=google_trends&api_key=YOUR_API_KEY&geo=US&q=american%20football&date=2021-01-01%202022-01-01")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body

#1: Query Parameter

Parameter
Type
Description
q
string
The keyword that you are searching for (the query).
product_id
string
The product ID for your query.

#2: Request Customisation Parameters

Parameter
Type
Description
store
string
The store on which you would like to perform the query. Can be either apps or books.
type
string
The type of your query. Can be either search or product.

#3: Localisation Parameters

Parameter
Type
Description
hl
string
The language you want to use for your google search. List of supported languages
gl
string
The country you want to use for your google search. List of supported countries
Response Example
Copy link
Outline
Google Trends API Integration Example
Ready to Use Google Trends API Scraping Scripts
Google Trends API Parameters