Google Trends API

Google Trends API uses /api/v1/search?engine=google_trends API endpoint to scrape real-time results

API Parameters

Search Query

  • Name
    q
    Required
    Required
    Description

    Parameter defines the query you want to search.
    Maximum amount of queries can be 5 that should be seperated by ,. For instance: Java,JavaScript,Python.
    Related Queries and Related Topics can be used only with one query.

Data Type

  • Name
    data_type
    Required
    Required
    Description

    Parameter defines the data type you wish to search for. You have several options to choose from:

    • TIMESERIES also known as Interest Over Time, used to return historical, indexed data for a given input.
    • GEO_MAP also known as Interest Over Region, used for geographical data.
    • RELATED_QUERIES corresponds to searches for queries that are related to the given input.
    • RELATED_TOPICS represents searches related to specific topics.

Categories

  • Name
    cat
    Required
    Optional
    Description

    The parameter for category selection defaults to 0, representing All Categories. This parameter determines the category to be used for the specified search. Please refer to the complete list of supported Google Trends Categories for more details.

  • Name
    region
    Required
    Optional
    Description

    The parameter specifies the geographical region for your chosen search. It is usable only with GEO_MAP data_type. There are few options to consider:

    • COUNTRY - selects data from country searches. Usable only with Worldwide geo value.
    • REGION - selects data from a states or provinces.
    • DMA - selects data from metros.
    • CITY - selects data from cities.

Localization

  • Name
    geo
    Required
    Optional
    Description

    The default value for the location parameter is set to Worldwide, which denotes a global scope for the search. This parameter specifies the geographical area for the query search. If it is not explicitly set, the search defaults to a worldwide range. Check the full list of supported Google Trends geo locations.

  • Name
    tz
    Required
    Optional
    Description

    Parameter defines timezone offset (the difference in hours and minutes between a particular time zone and UTC). Could be selected from -1439 to 1439. Default - 420.

Filters

  • Name
    gprop
    Required
    Optional
    Description

    This parameter can be customized according to different search types, with each corresponding to a distinct functionality. The options include:

    • "" represents Web Search (Default value).
    • images represents Image Search.
    • news represents News Search.
    • froogle represents Google Shopping.
    • youtube represents YouTube Search.

  • Name
    time
    Required
    Optional
    Description

    The parameter determines the time range for the data retrieval. There are a few options:

    • now 1-H - data from the past hour.
    • now 4-H - data from the past 4 hours.
    • now 1-d - data from the past day.
    • now 7-d - data from the past 7 days.
    • today 1-m - data from the past 30 days.
    • today 3-m - data from the past 90 days.
    • today 12-m - data from the past 12 months.
    • today 5-y - data from the past 5 years.
    • all - All available data since 2004.
    To select a custom date range, use the format yyyy-mm-dd. For example, 2019-01-01 2019-12-31 will retrieve data for the entire year of 2019. If you want to select a specific hourly range within the past week, use the format yyyy-mm-ddThh. For instance, 2024-04-24T21 2024-04-25T04 will retrieve data from 9PM on 2024-04-24, until 4AM on 2024-04-25.
    Note: tz parameter significantly influences the results, and hourly range selections are limited to data from the previous week.

Engine

  • Name
    engine
    Required
    Required
    Description

    Parameter defines an engine that will be used to retrieve real-time data. It must be set to google_trends.

API key

  • Name
    api_key
    Required
    Required
    Description

    The api_key authenticates your requests. Use it as a query parameter (https://www.searchapi.io/api/v1/search?api_key=YOUR_API_KEY) or in the Authorization header (Bearer YOUR_API_KEY).

API Examples

Interest Over Time

Interest Over Time
GET
https://www.searchapi.io/api/v1/search?data_type=TIMESERIES&engine=google_trends&q=Java%2CPython%2CRuby%2CAssembly%2CJavaScript
Request
import requests

url = "https://www.searchapi.io/api/v1/search"
params = {
  "engine": "google_trends",
  "q": "Java,Python,Ruby,Assembly,JavaScript",
  "data_type": "TIMESERIES"
}

response = requests.get(url, params = params)
print(response.text)
Response
{
  "interest_over_time": {
    "averages": [
      {
        "query": "Java",
        "value": 58
      },
      {
        "query": "Python",
        "value": 85
      },
      {
        "query": "Ruby",
        "value": 17
      },
      {
        "query": "Assembly",
        "value": 13
      },
      {
        "query": "JavaScript",
        "value": 28
      }
    ],
    "timeline_data": [
      {
        "date": "May 1 – 7, 2022",
        "timestamp": "1651363200",
        "values": [
          {
            "query": "Java",
            "value": "59",
            "extracted_value": 59
          },
          {
            "query": "Python",
            "value": "87",
            "extracted_value": 87
          },
          {
            "query": "Ruby",
            "value": "17",
            "extracted_value": 17
          },
          {
            "query": "Assembly",
            "value": "14",
            "extracted_value": 14
          },
          {
            "query": "JavaScript",
            "value": "29",
            "extracted_value": 29
          }
        ]
      },
      {
        "date": "May 8 – 14, 2022",
        "timestamp": "1651968000",
        "values": [
          {
            "query": "Java",
            "value": "65",
            "extracted_value": 65
          },
          {
            "query": "Python",
            "value": "90",
            "extracted_value": 90
          },
          {
            "query": "Ruby",
            "value": "18",
            "extracted_value": 18
          },
          {
            "query": "Assembly",
            "value": "13",
            "extracted_value": 13
          },
          {
            "query": "JavaScript",
            "value": "30",
            "extracted_value": 30
          }
        ]
      },
      {
        "date": "May 15 – 21, 2022",
        "timestamp": "1652572800",
        "values": [
          {
            "query": "Java",
            "value": "60",
            "extracted_value": 60
          },
          {
            "query": "Python",
            "value": "80",
            "extracted_value": 80
          },
          {
            "query": "Ruby",
            "value": "17",
            "extracted_value": 17
          },
          {
            "query": "Assembly",
            "value": "12",
            "extracted_value": 12
          },
          {
            "query": "JavaScript",
            "value": "31",
            "extracted_value": 31
          }
        ]
      }
    ]
  }
}

Interest by Region

Interest by Region
GET
https://www.searchapi.io/api/v1/search?data_type=GEO_MAP&engine=google_trends&q=Java%2CPython%2CRuby%2CAssembly%2CJavaScript&region=COUNTRY
Request
import requests

url = "https://www.searchapi.io/api/v1/search"
params = {
  "engine": "google_trends",
  "q": "Java,Python,Ruby,Assembly,JavaScript",
  "data_type": "GEO_MAP",
  "region": "COUNTRY"
}

response = requests.get(url, params = params)
print(response.text)
Response
{
  "interest_by_region": [
    {
      "geo": "US-MA",
      "name": "Massachusetts",
      "values": [
        {
          "query": "Java",
          "value": "18%",
          "extracted_value": 18
        },
        {
          "query": "JavaScript",
          "value": "9%",
          "extracted_value": 9
        },
        {
          "query": "Python",
          "value": "49%",
          "extracted_value": 49
        },
        {
          "query": "Ruby",
          "value": "7%",
          "extracted_value": 7
        },
        {
          "query": "Assembly",
          "value": "17%",
          "extracted_value": 17
        }
      ]
    },
    {
      "geo": "US-WA",
      "name": "Washington",
      "values": [
        {
          "query": "Java",
          "value": "29%",
          "extracted_value": 29
        },
        {
          "query": "JavaScript",
          "value": "11%",
          "extracted_value": 11
        },
        {
          "query": "Python",
          "value": "42%",
          "extracted_value": 42
        },
        {
          "query": "Ruby",
          "value": "11%",
          "extracted_value": 11
        },
        {
          "query": "Assembly",
          "value": "7%",
          "extracted_value": 7
        }
      ]
    },
    {
      "geo": "US-CA",
      "name": "California",
      "values": [
        {
          "query": "Java",
          "value": "21%",
          "extracted_value": 21
        },
        {
          "query": "JavaScript",
          "value": "11%",
          "extracted_value": 11
        },
        {
          "query": "Python",
          "value": "49%",
          "extracted_value": 49
        },
        {
          "query": "Ruby",
          "value": "10%",
          "extracted_value": 10
        },
        {
          "query": "Assembly",
          "value": "9%",
          "extracted_value": 9
        }
      ]
    }
  ]
}
Related Queries
GET
https://www.searchapi.io/api/v1/search?data_type=RELATED_QUERIES&engine=google_trends&q=Java
Request
import requests

url = "https://www.searchapi.io/api/v1/search"
params = {
  "engine": "google_trends",
  "q": "Java",
  "data_type": "RELATED_QUERIES"
}

response = requests.get(url, params = params)
print(response.text)
Response
{
  "related_queries": {
    "top": [
      {
        "position": 1,
        "query": "minecraft",
        "values": "100",
        "extracted_value": 100,
        "link": "https://trends.google.com/trends/explore?q=minecraft&date=today+12-m"
      },
      {
        "position": 2,
        "query": "minecraft java",
        "values": "99",
        "extracted_value": 99,
        "link": "https://trends.google.com/trends/explore?q=minecraft+java&date=today+12-m"
      },
      {
        "position": 3,
        "query": "string java",
        "values": "86",
        "extracted_value": 86,
        "link": "https://trends.google.com/trends/explore?q=string+java&date=today+12-m"
      },
      {
        "position": 4,
        "query": "java download",
        "values": "79",
        "extracted_value": 79,
        "link": "https://trends.google.com/trends/explore?q=java+download&date=today+12-m"
      },
      {
        "position": 5,
        "query": "array java",
        "values": "57",
        "extracted_value": 57,
        "link": "https://trends.google.com/trends/explore?q=array+java&date=today+12-m"
      },
      {
        "position": 6,
        "query": "what is java",
        "values": "54",
        "extracted_value": 54,
        "link": "https://trends.google.com/trends/explore?q=what+is+java&date=today+12-m"
      },
      {
        "position": 7,
        "query": "java list",
        "values": "48",
        "extracted_value": 48,
        "link": "https://trends.google.com/trends/explore?q=java+list&date=today+12-m"
      },
      {
        "position": 8,
        "query": "java code",
        "values": "46",
        "extracted_value": 46,
        "link": "https://trends.google.com/trends/explore?q=java+code&date=today+12-m"
      },
      {
        "position": 9,
        "query": "java program",
        "values": "43",
        "extracted_value": 43,
        "link": "https://trends.google.com/trends/explore?q=java+program&date=today+12-m"
      }
    ]
  }
}
Related Topics
GET
https://www.searchapi.io/api/v1/search?data_type=RELATED_TOPICS&engine=google_trends&q=Python
Request
import requests

url = "https://www.searchapi.io/api/v1/search"
params = {
  "engine": "google_trends",
  "q": "Python",
  "data_type": "RELATED_TOPICS"
}

response = requests.get(url, params = params)
print(response.text)
Response
{
  "related_topics": {
    "top": [
      {
        "position": 1,
        "id": "/m/05z1_",
        "title": "Python",
        "type": "Programming language",
        "value": "100",
        "extracted_value": 100,
        "link": "https://trends.google.com/trends/explore?q=/m/05z1_&date=today+12-m"
      },
      {
        "position": 2,
        "id": "/m/01dlmc",
        "title": "List",
        "type": "Abstract data type",
        "value": "7",
        "extracted_value": 7,
        "link": "https://trends.google.com/trends/explore?q=/m/01dlmc&date=today+12-m"
      },
      {
        "position": 3,
        "id": "/m/06x16",
        "title": "String",
        "type": "Computer science",
        "value": "7",
        "extracted_value": 7,
        "link": "https://trends.google.com/trends/explore?q=/m/06x16&date=today+12-m"
      },
      {
        "position": 4,
        "id": "/m/020s1",
        "title": "Computer file",
        "type": "Topic",
        "value": "7",
        "extracted_value": 7,
        "link": "https://trends.google.com/trends/explore?q=/m/020s1&date=today+12-m"
      },
      {
        "position": 5,
        "id": "/m/026sq",
        "title": "Data",
        "type": "Topic",
        "value": "4",
        "extracted_value": 4,
        "link": "https://trends.google.com/trends/explore?q=/m/026sq&date=today+12-m"
      },
      {
        "position": 6,
        "id": "/m/02v_93z",
        "title": "Function",
        "type": "Mathematics",
        "value": "4",
        "extracted_value": 4,
        "link": "https://trends.google.com/trends/explore?q=/m/02v_93z&date=today+12-m"
      },
      {
        "position": 7,
        "id": "/m/0nk18",
        "title": "Associative array",
        "type": "Topic",
        "value": "3",
        "extracted_value": 3,
        "link": "https://trends.google.com/trends/explore?q=/m/0nk18&date=today+12-m"
      }
    ]
  }
}