# Tweets-x-Scraper (`mikolabs/tweets-x-scraper`) Actor

Extract anything from X (Twitter) with speed and precision. This smart scraper auto-detects what to collect—tweets, profiles, users, lists, or media—and delivers clean, structured data instantly. Just enter usernames, URLs, or keywords and let automation do the rest.

- **URL**: https://apify.com/mikolabs/tweets-x-scraper.md
- **Developed by:** [Mikolabs](https://apify.com/mikolabs) (community)
- **Categories:** Automation, Social media, Lead generation
- **Features:** Limited permissions
- **Stats:** 321 total users, 17 monthly users, 100.0% runs succeeded, 4 bookmarks
- **User rating**: 5.00 out of 5 stars

## Pricing

from $10.00 / 1,000 results

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

## Tweets-x-Scraper

Extract anything from X (Twitter) with speed and precision. This smart scraper auto-detects what to collect—tweets, profiles, users, lists, or media—and delivers clean, structured data instantly. Just enter usernames, URLs, or keywords and let automation do the rest.

### 🚀 Features

#### Smart Automatic Routing

The Actor **automatically detects** what you want to scrape based on your inputs:

- **Twitter Usernames** → Automatically scrapes profiles (smart mode detection)
- **Twitter List URLs** → Automatically scrapes list content
- **Tweet URLs** → Automatically scrapes specific tweets and their entire threads
- **Search Terms** → Automatically searches tweets or users

#### Intelligent Profile Scraping

When scraping profiles, the Actor automatically selects the best mode:

- ✅ **Media Only Mode** — Check `Media Only` to extract only tweets with images/videos
- ✅ **With Replies Mode** — Enable `Include Replies` to get all tweets including replies
- ✅ **Normal Mode** — Standard tweet scraping (default)
- ✅ **Profile Search** — Add search terms to find specific content within profiles

#### Advanced Features

- 🎯 **Advanced Filtering** — Filter by date, location, media type, engagement metrics
- 👤 **Profile Information** — Extract complete profile details (bio, stats, avatar, banner)
- 📷 **Media Extraction** — Get direct URLs for images and videos with HLS preview links
- 📊 **Engagement Stats** — Collect likes, retweets, comments, and quotes
- 🔄 **Rate Limiting Protection** — Built-in retry logic and exponential backoff
- 📄 **Pagination** — Automatic handling of multiple pages
- 📋 **Structured Output** — Clean JSON output to Apify dataset

***

### 📋 Input Configuration

#### Main Input Fields

##### 1. Twitter Usernames

Add one or more Twitter usernames to scrape profiles. The Actor will automatically:

- Choose between normal, with-replies, or media-only mode based on your settings
- Apply profile search if search terms are provided

**Examples:**

```
elonmusk
apify
@naval (@ symbol is optional)
```

##### 2. Twitter List URLs

Add Twitter/X list URLs to scrape all tweets from lists.

**Supported formats:**

```
https://x.com/i/lists/123456
https://twitter.com/i/lists/123456
https://X (Twitter).net/i/lists/123456
```

##### 3. Search Terms

Add search queries to find tweets or users across Twitter.

**Examples:**

```
web scraping
AI technology
from:apify
#python
```

#### Profile Options

- **Include Replies** - Include reply tweets (automatically switches to "with replies" mode)
- **Include Retweets** - Include retweets in results
- **Media Only** - Only scrape tweets containing images or videos (uses dedicated media scraper)

#### Search Options

When using Search Terms, choose what to search:

- **Search Tweets Globally** - Find tweets across all Twitter
- **Search Users** - Find Twitter accounts
- **Search Within Profiles** - Search for specific content in provided profiles (requires Twitter Usernames)

#### Content Filters

Filter tweets by content characteristics:

- **Only Images** - Filter tweets containing images
- **Only Videos** - Filter tweets containing videos
- **Only Verified Users** - Only include verified accounts
- **Only Quote Tweets** - Only include quote tweets
- **Include Native Retweets** - Include native retweets
- **Only Tweets with Links** - Filter tweets with external links
- **Safe Search** - Enable to filter sensitive content

#### Date & Location Filters

- **Start Date (From)** - Filter tweets from this date onwards (YYYY-MM-DD format)
- **End Date (Until)** - Filter tweets up to this date
- **Location Filter** - Filter by location (e.g., "Los Angeles", "New York")

#### Engagement Filters

Set minimum engagement thresholds:

- **Minimum Likes** - Minimum number of likes required
- **Minimum Replies** - Minimum number of replies required
- **Minimum Retweets** - Minimum number of retweets required

#### Limits & Pagination

- **Max Items to Scrape** - Maximum items (tweets/users) to collect (0 = unlimited)
- **Max Pages** - Maximum pages to scrape per handle/query

#### Advanced Options

- **Tweet Language** - Filter by language code (e.g., "en", "es", "fr")
- **Scrape Profile Info** - Extract detailed profile information
- **X (Twitter) Instance URL** - Custom X (Twitter) instance (advanced users)

### 🔧 Usage Examples

#### Example 1: Simple Profile Scraping

```json
{
  "twitterHandles": ["elonmusk", "apify"],
  "maxItems": 100
}
```

**What happens:** Scrapes the last 100 tweets from each profile using normal mode.

**What happens:** Scrapes the last 100 tweets from each profile using normal mode.

#### Example 2: Profile with Replies

```json
{
  "twitterHandles": ["elonmusk"],
  "includeReplies": true,
  "maxItems": 200
}
```

**What happens:** Automatically switches to "with replies" mode to get all tweets including replies.

#### Example 3: Media Only Scraping

```json
{
  "twitterHandles": ["apify", "elonmusk"],
  "mediaOnly": true
}
```

**What happens:** Uses the dedicated media scraper to extract only tweets with images/videos.

#### Example 4: Global Tweet Search with Filters

```json
{
  "searchTerms": ["web scraping", "#ai"],
  "searchType": "tweets",
  "startDate": "2024-01-01",
  "endDate": "2024-12-31",
  "onlyVerified": true,
  "minLikes": 10,
  "tweetLanguage": "en"
}
```

**What happens:** Searches for tweets globally with engagement and verification filters.

#### Example 5: Profile Search (Find Specific Content)

```json
{
  "twitterHandles": ["apify"],
  "searchTerms": ["scraping", "automation"],
  "searchType": "profile_tweets",
  "startDate": "2024-01-01"
}
```

**What happens:** Searches for specific keywords within the provided profile's tweets.

#### Example 6: Scrape Twitter List

```json
{
  "listUrls": ["https://x.com/i/lists/78783491"],
  "maxItems": 200
}
```

**What happens:** Scrapes up to 200 tweets from the specified list.

#### Example 7: User Search

```json
{
  "searchTerms": ["data scientist", "ML engineer"],
  "searchType": "users",
  "maxItems": 50
}
```

**What happens:** Finds Twitter users matching the search terms.

#### Example 8: Combined Scraping

```json
{
  "twitterHandles": ["apify"],
  "listUrls": ["https://x.com/i/lists/123456"],
  "searchTerms": ["web scraping"],
  "searchType": "tweets",
  "maxItems": 100
}
```

**What happens:** Scrapes all three: profile tweets, list tweets, and search results.

### 📊 Output Format

Data is saved to the Apify dataset with structured JSON objects:

#### Profile Output

```json
{
  "type": "profile",
  "username": "apify",
  "fullname": "Apify",
  "bio": "Web scraping and automation platform...",
  "stats": {
    "tweets": "1,234",
    "followers": "12.5K",
    "following": "567"
  },
  "avatar": "https://pbs.twimg.com/...",
  "banner": "https://pbs.twimg.com/...",
  "website": "https://apify.com",
  "location": "San Francisco, CA",
  "joined": "Joined January 2024",
  "scrape_date": "2024-10-24T12:00:00.000Z"
}
```

#### Tweet Output

```json
{
  "type": "tweet",
  "tweet_url": "https://x.com/apify/status/123456",
  "tweet_id": "123456",
  "profile_username": "apify",
  "author": {
    "fullname": "Apify",
    "username": "@apify",
    "avatar": "https://pbs.twimg.com/...",
    "verified": true,
    "verified_type": "blue"
  },
  "text": "Tweet content here...",
  "date": "Oct 24, 2024 · 12:00 PM UTC",
  "date_short": "Oct 24",
  "hashtags": ["#webscraping", "#automation"],
  "mentions": ["@user1", "@user2"],
  "urls": ["https://example.com"],
  "stats": {
    "comments": 12,
    "retweets": 34,
    "quotes": 5,
    "likes": 156
  },
  "media": [
    {
      "type": "video",
      "url": "https://video.twimg.com/...",
      "hls_preview": "https://hlsjs.video-dev.org/demo/?src=...",
      "thumbnail": "https://pbs.twimg.com/...",
      "requires_hls": false
    },
    {
      "type": "image",
      "url": "https://pbs.twimg.com/...",
      "thumbnail": "https://pbs.twimg.com/..."
    }
  ],
  "is_retweet": false,
  "scrape_date": "2024-10-24T12:00:00.000Z"
}
```

#### Media Tweet Output

```json
{
  "type": "media_tweet",
  "profile_username": "apify",
  "tweet_id": "123456",
  "media": [
    {
      "type": "image",
      "url": "https://pbs.twimg.com/...",
      "thumbnail": "https://pbs.twimg.com/..."
    }
  ],
  "stats": {
    "comments": 5,
    "retweets": 10,
    "quotes": 2,
    "likes": 45
  },
  "scrape_date": "2024-10-24T12:00:00.000Z"
}
```

#### User Search Output

```json
{
  "type": "user",
  "search_query": "data scientist",
  "username": "@john_doe",
  "fullname": "John Doe",
  "display_name": "John Doe",
  "handle": "@john_doe",
  "bio": "Data Scientist | ML Engineer...",
  "avatar": "https://pbs.twimg.com/...",
  "verified": true,
  "verified_type": "blue",
  "protected": false,
  "hashtags": ["#DataScience", "#ML"],
  "mentions": [],
  "urls": ["https://johndoe.com"],
  "profile_url": "https://x.com/john_doe",
  "scrape_date": "2024-10-24T12:00:00.000Z"
}
```

### 🛠️ Technical Details

#### Architecture

The Actor uses:

- **Smart Routing Logic** - Automatically detects scraping mode based on inputs
- **X (Twitter)** - Privacy-focused Twitter frontend for scraping
- **Apify SDK** - Full integration with Apify platform

#### Automatic Mode Detection

The Actor intelligently routes requests:

```
IF twitterHandles PROVIDED:
  IF mediaOnly = true → profile_media.py
  ELSE IF includeReplies OR includeRetweets → profile_with_reply.py
  ELSE → profile_main.py
  
  IF searchTerms PROVIDED AND searchType = "profile_tweets" → profile_search.py

IF listUrls PROVIDED → list_extractor.py

IF searchTerms PROVIDED (without twitterHandles):
  IF searchType = "tweets" → search_post.py
  ELSE IF searchType = "users" → search_user.py
```

#### Rate Limiting

- Automatic retry logic with exponential backoff
- Configurable delays between requests (4-8 seconds)
- Maximum retry attempts (default: 5)
- HTTP/2 connection pooling for efficiency

#### Proxy Support

- Automatic proxy rotation
- Configurable proxy groups and countries
- Fallback to non-proxy mode if configuration fails

### 📝 Notes

#### Limitations

- Scraping speed depends on X (Twitter) instance availability
- Some X (Twitter) instances may be rate-limited or temporarily blocked
- Historical data availability depends on X (Twitter) caching

#### Best Practices

2. **Set Reasonable Limits** - Use `maxItems` and `maxPages` to control scope
3. **Respect Delays** - The Actor includes automatic delays; don't circumvent them
4. **Monitor Runs** - Check logs for any issues with X (Twitter) instances
5. **Rotate Instances** - If one instance fails, try another in advanced settings
6. **Start Small** - Test with small limits before scaling up

### 🔐 Privacy & Ethics

This Actor uses X (Twitter), a privacy-focused Twitter frontend. Please ensure you:

- ✅ Comply with Twitter's Terms of Service
- ✅ Respect user privacy and data protection laws (GDPR, CCPA, etc.)
- ✅ Don't scrape personal/sensitive information withoutGot it 👍 Here’s your **cleaned-up README**
  This version is suitable for public release on Apify or GitHub:

***

## 🐦 Twitter Scraper – Smart Mode

A comprehensive Twitter scraper powered by **smart automatic detection**.
No mode selection needed — simply provide your inputs, and the Actor determines what to scrape automatically!

### 🚀 Features

#### Smart Mode Detection

The scraper **intelligently detects** what to extract based on the provided inputs:

- **Twitter Usernames** → Scrapes user profiles
- **List URLs** → Scrapes list content
- **Search Terms** → Finds tweets or users across Twitter

#### Flexible Profile Scraping

- ✅ **Media Only Mode** — Extract tweets with images/videos
- ✅ **Include Replies** — Get all tweets including replies
- ✅ **Standard Mode** — Regular tweet scraping
- ✅ **Profile Search** — Find specific content within a user’s profile

#### Advanced Capabilities

- 🎯 **Filtering Options** — By date, location, media, or engagement
- 👤 **Profile Info** — Get bio, stats, avatar, banner, and location
- 📷 **Media Extraction** — Collect URLs for images and videos
- 📊 **Engagement Stats** — Likes, retweets, comments, quotes
- 🔄 **Automatic Pagination** — Seamlessly fetch multiple pages
- 📋 **Structured Output** — Clean JSON format compatible with Apify datasets

***

### 📋 Input Configuration

#### Main Input Fields

##### 1. Twitter Usernames

Add one or more usernames to scrape profiles.
**Examples:**

```
elonmusk
apify
@naval
```

##### 2. Twitter List URLs

Scrape tweets from lists.
**Examples:**

```
https://x.com/i/lists/123456
https://twitter.com/i/lists/123456
```

##### 3. Search Terms

Search tweets or users globally.
**Examples:**

```
web scraping
AI technology
from:apify
#python
```

***

#### Profile Options

- **Include Replies** – Include reply tweets
- **Include Retweets** – Include retweets
- **Media Only** – Extract tweets with media only

#### Search Options

- **Search Tweets Globally**
- **Search Users**
- **Search Within Profiles** (requires usernames)

#### Filters

- **By Content** — images, videos, links, verified users
- **By Date** — start and end date
- **By Engagement** — likes, replies, retweets thresholds
- **By Language** — specify language codes (e.g., `en`, `es`)

***

### 🔧 Example Inputs

**Profile Scrape**

```json
{
  "twitterHandles": ["elonmusk"],
  "maxItems": 100
}
```

**Global Tweet Search**

```json
{
  "searchTerms": ["web scraping", "#ai"],
  "startDate": "2024-01-01",
  "endDate": "2024-12-31",
  "onlyVerified": true
}
```

**What happens:** Searches for tweets globally with engagement and verification filters.

**User Search**

```json
{
  "searchTerms": ["data scientist", "ML engineer"],
  "searchType": "users",
  "maxItems": 50
}
```

**What happens:** Finds Twitter users matching the search terms.

#### Example 8: Combined Scraping

```json
{
  "twitterHandles": ["apify"],
  "listUrls": ["https://x.com/i/lists/123456"],
  "searchTerms": ["web scraping"],
  "searchType": "tweets",
  "maxItems": 100
}
```

**What happens:** Scrapes all three: profile tweets, list tweets, and search results.

***

### 📊 Output Format

**Profile Example**

```json
{
  "type": "profile",
  "username": "apify",
  "fullname": "Apify",
  "bio": "Web scraping and automation platform...",
  "followers": "12.5K",
  "following": "567",
  "joined": "Joined January 2024"
}
```

**Tweet Example**

```json
{
  "type": "tweet",
  "tweet_url": "https://x.com/apify/status/123456",
  "username": "@apify",
  "text": "Tweet content here...",
  "hashtags": ["#webscraping"],
  "stats": {
    "likes": 150,
    "retweets": 30,
    "comments": 10
  }
}
```

**User Search Example**

```json
{
  "type": "user",
  "search_query": "data scientist",
  "username": "@john_doe",
  "fullname": "John Doe",
  "verified": true,
  "bio": "Data Scientist | ML Engineer"
}
```

***

### 🧩 Technical Overview

- **Smart Detection System** — Determines the correct scraping mode automatically
- **Flexible Input Types** — Supports usernames, lists, and search terms
- **Automatic Pagination** — Handles multiple pages seamlessly
- **Robust Filtering** — Date, engagement, and language filters

***

### ⚙️ Best Practices

- Use reasonable limits for `maxItems` and `maxPages`
- Always test small runs first
- Monitor logs for any warnings or skipped items
- Respect content and rate restrictions

***

### 🐛 Troubleshooting

**No data returned**

- Verify input format and spelling of usernames
- Try reducing filters (date or language)

**Empty media results**

- Ensure the target profile actually has media posts
- Disable `mediaOnly` to confirm tweets exist

**Search returns nothing**

- Simplify search terms
- Broaden filters or remove date limits

***

### 📚 Resources

- [Apify Documentation](https://docs.apify.com)
- [Apify SDK for Python](https://docs.apify.com/sdk/python)

***

### 🤝 Support

For help or feature requests:

- Contact Apify support
- Review Actor logs for details
- Recheck this README for usage instructions

***

### 📄 License

This Actor is provided as-is for use on the Apify platform.
Use responsibly and in accordance with all applicable data and platform policies.

***

Would you like me to **reword it slightly for Apify Marketplace tone** (shorter intro, feature bullets first, less technical details) or keep this as a **developer-oriented** version?
proper consent

- ✅ Use scraped data responsibly and ethically
- ✅ Implement appropriate rate limiting
- ✅ Don't overload servers or abuse the service

### 🐛 Troubleshooting

#### Issue: No data returned

**Solutions:**

- Check if the X (Twitter) instance is working (visit X (Twitter).net in browser)
- Try a different X (Twitter) instance in advanced settings
- Verify Twitter usernames exist and are spelled correctly

#### Issue: Rate limiting errors

**Solutions:**

- Increase delays between requests (default is already 4-8 seconds)
- Reduce `maxPages` parameter
- Try a different X (Twitter) instance

#### Issue: Proxy errors

**Solutions:**

- Verify proxy configuration is correct
- Ensure you have Apify proxy credits available
- Try different proxy groups/countries
- Check proxy group availability in Apify Console

#### Issue: Empty media results

**Solutions:**

- Ensure the profile actually has media tweets
- Try without `mediaOnly` filter to see all tweets first
- Check if the X (Twitter) instance properly displays media

#### Issue: Search returns no results

**Solutions:**

- Verify search terms are spelled correctly
- Try broader search terms
- Remove date filters to expand search range
- Try different search type (tweets vs users)

### 📚 Resources

- [X (Twitter) GitHub](https://github.com/zedeus/X "Twitter")
- \[X (Twitter) Instances List]\(https://github.com/zedeus/X (Twitter)/wiki/Instances)
- [Apify Documentation](https://docs.apify.com)
- [Apify SDK for Python](https://docs.apify.com/sdk/python)

### 🤝 Support

For issues, questions, or feature requests:

- Contact Apify support
- Check the Actor's logs for detailed error messages
- Review this documentation for troubleshooting steps

### 📄 License

This Actor is provided as-is for use on the Apify platform. Please ensure compliance with all applicable laws, terms of service, and ethical guidelines when using this tool.

### 🎯 Quick Start

1. Add Twitter usernames, list URLs, or search terms
2. Configure filters (optional)
3. Click "Start" - the Actor handles the rest automatically!

No mode selection needed - just provide your inputs and go! 🚀

# Actor input Schema

## `twitterHandles` (type: `array`):

Enter Twitter usernames to scrape (with or without @). Example: elonmusk, apify

## `listUrls` (type: `array`):

Enter Twitter/X list URLs to scrape. Format: https://x.com/i/lists/123456 or https://twitter.com/i/lists/123456

## `searchTerms` (type: `array`):

Search queries to find tweets or users. For profile search, provide both username and search term. Examples: 'web scraping', 'AI', '#python'

## `searchType` (type: `string`):

When using Search Terms, what to search for

## `includeReplies` (type: `boolean`):

Include reply tweets from profiles (automatically switches to 'with replies' mode)

## `includeRetweets` (type: `boolean`):

Include retweets in profile results (automatically switches to 'with replies' mode)

## `mediaOnly` (type: `boolean`):

Only scrape tweets that contain images or videos

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

Maximum number of items (tweets/users) to scrape per target. If 0, scrapes all available items with no limit; if a fixed number is specified, stops exactly at that limit.

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

Filter tweets from this date onwards (YYYY-MM-DD format). Works seamlessly on both profiles (twitterHandles) and search queries (searchTerms).

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

Filter tweets up to this date (YYYY-MM-DD format)

## `location` (type: `string`):

Filter tweets by location (e.g., 'Los Angeles', 'New York', 'London')

## `onlyImages` (type: `boolean`):

Filter tweets that contain images

## `onlyVideos` (type: `boolean`):

Filter tweets that contain videos

## `onlyVerified` (type: `boolean`):

Only include tweets from verified accounts

## `onlyQuotes` (type: `boolean`):

Only include quote tweets

## `includeNativeRetweets` (type: `boolean`):

Include native retweets in search results

## `includeLinks` (type: `boolean`):

Filter tweets that contain external links

## `latestTweets` (type: `boolean`):

Only scrape tweets from the last 7 days

## `safeSearch` (type: `boolean`):

Enable safe search to filter sensitive content

## `minLikes` (type: `integer`):

Minimum number of likes a tweet must have

## `minReplies` (type: `integer`):

Minimum number of replies a tweet must have

## `minRetweets` (type: `integer`):

Minimum number of retweets a tweet must have

## `tweetLanguage` (type: `string`):

Filter by language code (e.g., 'en' for English, 'es' for Spanish, 'fr' for French)

## `scrapeProfileInfo` (type: `boolean`):

Extract detailed profile information (bio, stats, avatar, etc.)

## `useResidentialProxy` (type: `boolean`):

Enable Apify residential proxies for resilient and unblocked scraping.

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

Apify proxy settings. Direct connection (no proxy) is used by default.

## `maxRetries` (type: `integer`):

Number of retry attempts for failed requests

## Actor input object example

```json
{
  "twitterHandles": [],
  "listUrls": [],
  "searchTerms": [
    "AI"
  ],
  "searchType": "tweets",
  "includeReplies": false,
  "includeRetweets": true,
  "mediaOnly": false,
  "maxItems": 20,
  "startDate": "2024-01-01",
  "endDate": "2024-12-31",
  "location": "",
  "onlyImages": false,
  "onlyVideos": false,
  "onlyVerified": false,
  "onlyQuotes": false,
  "includeNativeRetweets": true,
  "includeLinks": false,
  "latestTweets": false,
  "safeSearch": false,
  "minLikes": 0,
  "minReplies": 0,
  "minRetweets": 0,
  "tweetLanguage": "en",
  "scrapeProfileInfo": true,
  "useResidentialProxy": true,
  "proxyConfiguration": {
    "useApifyProxy": true
  },
  "maxRetries": 5
}
```

# Actor output Schema

## `overview` (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 = {
    "twitterHandles": [],
    "listUrls": [],
    "searchTerms": [
        "AI"
    ],
    "proxyConfiguration": {
        "useApifyProxy": true
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("mikolabs/tweets-x-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 = {
    "twitterHandles": [],
    "listUrls": [],
    "searchTerms": ["AI"],
    "proxyConfiguration": { "useApifyProxy": True },
}

# Run the Actor and wait for it to finish
run = client.actor("mikolabs/tweets-x-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 '{
  "twitterHandles": [],
  "listUrls": [],
  "searchTerms": [
    "AI"
  ],
  "proxyConfiguration": {
    "useApifyProxy": true
  }
}' |
apify call mikolabs/tweets-x-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,mikolabs/tweets-x-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/aHK74Qadqg4Cln5N6/builds/fuLyr8hvwsvdudgPZ/openapi.json
