PyLatestTrends
PyLatestTrends is a Python library that allows you to fetch and analyze trending topics from Google Trends. Whether you're building a data analytics dashboard, content pipeline, or market intelligence tool, this package provides a simple interface to extract trending keywords by country, category, time period, and relevance.
🚀 Features
- 📈 Scrape trends going on in countries from Google Trends in real time.
- 🌍 Filter by country (using ISO codes) for localized trends.
- 🕒 Customize time ranges like last 4 hours, 24 hours, or 7 days.
- 🗂 Sort by volume, recency, or relevance.
- 🧠 Filter by specific categories (e.g., Technology, Business, Health).
- 🐍 Built for data science — returns results in a Pandas DataFrame.
- 🔍 Optional logging for debugging or verbose insights.
📦 Installation
pip install pylatesttrends
🧑💻 Quick Start
You can start by plucking in only this code and you will be able to get the trends.
from pylatesttrends import generate_payload, get_trends
# Create payload for the US
payload = generate_payload("US")
# Fetch trending data
result = get_trends(payload)
# View DataFrame
print(result.head())
⚙️ Parameters & Customization
You can customize the generate_payload() function with the following options:
geo (Required)
The ISO 3166-1 alpha-2 country code to fetch trends from.
payload = generate_payload("US")
Full list of supported ISO codes (e.g., US, IN, GB, DE, JP) is provided below.
start_trending
Filter trends based on time when they started trending.
payload = generate_payload("US", start_trending="48h")
Valid time options:
4h, 24h, 48h, 7d
category
Choose a trend category to narrow the results.
payload = generate_payload("US", category="Technology")
Available categories:
Autos and Vehicles, Beauty and Fashion, Business and Finance, Climate, Entertainment, Food and Drink,
Games, Health, Hobbies and Leisure, Jobs and Education, Law and Government, Other, Pets and Animals,
Politics, Science, Shopping, Sports, Technology, Travel and Transportation
trend_status_active_trends
Include or exclude active trending status.
payload = generate_payload("US", trend_status_active_trends=True)
True: show only currently active trendsFalse: include historical or past-trending keywords
sort_by
Sort the results using various attributes:
payload = generate_payload("US", sort_by="recency")
Valid values:
title, search-volume, recency, relevance
base_url (Advanced)
Set a custom base URL for data scraping (for proxies or mirrors).
Set a custom base URL for data scraping (for proxies or mirrors).
Logging Option
Enable logging for insight into data retrieval:
result = get_trends(payload, "print") # or use "logging"
Output Format
The result returned from get_trends() is a pandas DataFrame containing:
- Trends: trend name
- Search volume: volume of the search
- Started: trend start time
- Ended: trend end time
- Trend breakdown: searches
- Explore link: trend explore link
Use Cases
Content Strategy: Discover trending topics in your region for blogs, YouTube, or news content. Market Research: Analyze shifts in consumer interest over time. Social Media: Track viral search terms to time your posts effectively. SEO Planning: Create keyword-rich content based on real-time demand.
Requirements
- Python 3.9+
- Selenium
- Pandas
- Webdriver Manager
(Dependencies are installed automatically with pip.)
Example: Get Trending Tech Topics in United States Over Last 24 Hours
payload = generate_payload("US", category="Technology", start_trending="24h")
df = get_trends(payload, "logging")
print(df[['Trends', 'Search volume', 'Explore link']])
Links
Contributing
Contributions are welcome! Open issues, fork the repo, and submit pull requests.
License
This project is licensed under the GNU General Public License v3 (GPLv3) License.
Metadata
Release files for pylatesttrends 0.1.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pylatesttrends-0.1.7.tar.gz | 20.5 kB | With provenance | Details for pylatesttrends-0.1.7.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pylatesttrends-0.1.7-py3-none-any.whl | Python 3 | none | any | Details for pylatesttrends-0.1.7-py3-none-any.whl |
Total release size: 39.4 kB
Release files / pylatesttrends-0.1.7.tar.gz
| Download URL | pylatesttrends-0.1.7.tar.gz |
|---|---|
| Size | 20.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9f07714ef3315904bc4b6422c8639509c77acd9668dab72866ba5eb357fea2ca
|
|
BLAKE2b-256 checksum How to use checksums |
b7d17ce6c78a4cbc864ee86710ba8f07080cf18296dd1f8af0366e5bf147cd61
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 8, 2025.
Transparency logRelease files / pylatesttrends-0.1.7-py3-none-any.whl
| Download URL | pylatesttrends-0.1.7-py3-none-any.whl |
|---|---|
| Size | 18.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8f38480a2bbea6e5670e3a9c17ec4df7929d7adfd2415ab034789fc59da13fa8
|
|
BLAKE2b-256 checksum How to use checksums |
5494fa1397dfa9d9e5022af47962a14ca47e4d509cfa5fde9188df34591e0929
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 8, 2025.
Transparency logSecurity for pylatesttrends 0.1.7
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for pylatesttrends-0.1.7.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 8, 2025.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.