# X Trends History Archive: Hourly Timeline & Rank History (`xyrelith-data/twitter-trends-history`) Actor

Cookieless X (Twitter) trend history by country or city. Returns the last 24 hourly snapshots, dated archive lists, per-trend rank histories across 24 hours, 7 days, 30 days and a year, and longest-trending or most-tweeted leaderboards.

- **URL**: https://apify.com/xyrelith-data/twitter-trends-history.md
- **Developed by:** [Xyrelith Data](https://apify.com/xyrelith-data) (community)
- **Categories:** Social media, Automation, 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.49 / 1,000 results

This Actor is paid per event and usage. You are charged both the fixed price for specific events and for Apify platform usage.
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 Trends History Archive

X (Twitter) trend data with a memory: hourly snapshots, dated top-50 lists, per-trend rank histories and longest-trending or most-tweeted leaderboards. Everything is collected from public trend archives without cookies, logins or API keys.

The actor covers **467 locations** — Worldwide, 62 countries and 404 cities — and stores the real timestamp of every snapshot so a timeline can be compared across countries, days and hours.

### Modes

| Mode | What it returns |
|---|---|
| `hourlyTimeline` | The latest timestamped snapshots for a location, aggregated per trend: best rank, latest rank, average rank, first seen, last seen, hours trending and an optional rank history. Set `groupBy` to `snapshot` for one flat row per trend per snapshot. |
| `dateRangeArchive` | One ranked list per requested UTC date-hour. Rows are deduplicated per location, date, hour and trend. |
| `trendLookup` | For named trends or hashtags: worldwide rank, rank in your chosen location, how many locations it trends in, and rank samples for the last 24 hours, 7 days, 30 days and year. |
| `topLists` | Most-tweeted and longest-trending hashtags for a day, week, month or year, with score, total trending duration and last-seen time. |
| `locations` | Every supported country and city with its archive URLs and source coverage. |

### Inputs

| Field | Type | Default | Used by |
|---|---|---|---|
| `mode` | select | `hourlyTimeline` | all modes |
| `locations` | string list | `["United States"]` | timeline, archive, top lists; first location is the context in trend lookup |
| `trends` | string list | `["Gane"]` | trend lookup |
| `startDate` | text | – | date-range archive (today UTC when empty) |
| `endDate` | text | – | date-range archive (today UTC when empty) |
| `hours` | string list | `[]` (all 24) | date-range archive |
| `trendType` | select | `all` | all trend rows |
| `keywordContains` | text | – | all trend rows |
| `keywordExcludes` | text | – | all trend rows |
| `maxRank` | integer | `50` | all trend rows |
| `maxItems` | integer | `500` (prefill `3`) | all modes |
| `maxSnapshots` | integer | `48` (prefill `24`) | timeline and archive |
| `fillMissingHours` | boolean | `true` (prefill `false`) | hourly timeline |
| `groupBy` | select | `trend` | hourly timeline |
| `includeRankHistory` | boolean | `true` | timeline and trend lookup |
| `includeSearchUrls` | boolean | `true` | all trend rows |
| `archiveFallback` | boolean | `true` | date-range archive |
| `period` | select | `week` | top lists |
| `metric` | select | `both` | top lists |

Locations accept a country name, a country/city path, a slug or an ISO code: `United States`, `US`, `United Kingdom/London`, `united-states/new-york`, `Tokyo`, `Japan/Tokyo`. Run `mode: locations` to see the full catalog.

### Output

Every row has `type`, `mode`, the resolved `location`, `locationId`, `country`, `countryCode`, `locationType`, `source` and `collectedAt`. Fields that do not apply are omitted — there are no nulls, empty strings or placeholder rows.

| Field | Appears in | Meaning |
|---|---|---|
| `date`, `hourUtc`, `snapshotAt` | archive, snapshot rows | UTC date, hour and exact capture time |
| `rank` | archive, snapshot, top lists | Position in that list |
| `trend` | all trend rows | Topic or hashtag |
| `isHashtag`, `isCashtag` | all trend rows | `#` and `$` flags |
| `bestRank`, `latestRank`, `averageRank` | timeline | Aggregates over the window |
| `firstSeenAt`, `lastSeenAt` | timeline, lookup | Oldest and newest observation |
| `hoursTrending`, `snapshotsSeen` | timeline | Distinct hours and snapshots observed |
| `rankHistory` | timeline | `[{at, rank}]` samples |
| `rankHistory24h`, `rankHistory7d`, `rankHistory30d`, `rankHistoryYear` | trend lookup | Rank samples decoded from the source's history charts |
| `worldwideRank`, `currentRank`, `locationCount`, `currentlyTrendingCount` | trend lookup | Cross-location position |
| `locationsTrendingIn` | trend lookup | Location names, ranks and last-seen text |
| `score` | top lists | Source score for most-tweeted lists |
| `trendingHours` | top lists | Total duration on the longest-trending list |
| `tweetVolume` | timeline, archive | Published post count, only when the source still exposes one |
| `datedListSource` | location rows | `getdaytrends` for countries/Worldwide, `trends24+wayback` for cities |
| `searchUrl`, `trendUrl` | trend rows | X search link and source trend page |

### Example inputs

Daily-style timeline for one country:

```json
{
  "mode": "hourlyTimeline",
  "locations": ["United States"],
  "maxItems": 20,
  "maxSnapshots": 24,
  "groupBy": "trend"
}
```

Two days of archived ranks for a city:

```json
{
  "mode": "dateRangeArchive",
  "locations": ["United Kingdom/London"],
  "startDate": "2026-11-14",
  "endDate": "2026-11-15",
  "hours": ["8", "12", "18"],
  "maxItems": 500
}
```

Rank history for hashtags:

```json
{
  "mode": "trendLookup",
  "trends": ["#UFC334", "Gane"],
  "locations": ["United States"],
  "maxItems": 5
}
```

### Data sources and coverage

Three public, cookieless sources are combined:

1. **trends24.in** — country and city pages with 24 timestamped snapshots each, 50 trends per snapshot. This powers the fast hourly timeline and the recent part of the date-range archive, and it is the only source with city-level history.
2. **getdaytrends.com** — 62 country pages, hourly/dated lists, trend pages with rank-history charts, and most-tweeted / longest-trending leaderboards. Dated lists are the primary archive source for countries.
3. **Internet Archive Wayback Machine** — best-effort fallback for older dated lists, especially cities, when the live archive page is unavailable. Wayback coverage is sparse, so not every historical hour exists.

The actor picks its pacing and proxy automatically. No proxy setup, cookie or token is required.

### Limits you should know

- **Post volumes are mostly gone.** X stopped publishing trend post counts in January 2026, and the public archives do not carry a reliable replacement. `tweetVolume` is emitted only when a source genuinely exposes it; most rows omit the field. Top-list `score` and `trendingHours` are ranking metrics, not post counts.
- **The hourly window is source-dependent.** trends24 keeps its 24 latest snapshot cards, which usually span about 18–24 hours. For countries, `fillMissingHours` extends gaps with getdaytrends relative-hour lists. The exact coverage is visible in `windowStart` / `windowEnd` and every row's `snapshotAt`.
- **Dated country lists can be rate-limited.** getdaytrends returns a Cloudflare 520 after a burst of archive requests from one IP. The actor paces requests, rotates through Apify Proxy's datacenter pool on a real block, and falls back to the Internet Archive when necessary. Wayback then supplies whatever trends24 snapshots it captured; a specific hour can still be unavailable if no upstream has it.
- **Cities do not have getdaytrends dated pages.** Recent city hours come from trends24; older city hours depend on Wayback snapshots.
- **Trend lookup charts are worldwide.** The rank-history charts describe the trend's worldwide page; `currentRank` is the rank in the location you requested. A trend that only trends locally may still have a worldwide page with sparse samples.
- **Snapshot timestamps are UTC.** Dates and `hours` are UTC, not the location's local time.

### FAQ

**Do I need a login or an X account?** No. There are no cookies, no API keys and no user tokens.

**How far back can I go?** As far as the public archives go. Country lists are available on getdaytrends for its supported date range (from May 2024); Wayback adds whatever snapshots it captured. The actor never invents data for a missing hour.

**Why is `tweetVolume` missing?** Because no public source currently reports it. The actor does not fabricate a value.

**Can I get one row per snapshot instead of per trend?** Yes — set `groupBy` to `snapshot`.

**How do I find a location slug?** Run `mode: locations`, or use a name you already know; the resolver accepts country names, ISO codes, `country/city`, `City, Country` and slugs.

**Does it work for hashtags only?** Set `trendType` to `hashtagsOnly`; use `excludeHashtags` for the opposite.

### Daily prefill

The default prefill is the smallest run with output: `hourlyTimeline` for `United States`, `maxItems: 3`, `maxSnapshots: 24`. It fetches one trends24 page and returns three ranked trends with their window aggregates.

# Actor input Schema

## `mode` (type: `string`):

hourlyTimeline: aggregate the last 24 hourly snapshots per trend. dateRangeArchive: ranked lists for chosen UTC date-hours. trendLookup: rank history for named trends. topLists: most-tweeted or longest-trending leaderboards. locations: supported countries and cities.

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

Country or country/city names, slugs or ISO codes, for example United States, US, Japan, United Kingdom/London or united-states/new-york. In trendLookup the first location is the context for currentRank; worldwide rank is always included.

## `trends` (type: `array`):

Trend names or hashtags to look up, for example Gane, #UFC334, #HookEm.

## `startDate` (type: `string`):

First UTC date to archive, in YYYY-MM-DD format. Empty means today (UTC).

## `endDate` (type: `string`):

Last UTC date to archive, inclusive, in YYYY-MM-DD format. Empty means today (UTC).

## `hours` (type: `array`):

Hours of day to fetch, 0-23. Leave empty for every hour. Example: 8, 12, 18.

## `trendType` (type: `string`):

Keep all trends, hashtags only, or everything except hashtags.

## `keywordContains` (type: `string`):

Keep only trends containing this text (case-insensitive).

## `keywordExcludes` (type: `string`):

Drop trends containing this text (case-insensitive).

## `maxRank` (type: `integer`):

Drop trends ranked below this position (1-50).

## `maxItems` (type: `integer`):

Hard cap on dataset rows. The daily prefill uses 3.

## `maxSnapshots` (type: `integer`):

Hourly timeline: newest snapshots to aggregate (max 25). Date-range archive: total requested date-hours (max 200).

## `fillMissingHours` (type: `boolean`):

For countries, fill hours that trends24 does not cover with getdaytrends relative-hour lists, extending the timeline toward a full 24 hours. Cities stay on trends24 only.

## `groupBy` (type: `string`):

trend: one row per trend with rankHistory and aggregates. snapshot: one row per trend per snapshot.

## `includeRankHistory` (type: `boolean`):

Add rankHistory arrays to timeline rows and rankHistory24h/7d/30d/year arrays to trendLookup rows.

## `includeSearchUrls` (type: `boolean`):

Add X search links for every trend.

## `archiveFallback` (type: `boolean`):

When an older dated list is unavailable from getdaytrends, try the Internet Archive's snapshots of trends24.

## `period` (type: `string`):

Leaderboard window for topLists.

## `metric` (type: `string`):

Most-tweeted leaderboard, longest-trending leaderboard, or both.

## Actor input object example

```json
{
  "mode": "hourlyTimeline",
  "locations": [
    "United States"
  ],
  "trends": [
    "Gane",
    "#UFC334"
  ],
  "hours": [],
  "trendType": "all",
  "maxRank": 50,
  "maxItems": 3,
  "maxSnapshots": 24,
  "fillMissingHours": false,
  "groupBy": "trend",
  "includeRankHistory": true,
  "includeSearchUrls": true,
  "archiveFallback": true,
  "period": "week",
  "metric": "both"
}
```

# Actor output Schema

## `rows` (type: `string`):

Dataset containing timeline, archive, lookup, top-list or location rows.

# 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 = {
    "mode": "hourlyTimeline",
    "locations": [
        "United States"
    ],
    "trends": [
        "Gane",
        "#UFC334"
    ],
    "hours": [],
    "trendType": "all",
    "maxRank": 50,
    "maxItems": 3,
    "maxSnapshots": 24,
    "fillMissingHours": false,
    "groupBy": "trend",
    "includeRankHistory": true,
    "includeSearchUrls": true,
    "archiveFallback": true,
    "period": "week",
    "metric": "both"
};

// Run the Actor and wait for it to finish
const run = await client.actor("xyrelith-data/twitter-trends-history").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 = {
    "mode": "hourlyTimeline",
    "locations": ["United States"],
    "trends": [
        "Gane",
        "#UFC334",
    ],
    "hours": [],
    "trendType": "all",
    "maxRank": 50,
    "maxItems": 3,
    "maxSnapshots": 24,
    "fillMissingHours": False,
    "groupBy": "trend",
    "includeRankHistory": True,
    "includeSearchUrls": True,
    "archiveFallback": True,
    "period": "week",
    "metric": "both",
}

# Run the Actor and wait for it to finish
run = client.actor("xyrelith-data/twitter-trends-history").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 '{
  "mode": "hourlyTimeline",
  "locations": [
    "United States"
  ],
  "trends": [
    "Gane",
    "#UFC334"
  ],
  "hours": [],
  "trendType": "all",
  "maxRank": 50,
  "maxItems": 3,
  "maxSnapshots": 24,
  "fillMissingHours": false,
  "groupBy": "trend",
  "includeRankHistory": true,
  "includeSearchUrls": true,
  "archiveFallback": true,
  "period": "week",
  "metric": "both"
}' |
apify call xyrelith-data/twitter-trends-history --silent --output-dataset

```

## MCP server setup

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

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/PTJQee1E0t8NrwYyE/builds/V74YbravgSfTy7h13/openapi.json
