Skip to main content

Free, open-source Python library for real-time Google Trends data with CLI and API - pytrends alternative with 188K+ configurations

Project description

trendspyg

PyPI version PyPI Downloads Python 3.8+ Tests License: MIT

Python library for downloading real-time Google Trends data. A modern alternative to the archived pytrends.

Using this library from a coding agent? See AGENTS.md for a concise, agent-ready reference.

Installation

pip install trendspyg

# With async support
pip install trendspyg[async]

# With CLI
pip install trendspyg[cli]

# All features
pip install trendspyg[all]

Quick Start

RSS Feed (Fast - 0.2s)

from trendspyg import download_google_trends_rss

# Get current trends with news articles
trends = download_google_trends_rss(geo='US')

for trend in trends[:3]:
    print(f"{trend['trend']} - {trend['traffic']}")
    if trend['news_articles']:
        print(f"  {trend['news_articles'][0]['headline']}")

CSV Export (Comprehensive - 10s)

from trendspyg import download_google_trends_csv

# Get 480+ trends with filtering (requires Chrome)
df = download_google_trends_csv(
    geo='US',
    hours=168,            # Past 7 days
    category='sports',
    output_format='dataframe'
)

Async (Parallel Fetching)

import asyncio
from trendspyg import download_google_trends_rss_batch_async

async def main():
    results = await download_google_trends_rss_batch_async(
        ['US', 'GB', 'CA', 'DE', 'JP'],
        max_concurrent=5
    )
    for country, trends in results.items():
        print(f"{country}: {len(trends)} trends")

asyncio.run(main())

CLI

trendspyg rss --geo US
trendspyg csv --geo US-CA --category sports --hours 168
trendspyg list --type countries

Data Sources

Feature RSS CSV
Speed 0.2s ~10s
Trends 5–25 (varies by region/time) 480+
News articles Yes No
Time filtering No Yes (4h/24h/48h/7d)
Category filter No Yes (20 categories)
Requires Chrome No Yes

Features

  • 125 countries + 51 US states
  • 20 categories (sports, tech, health, etc.)
  • 4 time periods (4h, 24h, 48h, 7 days)
  • 4 output formats (dict, DataFrame, JSON, CSV)
  • Async support for parallel fetching
  • Built-in caching (5-min TTL)
  • CLI for terminal access

Normalized output (for agents & pipelines)

Pass normalize=True to get one unified, JSON-native schema that is identical for both the RSS and CSV paths — no need to learn two different shapes.

from trendspyg import download_google_trends_rss

env = download_google_trends_rss(geo='US', normalize=True)
# {'schema_version': '1.0', 'source': 'rss', 'geo': 'US',
#  'fetched_at': '2026-05-22T...Z', 'count': 10, 'trends': [...]}

for t in env['trends']:
    print(t['rank'], t['keyword'], t['volume_min'])  # volume_min is a real int

Every trend has a fixed, JSON-safe shape: keyword, rank, volume_text, volume_min (int), started_at / ended_at (ISO 8601 or None), is_active, related_queries (list), news (list), image, explore_url. normalize=True works on every entry point — RSS, CSV, async, and the batch functions (each geo then maps to its own envelope) — and on the CLI (trendspyg rss --geo US --normalize). It is opt-in — default output is unchanged.

Caching

from trendspyg import clear_rss_cache, get_rss_cache_stats

# Results are cached for 5 minutes by default
trends = download_google_trends_rss(geo='US')  # Network call
trends = download_google_trends_rss(geo='US')  # From cache

# Bypass cache
trends = download_google_trends_rss(geo='US', cache=False)

# Check cache stats
print(get_rss_cache_stats())

# Clear cache
clear_rss_cache()

Documentation

Requirements

  • Python 3.8+
  • Chrome browser (for CSV export only)

License

MIT License - see LICENSE for details.

Links

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

trendspyg-0.5.1.tar.gz (55.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

trendspyg-0.5.1-py3-none-any.whl (35.8 kB view details)

Uploaded Python 3

File details

Details for the file trendspyg-0.5.1.tar.gz.

File metadata

  • Download URL: trendspyg-0.5.1.tar.gz
  • Upload date:
  • Size: 55.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.12

File hashes

Hashes for trendspyg-0.5.1.tar.gz
Algorithm Hash digest
SHA256 e2c387e0d6503d3040c929dba824cd1fab0e401c446fdff96a7a8f5bfac76980
MD5 0a230a639d46a1c9bc8d50afa27df393
BLAKE2b-256 b25940a46f6a2d751d9ae33428ce7c7f4eba0f19027e5912e02705ca736c72b3

See more details on using hashes here.

File details

Details for the file trendspyg-0.5.1-py3-none-any.whl.

File metadata

  • Download URL: trendspyg-0.5.1-py3-none-any.whl
  • Upload date:
  • Size: 35.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.12

File hashes

Hashes for trendspyg-0.5.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7871edb840d8aa5538e0d88497411690c35fc9b28ff1706a120aacb12fde9bc0
MD5 6e2839310e15b911060d5b1df2aac09c
BLAKE2b-256 741f4e9225ecf31d00108e7d8c162a365bc1b94d2a9f7f3769ffc235330eeb25

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page