# X (Twitter) Trends Scraper (Trends by Country & City) (`webdatatools/twitter-trends-scraper`) Actor

Scrape X (Twitter) trending topics by country or city from trends24.in: rank, trend name, search link and the hourly snapshot time for the last 24 hours.

- **URL**: https://apify.com/webdatatools/twitter-trends-scraper.md
- **Developed by:** [Murat Uzun](https://apify.com/webdatatools) (community)
- **Categories:** Social media, News, Marketing
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.18 / 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

### What is X (Twitter) Trends Scraper?

X (Twitter) Trends Scraper collects the trending topics on X by country or city, from trends24.in. For each location you get the ranked trends of the latest hourly snapshot, or of the last several snapshots of the past 24 hours, with the snapshot time and a link to the search on X. No X login or API key is needed.

### Why use X (Twitter) Trends Scraper?

- Trend rank and name for any country or city, hour by hour over the last 24 hours.
- A search link for every trend, to check the conversation on X.
- Several locations in one run, for comparison across countries.
- Pay only for trends saved.

### How to use X (Twitter) Trends Scraper

1. Enter locations as trends24.in paths: a country (`united-states`, `turkey`, `united-kingdom`) or a city (`united-states/new-york`, `united-kingdom/london`). Full trends24 URLs also work.
2. Set how many hourly snapshots to collect (1 = the latest only, up to 24).
3. Set how many trends per snapshot (up to 50).
4. Run it and download the dataset as JSON, CSV, Excel or HTML, or read it through the API.

### Example input

```json
{
    "locations": ["united-states", "turkey"],
    "snapshots": 1,
    "maxTrendsPerSnapshot": 50
}
```

### Example output

A real row from a run on 2026-10-23 (`united-states`, latest snapshot):

```json
{
    "source": "trends24",
    "location": "united-states",
    "locationName": "United States",
    "snapshotAt": "2026-10-23T01:16:06.996Z",
    "snapshotIndex": 0,
    "rank": 1,
    "trend": "Cavs",
    "trendUrl": "https://twitter.com/search?q=Cavs",
    "url": "https://trends24.in/united-states/",
    "position": 1
}
```

### Data table

| Field | Meaning |
|---|---|
| `location`, `locationName` | trends24.in path and the name shown on the page |
| `snapshotAt` | time of the hourly snapshot (UTC) |
| `snapshotIndex` | 0 = newest snapshot, 1 = the one before, and so on |
| `rank` | position in that snapshot (1 = top) |
| `trend` | trend name as shown on the page |
| `trendUrl` | search link on X for the trend |
| `url` | trends24.in page the row came from |

Tweet volumes are not returned. The trends24.in page does not show them in its HTML, so the Actor does not fill that field.

### Input parameters

- **Locations**: trends24.in country or city paths, or full URLs.
- **Snapshots (hours)**: 1 to 24, newest first.
- **Max trends per snapshot**: 1 to 50, in rank order.
- **Proxy configuration**: keep the RESIDENTIAL group. trends24.in blocks datacenter IPs (HTTP 403).

### Pricing

Pay per trend row saved (see the Actor page for the current price). The run stops before it would exceed your max total charge.

### X (Twitter) Trends Scraper vs. the X API

The X API needs a developer account and API keys. This Actor reads the public trends24.in pages instead, so it needs no X account. It only covers what trends24.in publishes: trend names, rank, time and location. It does not include tweets, users or tweet volumes.

### Using X (Twitter) Trends Scraper with AI agents and MCP

Use it from the Apify MCP server or the API with a location path. Pay-per-event pricing is charged per row, so an agent that sets a `maxTotalChargeUsd` never goes over that budget.

### FAQ

**Why are there no tweet counts?**
The trends24.in page does not contain them in the HTML this Actor reads, so they are left out rather than estimated.

**Why does a snapshot have fewer than 50 trends?**
trends24.in sometimes lists fewer trends for an hour. The Actor returns what the page shows.

**Why does the run need a residential proxy?**
trends24.in returned HTTP 403 for datacenter requests during testing (2026-10-23). The residential route returned the pages.

### Support and feedback

If you find a problem, open an issue in the Actor's Issues tab. A review helps other users find it.

# Actor input Schema

## `locations` (type: `array`):

trends24.in location paths: a country (`united-states`, `turkey`, `united-kingdom`) or a city (`united-states/new-york`). Full trends24 URLs also work.

## `snapshots` (type: `integer`):

How many hourly snapshots of the last 24 hours to collect, newest first. 1 = the latest trends only.

## `maxTrendsPerSnapshot` (type: `integer`):

Trends per snapshot, in rank order (trends24 lists up to 50).

## `proxyConfiguration` (type: `object`):

trends24.in blocks datacenter IPs. Keep Apify Proxy with the RESIDENTIAL group.

## Actor input object example

```json
{
  "locations": [
    "united-states"
  ],
  "snapshots": 1,
  "maxTrendsPerSnapshot": 50,
  "proxyConfiguration": {
    "useApifyProxy": true,
    "apifyProxyGroups": [
      "RESIDENTIAL"
    ]
  }
}
```

# Actor output Schema

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

All trends from this run.

# 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 = {
    "locations": [
        "united-states"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("webdatatools/twitter-trends-scraper").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 = { "locations": ["united-states"] }

# Run the Actor and wait for it to finish
run = client.actor("webdatatools/twitter-trends-scraper").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 '{
  "locations": [
    "united-states"
  ]
}' |
apify call webdatatools/twitter-trends-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,webdatatools/twitter-trends-scraper"
        }
    }
}
```

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/IEYgKJbyojpy0OSDr/builds/DbO2zSP98uACtYzQj/openapi.json
