# X (Twitter) Profile Scraper (`alvaraaz/x-profile-scraper`) Actor

X Profile Scraper automates extraction of X (Twitter) profiles, posts, likes, retweets, and engagement metrics. Ideal for social media analytics, competitor research, brand monitoring and marketing.

- **URL**: https://apify.com/alvaraaz/x-profile-scraper.md
- **Developed by:** [Jose Fernando Álvarez Romero](https://apify.com/alvaraaz) (community)
- **Categories:** Lead generation, Social media, Automation
- **Stats:** 66 total users, 21 monthly users, 100.0% runs succeeded, 2 bookmarks
- **User rating**: No ratings yet

## Pricing

$6.00 / 1,000 posts

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

## X Profile Scraper

![Apify](https://img.shields.io/badge/Apify-Actor-blue)
![TypeScript](https://img.shields.io/badge/TypeScript-5.9-blue)
![Bun](https://img.shields.io/badge/Bun-1.0+-yellow)
![Playwright](https://img.shields.io/badge/Playwright-Firefox-green)
![Zod](https://img.shields.io/badge/Zod-Schema%20Validation-purple)

**Last updated: 27 March 2026** | [Apify Platform](https://apify.com) | [Documentation](https://docs.apify.com)

---

### What is X Profile Scraper?

X Profile Scraper is an [Apify Actor](https://apify.com) that extracts profile information and posts from X (Twitter). It retrieves usernames, display names, bios, locations, websites, profile and banner images, follower counts, and recent posts with full engagement metrics. The scraper uses Playwright with Firefox browser for reliable data extraction and Zod for data validation.

This tool is designed for social media analysts, researchers, marketers, and developers who need to collect X profile data programmatically. It efficiently collects posts by scrolling through the profile, extracting as much 100 posts per profile with likes, retweets, replies, views, media URLs, and hashtags.

---

### Quick Start

1. Open on [Apify Console](https://console.apify.com)
2. Enter your profile URLs
3. Click **Run**
4. Download results from the **Dataset** tab

```json
{
  "profileUrls": [{ "url": "https://x.com/Topuriailia" }, { "url": "https://x.com/cristiano" }],
  "maxPosts": 20
}
````

***

### Input Parameters

| Parameter     | Type    | Required | Default | Description                                 |
| ------------- | ------- | -------- | ------- | ------------------------------------------- |
| `profileUrls` | array   | Yes      | -       | X (Twitter) profile URLs to scrape          |
| `maxPosts`    | integer | No       | 20      | Maximum posts to scrape per profile (5-100) |

***

### Output Example

```json
{
  "username": "Topuriailia",
  "displayName": "Ilia Topuria",
  "bio": "El Matador • Double UFC World Champion  • Prove them wrong  • Undefeated 17 - 0",
  "location": "Alicante, España",
  "website": "links.iliatopuriaoficial.com",
  "profileImageUrl": "https://pbs.twimg.com/profile_images/1967302527025598466/w153u0mM_200x200.jpg",
  "followersCount": 563800,
  "followingCount": 87,
  "postsCount": 690,
  "isVerified": false,
  "isPrivate": false,
  "posts": [
    {
      "postId": "1880858384427327883",
      "text": "Islam, if I want to, I can finish you.if I want to, I can knock you out. I'll make it look easy. Se you soon ",
      "createdAt": "2025-01-19T06:02:38.000Z",
      "likes": 97000,
      "retweets": 8700,
      "replies": 3300,
      "views": 13000000,
      "isPinned": false,
      "isReply": true,
      "mediaUrls": ["https://abs-0.twimg.com/emoji/v2/svg/1f609.svg"]
    },
    {
      "postId": "1759134716832407716",
      "text": "Cada gota de sangre valió la pena.\n#AndNew #15 ",
      "createdAt": "2024-02-18T08:36:14.000Z",
      "likes": 87000,
      "retweets": 13000,
      "replies": 1600,
      "views": 3600000,
      "isPinned": false,
      "isReply": true,
      "mediaUrls": [
        "https://abs-0.twimg.com/emoji/v2/svg/1f339.svg",
        "https://pbs.twimg.com/ext_tw_video_thumb/1759134558216499200/pu/img/Fqn2kUe4Ewyo3L_L.jpg"
      ],
      "hashtags": ["AndNew"]
    },
    {
      "postId": "1852700468637520324",
      "text": "I didn't expect someone like you to be unable to distinguish between confidence and arrogance. But, at the end of the day, we all reflect our own reality onto others. I wish you the best for what remains of your career, and  God bless your family.",
      "createdAt": "2024-11-02T13:13:07.000Z",
      "likes": 85000,
      "retweets": 6900,
      "replies": 2300,
      "views": 8800000,
      "isPinned": false,
      "isReply": true
    }
  ],
  "scrapedAt": "2026-03-27T12:21:15.067Z"
}
```

#### Output Fields

| Field             | Type    | Description                                |
| ----------------- | ------- | ------------------------------------------ |
| `username`        | string  | X username (without @)                     |
| `displayName`     | string  | Profile display name                       |
| `bio`             | string? | Profile biography                          |
| `location`        | string? | Profile location                           |
| `website`         | string? | Website URL from profile                   |
| `profileImageUrl` | string? | Profile picture URL                        |
| `bannerImageUrl`  | string? | Profile banner URL                         |
| `followersCount`  | number  | Number of followers                        |
| `followingCount`  | number  | Number of accounts followed                |
| `postsCount`      | number  | Total posts displayed on profile           |
| `isVerified`      | boolean | Whether account is verified                |
| `isPrivate`       | boolean | Whether account is private                 |
| `posts`           | Post\[]  | Array of scraped posts                     |
| `scrapedAt`       | string  | ISO 8601 timestamp when data was collected |

#### Post Fields

| Field       | Type     | Description                   |
| ----------- | -------- | ----------------------------- |
| `postId`    | string   | Unique X post ID (required)   |
| `text`      | string   | Post text content (required)  |
| `createdAt` | string?  | ISO 8601 timestamp            |
| `likes`     | number   | Number of likes               |
| `retweets`  | number   | Number of retweets            |
| `replies`   | number?  | Number of replies             |
| `views`     | number?  | Number of views (impressions) |
| `isPinned`  | boolean  | Whether post is pinned        |
| `isReply`   | boolean  | Whether post is a reply       |
| `mediaUrls` | string\[] | URLs of attached media        |
| `hashtags`  | string\[] | Hashtags used in post         |

***

### Features

| Feature                | Description                                         |
| ---------------------- | --------------------------------------------------- |
| **Profile Extraction** | Username, display name, bio, location, website      |
| **Media Collection**   | Profile image, banner image                         |
| **Follower Stats**     | Followers and following counts                      |
| **Post Scraping**      | Up to 100 posts per profile with engagement metrics |
| **Engagement Metrics** | Likes, retweets, replies, views                     |
| **Media Extraction**   | Images, videos from posts                           |
| **Hashtag Detection**  | Extracts hashtags from posts                        |
| **Data Validation**    | Zod schemas ensure structured output                |
| **Incremental Scroll** | Efficient post collection by scrolling              |

***

### Use Cases

#### Social Media Analytics

```json
{
  "profileUrls": ["https://x.com/nasa", "https://x.com/spacex"],
  "maxPosts": 100
}
```

Analyze engagement metrics across multiple profiles to understand audience behavior, content performance, and growth trends.

#### Brand Monitoring

```json
{
  "profileUrls": ["https://x.com/yourbrand"],
  "maxPosts": 100
}
```

Track your brand's X presence, analyze post performance, and monitor engagement over time.

#### Competitor Research

```json
{
  "profileUrls": ["https://x.com/competitor1", "https://x.com/competitor2"],
  "maxPosts": 100
}
```

Compare competitor posting patterns, engagement rates, and content strategies.

#### Content Research

```json
{
  "profileUrls": ["https://x.com/influencer"],
  "maxPosts": 100
}
```

Study content patterns, hashtag usage, and viral posts from industry influencers.

***

### Comparison: X Profile Scraper vs. Other Methods

| Feature     | This Actor           | Manual Search     | Third-Party APIs       |
| ----------- | -------------------- | ----------------- | ---------------------- |
| Cost        | $0.50 per profile    | Free (labor cost) | $1.00-5.00 per profile |
| Speed       | 40 profiles/min      | 1 profile/min     | Varies                 |
| Data depth  | Full profile + posts | Limited           | Varies                 |
| Engagement  | Complete metrics     | Manual count      | Often limited          |
| Media       | Full URLs            | Manual            | Rarely                 |
| Data format | Clean JSON           | Copy-paste        | Varies                 |

***

### Tech Stack

- [**Apify SDK**](https://docs.apify.com/sdk) — Actor platform for cloud execution
- [**Bun**](https://bun.sh/) — JavaScript runtime for fast performance
- [**Playwright**](https://playwright.dev/) — Browser automation with Firefox
- [**TypeScript**](https://www.typescriptlang.org/) — Type safety and better developer experience
- [**Zod**](https://zod.dev/) — Schema validation for data integrity

***

### Frequently Asked Questions

#### How does this scraper work?

The actor uses Playwright with Chromium browser to navigate to X profile pages. It extracts profile information from the page DOM, then scrolls through the profile to collect posts with their engagement metrics. Data is validated using Zod schemas and stored in the Apify dataset.

#### Is this legal?

This tool scrapes publicly available profile data from X. It should be used for legitimate data collection purposes only. Ensure compliance with X's Terms of Service. This is not affiliated with X (formerly Twitter).

#### How many posts can I collect?

The `maxPosts` parameter allows you to set a limit up to 100 posts per profile. The default is 20 posts to balance data collection with execution time. The minimum number of posts to collect is 5.

#### Does this work with private accounts?

No. Private accounts require authentication and the scraper cannot access their content.

#### How fast is the scraper?

The actor processes approximately 40 profiles per minute, depending on the number of posts requested. Each post requires scrolling to load, so higher post counts take longer.

***

### Related Tools

- [X Platform](https://x.com) — Official X website
- [Apify Platform](https://apify.com) — Actor hosting platform
- [Apify SDK Documentation](https://docs.apify.com) — Actor development

***

### Pricing

This actor supports pay-per-event pricing. Each scraped profile charges for the number of posts extracted (configured as `posts` event).

***

### Legal Notice

This tool is for legitimate data collection purposes only. Ensure compliance with X's Terms of Service. This tool is not affiliated with, endorsed by, or connected to X Corp.

# Actor input Schema

## `profileUrls` (type: `array`):

X (Twitter) profile URLs to scrape (e.g., https://x.com/username)

## `maxPosts` (type: `integer`):

Maximum number of posts to scrape per profile

## Actor input object example

```json
{
  "profileUrls": [
    {
      "url": "https://x.com/Topuriailia"
    },
    {
      "url": "https://x.com/Cristiano"
    }
  ],
  "maxPosts": 20
}
```

# Actor output Schema

## `results` (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 = {
    "profileUrls": [
        {
            "url": "https://x.com/Topuriailia"
        },
        {
            "url": "https://x.com/Cristiano"
        }
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("alvaraaz/x-profile-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 = { "profileUrls": [
        { "url": "https://x.com/Topuriailia" },
        { "url": "https://x.com/Cristiano" },
    ] }

# Run the Actor and wait for it to finish
run = client.actor("alvaraaz/x-profile-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 '{
  "profileUrls": [
    {
      "url": "https://x.com/Topuriailia"
    },
    {
      "url": "https://x.com/Cristiano"
    }
  ]
}' |
apify call alvaraaz/x-profile-scraper --silent --output-dataset

```

## MCP server setup

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

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "X (Twitter) Profile Scraper",
        "description": "X Profile Scraper automates extraction of X (Twitter) profiles, posts, likes, retweets, and engagement metrics. Ideal for social media analytics, competitor research, brand monitoring and marketing.",
        "version": "0.0",
        "x-build-id": "NdMlMKajMaJmd99IT"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/alvaraaz~x-profile-scraper/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-alvaraaz-x-profile-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/alvaraaz~x-profile-scraper/runs": {
            "post": {
                "operationId": "runs-sync-alvaraaz-x-profile-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/alvaraaz~x-profile-scraper/run-sync": {
            "post": {
                "operationId": "run-sync-alvaraaz-x-profile-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": [
                    "profileUrls"
                ],
                "properties": {
                    "profileUrls": {
                        "title": "Profile URLs",
                        "minItems": 1,
                        "type": "array",
                        "description": "X (Twitter) profile URLs to scrape (e.g., https://x.com/username)",
                        "items": {
                            "type": "object",
                            "required": [
                                "url"
                            ],
                            "properties": {
                                "url": {
                                    "type": "string",
                                    "title": "URL of a web page",
                                    "format": "uri"
                                }
                            }
                        }
                    },
                    "maxPosts": {
                        "title": "Maximum Posts Per Profile",
                        "minimum": 5,
                        "maximum": 100,
                        "type": "integer",
                        "description": "Maximum number of posts to scrape per profile",
                        "default": 20
                    }
                }
            },
            "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
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
