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.
Google Trends API Integration Example
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
Ready to Use Google Trends API Scraping Scripts
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
Google Trends API Parameters
#1: Query Parameter
Parameter | Type | Description |
---|---|---|
|
| The keyword that you are searching for (the query). |
#2: Request Customisation Parameters
Parameter | Type | Description |
---|---|---|
|
| The location you want to find the results for. It defaults to |
|
| This parameter is used to get more specific results when using results for all |
|
| You must use the format |
|
| This is the category parameter. You can find the full list of Google Trends categories here. |
Response Example
{
"search_parameters": {
"google_trends_url": "https://trends.google.com/trends/explore?q=american%20football&geo=US&date=2021-01-01%202022-01-01",
"engine": "google_trends",
"google_trends_domain": "google.com",
"device": "desktop",
"q": "american football",
"geo": "US",
"date": "2021-01-01 2022-01-01"
},
"search_information": {
"organic_results_state": "Results for exact spelling",
"query_displayed": "american football"
},
"results": {
"interest_over_time": [
{
"time": "1609632000",
"formattedTime": "Jan 3 – 9, 2021",
"formattedAxisTime": "Jan 3, 2021",
"value": [
47
],
"hasData": [
true
],
"formattedValue": [
"47"
]
},
{
"time": "1610236800",
"formattedTime": "Jan 10 – 16, 2021",
"formattedAxisTime": "Jan 10, 2021",
"value": [
44
],
"hasData": [
true
],
"formattedValue": [
"44"
]
},
{
"time": "1610841600",
"formattedTime": "Jan 17 – 23, 2021",
"formattedAxisTime": "Jan 17, 2021",
"value": [
47
],
"hasData": [
true
],
"formattedValue": [
"47"
]
},
{
"time": "1611446400",
"formattedTime": "Jan 24 – 30, 2021",
"formattedAxisTime": "Jan 24, 2021",
"value": [
48
],
"hasData": [
true
],
"formattedValue": [
"48"
]
},
{
"time": "1612051200",
"formattedTime": "Jan 31 – Feb 6, 2021",
"formattedAxisTime": "Jan 31, 2021",
"value": [
38
],
"hasData": [
true
],
"formattedValue": [
"38"
]
},
{
"time": "1612656000",
"formattedTime": "Feb 7 – 13, 2021",
"formattedAxisTime": "Feb 7, 2021",
"value": [
59
],
"hasData": [
true
],
"formattedValue": [
"59"
]
},
{
"time": "1613260800",
"formattedTime": "Feb 14 – 20, 2021",
"formattedAxisTime": "Feb 14, 2021",
"value": [
31
],
"hasData": [
true
],
"formattedValue": [
"31"
]
},
{
"time": "1613865600",
"formattedTime": "Feb 21 – 27, 2021",
"formattedAxisTime": "Feb 21, 2021",
"value": [
29
],
"hasData": [
true
],
"formattedValue": [
"29"
]
},
{
"time": "1614470400",
"formattedTime": "Feb 28 – Mar 6, 2021",
"formattedAxisTime": "Feb 28, 2021",
"value": [
29
],
"hasData": [
true
],
"formattedValue": [
"29"
]
},
{
"time": "1615075200",
"formattedTime": "Mar 7 – 13, 2021",
"formattedAxisTime": "Mar 7, 2021",
"value": [
29
],
"hasData": [
true
],
"formattedValue": [
"29"
]
},
{
"time": "1615680000",
"formattedTime": "Mar 14 – 20, 2021",
"formattedAxisTime": "Mar 14, 2021",
"value": [
35
],
"hasData": [
true
],
"formattedValue": [
"35"
]
},
{
"time": "1616284800",
"formattedTime": "Mar 21 – 27, 2021",
"formattedAxisTime": "Mar 21, 2021",
"value": [
38
],
"hasData": [
true
],
"formattedValue": [
"38"
]
},
{
"time": "1616889600",
"formattedTime": "Mar 28 – Apr 3, 2021",
"formattedAxisTime": "Mar 28, 2021",
"value": [
31
],
"hasData": [
true
],
"formattedValue": [
"31"
]
},
{
"time": "1617494400",
"formattedTime": "Apr 4 – 10, 2021",
"formattedAxisTime": "Apr 4, 2021",
"value": [
29
],
"hasData": [
true
],
"formattedValue": [
"29"
]
},
{
"time": "1618099200",
"formattedTime": "Apr 11 – 17, 2021",
"formattedAxisTime": "Apr 11, 2021",
"value": [
27
],
"hasData": [
true
],
"formattedValue": [
"27"
]
},
{
"time": "1618704000",
"formattedTime": "Apr 18 – 24, 2021",
"formattedAxisTime": "Apr 18, 2021",
"value": [
34
],
"hasData": [
true
],
"formattedValue": [
"34"
]
},
{
"time": "1619308800",
"formattedTime": "Apr 25 – May 1, 2021",
"formattedAxisTime": "Apr 25, 2021",
"value": [
38
],
"hasData": [
true
],
"formattedValue": [
"38"
]
},
{
"time": "1619913600",
"formattedTime": "May 2 – 8, 2021",
"formattedAxisTime": "May 2, 2021",
"value": [
33
],
"hasData": [
true
],
"formattedValue": [
"33"
]
},
{
"time": "1620518400",
"formattedTime": "May 9 – 15, 2021",
"formattedAxisTime": "May 9, 2021",
"value": [
35
],
"hasData": [
true
],
"formattedValue": [
"35"
]
},
{
"time": "1621123200",
"formattedTime": "May 16 – 22, 2021",
"formattedAxisTime": "May 16, 2021",
"value": [
28
],
"hasData": [
true
],
"formattedValue": [
"28"
]
},
{
"time": "1621728000",
"formattedTime": "May 23 – 29, 2021",
"formattedAxisTime": "May 23, 2021",
"value": [
29
],
"hasData": [
true
],
"formattedValue": [
"29"
]
},
{
"time": "1622332800",
"formattedTime": "May 30 – Jun 5, 2021",
"formattedAxisTime": "May 30, 2021",
"value": [
32
],
"hasData": [
true
],
"formattedValue": [
"32"
]
},
{
"time": "1622937600",
"formattedTime": "Jun 6 – 12, 2021",
"formattedAxisTime": "Jun 6, 2021",
"value": [
29
],
"hasData": [
true
],
"formattedValue": [
"29"
]
},
{
"time": "1623542400",
"formattedTime": "Jun 13 – 19, 2021",
"formattedAxisTime": "Jun 13, 2021",
"value": [
30
],
"hasData": [
true
],
"formattedValue": [
"30"
]
},
{
"time": "1624147200",
"formattedTime": "Jun 20 – 26, 2021",
"formattedAxisTime": "Jun 20, 2021",
"value": [
29
],
"hasData": [
true
],
"formattedValue": [
"29"
]
},
{
"time": "1624752000",
"formattedTime": "Jun 27 – Jul 3, 2021",
"formattedAxisTime": "Jun 27, 2021",
"value": [
29
],
"hasData": [
true
],
"formattedValue": [
"29"
]
},
{
"time": "1625356800",
"formattedTime": "Jul 4 – 10, 2021",
"formattedAxisTime": "Jul 4, 2021",
"value": [
37
],
"hasData": [
true
],
"formattedValue": [
"37"
]
},
{
"time": "1625961600",
"formattedTime": "Jul 11 – 17, 2021",
"formattedAxisTime": "Jul 11, 2021",
"value": [
38
],
"hasData": [
true
],
"formattedValue": [
"38"
]
},
{
"time": "1626566400",
"formattedTime": "Jul 18 – 24, 2021",
"formattedAxisTime": "Jul 18, 2021",
"value": [
41
],
"hasData": [
true
],
"formattedValue": [
"41"
]
},
{
"time": "1627171200",
"formattedTime": "Jul 25 – 31, 2021",
"formattedAxisTime": "Jul 25, 2021",
"value": [
60
],
"hasData": [
true
],
"formattedValue": [
"60"
]
},
{
"time": "1627776000",
"formattedTime": "Aug 1 – 7, 2021",
"formattedAxisTime": "Aug 1, 2021",
"value": [
53
],
"hasData": [
true
],
"formattedValue": [
"53"
]
},
{
"time": "1628380800",
"formattedTime": "Aug 8 – 14, 2021",
"formattedAxisTime": "Aug 8, 2021",
"value": [
55
],
"hasData": [
true
],
"formattedValue": [
"55"
]
},
{
"time": "1628985600",
"formattedTime": "Aug 15 – 21, 2021",
"formattedAxisTime": "Aug 15, 2021",
"value": [
56
],
"hasData": [
true
],
"formattedValue": [
"56"
]
},
{
"time": "1629590400",
"formattedTime": "Aug 22 – 28, 2021",
"formattedAxisTime": "Aug 22, 2021",
"value": [
61
],
"hasData": [
true
],
"formattedValue": [
"61"
]
},
{
"time": "1630195200",
"formattedTime": "Aug 29 – Sep 4, 2021",
"formattedAxisTime": "Aug 29, 2021",
"value": [
84
],
"hasData": [
true
],
"formattedValue": [
"84"
]
},
{
"time": "1630800000",
"formattedTime": "Sep 5 – 11, 2021",
"formattedAxisTime": "Sep 5, 2021",
"value": [
100
],
"hasData": [
true
],
"formattedValue": [
"100"
]
},
{
"time": "1631404800",
"formattedTime": "Sep 12 – 18, 2021",
"formattedAxisTime": "Sep 12, 2021",
"value": [
88
],
"hasData": [
true
],
"formattedValue": [
"88"
]
},
{
"time": "1632009600",
"formattedTime": "Sep 19 – 25, 2021",
"formattedAxisTime": "Sep 19, 2021",
"value": [
83
],
"hasData": [
true
],
"formattedValue": [
"83"
]
},
{
"time": "1632614400",
"formattedTime": "Sep 26 – Oct 2, 2021",
"formattedAxisTime": "Sep 26, 2021",
"value": [
74
],
"hasData": [
true
],
"formattedValue": [
"74"
]
},
{
"time": "1633219200",
"formattedTime": "Oct 3 – 9, 2021",
"formattedAxisTime": "Oct 3, 2021",
"value": [
75
],
"hasData": [
true
],
"formattedValue": [
"75"
]
},
{
"time": "1633824000",
"formattedTime": "Oct 10 – 16, 2021",
"formattedAxisTime": "Oct 10, 2021",
"value": [
76
],
"hasData": [
true
],
"formattedValue": [
"76"
]
},
{
"time": "1634428800",
"formattedTime": "Oct 17 – 23, 2021",
"formattedAxisTime": "Oct 17, 2021",
"value": [
75
],
"hasData": [
true
],
"formattedValue": [
"75"
]
},
{
"time": "1635033600",
"formattedTime": "Oct 24 – 30, 2021",
"formattedAxisTime": "Oct 24, 2021",
"value": [
74
],
"hasData": [
true
],
"formattedValue": [
"74"
]
},
{
"time": "1635638400",
"formattedTime": "Oct 31 – Nov 6, 2021",
"formattedAxisTime": "Oct 31, 2021",
"value": [
70
],
"hasData": [
true
],
"formattedValue": [
"70"
]
},
{
"time": "1636243200",
"formattedTime": "Nov 7 – 13, 2021",
"formattedAxisTime": "Nov 7, 2021",
"value": [
74
],
"hasData": [
true
],
"formattedValue": [
"74"
]
},
{
"time": "1636848000",
"formattedTime": "Nov 14 – 20, 2021",
"formattedAxisTime": "Nov 14, 2021",
"value": [
72
],
"hasData": [
true
],
"formattedValue": [
"72"
]
},
{
"time": "1637452800",
"formattedTime": "Nov 21 – 27, 2021",
"formattedAxisTime": "Nov 21, 2021",
"value": [
88
],
"hasData": [
true
],
"formattedValue": [
"88"
]
},
{
"time": "1638057600",
"formattedTime": "Nov 28 – Dec 4, 2021",
"formattedAxisTime": "Nov 28, 2021",
"value": [
77
],
"hasData": [
true
],
"formattedValue": [
"77"
]
},
{
"time": "1638662400",
"formattedTime": "Dec 5 – 11, 2021",
"formattedAxisTime": "Dec 5, 2021",
"value": [
70
],
"hasData": [
true
],
"formattedValue": [
"70"
]
},
{
"time": "1639267200",
"formattedTime": "Dec 12 – 18, 2021",
"formattedAxisTime": "Dec 12, 2021",
"value": [
66
],
"hasData": [
true
],
"formattedValue": [
"66"
]
},
{
"time": "1639872000",
"formattedTime": "Dec 19 – 25, 2021",
"formattedAxisTime": "Dec 19, 2021",
"value": [
59
],
"hasData": [
true
],
"formattedValue": [
"59"
]
},
{
"time": "1640476800",
"formattedTime": "Dec 26, 2021 – Jan 1, 2022",
"formattedAxisTime": "Dec 26, 2021",
"value": [
83
],
"hasData": [
true
],
"formattedValue": [
"83"
]
}
],
"interest_by_subregion": [
{
"geoCode": "US-IA",
"geoName": "Iowa",
"value": [
100
],
"formattedValue": [
"100"
],
"maxValueIndex": 0,
"hasData": [
true
]
},
{
"geoCode": "US-NE",
"geoName": "Nebraska",
"value": [
99
],
"formattedValue": [
"99"
],
"maxValueIndex": 0,
"hasData": [
true
]
},
{
"geoCode": "US-AL",
"geoName": "Alabama",
"value": [
97
],
"formattedValue": [
"97"
],
"maxValueIndex": 0,
"hasData": [
true
]
},
{
"geoCode": "US-UT",
"geoName": "Utah",
"value": [
91
],
"formattedValue": [
"91"
],
"maxValueIndex": 0,
"hasData": [
true
]
},
{
"geoCode": "US-OK",
"geoName": "Oklahoma",
"value": [
89
],
"formattedValue": [
"89"
],
"maxValueIndex": 0,
"hasData": [
true
]
},
{
"geoCode": "US-SD",
"geoName": "South Dakota",
"value": [
84
],
"formattedValue": [
"84"
],
"maxValueIndex": 0,
"hasData": [
true
]
},
{
"geoCode": "US-ND",
"geoName": "North Dakota",
"value": [
81
],
"formattedValue": [
"81"
],
"maxValueIndex": 0,
"hasData": [
true
]
},
{
"geoCode": "US-WV",
"geoName": "West Virginia",
"value": [
81
],
"formattedValue": [
"81"
],
"maxValueIndex": 0,
"hasData": [
true
]
},
{
"geoCode": "US-MS",
"geoName": "Mississippi",
"value": [
80
],
"formattedValue": [
"80"
],
"maxValueIndex": 0,
"hasData": [
true
]
},
{
"geoCode": "US-KS",
"geoName": "Kansas",
"value": [
78
],
"formattedValue": [
"78"
],
"maxValueIndex": 0,
"hasData": [
true
]
},
{
"geoCode": "US-SC",
"geoName": "South Carolina",
"value": [
77
],
"formattedValue": [
"77"
],
"maxValueIndex": 0,
"hasData": [
true
]
},
{
"geoCode": "US-AR",
"geoName": "Arkansas",
"value": [
77
],
"formattedValue": [
"77"
],
"maxValueIndex": 0,
"hasData": [
true
]
},
{
"geoCode": "US-OH",
"geoName": "Ohio",
"value": [
76
],
"formattedValue": [
"76"
],
"maxValueIndex": 0,
"hasData": [
true
]
},
{
"geoCode": "US-GA",
"geoName": "Georgia",
"value": [
74
],
"formattedValue": [
"74"
],
"maxValueIndex": 0,
"hasData": [
true
]
},
{
"geoCode": "US-LA",
"geoName": "Louisiana",
"value": [
73
],
"formattedValue": [
"73"