Skip to main content

A type-safe Python library for querying, streaming, and exporting Google Trends data

Project description

Trendflow logo

Trendflow

PyPI version

A type-safe Python library for querying, streaming, and exporting Google Trends data

Features

  • Type-safe API: regions, timeframes, resolutions, and export formats use enums instead of raw strings.
  • Rich queries: interest over time, regional breakdown, live trending searches, and related queries, with dataclass results.
  • Exports: JSON, CSV, or load results into a pandas DataFrame.

Usage

import trendflow
from trendflow import Region, Timeframe, Resolution, ExportFormat

# Initialize client (optional API config)
tf = trendflow.Client(language="en", timeout=10)

# --- Enums for type safety ---
# Region.US, Region.GB, Region.DE ...
# Timeframe.PAST_DAY, Timeframe.PAST_WEEK, Timeframe.PAST_YEAR, Timeframe.PAST_5_YEARS
# Resolution.COUNTRY, Resolution.REGION, Resolution.CITY

# Fetch interest over time
data = tf.interest_over_time(
    keywords=["Python", "JavaScript", "Rust"],
    timeframe=Timeframe.PAST_YEAR,
    region=Region.US,
)

# Dataclass-backed results
print(data.keywords)        # ["Python", "JavaScript", "Rust"]
print(data.granularity)     # "weekly"
print(data.points)          # list of TrendPoint(date, scores: dict)

# Get regional breakdown (region defaults to Region.US)
regional = tf.interest_by_region(
    keyword="Python",
    resolution=Resolution.COUNTRY,
)

# Trending searches right now
trending = tf.trending_now(region=Region.US)
for item in trending.results:
    print(item.title, item.traffic, item.articles)  # TrendingItem dataclass

# Related queries — returns RelatedResult dataclass
related = tf.related_queries("machine learning")
for query in related.top:
    print(query.term, query.value)    # RelatedQuery(term, value)
for query in related.rising:
    print(query.term, query.breakout) # RelatedQuery(term, breakout%)

# --- Exports ---
data.export(ExportFormat.CSV,  path="trends.csv")
data.export(ExportFormat.JSON, path="trends.json")
data.to_dataframe()  # pandas DataFrame

Documentation

Documentation is built with Zensical and deployed to GitHub Pages.

API documentation is auto-generated from docstrings using mkdocstrings.

Docs deploy automatically on push to main via GitHub Actions.

Development

To set up for local development:

# Clone your fork
git clone git@github.com:dariomory/trendflow.git
cd trendflow

# Install in editable mode with live updates
uv tool install --editable .

This installs the CLI globally but with live updates - any changes you make to the source code are immediately available when you run trendflow.

Run tests:

uv run pytest

Run quality checks (format, lint, type check, test):

just qa

Author

Trendflow was created in 2026 by Dario Mory

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

trendflow_py-0.1.0.tar.gz (181.3 kB view details)

Uploaded Source

Built Distribution

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

trendflow_py-0.1.0-py3-none-any.whl (17.4 kB view details)

Uploaded Python 3

File details

Details for the file trendflow_py-0.1.0.tar.gz.

File metadata

  • Download URL: trendflow_py-0.1.0.tar.gz
  • Upload date:
  • Size: 181.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for trendflow_py-0.1.0.tar.gz
Algorithm Hash digest
SHA256 3e1ee408e7dadd89a51c6991345e33c1b4437538d84804c5618f417ba8f57f41
MD5 24d9051bd0254b90cfe12205423f22b7
BLAKE2b-256 158a1f7fdf11e3290aafeab0a7645122913acf85585b806a2c38970ffce027ee

See more details on using hashes here.

Provenance

The following attestation bundles were made for trendflow_py-0.1.0.tar.gz:

Publisher: publish.yml on dariomory/trendflow

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file trendflow_py-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: trendflow_py-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 17.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for trendflow_py-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1fd8e7ca01c8d353790d9e5e6782679d1479e2982a83c20c983f5ca2c46a7769
MD5 7709d85124ab27ea75e1801de9278037
BLAKE2b-256 d3724da6d4148bcebe663bf59397d8f1392d3ff6f8b71726a78b699c2daf0a32

See more details on using hashes here.

Provenance

The following attestation bundles were made for trendflow_py-0.1.0-py3-none-any.whl:

Publisher: publish.yml on dariomory/trendflow

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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