Skip to main content

Google Trends CLI Tool

Google Trends CLI Logo

PyPI version License Build status Python versions

A powerful tool for fetching and analyzing Google Trends data, available as both a command-line tool and an HTTP API. Specially designed for content creators looking to identify what topics are worthy of writing about right now.

Note: For a list of known issues and limitations, see KNOWN_ISSUES.md.


โœจ Features

  • ๐Ÿ“ˆ Real-time Trends: Access trending searches with a simple command
  • ๐Ÿ” Deep Analysis: Explore related topics and queries for any search term
  • ๐Ÿ“Š Comparative Insights: Compare interest across different topics and timeframes
  • โœ๏ธ Writer Suggestions: Get data-driven content ideas specifically for writers
  • ๐Ÿ“ฑ Geographic Analysis: See how trends vary by region, country, or city
  • ๐Ÿ“‰ Independent Normalization: Track hundreds of topics with individual trend lines
  • ๐Ÿ“ฐ News Integration: Find trending topics with associated news articles
  • ๐Ÿ“ Multiple Export Formats: Save data as CSV, JSON, or Excel files with enhanced JSON structure
  • ๐Ÿ–ผ๏ธ Visual Reporting: Generate high-quality trend visualizations with matplotlib
  • ๐ŸŒ HTTP API: Access all functionality via a RESTful API
  • ๐Ÿ”„ Environment Configuration: Easily configure for development, testing, or production
  • ๐Ÿณ Docker Support: Deploy as containerized services with health checks and security
  • ๐Ÿงช Comprehensive Testing: Extensive unit and integration test coverage
  • ๐Ÿ›ก๏ธ Quality Assurance: Built-in tooling for code quality and security checks

๐Ÿง  Architecture

The project follows a modern service-oriented architecture with clear separation of concerns:

google-trends-cli/
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ gtrends_core/        # Core business logic library
โ”‚   โ”œโ”€โ”€ gtrends_cli/         # CLI presentation layer
โ”‚   โ””โ”€โ”€ gtrends_api/         # HTTP API layer
โ”œโ”€โ”€ tests/
โ”‚   โ”œโ”€โ”€ unit/                # Unit tests
โ”‚   โ””โ”€โ”€ integration/         # Integration tests
โ”œโ”€โ”€ config/                  # Environment configurations
โ”œโ”€โ”€ docker/                  # Docker configuration
โ””โ”€โ”€ scripts/                 # Utility scripts

This architecture enables:

  • Independent Development: Core logic can be tested and developed separately
  • Multiple Interfaces: CLI and API layers share the same core logic
  • Easy Extension: Add new interfaces without modifying business logic
  • Robust Testing: Comprehensive test coverage across all layers

๐ŸŒ API Access

All functionality is available through an HTTP API, making it easy to integrate Google Trends data into your applications:

# Start the API server
gtrends-api

# By default, the API runs on http://localhost:8000

API Endpoints

Endpoint Description
/api/v1/trending Get trending searches
/api/v1/related/topics Find related topics
/api/v1/related/queries Find related queries
/api/v1/comparison Compare interest across topics
/api/v1/suggestions Get content creation suggestions
/api/v1/opportunities Find writing opportunities
/api/v1/growth Track growth for multiple topics
/api/v1/geo Analyze geographic distribution
/api/v1/health API health check
/api/docs Interactive API documentation

For detailed API documentation, visit the /api/docs endpoint when the server is running.

๐Ÿš€ Installation

Quick Install

# Basic installation (CLI only)
pip install gtrends-cli

# Installation with API support
pip install "gtrends-cli[api]"

# Installation with all dependencies (API + production + development)
pip install "gtrends-cli[all]"

Using the Setup Script

For convenience, you can use the provided setup script:

# Clone the repository
git clone https://github.com/Nao-30/google-trends-cli.git
cd google-trends-cli

# Make the script executable
chmod +x scripts/setup.sh

# Run the setup script (development environment)
./scripts/setup.sh

From Source

# Clone the repository
git clone https://github.com/Nao-30/google-trends-cli.git
cd google-trends-cli

# CLI only
pip install .

# With API support
pip install ".[api]"

# With development dependencies
pip install ".[dev]"

# With production dependencies
pip install ".[prod]"

# With all dependencies
pip install ".[all]"

Docker

# Using docker-compose (recommended)
cd google-trends-cli/docker
docker-compose up -d

# Or pull and run the API image directly
docker pull nao30/gtrends-api:latest
docker run -p 8000:8000 nao30/gtrends-api:latest

For more detailed installation instructions, see the Installation Guide.

๐Ÿงช Development and Testing

The project includes comprehensive tools for development and testing:

# Setup development environment
./scripts/setup.sh

# Run all tests with coverage
./scripts/test.sh

# Run only unit tests
./scripts/test.sh --unit-only

# Run only integration tests
./scripts/test.sh --integration-only

# Run only linting checks
./scripts/test.sh --lint-only

# Deploy to production (requires configuration)
./scripts/deploy.sh --target=docker --env=production

๐Ÿ”ง Configuration

The project supports multiple environment configurations:

# Set environment (development, testing, production, docker)
export GTRENDS_ENV=development

# Configuration files are in the config/ directory:
# - development.yml: Development settings
# - testing.yml: Test settings
# - production.yml: Production settings
# - docker.yml: Docker deployment settings

๐Ÿ’ป Quick Start

# Show trending searches
gtrends trending

# Get content suggestions for creators
gtrends suggest-topics

# Find writing opportunities
gtrends writing-opportunities

๐Ÿ“– Usage Examples

Basic Commands

# Show trending searches
gtrends trending

# Show trending searches with news articles
gtrends trending --with-articles

# Show topics and queries related to a term
gtrends related topics "book publishing"
gtrends related queries "book publishing"

# Compare interest in multiple topics
gtrends compare "fiction books" "non-fiction books" "poetry"

# Get content suggestions for writers
gtrends suggest-topics --category=books

# Find writing opportunities
gtrends writing-opportunities "science fiction" "fantasy"

# Analyze growth patterns for topics (up to 500+ topics)
gtrends topic-growth "science fiction" "fantasy" "romance" "mystery" --period=24h

# Show geographic interest distribution
gtrends geo-interest "literature" --resolution=COUNTRY

# Search for category IDs
gtrends categories --find=book

# Search for location codes
gtrends geo "middle east"

# Show supported timeframe formats
gtrends help-timeframe

For Content Creators

Commands specially designed for content creators looking to identify trending topics:

# Get topic suggestions in the books category
gtrends suggest-topics --category=books --region=US

# Find specific writing opportunities based on rising trends
gtrends writing-opportunities "book publishing" "fiction" --count=10

# Compare interest in publishing trends over time with visualization
gtrends compare "self-publishing" "traditional publishing" --visualize

# Monitor rapid growth patterns for genres (independently normalized)
gtrends topic-growth "mystery" "thriller" "romance" "sci-fi" "fantasy" --period=7d

Export Options

# Export trending searches to CSV (default)
gtrends trending --export

# Export to a specific location and format
gtrends suggest-topics --export --export-path="~/my-projects" --format=json

# Generate visualization and export data
gtrends compare "poetry" "prose" "fiction" --export --visualize

# Export comparison data with enhanced JSON structure
gtrends compare "fiction" "non-fiction" --export --format=json

๐Ÿ“‹ Available Commands

Command Description
trending Show current trending searches
related Find related topics and queries
suggest-topics Get content creation suggestions
compare Compare interest across topics
writing-opportunities Find specific writing opportunities
topic-growth Track growth for multiple topics
geo-interest Analyze geographic distribution
categories List available content categories
geo Search for location codes
help-timeframe Show timeframe format help

โš™๏ธ Common Options

Option Description
--region, -r Region code (e.g., US, GB, AE)
--count, -n Number of results to display
--timeframe, -t Time range (e.g., 'now 1-d', 'today 3-m')
--export, -e Export results to file
--export-path Directory to save exported data
--format, -f Export format (csv, json, xlsx)
--visualize, -v Generate visualization

๐Ÿ•’ Timeframe Formats

Standard formats:    'now 1-H', 'today 3-m', 'today 12-m'
Custom intervals:    'now 123-H', 'today 45-d', 'today 18-m'
Date-based:          '2024-02-01 10-d', '2024-01-01 2024-12-31'
Hourly precision:    '2024-03-25T12 2024-03-25T15'
All available data:  'all'

๐Ÿ“ˆ Version History

For a complete list of changes, see the Changelog.

  • 0.3.0: Comprehensive testing, Docker containerization, environment configuration, quality assurance
  • 0.2.0: Service-oriented architecture, API access, enhanced visualization
  • 0.1.x: Initial release with core functionality

๐Ÿ‘ฅ Authors

This project is brought to you by:

Top contributors:

contrib.rocks image

(back to top)

๐Ÿ‘ฅ Contributing

Contributions are welcome! Please check the Contributing Guide for details.

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

Download files

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

Source Distribution

gtrends_cli-0.3.5.tar.gz (2.2 MB view details)

Uploaded Source

Built Distribution

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

gtrends_cli-0.3.5-py3-none-any.whl (82.3 kB view details)

Uploaded Python 3

File details

Details for the file gtrends_cli-0.3.5.tar.gz.

File metadata

  • Download URL: gtrends_cli-0.3.5.tar.gz
  • Upload date:
  • Size: 2.2 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.23

File hashes

Hashes for gtrends_cli-0.3.5.tar.gz
Algorithm Hash digest
SHA256 e172c26d4e257593d9eb2532e1302ed0d98cc4ad6f1e8a264ff0da858567014f
MD5 c5553d89800ce23fff5872b022d7b0d0
BLAKE2b-256 ead4dff5580cdd56533f2906ced6d4a13c00abbdac600c7af67c087abcbc0cf9

See more details on using hashes here.

File details

Details for the file gtrends_cli-0.3.5-py3-none-any.whl.

File metadata

  • Download URL: gtrends_cli-0.3.5-py3-none-any.whl
  • Upload date:
  • Size: 82.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.23

File hashes

Hashes for gtrends_cli-0.3.5-py3-none-any.whl
Algorithm Hash digest
SHA256 2af8091a4dd74caed43e202ccd268bd1314ca83528a6156f02aa2fd8b5740362
MD5 c7b3227bf78a745ce6aaf001ee58542d
BLAKE2b-256 26ef985540ef6ab50bcfc04d7366b8fa7ebc6d5fed6aa8251fe6faac48969182

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.3.5 This release

2 files

0.3.4

2 files

0.3.2

2 files

0.3.0

2 files

0.1.3

2 files

0.1.2

2 files

0.1.1

2 files

Supported by

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