# Twitter Trends Scraper (`api-empire/twitter-trends-scraper`) Actor

Twitter Trends Scraper helps you collect trending topics and hashtags from Twitter in real time. Extract trend names, tweet volume, locations, and related metadata for market research, brand monitoring, content planning, and social media analysis.

- **URL**: https://apify.com/api-empire/twitter-trends-scraper.md
- **Developed by:** [API Empire](https://apify.com/api-empire) (community)
- **Categories:** Social media, Automation, Developer tools
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, NaN bookmarks
- **User rating**: No ratings yet

## Pricing

from $4.99 / 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.

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

## What's an Apify Actor?

Actors are a software tools running on the Apify platform, for all kinds of web data extraction and automation use cases.
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.
Actors are written with capital "A".

## 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.
The best way to integrate Actors is as follows.

In JavaScript/TypeScript projects, use official [JavaScript/TypeScript client](https://docs.apify.com/api/client/js.md):

```bash
npm install apify-client
```

In Python projects, use official [Python client library](https://docs.apify.com/api/client/python.md):

```bash
pip install apify-client
```

In shell scripts, use [Apify CLI](https://docs.apify.com/cli/docs.md):

````bash
# MacOS / Linux
curl -fsSL https://apify.com/install-cli.sh | bash
# Windows
irm https://apify.com/install-cli.ps1 | iex
```bash

In AI frameworks, you might use the [Apify MCP server](https://docs.apify.com/platform/integrations/mcp.md).

If your project is in a different language, use the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).


# README

### What is a Twitter Trends Scraper?

A Twitter Trends Scraper is a tool that collects trending topics, hashtags, and tweet volumes in real time. Instead of manually refreshing Twitter to see what’s popular, scrapers automate the process and deliver structured data. Variations like a twitter scraper, x twitter scraper, or apify twitter scraper make it possible to track both global and country-specific trends. Manual tracking is time-consuming and inconsistent, while automated scraping ensures accuracy, scale, and historical insights. This makes it easier for marketers, researchers, and analysts to monitor conversations, spot emerging trends early, and base decisions on reliable data.

### What Twitter Trends Data Can You Extract?

| Data Point | Description |
| --- | --- |
| Trending Topic/Hashtag | Top hashtags and keywords trending globally or locally. |
| Tweet Volume | Measure popularity with live metrics and check Twitter trend count. |
| Country/Region | Track regional insights, including Twitter USA traffic and international data. |
| Time Period | Monitor trends by snapshot: Live, hourly, or daily history. |
| Engagement Signals | Extract retweets, likes, and mentions using a tweet scraper. |
| Follower Insights | Collect basic metrics through Twitter followers scraping for audience analysis. |
 

#### Key Features of Twitter Trends Scraper

*   Real-Time & Historical Tracking  
    Capture live trending topics as well as trends from the past hours or days.  
      
    
*   Proxy Support for Stability  
    Handle large-scale scraping securely without hitting Twitter rate limits.  
      
    
*   Multiple Export Formats  
    Download results in CSV, JSON, or Excel for reporting or analysis.  
      
    
*   Developer-Friendly  
    Works with twitter scraper Python scripts, GitHub repos, and CLI tools for custom workflows.  
      
    
*   Ready-to-Use Automation  
    Supports Apify Twitter Trends Scraper for easy, no-code trend collection.
    

### How to Use Twitter Trends Scraper

Using a Twitter Trends Scraper is straightforward whether you prefer a ready-to-use platform like Apify or a custom setup with twitter scraper Python scripts. Here’s the step-by-step process:

1.  Create an Account or Install Script  
      
    

*   Sign up on Apify to access the Apify Twitter Trends Scraper.  
      
      
    

3.  Set Input Parameters  
      
    

*   Choose the location: worldwide or a specific country (e.g., to track Twitter USA traffic).  
      
    
*   Define the time period (live, hourly, or daily history).  
      
    

5.  Run the Scraper  
      
    

*   Start the run and the tool will scrape Twitter trends in real time.  
      
    
*   Data includes trending topics, tweet volumes, and engagement signals.  
      
    

7.  Download or Export Results  
      
    

*   Export data in CSV, Excel, or JSON format.  
      
    
*   Integrate directly into dashboards or research pipelines.  
      
    

9.  Optional: Automate with Workflows  
      
    

*   Use Twitter data collection Python scripts to schedule regular scraping.  
      
    
*   Build custom alerts or analytics workflows for marketing, research, or brand monitoring.  
      
#### Input
```json
{
    "day2": false,
    "day3": false,
    "hour1": false,
    "hour12": false,
    "hour24": false,
    "hour3": false,
    "hour6": false,
    "live": false,
    "startUrls": [
        {
            "url": "https://getdaytrends.com/",
            "method": "GET"
        },
        {
            "url": "https://getdaytrends.com/2025-09-22/1/",
            "method": "GET"
        },
        {
            "url": "https://getdaytrends.com/2025-09-22/3/",
            "method": "GET"
        },
        {
            "url": "https://getdaytrends.com/2025-09-22/6/",
            "method": "GET"
        },
        {
            "url": "https://getdaytrends.com/2025-09-22/12/",
            "method": "GET"
        },
        {
            "url": "https://getdaytrends.com/2025-09-22/24/",
            "method": "GET"
        },
        {
            "url": "https://getdaytrends.com/2025-09-21/24/",
            "method": "GET"
        },
        {
            "url": "https://getdaytrends.com/2025-09-20/24/",
            "method": "GET"
        }
    ]
}
````

#### Output

```json
[
  {
    "time": "2025-09-22T05:53:04.664851Z",
    "timePeriod": "Custom",
    "trend": "Guana",
    "volume": "65.3K tweets"
  },
  {
    "time": "2025-09-22T05:53:04.664851Z",
    "timePeriod": "Custom",
    "trend": "#Navratri2025",
    "volume": "23.8K tweets"
  },
  {
    "time": "2025-09-22T05:53:04.664851Z",
    "timePeriod": "Custom",
    "trend": "Aldo",
    "volume": "102.6K tweets"
  },
  {
    "time": "2025-09-22T05:53:04.664851Z",
    "timePeriod": "Custom",
    "trend": "#LCDFMX3",
    "volume": "11.0K tweets"
  },
  {
    "time": "2025-09-22T05:53:04.664851Z",
    "timePeriod": "Custom",
    "trend": "#LaCasaDeLosFamososMx3",
    "volume": "35.2K tweets"
  },
  {
    "time": "2025-09-22T05:53:04.664851Z",
    "timePeriod": "Custom",
    "trend": "Russell Wilson",
    "volume": "19.4K tweets"
  },
  {
    "time": "2025-09-22T05:53:04.664851Z",
    "timePeriod": "Custom",
    "trend": "Giants",
    "volume": "100.8K tweets"
  },
  {
    "time": "2025-09-22T05:53:04.664851Z",
    "timePeriod": "Custom",
    "trend": "Zayne",
    "volume": "45.8K tweets"
  },
  {
    "time": "2025-09-22T05:53:04.664851Z",
    "timePeriod": "Custom",
    "trend": "#नवरात्रि",
    "volume": "18.0K tweets"
  },
  {
    "time": "2025-09-22T05:53:04.664851Z",
    "timePeriod": "Custom",
    "trend": "Dart",
    "volume": "15.3K tweets"
  },
  {
    "time": "2025-09-22T05:53:04.664851Z",
    "timePeriod": "Custom",
    "trend": "Chiefs",
    "volume": "78.7K tweets"
  },
  {
    "time": "2025-09-22T05:53:04.664851Z",
    "timePeriod": "Custom",
    "trend": "#新参者",
    "volume": "Under 10K tweets"
  },
  {
    "time": "2025-09-22T05:53:04.664851Z",
    "timePeriod": "Custom",
    "trend": "Aarón",
    "volume": "119.9K tweets"
  },
  {
    "time": "2025-09-22T05:53:04.664851Z",
    "timePeriod": "Custom",
    "trend": "Yetus",
    "volume": "11.3K tweets"
  },
  {
    "time": "2025-09-22T05:53:04.664851Z",
    "timePeriod": "Custom",
    "trend": "Payday",
    "volume": "Under 10K tweets"
  },
  {
    "time": "2025-09-22T05:53:04.664851Z",
    "timePeriod": "Custom",
    "trend": "第2問の解答",
    "volume": "Under 10K tweets"
  },
  {
    "time": "2025-09-22T05:53:04.664851Z",
    "timePeriod": "Custom",
    "trend": "Mahomes",
    "volume": "28.0K tweets"
  },
  {
    "time": "2025-09-22T05:53:04.664851Z",
    "timePeriod": "Custom",
    "trend": "チャンミ",
    "volume": "Under 10K tweets"
  },
  {
    "time": "2025-09-22T05:53:04.664851Z",
    "timePeriod": "Custom",
    "trend": "Erika",
    "volume": "576.2K tweets"
  },
  {
    "time": "2025-09-22T05:53:04.664851Z",
    "timePeriod": "Custom",
    "trend": "エイトザタラソ",
    "volume": "15.1K tweets"
  },
  {
    "time": "2025-09-22T05:53:04.664851Z",
    "timePeriod": "Custom",
    "trend": "Daboll",
    "volume": "Under 10K tweets"
  },
  {
    "time": "2025-09-22T05:53:04.664851Z",
    "timePeriod": "Custom",
    "trend": "Toby",
    "volume": "92.0K tweets"
  },
  {
    "time": "2025-09-22T05:53:04.664851Z",
    "timePeriod": "Custom",
    "trend": "Thornton",
    "volume": "Under 10K tweets"
  },
  {
    "time": "2025-09-22T05:53:04.664851Z",
    "timePeriod": "Custom",
    "trend": "Indonesia Untuk Palestina",
    "volume": "Under 10K tweets"
  },
  {
    "time": "2025-09-22T05:53:04.664851Z",
    "timePeriod": "Custom",
    "trend": "Gentle Acne Facial Wash",
    "volume": "Under 10K tweets"
  },
  {
    "time": "2025-09-22T05:53:04.664851Z",
    "timePeriod": "Custom",
    "trend": "子ども食堂",
    "volume": "48.9K tweets"
  },
  {
    "time": "2025-09-22T05:53:04.664851Z",
    "timePeriod": "Custom",
    "trend": "forgiveness",
    "volume": "60.4K tweets"
  },
  {
    "time": "2025-09-22T05:53:04.664851Z",
    "timePeriod": "Custom",
    "trend": "Tylenol",
    "volume": "19.2K tweets"
  },
  {
    "time": "2025-09-22T05:53:04.664851Z",
    "timePeriod": "Custom",
    "trend": "महाराजा अग्रसेन",
    "volume": "Under 10K tweets"
  },
  {
    "time": "2025-09-22T05:53:04.664851Z",
    "timePeriod": "Custom",
    "trend": "Nabers",
    "volume": "10.0K tweets"
  },
  {
    "time": "2025-09-22T05:53:04.664851Z",
    "timePeriod": "Custom",
    "trend": "レイ先生",
    "volume": "Under 10K tweets"
  },
  {
    "time": "2025-09-22T05:53:04.664851Z",
    "timePeriod": "Custom",
    "trend": "Shakti Upasana",
    "volume": "17.6K tweets"
  },
  {
    "time": "2025-09-22T05:53:04.664851Z",
    "timePeriod": "Custom",
    "trend": "Vrat Upwas",
    "volume": "17.4K tweets"
  },
  {
    "time": "2025-09-22T05:53:04.664851Z",
    "timePeriod": "Custom",
    "trend": "Marchesin",
    "volume": "Under 10K tweets"
  },
  {
    "time": "2025-09-22T05:53:04.664851Z",
    "timePeriod": "Custom",
    "trend": "NINESTAR IS A LOST CAUSE",
    "volume": "18.3K tweets"
  },
  {
    "time": "2025-09-22T05:53:04.664851Z",
    "timePeriod": "Custom",
    "trend": "セレクト",
    "volume": "12.6K tweets"
  },
  {
    "time": "2025-09-22T05:53:04.664851Z",
    "timePeriod": "Custom",
    "trend": "食べ物・飲み物",
    "volume": "Under 10K tweets"
  },
  {
    "time": "2025-09-22T05:53:04.664851Z",
    "timePeriod": "Custom",
    "trend": "私の奴隷",
    "volume": "Under 10K tweets"
  },
  {
    "time": "2025-09-22T05:53:04.664851Z",
    "timePeriod": "Custom",
    "trend": "JMIBARRA ON MYXNOW",
    "volume": "11.0K tweets"
  },
  {
    "time": "2025-09-22T05:53:04.664851Z",
    "timePeriod": "Custom",
    "trend": "प्रथम स्वरूप",
    "volume": "Under 10K tweets"
  },
  {
    "time": "2025-09-22T05:53:04.664851Z",
    "timePeriod": "Custom",
    "trend": "Collinsworth",
    "volume": "Under 10K tweets"
  },
  {
    "time": "2025-09-22T05:53:04.664851Z",
    "timePeriod": "Custom",
    "trend": "जगत जननी",
    "volume": "Under 10K tweets"
  },
  {
    "time": "2025-09-22T05:53:04.664851Z",
    "timePeriod": "Custom",
    "trend": "交通安全ハット",
    "volume": "Under 10K tweets"
  },
  {
    "time": "2025-09-22T05:53:04.664851Z",
    "timePeriod": "Custom",
    "trend": "スタバとジェラピケのコラボ",
    "volume": "Under 10K tweets"
  },
  {
    "time": "2025-09-22T05:53:04.664851Z",
    "timePeriod": "Custom",
    "trend": "国勢調査",
    "volume": "31.3K tweets"
  },
  {
    "time": "2025-09-22T05:53:04.664851Z",
    "timePeriod": "Custom",
    "trend": "ガッチさん",
    "volume": "Under 10K tweets"
  },
  {
    "time": "2025-09-22T05:53:04.664851Z",
    "timePeriod": "Custom",
    "trend": "May Maa Durga",
    "volume": "14.3K tweets"
  },
  {
    "time": "2025-09-22T05:53:04.664851Z",
    "timePeriod": "Custom",
    "trend": "Butker",
    "volume": "Under 10K tweets"
  },
  {
    "time": "2025-09-22T05:53:04.664851Z",
    "timePeriod": "Custom",
    "trend": "Cam Skattebo",
    "volume": "Under 10K tweets"
  },
  {
    "time": "2025-09-22T05:53:04.664851Z",
    "timePeriod": "Custom",
    "trend": "Palacios",
    "volume": "Under 10K tweets"
  }
]
```

### 🎯 Use Cases

- Marketing & Content Strategy\
  Discover trending hashtags and conversations to shape campaigns and create content that resonates.

- Track Twitter Website Traffic Trends\
  Measure how discussions drive spikes in Twitter website traffic and engagement worldwide or by region.

- Monitor Competitors & Influencers\
  Follow what influencers and competitors are amplifying to spot opportunities or gaps in your niche.

- Research Cultural Events & Audience Behavior\
  Analyze how global or local events trend on Twitter, revealing public sentiment and participation.

- Academic & Media Studies\
  Collect structured data for journalism, sociology, or media research into digital conversations.

### How Many Results Can You Scrape?

A Twitter Trends Scraper can capture a wide range of trending data in a single run.

- From Top 10 → 50+ Trends\
  Depending on setup, you can extract the top 10, 25, or 50+ trending topics per country.

- Global + Country-Level Coverage\
  Trends can be collected worldwide or filtered by region, such as analyzing Twitter USA traffic for U.S.-specific insights.

- Historical Snapshots with Automation\
  By scheduling runs, you can track how a trend evolved hourly, daily, or over multiple days for deeper analysis

### How Much Will Scraping Twitter Trends Cost?

When it comes to scraping Twitter trends, you’ve got both free and paid options depending on your goals and scale.

#### Free Options

- You can try a twitter trends scraper free version built by the community.

- GitHub scripts and twitter scraper Python projects give you DIY flexibility without upfront cost.

- Downsides: requires setup, proxies, maintenance, and scripts may break when Twitter updates its structure.

#### Paid Options

- Tools like the Apify Twitter Scraper or other SaaS platforms offer ready-to-use solutions.

- These come with automation, proxy management, and support, saving hours of troubleshooting.

- They’re ideal for scaling beyond small tests—like scraping multiple countries daily.

#### Pricing Example

- Entry-level SaaS pricing often starts around $5 per month.

- This covers hundreds to thousands of trends, depending on the plan.

- Enterprise or large-scale projects may cost more, but you get speed, stability, and reliable updates.

### Is it Legal to Scrape Twitter Trends?

Scraping Twitter trends data falls into a mostly safe area—but with important limits.

- ✅ Public Data Is Allowed\
  You can collect hashtags, trend counts, and traffic metrics since they’re visible to all users.

- ❌ Private Data Is Off-Limits\
  Anything involving private user info, DMs, or protected accounts goes against the Twitter scraping policy and is not permitted.

- ⚖️ Follow Platform Rules\
  Always respect Twitter’s Terms of Service, copyright, and rate limits when scraping at scale.

#### Does Twitter Allow Scraping?

Twitter does not officially endorse scraping, but it provides a Trends API for developers. If you scrape manually or with tools, stay compliant by sticking to public, non-sensitive data only.

### FAQ – Twitter Trends Scraper

#### What is Twitter Trends Scraper?

It’s a tool that collects real-time and historical trending hashtags, topics, and tweet volumes from Twitter/X globally or by country.

#### How to scrape Twitter trends free?

You can use a twitter trends scraper free script from GitHub or community tools. These work but often require setup and ongoing maintenance.

#### Can I use twitter scraper Python scripts?

Yes. Many developers use twitter data collection Python scripts to scrape trends, traffic stats, or hashtags. They’re flexible but need coding skills.

#### What’s the difference between GitHub tools and Apify Twitter Scraper?

- GitHub tools: Free, DIY, customizable, but can break when Twitter changes.

- Apify Twitter Scraper: Paid, automated, proxy-ready, with support and easier scaling.

#### Is it safe for research and data analysis?

Yes, scraping public trends data is safe for academic, media, and marketing research as long as you avoid private data.

#### Does Twitter allow scraping of followers or private data?

No. Twitter scraping policy prohibits scraping followers, private info, or DMs. Stick to public hashtags and traffic metrics only.

### What are other Twitter scraping tools?

If you want to scrape specific Twitter data, you can use any of the dedicated scrapers below for faster and more targeted results.

| Scraper Name | Scraper Name |
|---|---|
| [Twitter (X) Tweets Scraper](https://apify.com/api-empire/twitter-x-tweets-scraper) | [Twitter Profile Phone Number Scraper](https://apify.com/api-empire/twitter-profile-phone-number-scraper) |
| [Twitter (X.com) Tweets & Profiles Scraper](https://apify.com/api-empire/twitter-scraper) | [Twitter Profile Scraper](https://apify.com/api-empire/twitter-profile-scraper) |
| [Twitter B2b Email Scraper](https://apify.com/api-empire/twitter-b2b-email-scraper) | [Twitter User Following Scraper](https://apify.com/api-empire/twitter-user-following-scraper) |
| [Twitter B2b Lead Scraper](https://apify.com/api-empire/twitter-b2b-lead-scraper) | [Twitter X Posts Scraper](https://apify.com/api-empire/Twitter-X-Posts-Scraper) |
| [Twitter B2b Phone Number Scraper](https://apify.com/api-empire/twitter-b2b-phone-number-scraper) | [Twitter X Reply Scraper](https://apify.com/api-empire/twitter-x-reply-scraper) |
| [Twitter Email Scraper](https://apify.com/api-empire/twitter-email-scraper) | [X Twitter Email Scraper](https://apify.com/api-empire/x-twitter-email-scraper) |
| [Twitter Lead Scraper](https://apify.com/api-empire/twitter-lead-scraper) | [X Twitter Lead Scraper](https://apify.com/api-empire/x-twitter-lead-scraper) |
| [Twitter Phone Number Scraper](https://apify.com/api-empire/twitter-phone-number-scraper) | [X Twitter Phone Number Scraper](https://apify.com/api-empire/x-twitter-phone-number-scraper) |
| [Twitter Profile Email Scraper](https://apify.com/api-empire/twitter-profile-email-scraper) | [X Twitter Posts Search](https://apify.com/api-empire/x-twitter-posts-search) |
| [Twitter Profile Lead Scraper](https://apify.com/api-empire/twitter-profile-lead-scraper) |  |

# Actor input Schema

## `live` (type: `boolean`):

Scrape the current live trends.

## `hour1` (type: `boolean`):

Scrape trends from 1 hour ago.

## `hour2` (type: `boolean`):

Scrape trends from 2 hours ago.

## `hour3` (type: `boolean`):

Scrape trends from 3 hours ago.

## `hour4` (type: `boolean`):

Scrape trends from 4 hours ago.

## `hour5` (type: `boolean`):

Scrape trends from 5 hours ago.

## `hour6` (type: `boolean`):

Scrape trends from 6 hours ago.

## `hour7` (type: `boolean`):

Scrape trends from 7 hours ago.

## `hour8` (type: `boolean`):

Scrape trends from 8 hours ago.

## `hour9` (type: `boolean`):

Scrape trends from 9 hours ago.

## `hour10` (type: `boolean`):

Scrape trends from 10 hours ago.

## `hour11` (type: `boolean`):

Scrape trends from 11 hours ago.

## `hour12` (type: `boolean`):

Scrape trends from 12 hours ago.

## `hour13` (type: `boolean`):

Scrape trends from 13 hours ago.

## `hour14` (type: `boolean`):

Scrape trends from 14 hours ago.

## `hour15` (type: `boolean`):

Scrape trends from 15 hours ago.

## `hour16` (type: `boolean`):

Scrape trends from 16 hours ago.

## `hour17` (type: `boolean`):

Scrape trends from 17 hours ago.

## `hour18` (type: `boolean`):

Scrape trends from 18 hours ago.

## `hour19` (type: `boolean`):

Scrape trends from 19 hours ago.

## `hour20` (type: `boolean`):

Scrape trends from 20 hours ago.

## `hour21` (type: `boolean`):

Scrape trends from 21 hours ago.

## `hour22` (type: `boolean`):

Scrape trends from 22 hours ago.

## `hour23` (type: `boolean`):

Scrape trends from 23 hours ago.

## `yesterday` (type: `boolean`):

Scrape yesterday's full-day summary.

## `weekAgo` (type: `boolean`):

Scrape trends from 1 week ago.

## `monthAgo` (type: `boolean`):

Scrape trends from 1 month ago.

## `yearAgo` (type: `boolean`):

Scrape trends from 1 year ago.

## `day2` (type: `boolean`):

Scrape yesterday's full-day summary (legacy option, same as 'yesterday').

## `day3` (type: `boolean`):

Scrape the summary from 2 days ago.

## `country` (type: `string`):

Select a country to scrape country-specific Twitter trends. Leave empty for worldwide trends.

## `proxy` (type: `object`):

Defaults to no proxy. If the selected proxy is rejected, the actor falls back to Apify RESIDENTIAL automatically.

## Actor input object example

```json
{
  "country": ""
}
```

# 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 = {};

// Run the Actor and wait for it to finish
const run = await client.actor("api-empire/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 = {}

# Run the Actor and wait for it to finish
run = client.actor("api-empire/twitter-trends-scraper").call(run_input=run_input)

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

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

```

## CLI example

```bash
echo '{}' |
apify call api-empire/twitter-trends-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=api-empire/twitter-trends-scraper",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "Twitter Trends Scraper",
        "description": "Twitter Trends Scraper helps you collect trending topics and hashtags from Twitter in real time. Extract trend names, tweet volume, locations, and related metadata for market research, brand monitoring, content planning, and social media analysis.",
        "version": "0.2",
        "x-build-id": "0anFMBlMhEY97aAAz"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/api-empire~twitter-trends-scraper/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-api-empire-twitter-trends-scraper",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        },
        "/acts/api-empire~twitter-trends-scraper/runs": {
            "post": {
                "operationId": "runs-sync-api-empire-twitter-trends-scraper",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor and returns information about the initiated run in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/runsResponseSchema"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/acts/api-empire~twitter-trends-scraper/run-sync": {
            "post": {
                "operationId": "run-sync-api-empire-twitter-trends-scraper",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "inputSchema": {
                "type": "object",
                "properties": {
                    "live": {
                        "title": "Live",
                        "type": "boolean",
                        "description": "Scrape the current live trends."
                    },
                    "hour1": {
                        "title": "1 hour ago",
                        "type": "boolean",
                        "description": "Scrape trends from 1 hour ago."
                    },
                    "hour2": {
                        "title": "2 hours ago",
                        "type": "boolean",
                        "description": "Scrape trends from 2 hours ago."
                    },
                    "hour3": {
                        "title": "3 hours ago",
                        "type": "boolean",
                        "description": "Scrape trends from 3 hours ago."
                    },
                    "hour4": {
                        "title": "4 hours ago",
                        "type": "boolean",
                        "description": "Scrape trends from 4 hours ago."
                    },
                    "hour5": {
                        "title": "5 hours ago",
                        "type": "boolean",
                        "description": "Scrape trends from 5 hours ago."
                    },
                    "hour6": {
                        "title": "6 hours ago",
                        "type": "boolean",
                        "description": "Scrape trends from 6 hours ago."
                    },
                    "hour7": {
                        "title": "7 hours ago",
                        "type": "boolean",
                        "description": "Scrape trends from 7 hours ago."
                    },
                    "hour8": {
                        "title": "8 hours ago",
                        "type": "boolean",
                        "description": "Scrape trends from 8 hours ago."
                    },
                    "hour9": {
                        "title": "9 hours ago",
                        "type": "boolean",
                        "description": "Scrape trends from 9 hours ago."
                    },
                    "hour10": {
                        "title": "10 hours ago",
                        "type": "boolean",
                        "description": "Scrape trends from 10 hours ago."
                    },
                    "hour11": {
                        "title": "11 hours ago",
                        "type": "boolean",
                        "description": "Scrape trends from 11 hours ago."
                    },
                    "hour12": {
                        "title": "12 hours ago",
                        "type": "boolean",
                        "description": "Scrape trends from 12 hours ago."
                    },
                    "hour13": {
                        "title": "13 hours ago",
                        "type": "boolean",
                        "description": "Scrape trends from 13 hours ago."
                    },
                    "hour14": {
                        "title": "14 hours ago",
                        "type": "boolean",
                        "description": "Scrape trends from 14 hours ago."
                    },
                    "hour15": {
                        "title": "15 hours ago",
                        "type": "boolean",
                        "description": "Scrape trends from 15 hours ago."
                    },
                    "hour16": {
                        "title": "16 hours ago",
                        "type": "boolean",
                        "description": "Scrape trends from 16 hours ago."
                    },
                    "hour17": {
                        "title": "17 hours ago",
                        "type": "boolean",
                        "description": "Scrape trends from 17 hours ago."
                    },
                    "hour18": {
                        "title": "18 hours ago",
                        "type": "boolean",
                        "description": "Scrape trends from 18 hours ago."
                    },
                    "hour19": {
                        "title": "19 hours ago",
                        "type": "boolean",
                        "description": "Scrape trends from 19 hours ago."
                    },
                    "hour20": {
                        "title": "20 hours ago",
                        "type": "boolean",
                        "description": "Scrape trends from 20 hours ago."
                    },
                    "hour21": {
                        "title": "21 hours ago",
                        "type": "boolean",
                        "description": "Scrape trends from 21 hours ago."
                    },
                    "hour22": {
                        "title": "22 hours ago",
                        "type": "boolean",
                        "description": "Scrape trends from 22 hours ago."
                    },
                    "hour23": {
                        "title": "23 hours ago",
                        "type": "boolean",
                        "description": "Scrape trends from 23 hours ago."
                    },
                    "yesterday": {
                        "title": "Yesterday",
                        "type": "boolean",
                        "description": "Scrape yesterday's full-day summary."
                    },
                    "weekAgo": {
                        "title": "Week Ago",
                        "type": "boolean",
                        "description": "Scrape trends from 1 week ago."
                    },
                    "monthAgo": {
                        "title": "Month Ago",
                        "type": "boolean",
                        "description": "Scrape trends from 1 month ago."
                    },
                    "yearAgo": {
                        "title": "Year Ago",
                        "type": "boolean",
                        "description": "Scrape trends from 1 year ago."
                    },
                    "day2": {
                        "title": "Day 2 (Yesterday) - Legacy",
                        "type": "boolean",
                        "description": "Scrape yesterday's full-day summary (legacy option, same as 'yesterday')."
                    },
                    "day3": {
                        "title": "Day 3",
                        "type": "boolean",
                        "description": "Scrape the summary from 2 days ago."
                    },
                    "country": {
                        "title": "Country",
                        "enum": [
                            "",
                            "DZ",
                            "AR",
                            "AU",
                            "AT",
                            "BH",
                            "BY",
                            "BE",
                            "BR",
                            "CA",
                            "CL",
                            "CO",
                            "DK",
                            "DO",
                            "EC",
                            "EG",
                            "FR",
                            "DE",
                            "GH",
                            "GR",
                            "GT",
                            "IN",
                            "ID",
                            "IE",
                            "IL",
                            "IT",
                            "JP",
                            "JO",
                            "KE",
                            "KR",
                            "KW",
                            "LV",
                            "LB",
                            "MY",
                            "MX",
                            "NL",
                            "NZ",
                            "NG",
                            "NO",
                            "OM",
                            "PK",
                            "PA",
                            "PE",
                            "PH",
                            "PL",
                            "PT",
                            "PR",
                            "QA",
                            "RU",
                            "SA",
                            "SG",
                            "ZA",
                            "ES",
                            "SE",
                            "CH",
                            "TH",
                            "TR",
                            "UA",
                            "AE",
                            "GB",
                            "US",
                            "VE",
                            "VN"
                        ],
                        "type": "string",
                        "description": "Select a country to scrape country-specific Twitter trends. Leave empty for worldwide trends.",
                        "default": ""
                    },
                    "proxy": {
                        "title": "Proxy configuration",
                        "type": "object",
                        "description": "Defaults to no proxy. If the selected proxy is rejected, the actor falls back to Apify RESIDENTIAL automatically."
                    }
                }
            },
            "runsResponseSchema": {
                "type": "object",
                "properties": {
                    "data": {
                        "type": "object",
                        "properties": {
                            "id": {
                                "type": "string"
                            },
                            "actId": {
                                "type": "string"
                            },
                            "userId": {
                                "type": "string"
                            },
                            "startedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "finishedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "status": {
                                "type": "string",
                                "example": "READY"
                            },
                            "meta": {
                                "type": "object",
                                "properties": {
                                    "origin": {
                                        "type": "string",
                                        "example": "API"
                                    },
                                    "userAgent": {
                                        "type": "string"
                                    }
                                }
                            },
                            "stats": {
                                "type": "object",
                                "properties": {
                                    "inputBodyLen": {
                                        "type": "integer",
                                        "example": 2000
                                    },
                                    "rebootCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "restartCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "resurrectCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "computeUnits": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "options": {
                                "type": "object",
                                "properties": {
                                    "build": {
                                        "type": "string",
                                        "example": "latest"
                                    },
                                    "timeoutSecs": {
                                        "type": "integer",
                                        "example": 300
                                    },
                                    "memoryMbytes": {
                                        "type": "integer",
                                        "example": 1024
                                    },
                                    "diskMbytes": {
                                        "type": "integer",
                                        "example": 2048
                                    }
                                }
                            },
                            "buildId": {
                                "type": "string"
                            },
                            "defaultKeyValueStoreId": {
                                "type": "string"
                            },
                            "defaultDatasetId": {
                                "type": "string"
                            },
                            "defaultRequestQueueId": {
                                "type": "string"
                            },
                            "buildNumber": {
                                "type": "string",
                                "example": "1.0.0"
                            },
                            "containerUrl": {
                                "type": "string"
                            },
                            "usage": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "integer",
                                        "example": 1
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "usageTotalUsd": {
                                "type": "number",
                                "example": 0.00005
                            },
                            "usageUsd": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "number",
                                        "example": 0.00005
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
