# Twitter(X.com) Tweets Scraper (`codenest/twitter-x-com-tweets-scraper`) Actor

🎯 Extract Twitter (X.com) tweets with videos, images & audio! Get structured JSON output with multiple resolutions & secure Apify storage. Perfect for researchers 🔬, marketers 📈 & content analysts 📊 needing reliable social media data extraction.❤️Twitter(X.com) Tweets Scraper❤️.

- **URL**: https://apify.com/codenest/twitter-x-com-tweets-scraper.md
- **Developed by:** [CodeNest](https://apify.com/codenest) (community)
- **Categories:** Social media, Developer tools, Other
- **Stats:** 6 total users, 0 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$7.00/month + usage

To use this Actor, you pay a monthly rental fee to the developer. The rent is subtracted from your prepaid usage every month after the free trial period.You also pay for the Apify platform usage, which gets cheaper the higher Apify subscription plan you have.

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

## 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

## Twitter(X.com) Tweets Scraper - Professional Social Media Extraction Tool

**🚀 Effortlessly scrape and download Twitter (X.com) tweets with our enterprise-grade powerful actor! This Apify actor enables you to batch extract tweet content including videos, images, and audio while preserving high quality and comprehensive metadata.**

---

### 📋 Overview
Need to archive Twitter content or analyze social media trends? This **Twitter(X.com) Tweets Scraper** delivers:
- **Multi-media extraction**: Videos, images, and audio files
- **Apify Storage**: Secure download URLs via Key-Value Store
- **Full metadata**: Tweet IDs, thumbnails, content statistics
- **Multiple resolutions**: Various quality options for videos
- **Bulk processing**: Handle multiple tweet URLs simultaneously

Perfect for researchers 🔬, marketers 📈, journalists 📰, and content analysts 📊!

### ⚡ Core Capabilities/Key Features

#### 🎥 Media Extraction
- **Video Download**: Extract videos in multiple resolutions (1280p, 852p, 568p)
- **Image Capture**: Download all images from tweets
- **Audio Extraction**: Separate audio tracks from video content
- **Format Variety**: MP4 videos, JPG images, MP3 audio
- **Batch Mode**: Process multiple tweet URLs in a single run

#### 📊 Metadata Mastery
- **Tweet Identification**: Unique Twitter IDs for each post
- **Content Analysis**: Video/image/audio counts
- **Resolution Options**: Available quality tiers
- **Thumbnail Access**: High-quality preview images
- **Format Details**: Supported container formats

#### 🔧 Advanced Technology
- **Quality Selection**: Multiple resolution options
- **Secure Storage**: Apify Key-Value Store integration
- **Structured Output**: Organized JSON data
- **Error Handling**: Success/failure status tracking
- **Scalable Processing**: Efficient batch operations

---

### 🎯 Input Configuration
Just enter the Twitter (X.com) tweet URLs in the Input Section then click the "start" button and wait for the results. Using this **Twitter(X.com) Tweets Scraper** is simple:

```json
{
  "key_value": true,
  "post_urls": [
    {
      "url": "https://x.com/Ndi_Muvenda_/status/1994827626960298171?s=20"
    },
    {
      "url": "https://x.com/elonmuskmel7/status/1995156723498393706?s=20"
    }
  ]
}
````

#### 📝 Input Specifications

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `key_value` | Boolean | Yes | Enable Apify Key-Value Store for media storage |
| `post_urls` | Array | Yes | Twitter (X.com) tweet URLs to scrape |
| `url` | String | Yes | Valid Twitter (X.com) tweet URL (status/ format) |

***

### 📤 Output Structure

The **Twitter(X.com) Tweets Scraper** produces comprehensive output like this:

```json
[
  {
    "success": true,
    "tweet_url": "https://x.com/Ndi_Muvenda_/status/1994827626960298171",
    "metadata": {
      "title": "Is this real? &#x1F633;&#x1F62D;",
      "twitter_id": "1994827626960298171",
      "thumbnail": "https://pbs.twimg.com/ext_tw_video_thumb/1994827537868800000/pu/img/gplh-qa6UzOkkjea.jpg",
      "video_count": 3,
      "image_count": 1,
      "audio_count": 1,
      "available_resolutions": ["1280p", "852p", "568p"],
      "available_formats": ["mp4"]
    },
    "videos": [
      {
        "format": "mp4",
        "codec": "avc1",
        "height": 1280,
        "width": 720,
        "quality": "1280p",
        "kv_store_url": "https://api.apify.com/v2/key-value-stores/RIeGpZfdrQQ2NPn6y/records/twitter_video_5ae7883f-f2c9-4900-89fa-8093077a47b2_1280p.mp4?token=apify_api_token"
      }
    ],
    "images": [
      {
        "format": "jpg",
        "kv_store_url": "https://api.apify.com/v2/key-value-stores/RIeGpZfdrQQ2NPn6y/records/twitter_image_ca2d5b9e-e1c5-41e5-a509-694f75fbc1fb.jpg?token=apify_api_token",
        "width": 675,
        "height": 1200,
        "resolution": "675x1200"
      }
    ],
    "audios": [
      {
        "format": "mp3",
        "kv_store_url": "https://api.apify.com/v2/key-value-stores/RIeGpZfdrQQ2NPn6y/records/twitter_audio_707b528e-296b-4ac3-bd96-4048b06db3b8.mp3?token=apify_api_token"
      }
    ]
  }
]
```

#### 📋 Output Field Documentation

**🎯 Status Information**
| Field | Description |
|-------|-------------|
| `success` | Boolean indicating successful extraction |
| `tweet_url` | Original Twitter (X.com) tweet URL |

**📊 Metadata Section**
| Field | Description |
|-------|-------------|
| `title` | Tweet content/title (HTML entities decoded) |
| `twitter_id` | Unique Twitter post identifier |
| `thumbnail` | URL to tweet thumbnail/preview image |
| `video_count` | Number of videos in the tweet |
| `image_count` | Number of images in the tweet |
| `audio_count` | Number of audio files in the tweet |
| `available_resolutions` | Array of available video quality options |
| `available_formats` | Array of supported media formats |

**🎥 Video Assets**
| Field | Description |
|-------|-------------|
| `format` | Video container format (mp4) |
| `codec` | Video codec specification |
| `height` | Vertical resolution in pixels |
| `width` | Horizontal resolution in pixels |
| `quality` | Quality label (1280p, 852p, etc.) |
| `kv_store_url` | Secure Apify Key-Value Store download URL |

**🖼️ Image Assets**
| Field | Description |
|-------|-------------|
| `format` | Image format (jpg, png, etc.) |
| `kv_store_url` | Secure Apify Key-Value Store download URL |
| `width` | Image width in pixels |
| `height` | Image height in pixels |
| `resolution` | Combined resolution string |

**🎵 Audio Assets**
| Field | Description |
|-------|-------------|
| `format` | Audio format (mp3, etc.) |
| `kv_store_url` | Secure Apify Key-Value Store download URL |

***

### 📈 Quality Tiers Available

This **Twitter(X.com) Tweets Scraper** automatically detects and provides multiple quality options for videos:

1. **High Definition** - 1280p (1280x720) with AVC codec support
2. **Standard Definition** - 852p (852x480) balanced quality
3. **Mobile Optimized** - 568p (568x320) for bandwidth efficiency

Each quality tier includes technical specifications for professional editing and analysis workflows.

***

### 🛠️ Technical Features

#### 🔧 Advanced Media Support

- Multi-format extraction (video, image, audio)
- Multiple resolution video options
- AVC/H.264 codec support for videos
- Separate media type categorization
- Secure Key-Value Store integration

#### 📊 Comprehensive Metadata

- Detailed content statistics
- Resolution and format availability
- Tweet identification data
- Media count tracking
- Thumbnail URL extraction

#### 🛡️ Reliability Features

- Secure Apify storage for media files
- Multiple quality fallback options
- Comprehensive error handling
- URL validation and normalization
- Success status tracking

***

### 💼 Use Cases

- **Social Media Analysts** – Track Twitter trends and virality patterns
- **Content Archivists** – Preserve important Twitter discussions
- **Marketing Agencies** – Collect competitor content and campaigns
- **Researchers** – Study social media behavior and content spread
- **Journalists** – Archive news-related tweets and media
- **App Developers** – Build Twitter-powered applications and services

This **Twitter(X.com) Tweets Scraper** is essential for anyone needing reliable Twitter content extraction.

***

#### ❓ Why Choose Our Twitter(X.com) Tweets Scraper?

- **Reliable Performance**: Stable and efficient scraping process
- **User-Friendly**: Simple interface for both beginners and advanced users
- **Regular Updates**: Maintained to ensure compatibility with Twitter/X changes
- **Comprehensive Data**: Get all media and metadata in one structured output
- **Secure Storage**: Apify Key-Value Store ensures safe media access

***

#### ⚠️ Limitations

- Only works with public Twitter (X.com) tweets
- The actor may be subject to Twitter's rate limits and API restrictions
- Requires valid tweet URLs in the correct format

### 🔗🛠 Related Actors (Full Content Scraping Suite)

Explore our full scraping suite for enhanced social media scraping:

#### 📱 Instagram Scrapers:

- [Instagram Reels Downloader](https://apify.com/codenest/instagram-reels-downloader)

#### 🎥 YouTube Scrapers:

- [YouTube Video Scraper](https://apify.com/codenest/youtube-video-scraper)
- [YouTube Video Transcript Scraper](https://apify.com/codenest/youtube-video-transcript-scraper)
- [YouTube Video Extractor](https://apify.com/codenest/youtube-video-extractor)

#### 🎵 Facebook Scrapers:

- [Facebook Video Downloader](https://apify.com/codenest/facebook-video-downloader)
- [Facebook Reels Downloader](https://apify.com/codenest/facebook-reels-downloader)

#### 🐦 Twitter/X.com Specialized Actors:

- [Twitter (X.com) Video Post Scraper](https://apify.com/codenest/twitter-x-com-video-post-scraper)
- [Twitter (X.com) Image Downloader](https://apify.com/codenest/twitter-x-com-image-downloader)
- [Twitter (X.com) mp3/Audio Downloader](https://apify.com/codenest/twitter-x-com-mp3-audio-downloader)

***

### 📧 Need Customization?

Want \*higher resolutions, \*\*batch processing enhancements, or \**additional metadata fields* for your **Twitter(X.com) Tweets Scraper**?

✉️ Email *[codenest2.0@gmail.com](mailto:mailto:codenest2.0@gmail.com)* for tailored solutions!

***

*Note: This **Twitter(X.com) Tweets Scraper** is designed for legitimate data collection purposes. Always comply with Twitter's Terms of Service and respect copyright laws when using extracted content.*

# Actor input Schema

## `post_urls` (type: `array`):

A list of public Twitter/X post URLs (videos and/or images).

## `key_value` (type: `boolean`):

Enable or disable storing files in the key-value store.

## Actor input object example

```json
{
  "post_urls": [
    {
      "url": "https://x.com/iamsrk/status/1994361290421383203"
    }
  ],
  "key_value": false
}
```

# 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 = {
    "post_urls": [
        {
            "url": "https://x.com/iamsrk/status/1994361290421383203"
        }
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("codenest/twitter-x-com-tweets-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 = { "post_urls": [{ "url": "https://x.com/iamsrk/status/1994361290421383203" }] }

# Run the Actor and wait for it to finish
run = client.actor("codenest/twitter-x-com-tweets-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 '{
  "post_urls": [
    {
      "url": "https://x.com/iamsrk/status/1994361290421383203"
    }
  ]
}' |
apify call codenest/twitter-x-com-tweets-scraper --silent --output-dataset

```

## MCP server setup

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

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "Twitter(X.com) Tweets Scraper",
        "description": "🎯 Extract Twitter (X.com) tweets with videos, images & audio! Get structured JSON output with multiple resolutions & secure Apify storage. Perfect for researchers 🔬, marketers 📈 & content analysts 📊 needing reliable social media data extraction.❤️Twitter(X.com) Tweets Scraper❤️.",
        "version": "0.0",
        "x-build-id": "FahgE6prjrQSglsu2"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/codenest~twitter-x-com-tweets-scraper/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-codenest-twitter-x-com-tweets-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/codenest~twitter-x-com-tweets-scraper/runs": {
            "post": {
                "operationId": "runs-sync-codenest-twitter-x-com-tweets-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/codenest~twitter-x-com-tweets-scraper/run-sync": {
            "post": {
                "operationId": "run-sync-codenest-twitter-x-com-tweets-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",
                "required": [
                    "post_urls"
                ],
                "properties": {
                    "post_urls": {
                        "title": "Twitter/X Post URLs",
                        "type": "array",
                        "description": "A list of public Twitter/X post URLs (videos and/or images).",
                        "items": {
                            "type": "object",
                            "properties": {
                                "url": {
                                    "title": "Post URL",
                                    "description": "The full URL of the public Twitter/X post.",
                                    "type": "string",
                                    "pattern": "^https://(www\\.)?(twitter\\.com|x\\.com)/[^/]+/status/"
                                }
                            },
                            "required": [
                                "url"
                            ]
                        }
                    },
                    "key_value": {
                        "title": "Store files in the key-value store?",
                        "type": "boolean",
                        "description": "Enable or disable storing files in the key-value store.",
                        "default": false
                    }
                }
            },
            "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
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
