# X / Twitter Profile Timeline Scraper (`social_developer/x-twitter-profile-timeline-scraper`) Actor

Scrape an X (Twitter) profile and its tweet timeline. Paste @handles or profile URLs — get profile metadata plus likes, replies, retweets, views, and text as clean JSON. MCP-ready for AI agents.

- **URL**: https://apify.com/social\_developer/x-twitter-profile-timeline-scraper.md
- **Developed by:** [Rishab](https://apify.com/social_developer) (community)
- **Categories:** Agents, Social media, MCP servers
- **Stats:** 2 total users, 2 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.00005 / actor start

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/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
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.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — 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 / Twitter Profile Timeline Scraper

**Paste an X (Twitter) @handle or profile URL. Get profile stats + timeline tweets — likes, replies, reposts, views & text as clean JSON. MCP-ready for AI.**

**Actor:** `social_developer/x-twitter-profile-timeline-scraper`\
**MCP:** `https://mcp.apify.com/?tools=social_developer/x-twitter-profile-timeline-scraper`

Turns any public X profile into structured rows:

- Profile: `username`, `name`, `bio`, `followersCount`, `followingCount`, `statusesCount`, `isBlueVerified`
- Timeline: `tweetId`, `text`, `likeCount`, `retweetCount`, `replyCount`, `quoteCount`, `viewCount`, `createdAt`, `url`, media

> Profile in → timeline out. One dataset row per tweet. Not affiliated with X Corp.

| Why this scraper | |
|---|---|
| Profile timeline focus | Resolves handle → paginates `UserTweets` |
| Stable schema | Predictable fields for sheets, agents, pipelines |
| Cookie + residential proxy | Depth that guest mode cannot deliver |
| MCP-ready | Same Apify MCP pattern as our IG / YT / FB actors |

***

### Sibling scrapers (same paste → JSON workflow)

| Actor | Best for |
|---|---|
| **X Profile Timeline** *(this)* | Profile + tweets by @handle |
| [Instagram Post & Reel Scraper](https://apify.com/social_developer/instagram-post-link-scraper) | IG link → views / likes / comments |
| [YouTube Video Link Scraper](https://console.apify.com/actors/dq0gHM2cIZyblDr1L/) | YT link → views / likes / comments |
| [Facebook Posts & Reels Scraper](https://console.apify.com/actors/Gxlh7dfGl46sVup4S/) | FB link → reactions / comments / shares / plays |

***

### Input

```json
{
  "profiles": ["https://x.com/handle"],
  "fromDate": "2026-08-18",
  "toDate": "2026-08-20"
}
```

| Field | Meaning |
|---|---|
| `profiles` | Profile **link** (`https://x.com/handle`) or `@handle` |
| `fromDate` | Start of window (inclusive), `YYYY-MM-DD` |
| `toDate` | End of window (inclusive), `YYYY-MM-DD` |

There is **no tweet cap**. The Actor returns every tweet in the date window (or the full recent timeline if dates are empty). Auth cookies are built in — users do not paste them.

Wide ranges are split into 5-day search windows internally.

***

### Output (one row per tweet)

```json
{
  "inputProfile": "NASA",
  "username": "NASA",
  "userId": "11348282",
  "name": "NASA",
  "followersCount": 85000000,
  "tweetId": "1234567890",
  "url": "https://x.com/NASA/status/1234567890",
  "text": "…",
  "likeCount": 1200,
  "retweetCount": 400,
  "replyCount": 80,
  "viewCount": 250000,
  "createdAt": "2026-01-15T12:00:00Z",
  "isRetweet": false,
  "isReply": false,
  "hasMedia": true,
  "mediaUrls": ["https://pbs.twimg.com/…"],
  "scrapedAt": "2026-08-01T19:00:00Z"
}
```

***

### Local run

```bash
cd X_TWITTER_PROFILE_TIMELINE_SCRAPER
python -m venv .venv && source .venv/bin/activate
pip install -r requirements.txt

## Profile link + date range (all tweets in window)
python run_local.py https://x.com/handle --from 2026-08-18 --to 2026-08-20 --out output/run.json
```

Apify local:

```bash
apify run -p
```

***

### How it works

1. Normalize `@handle` / `x.com/handle` / `twitter.com/handle`.
2. Refresh GraphQL `queryId`s from X client JS when possible.
3. `UserByScreenName` → profile metadata + `userId`.
4. Paginate until the date window (or timeline) is exhausted.
5. Emit one dataset row per tweet (profile fields denormalized).

GraphQL query IDs rotate when X ships a new web client. Baked IDs + fallbacks live in `src/constants.py`; the actor also refreshes from client JS on hard 404s. If feature flags break, update `FEATURES` / `USER_FEATURES` there.

***

### Out of scope (v1)

Followers/following export, keyword search, single-tweet-by-URL mode, posting, monitors, webhooks. Those can be separate actors later.

***

### License / affiliation

Independent third-party tool. Not affiliated with X Corp. "Twitter" and "X" are trademarks of X Corp. Use only on data you are allowed to access; respect X Terms of Service and applicable law.

# Actor input Schema

## `profiles` (type: `array`):

x.com or twitter.com profile URLs, or @handles.

## `fromDate` (type: `string`):

Keep tweets on/after this date (YYYY-MM-DD). Inclusive. Leave empty to start from the newest posts.

## `toDate` (type: `string`):

Keep tweets on/before this date (YYYY-MM-DD). Inclusive. Leave empty for now.

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

Keep retweets in the timeline.

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

Keep reply tweets.

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

Residential Apify Proxy is always enabled for this Actor and cannot be turned off.

## Actor input object example

```json
{
  "includeRetweets": true,
  "includeReplies": true,
  "proxyConfiguration": {
    "useApifyProxy": true,
    "apifyProxyGroups": [
      "RESIDENTIAL"
    ]
  }
}
```

# Actor output Schema

## `overview` (type: `string`):

Post thumbnail, following, media count, verified / blue verified, engagement

## `engagement` (type: `string`):

Likes, retweets, replies, views

## `profile` (type: `string`):

Following, media count, avatar, verified, blue verified

## `dataset` (type: `string`):

Full dataset export

# 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 = {
    "proxyConfiguration": {
        "useApifyProxy": true,
        "apifyProxyGroups": [
            "RESIDENTIAL"
        ]
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("social_developer/x-twitter-profile-timeline-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 = { "proxyConfiguration": {
        "useApifyProxy": True,
        "apifyProxyGroups": ["RESIDENTIAL"],
    } }

# Run the Actor and wait for it to finish
run = client.actor("social_developer/x-twitter-profile-timeline-scraper").call(run_input=run_input)

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

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

```

## CLI example

```bash
echo '{
  "proxyConfiguration": {
    "useApifyProxy": true,
    "apifyProxyGroups": [
      "RESIDENTIAL"
    ]
  }
}' |
apify call social_developer/x-twitter-profile-timeline-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,social_developer/x-twitter-profile-timeline-scraper"
        }
    }
}

```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/ydpFqlWddxdlOjfhO/builds/ve5IdFQJzTQqHofg5/openapi.json
