Skip to content

1.9.0 - pytrends code runs on trendspyg, and a faster opt-in engine

Latest

Choose a tag to compare

@flack0x flack0x released this 01 Oct 22:51

Existing pytrends code runs on trendspyg after changing its imports, and keyword analysis can now ask Google directly.

pytrends compatibility (trendspyg.compat)

from trendspyg.compat.request import TrendReq   # was: from pytrends.request import TrendReq
  • pytrends 4.9.2's TrendReq with the same method names, arguments and DataFrame shapes. Tests feed identical raw Google data to pytrends 4.9.2 and to trendspyg.compat and compare the frames under pandas 2 and 3.
  • One fetch per payload serves interest_over_time, related_queries (for every compared keyword) and interest_by_region, including inc_low_vol=True and US metro areas (resolution="DMA").
  • trending_searches, today_searches and realtime_trending_searches work again, from Google's Trending Now feed; in pytrends 4.9.2 they answer HTTP 404.
  • Not served, and each says so: related_topics() (Google serves that widget empty to automated sessions), top_charts() (endpoint retired), multirange, resolution="CITY". proxies= is refused rather than ignored. Regions Google reports without data are omitted where pytrends listed them as 0.
  • Guide: Migrating from pytrends. Requires trendspyg[analysis].

A direct engine, opt-in: engine="auto" / "http"

  • download_google_trends_interest_over_time, download_google_trends_explore and download_google_trends_comparison accept engine=. "auto" asks Google directly first and starts Chrome only if that fails; "http" never starts Chrome. The default stays "browser"; trendspyg.compat uses "auto".
  • Measured from one machine: 1-7 s per full question against 16-33 s per browser session, across worldwide/country/state geos, hourly to five-year ranges, YouTube, categories, topic IDs and comparisons.
  • Google still limits a machine: direct requests were refused after roughly a hundred in half an hour, and heavier use led to refusals for both engines. After a refusal, direct requests pause for five minutes. Do not loop.
  • Direct answers repeated each other exactly, but differed from browser answers by up to 7 points on the 0-100 scale, for reasons not yet established.
  • Direct requests follow HTTPS_PROXY / HTTP_PROXY; Chrome is not given the proxy, so use engine="http" to keep every request on a proxy.

Worth knowing: rising related queries for some keywords include searches unrelated to the keyword (for "coffee" in the US: "sports scores today", "home workout routines"), identically through every client tried on one machine. See Interpreting data.

Compatibility: existing calls behave as before: engine is a new last parameter defaulting to "browser". The root API stays at 49 names; no CLI, MCP tool or data-schema changes.

Validation: 925 offline tests pass with 98.57% coverage; all 22 module coverage floors pass. All 22 GitHub checks pass, including Python 3.8-3.13 on Linux, macOS and Windows, both MCP SDK lines, lint/type checks and the strict documentation build. Equivalence with pytrends 4.9.2 passes under pandas 3.0.6 and 2.3.3 (run locally; pytrends is not a dependency). Live: the pytrends README example through the browser engine; the direct engine (from source and from the installed wheel) through a rotating residential proxy. The built wheel was checked in a fresh environment with python -I: every installed source file matches the release commit.

Upgrade: pip install --upgrade "trendspyg[all]"