How to get Google Trends data in Python
Checked on 2026-11-19.
Google Trends has no open API yet: Google's own Trends API is an alpha that you apply for. Until you are let in, there are four other routes: the pytrends library (archived, and rate-limited by Google), the Download button on the Trends page, Google's BigQuery dataset of top terms, and an HTTP API that reads Trends for you. Here is each one, with code where there is code to write, and where it stops.
1. pytrends
A free library that takes no API key and returns pandas DataFrames.
# pip install pytrends
from pytrends.request import TrendReq
pytrends = TrendReq(hl="en-US", tz=360)
pytrends.build_payload(["pickleball"], cat=0, timeframe="today 12-m", geo="US", gprop="")
over_time = pytrends.interest_over_time() # a pandas DataFrame
by_region = pytrends.interest_by_region(resolution="REGION", inc_low_vol=True, inc_geo_code=False)
related = pytrends.related_queries() # a dictionary of DataFrames
print(over_time.tail())timeframe takes values such as today 12-m, today 5-y (the default) and all. geo is a two-letter country code, or empty for the world. The list of keywords holds up to five terms to compare.
Where it breaks: the repository was archived by its owner on April 17, 2025 and is read-only; the latest release, 4.9.2, is from April 2023. The README calls the library an "Unofficial API for Google Trends" that is "Only good until Google changes their backend again". The error its issue tracker reports again and again is HTTP 429, raised as TooManyRequestsError, and the README says: "Rate Limit is not publicly known". The guide to the pytrends 429 error covers what can and cannot be done about it.
2. Google's Trends API (alpha)
Google announced an official Google Trends API on July 24, 2025. On the day this guide was checked it was still an alpha: its page says "We're now accepting applications for alpha testers" and "we can't open the API for everyone yet". You apply with the form on developers.google.com/search/apis/trends. Google says it gives priority to developers who know what they want to do, can start soon and are willing to give feedback.
What it offers, according to the announcement: a rolling window of 1800 days (about 5 years) that ends 2 days ago; daily, weekly, monthly and yearly aggregation; regions and sub-regions. Its values are "consistently scaled" across requests instead of being scaled from 0 to 100 on every request, so data from separate requests can be joined.
Where it stops: you cannot sign up and call it. There is an application form, and we found no public reference to write code against, which is why there is no sample here.
3. The Download button
For a one-off, the Trends page is the simplest route. Google's help page gives the steps: open Google Trends, search for a term, and "In the top right of the chart, click Download". You get a CSV file for that chart, which opens in a spreadsheet application. Look at its first lines before you parse it in Python.
Where it stops: it is manual, one chart at a time. The same page says: "If you reuse Trends data, attribute the information to Google with a citation."
4. The BigQuery dataset
Google also publishes Trends data as public BigQuery datasets: the top 25 and the top 25 rising queries, for 210 market areas of the United States and for about 50 other countries. BigQuery's free tier covers up to 1 TB of queries a month, and its sandbox works without a credit card.
# pip install --upgrade google-cloud-bigquery
from google.cloud import bigquery
client = bigquery.Client()
query = """
SELECT * FROM `bigquery-public-data.google_trends.top_terms`
WHERE refresh_date = DATE_SUB(CURRENT_DATE(), INTERVAL 1 DAY)
LIMIT 25
"""
for row in client.query_and_wait(query):
print(row)Where it stops: it holds what is trending, not what you ask about. You cannot give it a term and get that term's interest over time. The Python client also needs Google credentials set up on your machine.
5. An HTTP API
Pipefetch reads Google Trends for one term and returns everything in one JSON answer: the timeline, the regions, the top and rising related queries, and a summary.
import os
import requests
res = requests.get(
"https://pipefetch.com/v1/google/trends",
params={"q": "pickleball", "geo": "US", "period": "12m"},
headers={"x-api-key": os.environ["PIPEFETCH_API_KEY"]},
timeout=90,
)
if res.status_code == 404:
print("Too little search volume for this term") # not charged
elif res.status_code == 502:
print("Google Trends turned the request away") # not charged, send it again
else:
res.raise_for_status()
data = res.json()["data"]
print(data["summary"]["averageInterest"], data["summary"]["trendDirection"])
for point in data["interestOverTime"]:
print(point["date"], point["interest"])
for region in data["interestByRegion"][:5]:
print(region["regionName"], region["interest"])
for query in data["relatedQueries"]["rising"][:5]:
print(query["query"], query["formattedValue"])geo is a two-letter country code; leave it out for the whole world. period is one of nine, from the past hour (1h) to everything since 2004 (all); the default is 12 months. The values are Google Trends' own index from 0 to 100. The last point of a timeline is usually incomplete and marked isPartial. The reference lists every field.
Where it stops: one request measures one term, so there are no comparisons of several terms. Related topics are not included. A single state or city cannot be asked for on its own. Google Trends limits how many searches one address may make, ours included: when it turns ours away, the request answers 502 upstream_error, costs nothing and can be sent again. And it is not an official API: Pipefetch is not affiliated with Google.
A request costs 1 credit, a term with too little data (404) costs nothing, and a new account has 100 free credits and needs no card.
Which one should you use?
| Situation | Use |
|---|---|
| A notebook on your own computer, a few terms | pytrends, with patience for 429 errors |
| One chart, once | The Download button |
| What is trending by day and area | The BigQuery dataset |
| A long-term product on official data | Apply for Google's Trends API alpha |
| A server, a scheduled job or an AI agent that needs a term's data now | An HTTP API such as Pipefetch |
What the numbers mean, whichever route you take
Trends values are not search counts. Google's FAQ says: "Each data point is divided by the total searches of the geography and time range it represents", and the results are "scaled on a range of 0 to 100". The data is a sample of searches, and a term with low volume appears as 0.
Two things follow. The Trends website scales the results from 0 to 100 on every request, and so does every route that reads the website: the 100 of one period is not the 100 of another, and two downloads cannot be glued together as they are. And a region's 100 means the largest share of that region's own searches, not the most searches, which can put a small region first. See why Wyoming is first in Google Trends.
Try it with 100 free credits. No card needed. No scraper to build or maintain. Get an API key or read the docs.
APIs used in this guide
More Google guides
- How to get Google search results in Python
- pytrends 429 TooManyRequestsError: what it means and what to do
- Why is Wyoming first in Google Trends?
- How to get Google search results in Node.js
- How to get Google search results into Google Sheets
- How to give an LLM live Google results with tool calling
Guides for other sources
Every source
YouTube
- How to get a YouTube transcript in Python
- How to get a YouTube transcript in Node.js
- YouTube API quota exceeded: what the error means and how to fix it
- How to find a YouTube channel ID from a handle or URL
- How to download YouTube subtitles as SRT or VTT
- youtube-transcript-api RequestBlocked or IpBlocked: why it happens and how to fix it
- How to get YouTube comments in Python
- How to search YouTube from Python
- How to list a YouTube channel's videos in Python
- How to summarize a YouTube video with an LLM in Python
- How to get YouTube transcripts and video stats in Google Sheets
- How to get YouTube video views and likes in Python
- How to get YouTube transcripts in n8n, Make and Zapier
- LangChain YoutubeLoader fails on a server: why, and a loader that works
- How to get a YouTube channel's subscriber count in Python
- How to give Claude or Cursor access to YouTube (MCP server)
- How to get YouTube comments in Node.js
- How to analyze YouTube comments with an LLM in Python
- How to list a YouTube channel's Shorts in Python
- How to search YouTube from JavaScript
- How to get an Instagram follower count in Python
- Instagram Basic Display API alternatives: what to use after the shutdown
- Instaloader 401 Unauthorized, 429 and "Login required": what to do
- How to calculate an Instagram engagement rate in Python
- How to get an Instagram follower count in Node.js
- How to get Instagram follower counts in Google Sheets
- How to get Instagram Reel views in Python
Websites
- Clearbit Logo API alternatives: get a company logo from its domain
- How to extract email addresses from a website in Python
- How to turn a web page into Markdown in Python
- How to detect what a website is built with, in Python
- How to get the contact emails and phone numbers of websites in Google Sheets
- How to build a LangChain tool that reads web pages and searches Google
- How to turn a web page into Markdown in JavaScript for RAG
- How to extract social media links from a website in Python
- How to get a website's favicon in Python
- How to check robots.txt in Python before you fetch a page
TikTok
- How to get a TikTok video's views and likes in Python
- How to get the comments of a TikTok video in Python
- How to get a TikTok follower count in Python
- TikTok Research API: who can get access, and what to do if you cannot
- How to get TikTok video views, likes and shares in Node.js
- How to get TikTok views, likes and follower counts in Google Sheets
- How to get a Facebook Page's posts without app review
- Is there a Facebook Marketplace API?
- Facebook Groups API alternatives after its removal in 2024
- How to get a Facebook Page's follower count and contact details in Python
Threads
- How to get LinkedIn company data in Python
- How to search LinkedIn jobs from Python
- How to get a LinkedIn company page's latest posts in Python