Repository navigation
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
TrendReqwith the same method names, arguments and DataFrame shapes. Tests feed identical raw Google data to pytrends 4.9.2 and totrendspyg.compatand compare the frames under pandas 2 and 3. - One fetch per payload serves
interest_over_time,related_queries(for every compared keyword) andinterest_by_region, includinginc_low_vol=Trueand US metro areas (resolution="DMA"). trending_searches,today_searchesandrealtime_trending_searcheswork 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_exploreanddownload_google_trends_comparisonacceptengine=."auto"asks Google directly first and starts Chrome only if that fails;"http"never starts Chrome. The default stays"browser";trendspyg.compatuses"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 useengine="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]"