APIs

PyTrends (Google Trends API)

In shortAn unofficial Python library that pulls Google Trends data, such as interest over time, by region and related queries, into your own code.

Updated 24 Oct 2026· 2 min read

PyTrends is an unofficial Python library for downloading data from Google Trends. Instead of copying charts from the Trends website, you request interest over time, interest by region, keyword suggestions and related queries in a few lines of code, which makes large or repeated research projects practical.

How it works

You create a connection object (TrendReq), build a payload with up to five keywords, a timeframe and a location, and then call methods such as:

  • interest_over_time() for the familiar trend line;
  • interest_by_region() for country or sub-region breakdowns;
  • related_queries() for top and rising related searches;
  • suggestions() for entity suggestions, which return Google Trends topics.

PyTrends works by calling the same internal endpoints the Trends website uses. There is no official contract behind it, so when Google changes the site, methods can break.

How it’s used in SEO and marketing

  • Spotting seasonality and planning content calendars.
  • Comparing brands to estimate share of search over time.
  • Finding rising related queries for content ideas.
  • Choosing which markets or regions to prioritise.
  • Feeding relative demand into forecasting models.

Example

MLforSEO’s guide shows share of search in four lines: take the weekly interest for several competing brands and divide each by the combined total for that week. The result is each brand’s percentage of combined interest, a reasonable proxy for share of voice that you can plot as an area chart.

Limitations and things to watch

  • As MLforSEO’s October 2026 re-test found, the PyTrends GitHub repository was archived in April 2025, so bugs will not be fixed.
  • Four methods (trending, today’s and realtime searches, and top charts) now return errors, and the historical hourly method was removed. TrendSpy or the Trending now RSS feed cover some gaps.
  • Rate limits (HTTP 429) are strict, so back off and retry politely.
  • Trends data is relative (0 to 100) and sampled, so values can shift between pulls and do not show absolute volume.
  • Google has launched an official Google Trends API in alpha, available by application. Treat PyTrends as an exploration tool, not a foundation for a client product.

Learn it on MLforSEO

Where PyTrends (Google Trends API) shows up on MLforSEO

Sources and further reading

Other terms from APIs

See all 15 APIs terms →