Key Takeaway: To pull Twitter (X) trending topics via API in 2026, send a GET request with a WOEID (Where On Earth IDentifier) for the location you want. The official X API v2 exposes GET /2/trends/by/woeid/{woeid} on paid tiers using a Bearer Token. Faster path: the Sorsa /trends endpoint returns the same trend list plus a ready-to-use search query, authenticated with a single API key.
Twitter trending topics are one of the few real-time signals on the open internet that reflect what hundreds of millions of people are paying attention to right now. Marketing teams use them to time campaigns, news desks use them to spot breaking stories, and analytics platforms use them to surface emerging conversations. The trouble is that pulling them programmatically in 2026 is more fragmented than most online tutorials suggest.
This guide explains exactly what is available today, how WOEID-based trend retrieval works, and how to fetch trending topics for any country or city without OAuth setup, app review, or a five-figure monthly contract. The Sorsa Twitter API handles all of this through a single endpoint and a single API key, and we will walk through how to use it with working code in Python, Node.js, and curl, plus a full WOEID reference table.
Most existing tutorials are 2-3 years out of date and still reference Tweepy with OAuth 1.0a, an authentication flow that no longer applies to trends in the current API. The information below reflects what actually works in April 2026.
Table of Contents
- What Is the Twitter Trends API?
- Twitter Trends API Options in 2026
- How WOEID Works (And Why You Need It)
- Getting Twitter Trends with the Sorsa API
- WOEID Reference: Top Countries and Cities
- Code Examples: Python, Node.js, and curl
- Combining Trends with Search for Deeper Analysis
- Use Cases for the Twitter Trends API
- Rate Limits, Caching, and Best Practices
- FAQ
What Is the Twitter Trends API?
A Twitter trends API is any HTTP endpoint that returns the list of currently trending topics on X (formerly Twitter) for a given geographic area. A typical response is an ordered list of around 20 to 50 items per region.
Trends are not personalized when accessed through an API. They reflect the platform-wide, location-scoped trends that X computes for each region, which is what you want for analytics. The personalized "Trends for you" view shown on the X website is a separate system and is not exposed through any API.
The trend list is recomputed by X every few minutes. For most polling workloads, fetching trends every 5 to 15 minutes is enough to catch new items as they emerge.
Twitter Trends API Options in 2026
There are two practical paths to get trending topics through code in 2026.
Option 1: Official X API v2
X exposes a trends endpoint at GET /2/trends/by/woeid/{woeid}. It accepts a WOEID as a path parameter and returns up to 50 trends per region. Each trend object contains:
trend_name: the display name of the trending topictweet_count: optional integer, the number of posts in the trend (only returned when explicitly requested via thetrend.fieldsparameter)
Authentication uses a Bearer Token, which means signing up for an X developer account, registering an app, and being on a paid tier of the X API. The trends endpoint is not part of the Free tier, and pricing for the official X API has shifted significantly over the past two years (see our breakdown of X API pricing in 2026).
The official endpoint returns the trend name and an optional volume figure, which is useful when you specifically need volume estimates straight from X. To pull the actual posts behind a trending topic, you have to construct your own search syntax and call the search endpoint separately.
Option 2: Sorsa Trends Endpoint
The Sorsa /trends endpoint is built around a different priority: making trend data immediately useful in the next step of your pipeline. The response includes the trend name plus a pre-built search query and a direct URL, so you can flow straight into deeper analysis without writing query-construction code.
Authentication is a single API key in the ApiKey header. There is no OAuth flow, no app registration, no developer review. Sign up, copy a key, send the request.
Pricing is flat per request across every endpoint, including trends. One trend list fetch costs the same as one user lookup or one search call. On the Pro plan ($199/month for 100,000 requests), that works out to roughly $0.002 per trend list fetch.
The rest of this guide walks through using the Sorsa endpoint specifically, with examples that go all the way from raw trends to actionable post-level data in a few lines of code.
How WOEID Works (And Why You Need It)
WOEID stands for Where On Earth IDentifier. It is a numeric ID that Yahoo originally assigned to geographic places to make geocoding consistent across services. Twitter adopted WOEIDs for its trends API around 2010 and never moved off them, even after Yahoo retired the service.
A WOEID identifies a single place. Some examples:
1is "Worldwide" (global trends)23424977is the United States2459115is New York City23424975is the United Kingdom44418is London
There are roughly 470 valid trend WOEIDs across about 60 countries. Country-level IDs (placeType code 12) cover the entire country, while town-level IDs (placeType code 7) cover a single metro area. Not every country has town-level trends; smaller markets typically only return a single country-wide list.
You only need to know the WOEID for the location you care about. There is no separate authentication step for different regions, and no per-region pricing. If you know the integer, you can fetch its trends.
A complete WOEID list for X-supported trend locations is maintained as a public gist on GitHub. The most common WOEIDs are listed in the reference table below, but for anything beyond the top markets you will want the full list.
Getting Twitter Trends with the Sorsa API
The Sorsa trends endpoint takes a single query parameter, woeid, and returns a list of trend objects.
Request:
GET https://api.sorsa.io/v3/trends?woeid=23424977
Header: ApiKey: YOUR_API_KEY
Response:
{
"trends": [
{
"name": "#FedDecision",
"query": "%23FedDecision",
"url": "https://twitter.com/search?q=%23FedDecision"
},
{
"name": "Powell",
"query": "Powell",
"url": "https://twitter.com/search?q=Powell"
},
{
"name": "rate cut",
"query": "%22rate+cut%22",
"url": "https://twitter.com/search?q=%22rate+cut%22"
}
]
}
Each trend object has three fields:
name: the human-readable label of the trending topic. Display this in your UI.query: the URL-encoded search string. Pass it directly to the Sorsa search endpoint to retrieve actual posts about the trend.url: a direct link to the X search results page. Useful for embedding clickable references in dashboards or alerts.
The endpoint returns the current trend list at the moment of the request. There is no historical mode and no pagination. To build a historical record, poll on your own schedule and store the results.
WOEID Reference: Top Countries and Cities
The table below covers the most common WOEIDs we see in production. For the complete list of all locations X supports for trends, refer to the public WOEID gist, which has all ~470 entries.
Global
| Location | WOEID |
|---|---|
| Worldwide | 1 |
Countries
| Country | WOEID |
|---|---|
| United States | 23424977 |
| United Kingdom | 23424975 |
| Canada | 23424775 |
| Australia | 23424748 |
| Germany | 23424829 |
| France | 23424819 |
| Spain | 23424950 |
| Italy | 23424853 |
| Netherlands | 23424909 |
| Sweden | 23424954 |
| Brazil | 23424768 |
| Mexico | 23424900 |
| Argentina | 23424747 |
| Japan | 23424856 |
| Korea | 23424868 |
| India | 23424848 |
| Indonesia | 23424846 |
| Singapore | 23424948 |
| Turkey | 23424969 |
| Saudi Arabia | 23424938 |
| United Arab Emirates | 23424738 |
| South Africa | 23424942 |
| Nigeria | 23424908 |
| Russia | 23424936 |
| Ukraine | 23424976 |
Major Cities
| City | WOEID |
|---|---|
| New York | 2459115 |
| Los Angeles | 2442047 |
| Chicago | 2379574 |
| San Francisco | 2487956 |
| Washington | 2514815 |
| Toronto | 4118 |
| London | 44418 |
| Manchester | 28218 |
| Dublin | 560743 |
| Paris | 615702 |
| Berlin | 638242 |
| Munich | 676757 |
| Madrid | 766273 |
| Barcelona | 753692 |
| Rome | 721943 |
| Milan | 718345 |
| Amsterdam | 727232 |
| Stockholm | 906057 |
| Tokyo | 1118370 |
| Osaka | 15015370 |
| Seoul | 1132599 |
| Singapore | 1062617 |
| Mumbai | 2295411 |
| Delhi | 20070458 |
| Bangalore | 2295420 |
| Jakarta | 1047378 |
| Sydney | 1105779 |
| Melbourne | 1103816 |
| São Paulo | 455827 |
| Rio de Janeiro | 455825 |
| Buenos Aires | 468739 |
| Mexico City | 116545 |
| Istanbul | 2344116 |
| Riyadh | 1939753 |
| Dubai | 1940345 |
| Cairo | 1521894 |
| Lagos | 1398823 |
| Johannesburg | 1582504 |
| Moscow | 2122265 |
| Saint Petersburg | 2123260 |
| Kyiv | 924938 |
For the rest, including smaller cities and regional markets, use the full WOEID gist.
Code Examples: Python, Node.js, and curl
These examples all hit the same endpoint and produce the same response. Pick the one that matches your stack.
curl
The simplest possible call. Useful for testing and for cron-driven shell scripts.
curl -H "ApiKey: YOUR_API_KEY" \
"https://api.sorsa.io/v3/trends?woeid=23424977"
Python
Plain requests, no SDK needed.
import requests
API_KEY = "YOUR_API_KEY"
BASE_URL = "https://api.sorsa.io/v3"
def get_trends(woeid: int) -> list[dict]:
response = requests.get(
f"{BASE_URL}/trends",
params={"woeid": woeid},
headers={"ApiKey": API_KEY},
timeout=10,
)
response.raise_for_status()
return response.json()["trends"]
# US trends
us_trends = get_trends(23424977)
for trend in us_trends[:10]:
print(f"{trend['name']:30} {trend['url']}")
For a deeper Python walkthrough including async polling and rate-limit handling, see the Twitter API in Python guide.
Node.js
Using native fetch, available in Node 18+ without dependencies.
const API_KEY = "YOUR_API_KEY";
const BASE_URL = "https://api.sorsa.io/v3";
async function getTrends(woeid) {
const response = await fetch(
`${BASE_URL}/trends?woeid=${woeid}`,
{ headers: { ApiKey: API_KEY } }
);
if (!response.ok) {
throw new Error(`Trends request failed: ${response.status}`);
}
const data = await response.json();
return data.trends;
}
// London trends
const trends = await getTrends(44418);
trends.slice(0, 10).forEach(t => console.log(t.name));
Polling multiple regions in parallel
If you are tracking several markets at once, fire requests concurrently rather than serially. The Sorsa API allows up to 20 requests per second per API key across all endpoints, so a single key can fetch up to 20 region trend lists per second.
import asyncio
import httpx
API_KEY = "YOUR_API_KEY"
BASE_URL = "https://api.sorsa.io/v3"
REGIONS = {
"US": 23424977,
"UK": 23424975,
"DE": 23424829,
"FR": 23424819,
"JP": 23424856,
"BR": 23424768,
}
async def fetch_one(client, label, woeid):
r = await client.get(
f"{BASE_URL}/trends",
params={"woeid": woeid},
headers={"ApiKey": API_KEY},
)
return label, r.json()["trends"]
async def fetch_all():
async with httpx.AsyncClient(timeout=10) as client:
tasks = [fetch_one(client, l, w) for l, w in REGIONS.items()]
return dict(await asyncio.gather(*tasks))
results = asyncio.run(fetch_all())
for label, trends in results.items():
print(f"\n=== {label} ===")
for t in trends[:5]:
print(t["name"])
This pattern returns a snapshot of six regions in roughly the time of a single request.
Combining Trends with Search for Deeper Analysis
The trends endpoint tells you what is trending. It does not tell you why, who is driving the conversation, or what the sentiment looks like. For that, pair /trends with /search-tweets.
This is where the Sorsa response shape pays off. Each trend already includes a query field that is a valid search string, so you can pipe it straight into the search endpoint without any query-construction logic of your own.
The flow:
- Fetch trends for the WOEID you care about.
- For each trend that matches your interests (a competitor name, a product category, a topic keyword), pass the trend's
queryfield into the search endpoint. - Aggregate or analyze the resulting posts however you need (volume, sentiment, top accounts).
import requests
import urllib.parse
API_KEY = "YOUR_API_KEY"
BASE_URL = "https://api.sorsa.io/v3"
HEADERS = {"ApiKey": API_KEY}
def get_trends_with_posts(woeid: int, keyword_filter: str):
# Step 1: fetch trends
trends = requests.get(
f"{BASE_URL}/trends",
params={"woeid": woeid},
headers=HEADERS,
).json()["trends"]
# Step 2: filter and search
results = []
for t in trends:
if keyword_filter.lower() not in t["name"].lower():
continue
decoded_query = urllib.parse.unquote_plus(t["query"])
posts = requests.post(
f"{BASE_URL}/search-tweets",
json={"query": decoded_query, "order": "popular"},
headers=HEADERS,
).json()
results.append({"trend": t["name"], "posts": posts.get("tweets", [])})
return results
# Get US trends mentioning "AI" along with the top posts driving each
ai_trends = get_trends_with_posts(23424977, "AI")
This is the workflow that turns a raw trend list into actionable intelligence. For more on search query syntax, see the Sorsa search operators reference.
Use Cases for the Twitter Trends API
Trend data is one of those resources that looks decorative until you see it integrated into a real pipeline. Here are the patterns that drive most production usage.
Real-time content marketing. Social teams pull regional trends every 10 to 15 minutes, score them against the brand's voice rules, and surface the ones safe to engage with. The classic Oreo Super Bowl moment was a manual version of this. Every brand of any size now runs an automated pipeline of the same shape, with the trends API as the input layer.
Newsroom alerting. News desks set up watchlists tied to specific WOEIDs (a primary market plus a handful of bordering markets) and trigger Slack alerts when an unfamiliar topic enters the top ten. This catches breaking news 5 to 30 minutes faster than waiting for it to appear in news feeds.
Trading signal research. Quant teams pull trends in target markets every minute, cross-reference against ticker symbols and sector keywords, and feed the output into systematic strategies. Trending topics often precede the corresponding price move by tens of minutes, which makes them a useful signal layer.
Localized campaign planning. Agencies pull trends for every WOEID their client operates in (often 20 to 40 cities) once or twice a day to inform what creative to ship in each market. The output is usually a Google Sheet or BI dashboard rather than a real-time system.
SEO and keyword research. Trending phrases are often early signals for keyword categories that have not yet shown up in traditional SEO tools. Daily trend snapshots, diffed against the previous day, surface topics worth getting in front of.
Influencer discovery. A trend tells you a phrase is hot. Combining it with the search endpoint and ranking accounts by engagement on those posts tells you who the dominant voices are right now, which is more current than any static influencer database.
Brand crisis monitoring. Sudden appearance of a brand name or product in regional trends is often the earliest possible signal of a PR event. Polling every 5 minutes against a small set of WOEIDs gives you a cheap, reliable alarm.
In every one of these patterns, the actual API call to fetch trends is the cheap part. The hard work is what you do with the result.
Rate Limits, Caching, and Best Practices
A few practical notes for running this kind of workload at scale.
Cache aggressively. Trends do not change second by second. They change every few minutes at most. Caching trend results for 5 to 10 minutes per WOEID covers nearly all real use cases and reduces request volume by orders of magnitude. Redis with a TTL is the simplest implementation.
Respect the rate limit. The Sorsa API enforces 20 requests per second per API key across all endpoints, including /trends. Polling 20 regions every 30 seconds is fine. Polling 200 regions every second is not, and will return 429 Too Many Requests. For higher throughput, write to contacts@sorsa.io for a custom rate limit.
Handle empty trend lists gracefully. Some smaller WOEIDs occasionally return very short lists or empty arrays. This is normal and reflects the underlying X data rather than an API error. Code defensively.
Use the query field, not the name field, for search. The name is human-readable but may include characters that need escaping. The query is already URL-encoded and is exactly what X uses internally. When passing it into the Sorsa search endpoint, URL-decode it first, since the search endpoint expects unencoded text.
Schedule polls intelligently. When tracking 50 WOEIDs, do not fire all 50 requests at once on the minute boundary. Stagger them across a 30-second window to avoid burst-load problems and ease pressure on shared infrastructure.
For more on optimizing API request patterns at scale, see the docs page on optimizing API usage.
FAQ
Does the X API v2 have a trends endpoint?
Yes. The endpoint is GET /2/trends/by/woeid/{woeid}. It accepts a WOEID as a path parameter, returns up to 50 trends per region, and supports an optional tweet_count field via trend.fields. Authentication uses a Bearer Token, and access is gated to paid X API tiers.
What is the difference between the official X trends API and Sorsa?
The official X trends endpoint returns the trend name and an optional tweet count. The Sorsa endpoint returns the trend name, a pre-built search query, and a direct search URL. Authentication also differs: X requires a Bearer Token tied to a registered developer app, while Sorsa uses a single API key. For workflows that combine trends with search, the ready-made query field eliminates the step of constructing search syntax manually.
Is there a free Twitter trends API?
Free trend access through the official X API is not available in 2026. Sorsa offers paid plans starting from the Starter tier, with no free tier, but the per-request cost is low enough that small workloads cost a few dollars per month. See the pricing page for current numbers.
Can I get trends for a specific city?
Yes, if X supports trends for that city. Roughly 400 town-level WOEIDs are supported, covering most major metros worldwide. Smaller cities typically do not have their own trend list and fall back to country-level data. The WOEID gist lists every supported location.
How often do Twitter trends update?
The underlying trend list is recomputed by X every few minutes. New entries typically appear within 5 to 10 minutes of a topic gaining momentum. Polling more often than once per minute per WOEID is wasteful, since the response will rarely change.
Do trends include tweet volume or counts?
The Sorsa endpoint returns the trend name, search query, and URL. It does not return tweet volume per trend. To estimate volume for a specific trend, query the search endpoint with the trend's query and count the results over a time window, which is a more reliable measure than the volume figure X itself returns.
What is WOEID and is it still maintained?
WOEID is a numeric place identifier originally created by Yahoo. The Yahoo service that hosted WOEIDs is gone, so the URLs that used to be returned in trend responses (where.yahooapis.com/...) are dead. The numeric IDs themselves still work and are stable. X has not migrated off WOEIDs and shows no signs of doing so.
Can I get historical Twitter trends?
The trends API only returns current data. To build a historical record, poll regularly and store the results. A typical setup polls every 10 to 15 minutes per WOEID and writes each snapshot to a time-series database. After a few weeks the dataset is large enough for meaningful trend-of-trends analysis.
How do I find the WOEID for my country?
Check the reference table earlier in this article. If your country is not listed, search the full WOEID gist, which has every supported country and its main cities. If the target location is not in the gist, X does not have trend data for it at the API level.
Why do trend queries return URL-encoded strings?
The query field is encoded so it can be plugged directly into a search URL without further escaping. When passing it into a different API like the Sorsa search endpoint, decode it first with urllib.parse.unquote_plus in Python or decodeURIComponent in JavaScript.
Can I use trends to power a public dashboard?
Yes. The data is public information, and there is no usage restriction on displaying it. Two practical things to watch: cache results so you do not hit the API on every page load, and credit X as the source.
Getting Started
The fastest path to fetching your first trend list:
- Create an account at api.sorsa.io and grab an API key.
- Run the curl example above with your key and a WOEID like
1(Worldwide) or23424977(US). - Pair
/trendswith/search-tweetsfor deeper analysis as shown above.
For complete endpoint documentation, see the Sorsa API reference. For higher rate limits or custom region coverage, write to contacts@sorsa.io.
Last updated: April 28, 2026
Daniel Kolbassen is a data engineer and API infrastructure consultant with 12+ years of experience building data pipelines around social media platforms. He has worked with the Twitter/X API since the v1.1 era and writes about APIs, scraping, and social data engineering.