# X (Twitter) Trends by Country — Trending Topics & Hashtags (`istmobot/x-trends-by-country`) Actor

Get the trending topics and hashtags of X (Twitter) for any country, hour by hour, without an X account or API key. Input: countries. Output: one row per trend with country, rank, trend text, hashtag form, X search link and the hour it trended.

- **URL**: https://apify.com/istmobot/x-trends-by-country.md
- **Developed by:** [Istmobot](https://apify.com/istmobot) (community)
- **Categories:** Social media, News
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.80 / 1,000 trends

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## X (Twitter) Trends by Country — Trending Topics & Hashtags

See **what is trending on X (Twitter) in any country, right now and hour by hour**. Give a list of countries and get one row per trend with its rank, the trend text, a hashtag form you can reuse on other networks, and the link to the X search. No X account, no API key, no login.

### What is X Trends by Country?

X shows a list of up to 50 trending topics per country. This Actor returns that list for about 60 countries, including the ones most tools skip: Panama, Colombia, Argentina, Chile, Peru, the Dominican Republic, Guatemala and more. It can also return the lists of the previous hours, up to 24, to see which trends rise and which fade.

Use it to:

- **Find content ideas** from what a country is talking about today.
- **Feed other scrapers**: use the `hashtag` column as hashtags for TikTok, Instagram or YouTube to get the videos of each trend.
- **Monitor news and brands**: schedule a run every hour and get alerted when a name enters the list.
- **Compare markets**: the same hour in several countries, side by side.
- **Time your posts and campaigns** around live topics.

### What data can I get?

| Field | Meaning |
|---|---|
| `country`, `countryCode` | Country of the list, e.g. `Panama`, `PA` |
| `rank` | Position in the list, 1 = top trend |
| `trend` | The trend as X shows it, e.g. `#LaMansionVip` or `Sistema Penitenciario` |
| `isHashtag` | `true` when the trend is a hashtag |
| `hashtag` | The trend as one word without `#`, ready to use as a hashtag elsewhere |
| `xSearchUrl` | Link to the trend's posts on X |
| `hoursAgo` | 0 = latest list, 1 = one hour before, and so on |
| `trendingAt` | Date and time of that list (exact, or rounded to the hour, depending on the source) |
| `source` | Site the list was read from |
| `scrapedAt` | Date and time of the run |

### How much does it cost?

| Event | Price |
|---|---|
| Actor start | $0.005 per run |
| `trend` | $0.001 per trend, or **$1 per 1,000** |

Examples: the top 20 trends of 3 countries cost about **$0.065**. The full list of one country every hour for a day costs about **$1.30**. Countries with no trends and failed requests are not charged. You can set a **maximum cost per run**.

### How to use X Trends by Country

1. Click **Try for free**.
2. Type the countries, as 2-letter codes or English names.
3. Choose how many trends per country and how many hours of history.
4. Click **Start**, then download the dataset as CSV, Excel or JSON.

### ⬇️ Input

```json
{
    "countries": ["US", "PA", "Mexico"],
    "maxTrendsPerCountry": 20,
    "hours": 1
}
```

| Field | Default | Description |
|---|---|---|
| `countries` | required | 2-letter codes or English names. `worldwide` gives the global list |
| `maxTrendsPerCountry` | `50` | Trends per country and hour, from the top (1–50) |
| `hours` | `1` | 1 = latest list only; up to 24 for the hours before |

### ⬆️ Output

```json
{
    "country": "Panama",
    "countryCode": "PA",
    "rank": 4,
    "trend": "#LaMansionVip",
    "isHashtag": true,
    "hashtag": "LaMansionVip",
    "xSearchUrl": "https://x.com/search?q=%23LaMansionVip",
    "hoursAgo": 0,
    "trendingAt": "2026-11-12T08:08:06.273Z",
    "source": "trends24.in",
    "scrapedAt": "2026-11-12T08:44:10.120Z"
}
```

### From a trend to its videos

The `hashtag` column works as input for video scrapers. Example with [TikTok Scraper (cheap)](https://apify.com/istmobot/tiktok-scraper-cheap), which can also save the MP4 files:

```json
{
    "hashtags": ["LaMansionVip", "SistemaPenitenciario"],
    "resultsPerPage": 10,
    "shouldDownloadVideos": true
}
```

### Integrations & API

```bash
curl -X POST "https://api.apify.com/v2/acts/istmobot~x-trends-by-country/run-sync-get-dataset-items?token=YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"countries":["PA","CO"],"maxTrendsPerCountry":10}'
```

```python
from apify_client import ApifyClient

client = ApifyClient("YOUR_TOKEN")
run = client.actor("istmobot/x-trends-by-country").call(run_input={"countries": ["PA"], "maxTrendsPerCountry": 10})
hashtags = [r["hashtag"] for r in client.dataset(run["defaultDatasetId"]).iterate_items() if "hashtag" in r]
```

Schedule it hourly and send new trends to Slack, Google Sheets, Make or n8n.

### 🤖 Use with AI agents (MCP)

`https://mcp.apify.com?tools=istmobot/x-trends-by-country`. Example prompt: "What are the top 10 trends on X in Panama and Colombia right now, and which ones appear in both?"

### ❓ FAQ

**Do I need an X account or API key?** No.

**Which countries work?** The ones where X publishes trends, about 60. A country with no list returns a free row with `errorCode: UNSUPPORTED_COUNTRY`.

**Does it return the number of posts per trend?** No. X no longer publishes that number for most trends.

**Does it return the posts or videos of a trend?** No, the list of trends only. `xSearchUrl` opens the posts on X. For videos, use the `hashtag` column in a video scraper (see above).

**How fresh is the data?** The latest list is at most about one hour old. `trendingAt` shows its exact time.

**Can I get cities?** Not yet. Countries and the worldwide list.

### Your feedback

Missing a country or a field? Open an issue on the **Issues** tab.

# Actor input Schema

## `countries` (type: `array`):

Countries to get trends for, one per line: a 2-letter code ("US", "PA", "MX") or an English name ("Panama", "United Kingdom"). Use "worldwide" for the global list. About 60 countries have trends on X.

## `maxTrendsPerCountry` (type: `integer`):

How many trends to return per country for each hour, from the top, e.g. 20. X lists up to 50. You pay per trend.

## `hours` (type: `integer`):

1 returns the latest list. A higher number, up to 24, also returns the lists of the hours before, to see how trends rise and fall. Each hour is a full list, charged per trend.

## Actor input object example

```json
{
  "countries": [
    "US",
    "PA",
    "MX"
  ],
  "maxTrendsPerCountry": 20,
  "hours": 1
}
```

# Actor output Schema

## `results` (type: `string`):

No description

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "countries": [
        "US",
        "PA",
        "MX"
    ],
    "maxTrendsPerCountry": 20
};

// Run the Actor and wait for it to finish
const run = await client.actor("istmobot/x-trends-by-country").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "countries": [
        "US",
        "PA",
        "MX",
    ],
    "maxTrendsPerCountry": 20,
}

# Run the Actor and wait for it to finish
run = client.actor("istmobot/x-trends-by-country").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "countries": [
    "US",
    "PA",
    "MX"
  ],
  "maxTrendsPerCountry": 20
}' |
apify call istmobot/x-trends-by-country --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,istmobot/x-trends-by-country"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/7e9y6ZzmOZSzUjrei/builds/IFB9O4BUF5bjAPORm/openapi.json
