How to get X (Twitter) trending topics by country

2 endpoints do it: X trends → X post search. The worked example below is 3 calls and costs $0.0200 in all; a failed call is not charged.

Updated 2026-11-06Open in ChatGPTOpen in Claude

You get the top 30 trending topics on X (Twitter) with their rank, worldwide or for one of ten countries, and the posts behind any of them.

Paste this to your AI assistant

With DataXAPI connected to Claude, ChatGPT or Cursor, paste:

Use DataXAPI to get the current X trends for the US (region US) and worldwide (no region), and tell me which topics are on both lists. A trend is only a name and a rank, so match the names, and say when each list was taken (meta.fetched_at).

What the recorded calls returned

  • The worldwide list: 30 trends, ranked 1 to 30, on one page with no next page.
  • Each trend had a name and a rank and nothing else: no count of posts and no ID.
  • Searching posts on a trend gives 20 posts a page, with a next page.

Step 1: X trends

Leave region out for the worldwide list, or give a country's two-letter code: US, GB, CA, AU, IN, JP, DE, FR, BR or MX. Each item has name and rank; the next step takes a name.

curl "https://api.dataxapi.com/v1/x/trends/list" \
  -H "Authorization: Bearer $DATAXAPI_API_KEY"
# pip install dataxapi
from dataxapi import DataXAPI

dx = DataXAPI()  # reads DATAXAPI_API_KEY
result = dx.x.trends.list()
print(result["data"]["items"])
// npm i @dataxapi/sdk
import { DataXAPI } from "@dataxapi/sdk";

const dx = new DataXAPI(); // reads DATAXAPI_API_KEY
const result = await dx.x.trends.list();
console.log(result.data.items);
dataxapi call x.trends.list
Recorded response
{
  "code": "ok",
  "request_id": "86caa2be-f053-4926-a0ef-f572a73d938b",
  "data": {
    "items": [
      { "name": "Weekend hiking", "rank": 1 },
      // … 29 more
    ]
  },
  "page": {
    "next_cursor": null,
    "cursor_expires_at": null,
    "has_more": false,
    "returned": 30
  },
  "warnings": [],
  "meta": {
    "capability": "x.trends.list",
    "result_status": "complete",
    "fetched_at": "2026-10-13T03:29:53.000Z",
    "cached": false,
    "replayed": false,
    "unavailable": { "id": "platform", "heat": "capability" },
    "billing": {
      "amount": "0.009",
      "currency": "USD",
      "balance_after": "9.991"
    }
  }
}

From a response recorded 2026-10-13 03:29 UTC. Names, text and IDs are examples, and so are the links: none is the recorded one (the page shows no one's personal data); the figures are as recorded. Long lists are cut. The request ID, cursor and balance are made up.

X trends · $0.0090 / a call · Parameters, fields and errors on the endpoint's page →

Step 2: X post search

Search posts with a trend's name as query to see what is being said about it.

curl -G "https://api.dataxapi.com/v1/x/posts/search" \
  --data-urlencode "query=weather forecast" \
  -H "Authorization: Bearer $DATAXAPI_API_KEY"
# pip install dataxapi
from dataxapi import DataXAPI

dx = DataXAPI()  # reads DATAXAPI_API_KEY
result = dx.x.posts.search(query="weather forecast")
print(result["data"]["items"])
// npm i @dataxapi/sdk
import { DataXAPI } from "@dataxapi/sdk";

const dx = new DataXAPI(); // reads DATAXAPI_API_KEY
const result = await dx.x.posts.search({ query: "weather forecast" });
console.log(result.data.items);
dataxapi call x.posts.search 'query=weather forecast'
Recorded response
{
  "code": "ok",
  "request_id": "f56e2410-206b-4506-a850-44cf2be4613e",
  "data": {
    "items": [
      {
        "id": "1860387339653354774",
        "url": "https://x.com/i/status/1860387339653354774",
        "type": "video",
        "text": "My honest take on weather forecast, a month in.",
        "lang": "en",
        "published_at": "2026-10-12T00:44:12.000Z",
        "author": {
          "id": "118815899823132376",
          "username": "trail_and_lens",
          "name": "Maya Chen",
          "avatar_url": "https://pbs.twimg.com/profile_images/1838837416644987075/31t9r3Fm_normal.jpg",
          "verified": true,
          "followers": 7425
        },
        "metrics": {
          "likes": 238,
          "comments": 37,
          "favorites": 145,
          "views": 8357,
          "reposts": 121
        },
        "images": [],
        "hashtags": [],
        "mentions": [
          {
            "id": "124366312906800227",
            "username": "fieldnotes_studio",
            "name": "Field Notes Studio"
          }
        ],
        "post_id": null,
        "parent_id": null
      },
      // … 19 more
    ]
  },
  "page": {
    "next_cursor": "c1.0BcduLiC6vViwQfDR_nS6Twlb6kjko4Qpbx3fUDt",
    "cursor_expires_at": "2026-10-12T20:10:39.000Z",
    "has_more": true,
    "returned": 20
  },
  "warnings": [],
  "meta": {
    "capability": "x.posts.search",
    "result_status": "complete",
    "fetched_at": "2026-10-12T19:10:39.000Z",
    "cached": false,
    "replayed": false,
    "unavailable": {
      "title": "platform",
      "metrics.shares": "platform",
      "is_pinned": "capability",
      "root_id": "platform"
    },
    "billing": {
      "amount": "0.002",
      "currency": "USD",
      "balance_after": "9.998"
    }
  }
}

From a response recorded 2026-10-12 19:10 UTC. Names, text and IDs are examples, and so are the links: none is the recorded one (the page shows no one's personal data); the figures are as recorded. Long lists are cut. The request ID, cursor and balance are made up.

X post search · $0.0020 / a call · Parameters, fields and errors on the endpoint's page →

What the example costs

the worldwide list and the US list, then one page of posts on one trend

EndpointCallsPriceSubtotal
X trends2$0.0090$0.0180
X post search1$0.0020$0.0020
Total3$0.0200

Prices are the prices in force when this page was built. A failed call costs nothing.

In your AI (MCP)

Connect DataXAPI to your AI client once. Then say what you want; the agent finds these endpoints, checks the price and calls them on your balance.

Say: Use DataXAPI to get the current X trends in the US and worldwide, and tell me which topics are on both lists.
What the agent sends to the call tool
{
  "capability": "x.trends.list",
  "idempotency_key": "<a new UUID>"
}

Sign in to copy the setup prompt with your keyAbout the MCP server →

With a Skill

Why DataXAPI

  • Steady: endpoints were available 100% of the last 30 days, on a public status page you can check.
  • Fast: a paid call took 2.1 seconds at the median over the last 7 days (counted 2026-11-06).
  • Fewer tokens: across 21 endpoints on X (Twitter), one recorded real response each, the platform's own JSON comes to 247k tokens and what an AI reads through DataXAPI's MCP server to 60k, 76% fewer; the JSON of a direct API call is 61% fewer too (counted 2026-11-06). Every platform answers in one shape: the author in author, counts in metrics, the next page in page.next_cursor, so another platform needs no new parser.
  • See before you pay: every endpoint's page shows a recorded real response, field by field.
  • Spending you control: a failed call is not charged; each key can have a limit, X-Max-Price caps one call, and the same Idempotency-Key within 24 hours is never charged twice.
  • Ready for AI: a remote MCP server listed in the official MCP registry as com.dataxapi/mcp, usable from Claude, Cursor and ChatGPT.
  • Free trial of up to 333 calls, no card.

Good to know

  • A list is a snapshot refreshed every five minutes, and meta.fetched_at says when it was taken.
  • A trend has a name and a rank only: no count of posts, no heat and no ID.
  • Only these ten countries and worldwide are offered; any other code is refused as an invalid parameter and not run.