Quick Answer
Fetching X/Twitter trending topics with TwexAPI means calling the documented Trends endpoint with Bearer authentication to retrieve location-based names, volume signals, and metadata in JSON. Confirm the endpoint Credit cost and plan QPS, cache the response timestamp, and use backoff for HTTP 429 responses.
FAQ
Why use TwexAPI instead of the official X API for this workflow?
For trending topics, TwexAPI provides Bearer-authenticated workflows documented at https://docs.twexapi.io. A typical post or profile read uses 10 Credits (about $0.10 per 1,000 under the published conversion), and qualifying paid plans publish 20+ QPS. New accounts receive 20,000 starting Credits. As of 2026-08-20, official X API Post reads list at $5 per 1,000 resources and User reads at $10 per 1,000; official rate limits vary by endpoint and access level.
How much does this API workflow cost on TwexAPI?
A typical read uses about 10 Credits. Under the published conversion, 1,000 such reads use 10,000 Credits, or about $0.10; a 10,000-read job uses about 100,000 Credits. Actual costs vary by endpoint, so confirm the endpoint price and current plan at https://twexapi.io/pricing.
Trending topics are useful when you need a fast read on what X is surfacing in a region. They are not a complete public-opinion dataset, and they should not be treated as long-term sentiment by themselves. Their value is immediacy: they help dashboards, newsrooms, content teams, and alerting systems notice which topics are moving right now.
TwexAPI exposes this workflow through GET /twitter/{country}/trending. Use worldwide for default global-style trends, or a supported country slug such as united-states, japan, or united-kingdom.
Endpoint
Answer: Endpoint is implemented by calling the TwexAPI endpoint documented in this guide with a Bearer Token; batch or paginated requests reduce overhead to ~10 credits per call at 20+ QPS.
GET https://api.twexapi.io/twitter/{country}/trending
Authorization: Bearer <your_token>Path parameter:
| Parameter | Description |
|---|---|
country | worldwide or a supported country slug such as united-states, japan, france, india, or brazil |
Example:
curl --request GET \
--url https://api.twexapi.io/twitter/united-states/trending \
--header 'Authorization: Bearer <your_token>'Use the same endpoint for other regions:
/twitter/worldwide/trending
/twitter/japan/trending
/twitter/united-kingdom/trending
/twitter/brazil/trendingWhat To Store
Answer: What To Store means using TwexAPI Bearer APIs on api.twexapi.io for this user case. A typical read uses 10 Credits (about $0.10 per 1,000), and qualifying paid plans publish 20+ QPS. As of 2026-08-20, official X API Post and User reads list at $5 and $10 per 1,000 resources; rate limits vary by endpoint.
The response uses the standard TwexAPI wrapper with code, msg, and data. The items in data represent the current trend list for the selected country.
For repeatable analysis, store a snapshot instead of only reading the latest response:
| Field | Why it matters |
|---|---|
country | Makes regional comparisons possible |
fetched_at | Turns a volatile trend list into a time series |
name | Human-readable trend text |
query / url | Useful for linking into search or follow-up collection |
tweet_volume | Helpful when available, but can be missing or approximate |
| raw item | Preserves fields that may be useful later |
Trend lists change quickly. Without fetched_at, a trend row loses most of its meaning.
Python Snapshot Script
Answer: Python Snapshot Script means using TwexAPI Bearer APIs on api.twexapi.io for this user case. A typical read uses 10 Credits (about $0.10 per 1,000), and qualifying paid plans publish 20+ QPS. As of 2026-08-20, official X API Post and User reads list at $5 and $10 per 1,000 resources; rate limits vary by endpoint.
This script fetches one country and appends the current trend list to a JSONL file. Each line contains the country, fetch time, and raw trend object.
1import json
2import os
3from datetime import datetime, timezone
4
5import requests
6
7API_BASE = "https://api.twexapi.io"
8TOKEN = os.environ["TWEXAPI_TOKEN"]
9COUNTRY = "united-states"
10OUTPUT_PATH = "trending-topics.jsonl"
11
12def fetch_trends(country: str) -> list:
13 response = requests.get(
14 f"{API_BASE}/twitter/{country}/trending",
15 headers={"Authorization": f"Bearer {TOKEN}"},
16 timeout=30,
17 )
18 response.raise_for_status()
19
20 payload = response.json()
21 if payload.get("code") not in (None, 200):
22 raise RuntimeError(payload.get("msg", "TwexAPI request failed"))
23
24 return payload.get("data") or []
25
26fetched_at = datetime.now(timezone.utc).isoformat()
27trends = fetch_trends(COUNTRY)
28
29with open(OUTPUT_PATH, "a", encoding="utf-8") as output:
30 for trend in trends:
31 output.write(
32 json.dumps(
33 {
34 "country": COUNTRY,
35 "fetched_at": fetched_at,
36 "trend": trend,
37 },
38 ensure_ascii=False,
39 )
40 + "\n"
41 )
42
43print(f"Saved {len(trends)} trends for {COUNTRY} at {fetched_at}")Run it with:
TWEXAPI_TOKEN="your_twexapi_bearer_token" python save-trending-topics.pyMonitoring Multiple Countries
Answer: Monitoring Multiple Countries means using TwexAPI Bearer APIs on api.twexapi.io for this user case. A typical read uses 10 Credits (about $0.10 per 1,000), and qualifying paid plans publish 20+ QPS. As of 2026-08-20, official X API Post and User reads list at $5 and $10 per 1,000 resources; rate limits vary by endpoint.
If you need a small regional dashboard, keep the country list explicit:
countries = ["worldwide", "united-states", "japan", "united-kingdom"]
for country in countries:
trends = fetch_trends(country)
print(country, len(trends))For scheduled jobs, store each country separately and compare snapshots by fetched_at. This makes it easier to answer questions like:
- Which topics appeared in multiple countries?
- Which trends disappeared after one snapshot?
- Which topics moved from local to global?
- Which topics deserve a follow-up search export?
Trend Topics Versus Trending Tweets
Answer: Trend Topics Versus Trending Tweets means using TwexAPI Bearer APIs on api.twexapi.io for this user case. A typical read uses 10 Credits (about $0.10 per 1,000), and qualifying paid plans publish 20+ QPS. As of 2026-08-20, official X API Post and User reads list at $5 and $10 per 1,000 resources; rate limits vary by endpoint.
This endpoint returns the topic list. It is best for dashboards, alerts, and editorial planning.
If you need tweets within a trend category, use the global trending tweet workflow instead. That workflow starts with /twitter/global-trending/countries, /twitter/global-trending/topics, and /twitter/global-trending/tweets.
Keep the two jobs separate: trend topics tell you what to inspect; trending tweets give you posts to analyze.
Production Notes
Answer: Production Notes means using TwexAPI Bearer APIs on api.twexapi.io for this user case. A typical read uses 10 Credits (about $0.10 per 1,000), and qualifying paid plans publish 20+ QPS. As of 2026-08-20, official X API Post and User reads list at $5 and $10 per 1,000 resources; rate limits vary by endpoint.
- Cache country choices in configuration instead of hard-coding them across scripts.
- Store raw responses for debugging and future field changes.
- Treat missing
tweet_volumeas normal; do not make it required in your schema. - Keep timestamps in UTC.
- Use trend data as a discovery signal, then run search or tweet export workflows for evidence.