Google Trends API

Our Google Trends API allows you to scrape results from the Google Trends search page. The API is accessed through the following endpoint: /search?engine=google_trends. A user may query the following: https://serpapi.com/search?engine=google_trends utilizing a GET request. Head to the playground for a live and interactive demo.

API Parameters

Search Query

q

Required

Parameter defines the query or queries you want to search. You can use anything that you would use in a regular Google Trends search. The maximum number of queries per search is 5 (this only applies to "Interest over time" and "Compared breakdown by region" data_type, other types of data will only accept 1 query per search).

When passing multiple queries you need to use a comma (,) to separate them (e.g. coffee,pizza,dark chocolate,/m/027lnzs,bread).

Query can be a "Search term" (e.g. World Cup, Eminem, iPhone, etc.) or a "Topic" (e.g. /m/0663v, /m/027lnzs, /g/11mw8j71m4, etc.). Queries that are "Topics" are encoded. To retrieve these values you can use our Google Trends Autocomplete API.

Geographic Location

geo

Optional

Parameter defines the location from where you want the search to originate. It defaults to Worldwide (activated when the value of geo parameter is not set or empty). Head to the Google Trends Locations for a full list of supported Google Trends locations.

region

Optional

Parameter is used for getting more specific results when using "Compared breakdown by region" and "Interest by region" data_type charts. Other data_type charts do not accept region parameter. The default value depends on the geo location that is set. Available options:

COUNTRY - Country
REGION - Subregion
DMA - Metro
CITY - City

Not all region options will return results for every geo location.

Search Type

data_type

Optional

Parameter defines the type of search you want to do. Available options:

TIMESERIES - Interest over time (default) - Accepts both single and multiple queries per search.
GEO_MAP - Compared breakdown by region - Accepts only multiple queries per search.
GEO_MAP_0 - Interest by region - Accepts only single query per search.
RELATED_TOPICS - Related topics - Accepts only single query per search.
RELATED_QUERIES - Related queries - Accepts only single query per search.

Serpapi Parameters

engine

Required

Set parameter to google_trends to use the Google Trends API engine.

no_cache

Optional

Parameter will force SerpApi to fetch the Google Trends results even if a cached version is already present. A cache is served only if the query and all parameters are exactly the same. Cache expires after 1h. Cached searches are free, and are not counted towards your searches per month. It can be set to false (default) to allow results from the cache, or true to disallow results from the cache. no_cache and async parameters should not be used together.

async

Optional

Parameter defines the way you want to submit your search to SerpApi. It can be set to false (default) to open an HTTP connection and keep it open until you got your search results, or true to just submit your search to SerpApi and retrieve them later. In this case, you'll need to use our Searches Archive API to retrieve your results. async and no_cache parameters should not be used together. async should not be used on accounts with Ludicrous Speed enabled.

api_key

Required

Parameter defines the SerpApi private key to use.

output

Optional

Parameter defines the final output you want. It can be set to json (default) to get a structured JSON of the results, or html to get the raw html retrieved.

API Results

JSON Results

JSON output includes structured data for Interest over time, Compared breakdown by region, Interest by region, Related queries and Related topics.

A search status is accessible through search_metadata.status. It flows this way: Processing -> Success || Error. If a search has failed, error will contain an error message. search_metadata.id is the search ID inside SerpApi.

HTML Results

HTML output is useful to debug JSON results or support features not supported yet by SerpApi. HTML output gives you the raw HTML results from Google Trends.
This API does not have html response, just a text. search_metadata.prettify_html_file contains prettified version of the result. It is displayed in the playground.

API Examples

Interest over time chart with q: coffee,milk,bread,pasta,steak and data_type: TIMESERIES

Interest over time chart with q: coffee,milk,bread,pasta,steak and data_type: TIMESERIES

JSON Example

{
  "search_metadata": {
    "id": "628e1083de983400a3b29c2e",
    "status": "Success",
    "json_endpoint": "https://serpapi.com/searches/c1bde9cbd0a44437/628e1083de983400a3b29c2e.json",
    "created_at": "2022-05-25 11:18:27 UTC",
    "processed_at": "2022-05-25 11:18:27 UTC",
    "google_trends_url": "https://trends.google.com/trends/api/explore?tz=420&req=%7B%22comparisonItem%22%3A%5B%7B%22keyword%22%3A%22coffee%22%2C%22geo%22%3A%22%22%2C%22time%22%3A%22today+12-m%22%7D%2C%7B%22keyword%22%3A%22milk%22%2C%22geo%22%3A%22%22%2C%22time%22%3A%22today+12-m%22%7D%2C%7B%22keyword%22%3A%22bread%22%2C%22geo%22%3A%22%22%2C%22time%22%3A%22today+12-m%22%7D%2C%7B%22keyword%22%3A%22pasta%22%2C%22geo%22%3A%22%22%2C%22time%22%3A%22today+12-m%22%7D%2C%7B%22keyword%22%3A%22steak%22%2C%22geo%22%3A%22%22%2C%22time%22%3A%22today+12-m%22%7D%5D%2C%22category%22%3A0%2C%22property%22%3A%22%22%7D",
    "raw_html_file": "https://serpapi.com/searches/c1bde9cbd0a44437/628e1083de983400a3b29c2e.html",
    "prettify_html_file": "https://serpapi.com/searches/c1bde9cbd0a44437/628e1083de983400a3b29c2e.prettify",
    "total_time_taken": 1.89
  },
  "search_parameters": {
    "engine": "google_trends",
    "q": "coffee,milk,bread,pasta,steak",
    "date": "today 12-m",
    "tz": "420",
    "data_type": "TIMESERIES"
  },
  "interest_over_time": {
    "timeline_data": [
      {
        "date": "May 30 – Jun 5, 2021",
        "values": [
          {
            "query": "coffee",
            "value": "80",
            "extracted_value": 80
          },
          {
            "query": "milk",
            "value": "58",
            "extracted_value": 58
          },
          {
            "query": "bread",
            "value": "35",
            "extracted_value": 35
          },
          ...
        ]
      },
      {
        "date": "Jun 6 – 12, 2021",
        "values": [
          {
            "query": "coffee",
            "value": "75",
            "extracted_value": 75
          },
          {
            "query": "milk",
            "value": "54",
            "extracted_value": 54
          },
          {
            "query": "bread",
            "value": "35",
            "extracted_value": 35
          },
          ...
        ]
      },
      {
        "date": "Jun 13 – 19, 2021",
        "values": [
          {
            "query": "coffee",
            "value": "78",
            "extracted_value": 78
          },
          {
            "query": "milk",
            "value": "54",
            "extracted_value": 54
          },
          {
            "query": "bread",
            "value": "35",
            "extracted_value": 35
          },
          ...
        ]
      },
      ...
    ],
    "averages": [
      {
        "query": "coffee",
        "value": 84
      },
      {
        "query": "milk",
        "value": 55
      },
      {
        "query": "bread",
        "value": 39
      },
      ...
    ]
  }
}

Compared breakdown by region chart with q: coffee,milk,bread,pasta,steak and data_type: GEO_MAP

Compared breakdown by region chart with q: coffee,milk,bread,pasta,steak and data_type: GEO_MAP

JSON Example

{
  "search_metadata": {
    "id": "628e1291de983400a5961cdc",
    "status": "Success",
    "json_endpoint": "https://serpapi.com/searches/c1bde9cbd0a44437/628e1291de983400a5961cdc.json",
    "created_at": "2022-05-25 11:27:13 UTC",
    "processed_at": "2022-05-25 11:27:14 UTC",
    "google_trends_url": "https://trends.google.com/trends/api/explore?tz=420&req=%7B%22comparisonItem%22%3A%5B%7B%22keyword%22%3A%22coffee%22%2C%22geo%22%3A%22%22%2C%22time%22%3A%22today+12-m%22%7D%2C%7B%22keyword%22%3A%22milk%22%2C%22geo%22%3A%22%22%2C%22time%22%3A%22today+12-m%22%7D%2C%7B%22keyword%22%3A%22bread%22%2C%22geo%22%3A%22%22%2C%22time%22%3A%22today+12-m%22%7D%2C%7B%22keyword%22%3A%22pasta%22%2C%22geo%22%3A%22%22%2C%22time%22%3A%22today+12-m%22%7D%2C%7B%22keyword%22%3A%22steak%22%2C%22geo%22%3A%22%22%2C%22time%22%3A%22today+12-m%22%7D%5D%2C%22category%22%3A0%2C%22property%22%3A%22%22%7D",
    "raw_html_file": "https://serpapi.com/searches/c1bde9cbd0a44437/628e1291de983400a5961cdc.html",
    "prettify_html_file": "https://serpapi.com/searches/c1bde9cbd0a44437/628e1291de983400a5961cdc.prettify",
    "total_time_taken": 1.73
  },
  "search_parameters": {
    "engine": "google_trends",
    "q": "coffee,milk,bread,pasta,steak",
    "date": "today 12-m",
    "tz": "420",
    "data_type": "GEO_MAP"
  },
  "compared_breakdown_by_region": [
    {
      "geo": "SG",
      "location": "Singapore",
      "max_value_index": 0,
      "values": [
        {
          "query": "coffee",
          "value": "43%",
          "extracted_value": 43
        },
        {
          "query": "milk",
          "value": "25%",
          "extracted_value": 25
        },
        {
          "query": "bread",
          "value": "16%",
          "extracted_value": 16
        },
        ...
      ]
    },
    {
      "geo": "IT",
      "location": "Italy",
      "max_value_index": 3,
      "values": [
        {
          "query": "coffee",
          "value": "5%",
          "extracted_value": 5
        },
        {
          "query": "milk",
          "value": "3%",
          "extracted_value": 3
        },
        {
          "query": "bread",
          "value": "2%",
          "extracted_value": 2
        },
        ...
      ]
    },
    {
      "geo": "AU",
      "location": "Australia",
      "max_value_index": 0,
      "values": [
        {
          "query": "coffee",
          "value": "38%",
          "extracted_value": 38
        },
        {
          "query": "milk",
          "value": "21%",
          "extracted_value": 21
        },
        {
          "query": "bread",
          "value": "17%",
          "extracted_value": 17
        },
        ...
      ]
    },
    ...
  ]
}

Interest by region chart with q: coffee and data_type: GEO_MAP_0

Interest by region chart with q: coffee and data_type: GEO_MAP_0

JSON Example

{
  "search_metadata": {
    "id": "628e13d2de983400a5961cdf",
    "status": "Success",
    "json_endpoint": "https://serpapi.com/searches/15f6e17aed843e35/628e13d2de983400a5961cdf.json",
    "created_at": "2022-05-25 11:32:34 UTC",
    "processed_at": "2022-05-25 11:32:34 UTC",
    "google_trends_url": "https://trends.google.com/trends/api/explore?tz=420&req=%7B%22comparisonItem%22%3A%5B%7B%22keyword%22%3A%22coffee%22%2C%22geo%22%3A%22%22%2C%22time%22%3A%22today+12-m%22%7D%5D%2C%22category%22%3A0%2C%22property%22%3A%22%22%7D",
    "raw_html_file": "https://serpapi.com/searches/15f6e17aed843e35/628e13d2de983400a5961cdf.html",
    "prettify_html_file": "https://serpapi.com/searches/15f6e17aed843e35/628e13d2de983400a5961cdf.prettify",
    "total_time_taken": 1.85
  },
  "search_parameters": {
    "engine": "google_trends",
    "q": "coffee",
    "date": "today 12-m",
    "tz": "420",
    "data_type": "GEO_MAP_0"
  },
  "interest_by_region": [
    {
      "geo": "SG",
      "location": "Singapore",
      "max_value_index": 0,
      "value": "100",
      "extracted_value": 100
    },
    {
      "geo": "AU",
      "location": "Australia",
      "max_value_index": 0,
      "value": "87",
      "extracted_value": 87
    },
    {
      "geo": "NZ",
      "location": "New Zealand",
      "max_value_index": 0,
      "value": "77",
      "extracted_value": 77
    },
    ...
  ]
}