WebScrapingAPI Docs
HomeLoginRegister
  • Introduction
    • Registration
    • Pricing
    • Free APIs
    • API Errors
    • Custom Response Headers
  • Browser API
    • Getting Started
      • Access the API
      • Authentication
      • API Parameters
    • Basic API Requests
      • GET Request
      • POST, PUT & PATCH Requests
      • Proxy Mode
    • Advanced API Features
      • Awaiting
      • Geolocation
      • Sessions
      • Forcing Timeouts
      • Custom Headers
      • Custom Cookies
      • Device Type
      • Viewport Sizing
      • Screenshot
      • Screenshot Options
      • Extraction Rules
      • JavaScript Instructions
      • Full JSON Response
      • JSON DOM Response
      • Block Resources
      • Captcha Solving
  • WebScrapingAPI
    • Getting Started
      • Access the API
      • API Parameters
    • Basic API Requests
      • GET Request
      • POST, PUT & PATCH Requests
    • Advanced API Features
      • Geolocation
      • Extraction Rules
      • Full JSON Response
      • JSON DOM Response
      • Rendering JavaScript
  • WebStealthProxy
    • Getting Started
      • Access the Proxy
      • Usage and Statistics
    • Basic Proxy Requests
    • Advanced Proxy Requests
      • Sessions
      • Geolocation
      • Custom Headers
      • Custom Cookies
      • Screenshots
  • Google Search API
    • Getting Started
      • Access the API
      • API Parameters
    • Google Search Engines
      • Google Search API
      • Google Maps API
      • Google Maps Reviews API
      • Google Reverse Image API
      • Google Trends API
        • Geo Parameter Options List
        • Google Trends Categories List
  • WB CUSTOM SEARCH API
    • Getting Started
      • Access the API
      • API Parameters
    • WB Custom Search Engines
      • Wayfair Product API
      • Best Buy Product API
      • Nordstrom Product API
  • Amazon Search API
    • Getting Started
      • API Parameters
      • Access the API
      • Supported Domains
    • Amazon Search Types
      • Amazon Search
      • Amazon Seller
        • Amazon Seller Products
        • Amazon Seller Profile
        • Amazon Seller Feedback
      • Amazon Product
      • Amazon Category
      • Amazon Bestsellers
      • Amazon New Releases
      • Amazon Deals
  • Bing Search API
    • Getting Started
      • Access the API
      • API Parameters
    • Basic API Requests
Powered by GitBook
On this page
  • Google Trends API Integration Example
  • Ready to Use Google Trends API Scraping Scripts
  • Google Trends API Parameters
  1. Google Search API
  2. Google Search Engines

Google Trends API

Stay on top of the market by scraping Google Trends in real time.

PreviousGoogle Reverse Image APINextGeo Parameter Options List

Last updated 7 months ago

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/v2?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/v2?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": "/v2?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()2
import http.client

conn = http.client.HTTPSConnection("serpapi.webscrapingapi.com")

conn.request("GET", "/v2?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/v2?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/v2?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/v2?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/v2?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/v2?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

q

string

The keyword that you are searching for (the query).

#2: Request Customization Parameters

Parameter
Type
Description

geo

string

date

string

You must use the format YYYY-MM-DD YYYY-MM-DD or one of the predefined values:

  • now 1-H, past 1 hour

  • now 4-H, past 4 hours

  • now 1-d, past day

  • now 7-d, past 7 days

  • today 1-m, past 30 days

  • today 3-m, past 90 days

  • today 12-m, past 12 months (default)

  • today 5-y , past 5 years

cat

string

gprop

string

This parameter specifies the Google property to filter on. Possible values are:

  • images

  • news

  • froogle (for Google Shopping)

  • youtube

If unspecified, it defaults to web search.

Response Example
{
    "widgets": [
        {
            "data": {
                "default": {
                    "timelineData": [],
                    "averages": []
                }
            },
            "id": "TIMESERIES",
            "type": "fe_line_chart",
            "title": "Interest over time"
        },
        {
            "data": {
                "default": {
                    "geoMapData": [
                        {
                            "geoCode": "US-AK",
                            "geoName": "Alaska",
                            "value": [
                                0
                            ],
                            "formattedValue": [
                                ""
                            ],
                            "maxValueIndex": 0,
                            "hasData": [
                                false
                            ]
                        },
                        {
                            "geoCode": "US-AL",
                            "geoName": "Alabama",
                            "value": [
                                0
                            ],
                            "formattedValue": [
                                ""
                            ],
                            "maxValueIndex": 0,
                            "hasData": [
                                false
                            ]
                        },
                        {
                            "geoCode": "US-AR",
                            "geoName": "Arkansas",
                            "value": [
                                0
                            ],
                            "formattedValue": [
                                ""
                            ],
                            "maxValueIndex": 0,
                            "hasData": [
                                false
                            ]
                        },
                        {
                            "geoCode": "US-AZ",
                            "geoName": "Arizona",
                            "value": [
                                0
                            ],
                            "formattedValue": [
                                ""
                            ],
                            "maxValueIndex": 0,
                            "hasData": [
                                false
                            ]
                        },
                        {
                            "geoCode": "US-CA",
                            "geoName": "California",
                            "value": [
                                0
                            ],
                            "formattedValue": [
                                ""
                            ],
                            "maxValueIndex": 0,
                            "hasData": [
                                false
                            ]
                        },
                        {
                            "geoCode": "US-CO",
                            "geoName": "Colorado",
                            "value": [
                                0
                            ],
                            "formattedValue": [
                                ""
                            ],
                            "maxValueIndex": 0,
                            "hasData": [
                                false
                            ]
                        },
                        {
                            "geoCode": "US-CT",
                            "geoName": "Connecticut",
                            "value": [
                                0
                            ],
                            "formattedValue": [
                                ""
                            ],
                            "maxValueIndex": 0,
                            "hasData": [
                                false
                            ]
                        },
                        {
                            "geoCode": "US-DC",
                            "geoName": "District of Columbia",
                            "value": [
                                0
                            ],
                            "formattedValue": [
                                ""
                            ],
                            "maxValueIndex": 0,
                            "hasData": [
                                false
                            ]
                        },
                        {
                            "geoCode": "US-DE",
                            "geoName": "Delaware",
                            "value": [
                                0
                            ],
                            "formattedValue": [
                                ""
                            ],
                            "maxValueIndex": 0,
                            "hasData": [
                                false
                            ]
                        },
                        {
                            "geoCode": "US-FL",
                            "geoName": "Florida",
                            "value": [
                                0
                            ],
                            "formattedValue": [
                                ""
                            ],
                            "maxValueIndex": 0,
                            "hasData": [
                                false
                            ]
                        },
                        {
                            "geoCode": "US-GA",
                            "geoName": "Georgia",
                            "value": [
                                0
                            ],
                            "formattedValue": [
                                ""
                            ],
                            "maxValueIndex": 0,
                            "hasData": [
                                false
                            ]
                        },
                        {
                            "geoCode": "US-HI",
                            "geoName": "Hawaii",
                            "value": [
                                0
                            ],
                            "formattedValue": [
                                ""
                            ],
                            "maxValueIndex": 0,
                            "hasData": [
                                false
                            ]
                        },
                        {
                            "geoCode": "US-IA",
                            "geoName": "Iowa",
                            "value": [
                                0
                            ],
                            "formattedValue": [
                                ""
                            ],
                            "maxValueIndex": 0,
                            "hasData": [
                                false
                            ]
                        },
                        {
                            "geoCode": "US-ID",
                            "geoName": "Idaho",
                            "value": [
                                0
                            ],
                            "formattedValue": [
                                ""
                            ],
                            "maxValueIndex": 0,
                            "hasData": [
                                false
                            ]
                        },
                        {
                            "geoCode": "US-IL",
                            "geoName": "Illinois",
                            "value": [
                                0
                            ],
                            "formattedValue": [
                                ""
                            ],
                            "maxValueIndex": 0,
                            "hasData": [
                                false
                            ]
                        },
                        {
                            "geoCode": "US-IN",
                            "geoName": "Indiana",
                            "value": [
                                0
                            ],
                            "formattedValue": [
                                ""
                            ],
                            "maxValueIndex": 0,
                            "hasData": [
                                false
                            ]
                        },
                        {
                            "geoCode": "US-KS",
                            "geoName": "Kansas",
                            "value": [
                                0
                            ],
                            "formattedValue": [
                                ""
                            ],
                            "maxValueIndex": 0,
                            "hasData": [
                                false
                            ]
                        },
                        {
                            "geoCode": "US-KY",
                            "geoName": "Kentucky",
                            "value": [
                                0
                            ],
                            "formattedValue": [
                                ""
                            ],
                            "maxValueIndex": 0,
                            "hasData": [
                                false
                            ]
                        },
                        {
                            "geoCode": "US-LA",
                            "geoName": "Louisiana",
                            "value": [
                                0
                            ],
                            "formattedValue": [
                                ""
                            ],
                            "maxValueIndex": 0,
                            "hasData": [
                                false
                            ]
                        },
                        {
                            "geoCode": "US-MA",
                            "geoName": "Massachusetts",
                            "value": [
                                0
                            ],
                            "formattedValue": [
                                ""
                            ],
                            "maxValueIndex": 0,
                            "hasData": [
                                false
                            ]
                        },
                        {
                            "geoCode": "US-MD",
                            "geoName": "Maryland",
                            "value": [
                                0
                            ],
                            "formattedValue": [
                                ""
                            ],
                            "maxValueIndex": 0,
                            "hasData": [
                                false
                            ]
                        },
                        {
                            "geoCode": "US-ME",
                            "geoName": "Maine",
                            "value": [
                                0
                            ],
                            "formattedValue": [
                                ""
                            ],
                            "maxValueIndex": 0,
                            "hasData": [
                                false
                            ]
                        },
                        {
                            "geoCode": "US-MI",
                            "geoName": "Michigan",
                            "value": [
                                0
                            ],
                            "formattedValue": [
                                ""
                            ],
                            "maxValueIndex": 0,
                            "hasData": [
                                false
                            ]
                        },
                        {
                            "geoCode": "US-MN",
                            "geoName": "Minnesota",
                            "value": [
                                0
                            ],
                            "formattedValue": [
                                ""
                            ],
                            "maxValueIndex": 0,
                            "hasData": [
                                false
                            ]
                        },
                        {
                            "geoCode": "US-MO",
                            "geoName": "Missouri",
                            "value": [
                                0
                            ],
                            "formattedValue": [
                                ""
                            ],
                            "maxValueIndex": 0,
                            "hasData": [
                                false
                            ]
                        },
                        {
                            "geoCode": "US-MS",
                            "geoName": "Mississippi",
                            "value": [
                                0
                            ],
                            "formattedValue": [
                                ""
                            ],
                            "maxValueIndex": 0,
                            "hasData": [
                                false
                            ]
                        },
                        {
                            "geoCode": "US-MT",
                            "geoName": "Montana",
                            "value": [
                                0
                            ],
                            "formattedValue": [
                                ""
                            ],
                            "maxValueIndex": 0,
                            "hasData": [
                                false
                            ]
                        },
                        {
                            "geoCode": "US-NC",
                            "geoName": "North Carolina",
                            "value": [
                                0
                            ],
                            "formattedValue": [
                                ""
                            ],
                            "maxValueIndex": 0,
                            "hasData": [
                                false
                            ]
                        },
                        {
                            "geoCode": "US-ND",
                            "geoName": "North Dakota",
                            "value": [
                                0
                            ],
                            "formattedValue": [
                                ""
                            ],
                            "maxValueIndex": 0,
                            "hasData": [
                                false
                            ]
                        },
                        {
                            "geoCode": "US-NE",
                            "geoName": "Nebraska",
                            "value": [
                                0
                            ],
                            "formattedValue": [
                                ""
                            ],
                            "maxValueIndex": 0,
                            "hasData": [
                                false
                            ]
                        },
                        {
                            "geoCode": "US-NH",
                            "geoName": "New Hampshire",
                            "value": [
                                0
                            ],
                            "formattedValue": [
                                ""
                            ],
                            "maxValueIndex": 0,
                            "hasData": [
                                false
                            ]
                        },
                        {
                            "geoCode": "US-NJ",
                            "geoName": "New Jersey",
                            "value": [
                                0
                            ],
                            "formattedValue": [
                                ""
                            ],
                            "maxValueIndex": 0,
                            "hasData": [
                                false
                            ]
                        },
                        {
                            "geoCode": "US-NM",
                            "geoName": "New Mexico",
                            "value": [
                                0
                            ],
                            "formattedValue": [
                                ""
                            ],
                            "maxValueIndex": 0,
                            "hasData": [
                                false
                            ]
                        },
                        {
                            "geoCode": "US-NV",
                            "geoName": "Nevada",
                            "value": [
                                0
                            ],
                            "formattedValue": [
                                ""
                            ],
                            "maxValueIndex": 0,
                            "hasData": [
                                false
                            ]
                        },
                        {
                            "geoCode": "US-NY",
                            "geoName": "New York",
                            "value": [
                                0
                            ],
                            "formattedValue": [
                                ""
                            ],
                            "maxValueIndex": 0,
                            "hasData": [
                                false
                            ]
                        },
                        {
                            "geoCode": "US-OH",
                            "geoName": "Ohio",
                            "value": [
                                0
                            ],
                            "formattedValue": [
                                ""
                            ],
                            "maxValueIndex": 0,
                            "hasData": [
                                false
                            ]
                        },
                        {
                            "geoCode": "US-OK",
                            "geoName": "Oklahoma",
                            "value": [
                                0
                            ],
                            "formattedValue": [
                                ""
                            ],
                            "maxValueIndex": 0,
                            "hasData": [
                                false
                            ]
                        },
                        {
                            "geoCode": "US-OR",
                            "geoName": "Oregon",
                            "value": [
                                0
                            ],
                            "formattedValue": [
                                ""
                            ],
                            "maxValueIndex": 0,
                            "hasData": [
                                false
                            ]
                        },
                        {
                            "geoCode": "US-PA",
                            "geoName": "Pennsylvania",
                            "value": [
                                0
                            ],
                            "formattedValue": [
                                ""
                            ],
                            "maxValueIndex": 0,
                            "hasData": [
                                false
                            ]
                        },
                        {
                            "geoCode": "US-RI",
                            "geoName": "Rhode Island",
                            "value": [
                                0
                            ],
                            "formattedValue": [
                                ""
                            ],
                            "maxValueIndex": 0,
                            "hasData": [
                                false
                            ]
                        },
                        {
                            "geoCode": "US-SC",
                            "geoName": "South Carolina",
                            "value": [
                                0
                            ],
                            "formattedValue": [
                                ""
                            ],
                            "maxValueIndex": 0,
                            "hasData": [
                                false
                            ]
                        },
                        {
                            "geoCode": "US-SD",
                            "geoName": "South Dakota",
                            "value": [
                                0
                            ],
                            "formattedValue": [
                                ""
                            ],
                            "maxValueIndex": 0,
                            "hasData": [
                                false
                            ]
                        },
                        {
                            "geoCode": "US-TN",
                            "geoName": "Tennessee",
                            "value": [
                                0
                            ],
                            "formattedValue": [
                                ""
                            ],
                            "maxValueIndex": 0,
                            "hasData": [
                                false
                            ]
                        },
                        {
                            "geoCode": "US-TX",
                            "geoName": "Texas",
                            "value": [
                                0
                            ],
                            "formattedValue": [
                                ""
                            ],
                            "maxValueIndex": 0,
                            "hasData": [
                                false
                            ]
                        },
                        {
                            "geoCode": "US-UT",
                            "geoName": "Utah",
                            "value": [
                                0
                            ],
                            "formattedValue": [
                                ""
                            ],
                            "maxValueIndex": 0,
                            "hasData": [
                                false
                            ]
                        },
                        {
                            "geoCode": "US-VA",
                            "geoName": "Virginia",
                            "value": [
                                0
                            ],
                            "formattedValue": [
                                ""
                            ],
                            "maxValueIndex": 0,
                            "hasData": [
                                false
                            ]
                        },
                        {
                            "geoCode": "US-VT",
                            "geoName": "Vermont",
                            "value": [
                                0
                            ],
                            "formattedValue": [
                                ""
                            ],
                            "maxValueIndex": 0,
                            "hasData": [
                                false
                            ]
                        },
                        {
                            "geoCode": "US-WA",
                            "geoName": "Washington",
                            "value": [
                                0
                            ],
                            "formattedValue": [
                                ""
                            ],
                            "maxValueIndex": 0,
                            "hasData": [
                                false
                            ]
                        },
                        {
                            "geoCode": "US-WI",
                            "geoName": "Wisconsin",
                            "value": [
                                0
                            ],
                            "formattedValue": [
                                ""
                            ],
                            "maxValueIndex": 0,
                            "hasData": [
                                false
                            ]
                        },
                        {
                            "geoCode": "US-WV",
                            "geoName": "West Virginia",
                            "value": [
                                0
                            ],
                            "formattedValue": [
                                ""
                            ],
                            "maxValueIndex": 0,
                            "hasData": [
                                false
                            ]
                        },
                        {
                            "geoCode": "US-WY",
                            "geoName": "Wyoming",
                            "value": [
                                0
                            ],
                            "formattedValue": [
                                ""
                            ],
                            "maxValueIndex": 0,
                            "hasData": [
                                false
                            ]
                        }
                    ]
                }
            },
            "id": "GEO_MAP",
            "type": "fe_geo_chart_explore",
            "title": "Interest by subregion"
        },
        {
            "data": {
                "default": {
                    "rankedList": [
                        {
                            "rankedKeyword": []
                        },
                        {
                            "rankedKeyword": []
                        }
                    ]
                }
            },
            "id": "RELATED_TOPICS",
            "type": "fe_related_searches",
            "title": "Related topics"
        },
        {
            "data": {
                "default": {
                    "rankedList": [
                        {
                            "rankedKeyword": []
                        },
                        {
                            "rankedKeyword": []
                        }
                    ]
                }
            },
            "id": "RELATED_QUERIES",
            "type": "fe_related_searches",
            "title": "Related queries"
        }
    ],
    "keywords": [
        {
            "keyword": "american%20football",
            "name": "american%20football",
            "type": "Search term"
        }
    ]
}

The location you want to find the results for. It defaults to worldwide. For a full list of supported geo options, feel free to check our .

This is the category parameter. You can find the full list of Google Trends categories .

list
here
Scrape Google Trends Page