explaingit

generalmills/pytrends

Analysis updated 2026-07-03

3,695PythonAudience · dataComplexity · 2/5Setup · easy

TLDR

Unofficial Python library for downloading Google Trends data, get search interest over time, by region, related topics, and trending searches, all returned as pandas DataFrames ready for analysis.

Mindmap

mindmap
  root((repo))
    What it does
      Download Google Trends data
      No manual clicking
      Returns pandas DataFrames
    Tech stack
      Python
      pandas
      Google Trends
    Use cases
      Track search interest
      Compare keywords
      Regional analysis
    Audience
      Data analysts
      Researchers
      Marketers
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Download historical Google Trends data for up to five keywords and analyze how public search interest changed over any time period.

USE CASE 2

Compare search interest by country or US state to understand regional demand for a product, brand, or topic.

USE CASE 3

Find related queries and topics that rise alongside your keyword to discover adjacent trends worth tracking.

USE CASE 4

Pull hourly Google Trends data over multiple weeks by automating the multiple sequential requests needed to piece it together.

What is it built with?

Pythonpandas

How does it compare?

generalmills/pytrendsgoogleapis/python-genaioctodns/octodns
Stars3,6953,6953,695
LanguagePythonPythonPython
Setup difficultyeasyeasymoderate
Complexity2/52/53/5
Audiencedatadeveloperops devops

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · easy Time to first run · 5min

Google may rate-limit your IP for bulk requests, configure proxies for large downloads and expect occasional breakage when Google updates its backend.

In plain English

Pytrends is an unofficial Python library that lets you download data from Google Trends without having to click through the website manually. Google Trends shows how often people search for particular words or topics over time, broken down by region, time period, and search type (web, news, YouTube, images, or Google Shopping). Pytrends gives you that same data in a format you can work with in Python, returned as tables (pandas DataFrames) you can analyze, chart, or save to a file. You install it with pip, create a connection object, tell it which keywords you want to track (up to five at a time), and then call whichever data method you need. The available methods include interest over time (a historical index of how search volume changed), interest by region (which countries or states search for the term most), related topics, related queries, trending searches, top charts, and keyword suggestions. There is also a method for pulling hourly historical data, which requires multiple requests to Google since Trends only exposes one week of hourly data at a time. The library is unofficial, meaning it works by mimicking the requests a browser would send to Google Trends rather than using a supported API. Google can and does change its backend, which can break the library without warning. The README acknowledges this directly and invites contributors to help fix it when that happens. Proxy support is built in for situations where Google rate-limits your IP address. Search terms can be either plain text or Google's internal topic IDs. Using topic IDs is more precise: searching for "iron" as plain text will match everything called iron, but the topic ID for "Iron (chemical element)" targets only that concept. The library includes a suggestions method to help you find the right topic ID. The project lists General Mills as the maintainer on GitHub, though it appears to be community-driven. As of the README, the project is looking for new maintainers.

Copy-paste prompts

Prompt 1
Using pytrends, write a Python script that downloads weekly Google Trends data for 'electric bikes' over the past 12 months and plots the interest-over-time chart with matplotlib.
Prompt 2
How do I use pytrends to compare search interest for 'ChatGPT' vs 'Gemini' by US state and save the results as a CSV?
Prompt 3
Show me how to use pytrends to get the top related queries for a keyword and identify which ones are labeled as breakout versus just rising.
Prompt 4
I'm being rate-limited by Google when using pytrends. How do I configure rotating proxies to avoid blocks when downloading large amounts of data?
Prompt 5
Using pytrends, how do I find the topic ID for 'iron the chemical element' instead of just searching the plain word 'iron', and why does the distinction matter for accurate data?

Frequently asked questions

What is pytrends?

Unofficial Python library for downloading Google Trends data, get search interest over time, by region, related topics, and trending searches, all returned as pandas DataFrames ready for analysis.

What language is pytrends written in?

Mainly Python. The stack also includes Python, pandas.

How hard is pytrends to set up?

Setup difficulty is rated easy, with roughly 5min to a first successful run.

Who is pytrends for?

Mainly data.

Open on GitHub → Explain another repo

This repo across BitVibe Labs

Scan in gitsafehub Deploy in gitdeployhub generalmills on gitmyhub

Verify against the repo before relying on details.