# Twitter/X Profile & Tweet Scraper (`headlessagent/twitter-x-profile-tweet-scraper`) Actor

Scrape Twitter/X profiles and tweet. Get clean JSON with profile stats, media URLs, captions, comments, tagged users, and more.

- **URL**: https://apify.com/headlessagent/twitter-x-profile-tweet-scraper.md
- **Developed by:** [Headless Agent](https://apify.com/headlessagent) (community)
- **Categories:** Automation, Social media, Videos
- **Stats:** 6 total users, 4 monthly users, 94.0% runs succeeded, NaN bookmarks
- **User rating**: No ratings yet

## Pricing

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

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

## Twitter Profile & Tweet Scraper

Scrape Twitter/X **user profiles** and **tweets** — no API key or login required. Get clean, formatted JSON with only the important fields. Supports usernames and tweet URLs as input.

### 🤔 What can Twitter Profile & Tweet Scraper do?

This Actor lets you **extract public data from Twitter/X profiles and tweets** in one place. Just provide usernames or tweet URLs and get structured results:

👤 Scrape **any public Twitter/X profile** — name, bio, followers, following, tweet count, verification status, and more

📝 Extract **tweet data** — text, timestamps, engagement stats (likes, retweets, replies, quotes, bookmarks)

📸 Extract **media attachments** — photos and videos with direct URLs

📊 Get **user information** embedded in tweets — name, screen name, verification status, profile picture

🏷️ Get **hashtags and URLs** mentioned in tweets

📦 Download results in **JSON, CSV, XML, or Excel** from the Apify Dataset

🦾 Integrate via **API, webhooks, SDKs** (Python & Node.js), or connect with tools like Zapier, n8n, Make, and more

### ✅ What data can I scrape from Twitter/X?

#### From profiles:

- 👤 User ID, name, screen name, description
- 🔗 Bio URLs / links
- 📊 Followers count, following count, tweet count, listed count
- ✅ Verification status (blue verified, legacy verified)
- 🔒 Private account status
- 🖼️ Profile picture URL and banner URL
- 📍 Location
- 📅 Account creation date
- ❤️ Favourites count, media count

#### From tweets:

- 🆔 Tweet ID, text, timestamp
- ❤️ Like count, retweet count, reply count, quote count, bookmark count
- 📝 Language
- 📸 Photo URLs and video URLs (highest quality)
- 🎬 Video duration (in milliseconds)
- 👤 User info — ID, name, screen name, profile picture, verification status
- 🏷️ Hashtags mentioned
- 🔗 URLs mentioned
- 💬 Reply and quote tweet status

### 🔧 How to scrape data from Twitter/X

1. [Create](https://console.apify.com/sign-up) a free Apify account.
2. Open Twitter Profile & Tweet Scraper.
3. Add **usernames** and/or **tweet URLs** — use any combination.
4. Optionally set a **proxy URL** to avoid rate limiting.
5. Click **Save & Start** and wait for the data to be extracted.
6. Download your data in JSON, CSV, XML, Excel, or access it via API.

### ⬇️ Input

Both main fields are optional, but **at least one must be provided**. You can use them independently or together in a single run.

| Field | Type | Description |
|-------|------|-------------|
| `usernames` | `string[]` | Twitter/X usernames or profile URLs (e.g. `elonmusk` or `https://x.com/elonmusk`) |
| `tweetUrls` | `string[]` | Twitter/X tweet URLs (e.g. `https://x.com/SawyerMerritt/status/2040823819162575055`) |
| `proxy` | `string` | Optional proxy URL (`http://` format) to avoid rate limiting |

#### Example input

```json
{
    "usernames": ["elonmusk", "sama"],
    "tweetUrls": ["https://x.com/SawyerMerritt/status/2040823819162575055"],
    "proxy": "http://user:pass@host:port"
}
````

### ⬆️ Output

Results are pushed to the Apify Dataset. Each item has a `type` field (`"user"` or `"tweet"`) so you can easily filter and process them. You can export data in JSON, CSV, XML, Excel, or access it programmatically via the Apify API.

#### 👤 User profile data sample

```json
{
    "type": "user",
    "id": "44196397",
    "name": "Elon Musk",
    "screen_name": "elonmusk",
    "description": "https://t.co/dDtDyVssfm",
    "profile_image_url": "https://pbs.twimg.com/profile_images/2035314704307081216/71U1ftM3_normal.jpg",
    "profile_banner_url": "https://pbs.twimg.com/profile_banners/44196397/1774145451",
    "followers_count": 237803015,
    "following_count": 1309,
    "tweet_count": 100697,
    "listed_count": 167977,
    "is_blue_verified": true,
    "is_verified": false,
    "is_private": false,
    "created_at": "Tue Jun 02 20:12:29 +0000 2009",
    "location": "",
    "url": null,
    "bio_urls": [
        {
            "url": "Terafab.ai",
            "expanded_url": "http://Terafab.ai"
        }
    ],
    "favourites_count": 221306,
    "media_count": 4434
}
```

#### 📝 Tweet data sample

```json
{
    "type": "tweet",
    "url": "https://x.com/SawyerMerritt/status/2040823819162575055",
    "id": "2040823819162575055",
    "text": "Positive Tesla Diner review from Forbes' Brooke Crothers:\n\n\"On Saturday, the Tesla Diner was busy if not packed at times. And obviously not failing, though some blogs and reports want you desperately to believe otherwise.\n\nContrary to all these eatery blogs and car blogs that say https://t.co/5Y6Pon3bQ8",
    "created_at": "Sun Apr 05 16:08:09 +0000 2026",
    "lang": "en",
    "like_count": 1658,
    "retweet_count": 177,
    "reply_count": 73,
    "quote_count": 9,
    "bookmark_count": 53,
    "is_quote_status": false,
    "is_reply": false,
    "in_reply_to_status_id": null,
    "in_reply_to_user_id": null,
    "source": null,
    "user": {
        "id": "243013409",
        "name": "Sawyer Merritt",
        "screen_name": "SawyerMerritt",
        "profile_image_url": "https://pbs.twimg.com/profile_images/1837744842715082752/xH9vYixL_normal.jpg",
        "is_blue_verified": true
    },
    "media": [
        {
            "type": "photo",
            "media_url": "https://pbs.twimg.com/media/HFJzX8fXUAAK059.jpg",
            "expanded_url": "https://x.com/SawyerMerritt/status/2040823819162575055/video/1"
        },
        {
            "type": "photo",
            "media_url": "https://pbs.twimg.com/media/HFJzbQTbsAA0n41.jpg",
            "expanded_url": "https://x.com/SawyerMerritt/status/2040823819162575055/video/1"
        },
        {
            "type": "video",
            "media_url": "https://pbs.twimg.com/amplify_video_thumb/2040823657275252736/img/1tIN4N6eIr52r-zf.jpg",
            "expanded_url": "https://x.com/SawyerMerritt/status/2040823819162575055/video/1",
            "video_url": "https://video.twimg.com/amplify_video/2040823657275252736/vid/avc1/1920x1080/rbtbKbejNboeBdZp.mp4?tag=21",
            "duration_ms": 185386
        }
    ],
    "hashtags": null,
    "urls": null
}
```

### 🔗 Integrations

You can connect Twitter Profile & Tweet Scraper with almost any cloud service or web app through [Apify integrations](https://apify.com/integrations). Connect with **Zapier, n8n, Make, Slack, Google Sheets, Google Drive, Airbyte, GitHub**, and many more.

You can also use [webhooks](https://docs.apify.com/integrations/webhooks) to trigger actions whenever a run finishes — for example, getting a notification or automatically processing the scraped data.

### 🦾 Using the Apify API

The Apify [API](https://docs.apify.com/api/v2) gives you programmatic access to Twitter Profile & Tweet Scraper. You can start runs, fetch datasets, monitor execution, and integrate the scraper into your own workflows.

- **Python**: Use the [`apify-client`](https://pypi.org/project/apify-client/) PyPI package
- **Node.js**: Use the [`apify-client`](https://www.npmjs.com/package/apify-client) NPM package

### ❓ FAQ

#### Can I scrape multiple profiles and tweets in one run?

Yes. Both input fields (`usernames`, `tweetUrls`) accept arrays. You can provide multiple items in each field, and even use both fields together in a single run. Each result will have a `type` field so you can tell them apart.

#### What format is the `created_at` timestamp?

Twitter returns human-readable date strings like `"Sun Apr 05 16:08:09 +0000 2026"`. You can parse these with any standard date library.

#### Why are some tweet fields null?

Some tweets may not be accessible via guest session if they require login, are from protected accounts, or have been deleted. When data is not available, fields will be `null`.

#### Does the scraper work with private accounts?

No. The scraper can only extract data from **public Twitter/X accounts**. Protected/private profiles and tweets are not accessible.

#### Can I use a proxy?

Yes. The optional `proxy` input field accepts HTTP proxy URLs. This is useful to avoid rate limiting or IP blocks when scraping at higher volumes.

#### Is it legal to scrape Twitter/X?

This scraper only extracts publicly available data. It does not access private accounts, login credentials, or any data behind authentication. However, scraped results could contain personal data protected by [GDPR](https://en.wikipedia.org/wiki/General_Data_Protection_Regulation) and other regulations. Ensure you have a legitimate reason for scraping and consult legal counsel if unsure. See also Apify's blog post on the [legality of web scraping](https://blog.apify.com/is-web-scraping-legal/).

# Actor input Schema

## `usernames` (type: `array`):

List of Twitter/X usernames or profile URLs to scrape.

## `tweetUrls` (type: `array`):

List of Twitter/X tweet URLs (e.g. https://x.com/user/status/1234567890).

## `proxy` (type: `string`):

Optional proxy URL (e.g. http://user:pass@host:port). Useful to avoid rate limiting.

## Actor input object example

```json
{
  "usernames": [
    "elonmusk",
    "sama"
  ],
  "tweetUrls": [
    "https://x.com/SawyerMerritt/status/2040823819162575055"
  ]
}
```

# 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 = {
    "usernames": [
        "elonmusk",
        "sama"
    ],
    "tweetUrls": [
        "https://x.com/SawyerMerritt/status/2040823819162575055"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("headlessagent/twitter-x-profile-tweet-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 = {
    "usernames": [
        "elonmusk",
        "sama",
    ],
    "tweetUrls": ["https://x.com/SawyerMerritt/status/2040823819162575055"],
}

# Run the Actor and wait for it to finish
run = client.actor("headlessagent/twitter-x-profile-tweet-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 '{
  "usernames": [
    "elonmusk",
    "sama"
  ],
  "tweetUrls": [
    "https://x.com/SawyerMerritt/status/2040823819162575055"
  ]
}' |
apify call headlessagent/twitter-x-profile-tweet-scraper --silent --output-dataset

```

## MCP server setup

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

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "Twitter/X Profile & Tweet Scraper",
        "description": "Scrape Twitter/X profiles and tweet. Get clean JSON with profile stats, media URLs, captions, comments, tagged users, and more.",
        "version": "1.0",
        "x-build-id": "fLZe3xqdzcRxAF1S6"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/headlessagent~twitter-x-profile-tweet-scraper/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-headlessagent-twitter-x-profile-tweet-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/headlessagent~twitter-x-profile-tweet-scraper/runs": {
            "post": {
                "operationId": "runs-sync-headlessagent-twitter-x-profile-tweet-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/headlessagent~twitter-x-profile-tweet-scraper/run-sync": {
            "post": {
                "operationId": "run-sync-headlessagent-twitter-x-profile-tweet-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": {
                    "usernames": {
                        "title": "Usernames",
                        "type": "array",
                        "description": "List of Twitter/X usernames or profile URLs to scrape.",
                        "items": {
                            "type": "string"
                        }
                    },
                    "tweetUrls": {
                        "title": "Tweet URLs",
                        "type": "array",
                        "description": "List of Twitter/X tweet URLs (e.g. https://x.com/user/status/1234567890).",
                        "items": {
                            "type": "string"
                        }
                    },
                    "proxy": {
                        "title": "Proxy URL",
                        "type": "string",
                        "description": "Optional proxy URL (e.g. http://user:pass@host:port). Useful to avoid rate limiting."
                    }
                }
            },
            "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
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
