5 minutes

How to Track Twitter Trends in Real Time

Monitor trending topics globally and by location. Build trend dashboards, detect breaking news, and spot viral content early.

1

Get your API key

Sign up at scrapebadger.com and grab your API key.

2

Fetch global trends

Get the current trending topics across all of Twitter.

from scrapebadger import ScrapeBadger

sb = ScrapeBadger(api_key="YOUR_API_KEY")
trends = sb.twitter.trends.get(category="trending", count=20)

for t in trends["data"]:
    print(f"{t['name']}: {t.get('tweet_volume', 'N/A')} tweets")
3

Get location-specific trends

Use WOEID codes to get trends for specific cities or countries.

# WOEID 23424977 = United States
us_trends = sb.twitter.trends.get_place("23424977")

# WOEID 2459115 = New York
ny_trends = sb.twitter.trends.get_place("2459115")

for t in us_trends["data"]:
    print(f"US Trending: {t['name']}")
4

Find WOEIDs for locations

Use the Geo Search endpoint to find WOEID codes for any location.

places = sb.twitter.geo.search(query="London")
for p in places["data"]:
    print(f"{p['name']}: WOEID {p['woeid']}")
5

Build a trend tracker

Schedule periodic trend fetches to build a historical trend database.

import time
import json
from datetime import datetime

while True:
    trends = sb.twitter.trends.get(category="trending")
    snapshot = {
        "timestamp": datetime.now().isoformat(),
        "trends": trends["data"]
    }
    with open("trend_history.jsonl", "a") as f:
        f.write(json.dumps(snapshot) + "\n")
    print(f"Saved {len(trends['data'])} trends at {snapshot['timestamp']}")
    time.sleep(300)  # Every 5 minutes

Frequently Asked Questions

Twitter updates trending topics every few minutes. We recommend polling every 5-15 minutes for trend tracking.

Twitter supports trends for most countries and major cities. Use Geo Search to check if your target location has a WOEID.

Tweet volume is the approximate number of tweets using that trend in the last 24 hours. Not all trends have volume data.

Yes. Monitor for rapid changes in trending topics. A new trend appearing with high volume often indicates breaking news.