# X (Twitter) Scraper – Tweets, Profiles, Followers & Search API (`b2b_leads/x-real-time-data`) Actor

Scrape X (Twitter) in real time — search tweets, profiles, timelines, followers, retweeters, quotes, lists, communities & Spaces. No API keys or login needed. Clean, LLM/MCP-ready JSON. Export to CSV, Excel, JSON or API. 15 tools in one Actor, pay only for what you use.

- **URL**: https://apify.com/b2b\_leads/x-real-time-data.md
- **Developed by:** [Chidubem Aneke](https://apify.com/b2b_leads) (community)
- **Categories:** Social media, Lead generation, MCP servers
- **Stats:** 7 total users, 2 monthly users, 99.8% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.20 / 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/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) Real-Time Data Scraper — Tweets, Profiles, Followers, Engagement & More

**Turn X (Twitter) into a clean, structured data feed.** Search tweets, pull profiles and timelines, map followers, find who retweeted or quoted a post, export lists, communities, and Spaces — and optionally your own notifications, analytics, and DMs. One Actor, 15 data sources, one predictable JSON schema.

No X API keys. No developer account. No browser automation to babysit. Just check the boxes for the data you want and press **Start**.

> ⚡ **Real-time** results • 🧩 **15 features** in one Actor • 🤖 **LLM & MCP-ready** JSON • 💸 Pay only for what you enable

***

### 💳 Paid only — requires a paid Apify plan

This Actor **requires a paid Apify plan** (Bronze or higher). It is not available on the Apify Free plan.

- **Free-plan accounts:** runs finish immediately with **no data** and a clear message asking you to upgrade. This is an intentional restriction of the Actor, not a bug.
- **Paid-plan users:** full output, no changes — every feature and cap works exactly as documented below.
- To upgrade, pick a plan in your Apify Console ([Billing → Plans](https://console.apify.com/billing)), then run the Actor again.

***

### Why this Actor

- **Skip the official X API.** No $100–$5,000/mo API tiers, no OAuth apps, no rate-limit math. Enable a feature and get data.
- **15 data sources, one schema.** Every row carries a `featureType` tag and flat `camelCase` fields — so search results, profiles, and followers all slot into the same table, spreadsheet, or database.
- **Built for scale.** Streams results straight to the dataset as they arrive. Runs comfortably on **256 MB** and scrapes up to **100,000 items** per run out of the box (raise it if you need more).
- **Never loses a run to one bad input.** A private account or deleted tweet becomes a tidy `unavailable` row — the rest of your run keeps going.
- **Automation-native.** Pipe results to Google Sheets, Airtable, a webhook, your database, or an AI agent via the Apify API and MCP.

***

### What you can collect

| # | Feature | Turn on with | You get |
|---|---------|--------------|---------|
| 1 | **Keyword & advanced search** *(on by default)* | `enableSearch` | Tweets or people matching keywords, hashtags, cashtags, or full X operators |
| 2 | **User profiles** | `enableUserProfiles` | Follower/following counts, bio, verification, location, join date |
| 3 | **User tweets / timelines** | `enableUserTweets` | Everything an account posts (with or without replies) |
| 4 | **Tweet details + replies** | `enableTweetDetails` | Full metrics for one or many tweets, plus entire reply threads |
| 5 | **Engagers** | `enableEngagers` | Who **retweeted** and who **quoted** a tweet |
| 6 | **Followers & following** | `enableNetwork` | Followers, following, verified followers, subscriptions |
| 7 | **Friendship check** | `enableFriendship` | Does user A follow user B? Mutual? |
| 8 | **Lists** | `enableLists` | List metadata, tweets, members, followers |
| 9 | **Communities** | `enableCommunities` | Community details, tweets, members, and discovery search |
| 10 | **Spaces** | `enableSpaces` | Space metadata, host, speakers, and optional audio stream URL |
| 11 | **Translation** | `enableTranslate` | Any tweet translated into your target language |
| 12 | **Scrape by URL** | `enableScrapeByUrl` | Paste any X link — auto-detects tweet, profile, list, community, Space, or search |
| 13 | **Your notifications** 🔐 | `enableNotifications` | Your account's notification timeline |
| 14 | **Your analytics** 🔐 | `enableAnalytics` | Impressions, engagements, follower growth over time |
| 15 | **Your DM inbox** 🔐 | `enableDmInbox` | Your conversations and messages |

🔐 = uses **your own** X session — see [Account data](#account-data-your-own-session).

***

### Use cases & outcomes

**📈 Social listening & brand monitoring**
Track every mention of your brand, product, or campaign in real time. Search by keyword + language, filter by minimum likes, exclude retweets, and route hits to Slack or a dashboard.

**🔍 Competitor & market intelligence**
Pull competitors' full timelines, watch their follower growth, and see who's amplifying them via retweets and quotes.

**🎯 Lead generation & audience building**
Export the followers of an account (or a curated list), enrich each profile with follower counts and bios, and filter for accounts above a follower threshold — a ready-made prospect list.

**🧠 Influencer & creator discovery**
Find people (not tweets) with People search, rank by followers and verification, and check verified-follower overlap between accounts.

**📰 Research, journalism & OSINT**
Reconstruct full conversation threads, map quote/retweet networks, and archive lists, communities, and Spaces with canonical `x.com` URLs and ISO timestamps on every record.

**🤖 AI agents & RAG pipelines**
Feed clean, flat JSON straight into an LLM. Stable `featureType` tags and predictable fields mean no brittle parsing — perfect for Apify MCP and agent tooling.

**📊 Your own performance analytics**
Export your notifications, engagement time series, and DM history for personal analytics, backups, or CRM sync.

***

### Quick start

1. Open the Actor in Apify Console and press **Start**. **Search is on by default** — you'll get tweets for the sample keyword immediately.
2. Type your own keywords, or check any of the other 14 features and fill in usernames, tweet IDs, or URLs.
3. Press **Start** and watch rows stream into the dataset.
4. Export as **JSON / CSV / Excel**, or pull via the **Apify API**, **integrations**, or **MCP**.

#### Try it — search only

```json
{
  "searchTerms": ["AI agents", "LLM"],
  "searchType": "Latest",
  "searchMaxResultsPerQuery": 100
}
```

#### Followers → lead list

```json
{
  "enableSearch": false,
  "enableNetwork": true,
  "networkUsernames": ["openai"],
  "networkType": "followers",
  "networkMinFollowers": 500,
  "maxItems": 5000
}
```

#### Profiles + full timelines

```json
{
  "enableSearch": false,
  "enableUserProfiles": true,
  "profileUsernames": ["nasa", "spacex"],
  "enableUserTweets": true,
  "timelineUsernames": ["nasa", "spacex"],
  "includeReplies": false
}
```

#### Who engaged with a tweet

```json
{
  "enableSearch": false,
  "enableEngagers": true,
  "engagerTweetUrls": ["https://x.com/nasa/status/1000000000000000001"],
  "engagerType": "both"
}
```

#### Paste any link

```json
{
  "enableSearch": false,
  "enableScrapeByUrl": true,
  "scrapeUrls": [
    "https://x.com/nasa",
    "https://x.com/i/status/1000000000000000001",
    "https://x.com/i/lists/1234567890123456"
  ]
}
```

> 💡 **API tip:** Search is on by default. For a single-purpose API run, set `"enableSearch": false` and turn on only the feature you need.

***

### Output you can trust

Every row is a **flat JSON object** with a consistent envelope, so mixed results stay easy to filter and join:

| Field | Meaning |
|-------|---------|
| `featureType` | Which feature produced this row — filter on it |
| `scrapedAt` | ISO 8601 UTC timestamp of collection |
| `sourceUrl` | Canonical `https://x.com/...` link when applicable |
| `inputRef` | The query, ID, or URL that produced the row |

**Tweet rows** include: `id`, `url`, `text`, `lang`, `createdAt`, `likeCount`, `replyCount`, `retweetCount`, `quoteCount`, `bookmarkCount`, `viewCount`, `hashtags`, `mentions`, `urls`, `media`, `isReply`, `isRetweet`, `isQuote`, `author`, and more.

**User rows** include: `id`, `username`, `displayName`, `bio`, `followersCount`, `followingCount`, `tweetCount`, `verified`, `isBlueVerified`, `location`, `website`, `profileImageUrl`, and more.

**Example — a search result:**

```json
{
  "featureType": "search",
  "scrapedAt": "2026-07-05T12:00:00.000Z",
  "sourceUrl": "https://x.com/nasa/status/1000000000000000001",
  "inputRef": "AI agents",
  "id": "1000000000000000001",
  "text": "Exploring the universe with AI agents…",
  "lang": "en",
  "likeCount": 1240,
  "retweetCount": 320,
  "viewCount": 98000,
  "authorUsername": "nasa",
  "createdAt": "2026-07-05T09:14:00.000Z"
}
```

Couldn't be fetched? You get an explicit marker instead of a silent gap:

```json
{
  "featureType": "unavailable",
  "reason": "private",
  "message": "User @example is protected.",
  "inputRef": "example",
  "scrapedAt": "2026-07-05T12:00:00.000Z"
}
```

After every run, the **OUTPUT** tab shows a summary: `enabledFeatures`, `recordCounts` per feature, `upstreamRequestCount`, and any non-fatal `errors`.

***

### Built for LLMs, agents & MCP

This Actor is designed to drop straight into AI workflows:

- **Flat, predictable records** — `camelCase` keys, `null` for missing values, no deep nesting to unravel.
- **Stable `featureType` enum** — agents filter by row type without guessing shapes.
- **Self-describing rows** — `inputRef`, `sourceUrl`, and `scrapedAt` on every record.
- **Canonical URLs** — full `https://x.com/...` links for every tweet and profile.

Use it through **Apify MCP** and ask your agent to filter on `featureType == "search"`, or export JSON/CSV from the dataset API and pipe into your RAG store.

***

### Dataset views

The dataset ships with ready-made tabbed views in the Console — **Overview, Search, Profiles, User tweets, Tweet details, Engagers, Network, Notifications, Analytics, Direct messages,** and **Unavailable** — so you can read results without building a single filter.

***

### Account data (your own session)

Three optional features — **notifications, analytics, and DM inbox** — read **your own** X account. They require credentials you provide at run time (all secret, never logged):

| Field | Needed for | Format |
|-------|-----------|--------|
| **X auth token** (`authToken`) | Notifications, Analytics, DM Inbox | Your `auth_token` cookie value |
| **Proxy host / port / username / password** | All account-data features | Filled in four simple fields (assembled for you) |
| **X ct0 token** (`ct0`) | DM Inbox | Your `ct0` CSRF cookie |

**How to get your auth token (and ct0):**

1. Log in to [x.com](https://x.com) in Chrome.
2. Press **F12** → open the **Application** tab → **Cookies** → `https://x.com`.
3. Copy the value of the cookie named **`auth_token`** (and **`ct0`** for DM Inbox).

Easier option: install the free **Cookie-Editor** or **EditThisCookie** Chrome extension, click it on x.com, and copy the `auth_token` / `ct0` values.

**Proxy:** enter your **host, port, username, and password** in the four dedicated fields — the Actor assembles them for you. (Advanced users can paste a full `host:port@user:pass` string instead.) Use a **stable, sticky** residential/ISP proxy you control — rotating IPs (including Apify's rotating proxy) can trigger X security challenges and are never used for logged-in features.

These features are **read-only** (no posting, liking, following, or sending messages). You're responsible for complying with X's Terms of Service and applicable privacy laws when exporting your own data.

***

### Controlling scope & cost

| Field | Default | What it does |
|-------|---------|--------------|
| `maxItems` | `100000` | Global ceiling for the whole run — the main cost lever |
| Per-feature max (e.g. `searchMaxResultsPerQuery`, `networkMaxUsers`) | varies | Cap a single feature; **`0` = unlimited** within `maxItems` |
| `maxRetries` | `5` | Automatic retries on rate limits / server errors |
| `includeRaw` | `false` | Attach the untouched upstream payload to each row |

Heavy jobs (full follower lists, complete reply threads) use more compute and time — lower `maxItems` or per-feature caps to keep runs lean. The full field list with defaults lives in the Console input form.

***

### FAQ

**Do I need an X/Twitter API key?** No. Public features work out of the box.

**Is this real-time?** Yes — each run fetches live data at request time.

**What formats can I export?** JSON, CSV, Excel, HTML, or RSS — plus the Apify API, webhooks, and integrations.

**Will one bad URL break my run?** No. Failed items become `unavailable` rows and the run continues.

**Can I schedule it?** Yes — use Apify Schedules to run hourly, daily, or on any cron you like.

***

### Support

Open an issue on the Actor page or contact the publisher with your run ID, the features you enabled, and your (redacted) input JSON.

***

### Contact me

Need something built beyond this Actor? I take on **custom projects** — from Apify scrapers and data pipelines to full-stack web apps.

| | |
|---|---|
| **Email** | <dubem115@gmail.com> |
| **GitHub** | [github.com/DrunkCodes](https://github.com/DrunkCodes) |

**What I can help with:**

- Custom scraping actors (X, Amazon, LinkedIn, e-commerce, lead gen, and more)
- Data extraction, enrichment, and automation workflows
- Web applications of any kind — dashboards, SaaS tools, internal tools, and APIs

Reach out with a short description of your project and timeline — happy to discuss scope and pricing.

# Actor input Schema

## `enableSearch` (type: `boolean`):

Search X by keyword, hashtag, cashtag, or advanced query. Returns tweets (or people for People search type). Enabled by default.

## `searchQueries` (type: `array`):

Full X search query strings (supports operators like min\_faves:, lang:, -is:retweet). Use searchTerms for plain keywords.

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

Plain keywords auto-combined into OR queries. Required when Search is enabled unless searchQueries is set.

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

Result type returned by search.

## `searchMaxResultsPerQuery` (type: `integer`):

Maximum items to collect per search query. Set 0 for unlimited (bounded by maxItems).

## `searchMaxPages` (type: `integer`):

Maximum cursor pages per query.

## `searchLanguage` (type: `string`):

Optional ISO language code (e.g. en, es). Applied in query and re-validated post-fetch.

## `searchMinLikes` (type: `integer`):

Filter tweets with at least this many likes. 0 = no filter.

## `searchExcludeRetweets` (type: `boolean`):

Exclude retweets from search results.

## `searchStartDate` (type: `string`):

ISO 8601 date — only include tweets on or after this date (filtered after fetch, not via since: operator).

## `searchEndDate` (type: `string`):

ISO 8601 date — only include tweets on or before this date.

## `enableUserProfiles` (type: `boolean`):

Fetch profile data for usernames or user IDs (batched up to 50 per request).

## `profileUsernames` (type: `array`):

X usernames without @.

## `profileUserIds` (type: `array`):

Numeric X user IDs.

## `includeAboutAccount` (type: `boolean`):

Fetch extended account info (username history, affiliates, account source). One extra request per username.

## `enableUserTweets` (type: `boolean`):

Fetch tweets posted by specific users.

## `timelineUsernames` (type: `array`):

Usernames whose timelines to scrape.

## `timelineUserIds` (type: `array`):

User IDs whose timelines to scrape (skips username resolution).

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

Include reply tweets in the timeline (tweets-and-replies vs tweets only).

## `timelineMaxTweets` (type: `integer`):

0 = unlimited (bounded by maxItems).

## `timelineMaxPages` (type: `integer`):

Maximum cursor pages per user timeline.

## `enableTweetDetails` (type: `boolean`):

Fetch full tweet data and optional conversation replies.

## `tweetIds` (type: `array`):

Numeric tweet IDs.

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

Full X tweet URLs (IDs extracted automatically).

## `includeConversationReplies` (type: `boolean`):

Paginate replies for each tweet.

## `repliesSort` (type: `string`):

Order in which conversation replies are returned.

## `repliesMaxPerTweet` (type: `integer`):

0 = unlimited (bounded by maxItems).

## `bulkMetricsOnly` (type: `boolean`):

Use batch details-by-ids for cheap engagement snapshots (no reply threads).

## `enableEngagers` (type: `boolean`):

Fetch retweeters and/or quote tweets for given tweet IDs.

## `engagerTweetIds` (type: `array`):

Numeric tweet IDs to fetch engagers for.

## `engagerTweetUrls` (type: `array`):

Full X tweet URLs to fetch engagers for (IDs extracted automatically).

## `engagerType` (type: `string`):

Which engagers to fetch: retweeters, quote tweets, or both.

## `engagersMaxPerTweet` (type: `integer`):

0 = unlimited (bounded by maxItems).

## `engagersMaxPages` (type: `integer`):

Maximum cursor pages per tweet when fetching engagers.

## `enableNetwork` (type: `boolean`):

Fetch followers, following, verified followers, or subscriptions for users.

## `networkUsernames` (type: `array`):

Usernames whose network (followers/following) to scrape.

## `networkUserIds` (type: `array`):

User IDs whose network to scrape (skips username resolution).

## `networkType` (type: `string`):

Which relationship to fetch for each user.

## `networkMaxUsers` (type: `integer`):

0 = unlimited (bounded by maxItems). Use for scraping all followers of an account.

## `networkMaxPages` (type: `integer`):

Maximum cursor pages per user when fetching network data.

## `networkPageSize` (type: `integer`):

Items per page when the list endpoint supports count (max 100).

## `networkMinFollowers` (type: `integer`):

Post-fetch filter: only include users with at least this many followers.

## `enableFriendship` (type: `boolean`):

Check if one user follows another.

## `friendshipPairs` (type: `array`):

Array of {subject, target} usernames or IDs.

## `enableLists` (type: `boolean`):

Scrape X list metadata, tweets, members, or followers.

## `listIds` (type: `array`):

Numeric X list IDs.

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

Full X list URLs (IDs extracted automatically).

## `listScrapeType` (type: `array`):

What to fetch for each list.

## `listMaxTweets` (type: `integer`):

0 = unlimited (bounded by maxItems).

## `listMaxMembers` (type: `integer`):

0 = unlimited (bounded by maxItems). Also applies to list followers.

## `listMaxPages` (type: `integer`):

Maximum cursor pages per list.

## `enableCommunities` (type: `boolean`):

Scrape community details, tweets, members, or search for communities.

## `communityIds` (type: `array`):

Numeric X community IDs.

## `communityUrls` (type: `array`):

Full X community URLs (IDs extracted automatically).

## `communitySearchQueries` (type: `array`):

Keywords to discover communities (requires 'search' in community scrape types).

## `communityScrapeType` (type: `array`):

What to fetch for each community.

## `communitySortBy` (type: `string`):

Order in which community tweets are returned.

## `communityMaxTweets` (type: `integer`):

0 = unlimited (bounded by maxItems).

## `communityMaxMembers` (type: `integer`):

0 = unlimited (bounded by maxItems).

## `communityMaxPages` (type: `integer`):

Maximum cursor pages per community.

## `enableSpaces` (type: `boolean`):

Fetch X Space metadata and optional HLS stream URL.

## `spaceIds` (type: `array`):

X Space IDs.

## `spaceUrls` (type: `array`):

Full X Space URLs (IDs extracted automatically).

## `includeStreamUrl` (type: `boolean`):

Resolve HLS audio stream URL from space mediaKey.

## `enableTranslate` (type: `boolean`):

Translate tweet text to a target language.

## `translateTweetIds` (type: `array`):

Numeric tweet IDs to translate.

## `translateTweetUrls` (type: `array`):

Full X tweet URLs to translate (IDs extracted automatically).

## `translateTargetLang` (type: `string`):

ISO language code (en, es, fr, de, ja, zh-CN, …).

## `enableScrapeByUrl` (type: `boolean`):

Paste any X URL — auto-detect page type and return structured data.

## `scrapeUrls` (type: `array`):

Any X URLs — tweets, profiles, lists, communities, Spaces, or search pages.

## `scrapeExtractType` (type: `string`):

Force a specific extraction type, or auto-detect from each URL.

## `scrapeIncludeReplies` (type: `boolean`):

For tweet URLs, also paginate and return conversation replies.

## `scrapeMaxItems` (type: `integer`):

0 = unlimited per URL (bounded by maxItems).

## `scrapeMaxPages` (type: `integer`):

Maximum cursor pages per URL.

## `enableNotifications` (type: `boolean`):

Read notifications for your own X account (requires authToken + sticky proxy).

## `enableAnalytics` (type: `boolean`):

Fetch engagement analytics for your own account.

## `enableDmInbox` (type: `boolean`):

Read DM conversations for your own account (requires authToken + ct0 + sticky proxy).

## `authToken` (type: `string`):

Your X account login token (the 'auth\_token' cookie). Required for any account-data feature (Notifications, Analytics, DM Inbox). HOW TO GET IT: 1) Log in to x.com in Chrome. 2) Press F12 → open the 'Application' tab → Cookies → https://x.com. 3) Copy the value of the cookie named 'auth\_token'. Easier option: install the free 'Cookie-Editor' or 'EditThisCookie' Chrome extension, click it on x.com, and copy the 'auth\_token' value. Treated as a secret and never logged.

## `ct0` (type: `string`):

Your X 'ct0' cookie value. Required for DM Inbox (and encrypted X Chat). Get it the same way as the auth token: F12 → Application tab → Cookies → https://x.com → copy the 'ct0' value (or use the Cookie-Editor extension). Treated as a secret and never logged.

## `proxyHost` (type: `string`):

Your proxy server address, e.g. proxy.example.com or 123.45.67.89. From your proxy provider's dashboard. Use a sticky (non-rotating) residential/ISP proxy — do NOT use Apify's rotating proxy for a logged-in account.

## `proxyPort` (type: `string`):

Your proxy port number, e.g. 8080. From your proxy provider's dashboard.

## `proxyUsername` (type: `string`):

The username/login for your proxy. From your proxy provider's dashboard.

## `proxyPassword` (type: `string`):

The password for your proxy. From your proxy provider's dashboard. Treated as a secret and never logged.

## `userProxy` (type: `string`):

Advanced: instead of the four proxy fields above, paste a full sticky proxy string in host:port@user:pass format (e.g. proxy.example.com:8080@myuser:mypass). If set, this overrides the separate fields. Required (via this field or the four above) for account-data features.

## `notificationsType` (type: `string`):

Which notifications timeline to read.

## `notificationsMax` (type: `integer`):

0 = unlimited (bounded by maxItems).

## `notificationsMaxPages` (type: `integer`):

Maximum cursor pages when reading notifications.

## `analyticsFromTime` (type: `string`):

ISO 8601 start time. Empty = 30 days ago.

## `analyticsToTime` (type: `string`):

ISO 8601 end time. Empty = now.

## `analyticsGranularity` (type: `string`):

Time bucket size for the analytics series.

## `analyticsShowVerifiedFollowers` (type: `boolean`):

Include verified follower counts in the analytics output.

## `dmScope` (type: `string`):

Which DM inbox timelines to read.

## `dmIncludeEncrypted` (type: `boolean`):

Also read encrypted X Chat history (requires xchatUserId and xchatPin).

## `xchatUserId` (type: `string`):

Your numeric user ID for encrypted DM setup.

## `xchatPin` (type: `string`):

Your X Chat PIN (4–6 digits) if reading encrypted history.

## `dmConversationIds` (type: `array`):

Specific conversation IDs. Empty = list inbox.

## `dmMaxMessages` (type: `integer`):

0 = unlimited (bounded by maxItems).

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

Global ceiling for this run. Default 100,000 — high enough to scrape all followers/replies/engagers. Lower to cap cost. Note: free Apify-plan accounts are blocked from running this Actor — upgrade to a paid plan to access the data.

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

Reactive retries on 429/5xx/transport errors before marking an item unavailable.

## `retryBaseDelayMs` (type: `integer`):

Initial backoff delay before the first retry (grows exponentially).

## `retryMaxDelayMs` (type: `integer`):

Maximum backoff delay between retries.

## `includeRaw` (type: `boolean`):

Attach untouched upstream JSON under the raw field on each record.

## `cacheTtlSeconds` (type: `integer`):

Cache stable entities across runs in KV store. 0 = off (real-time).

## Actor input object example

```json
{
  "enableSearch": true,
  "searchQueries": [],
  "searchTerms": [
    "AI agents"
  ],
  "searchType": "Latest",
  "searchMaxResultsPerQuery": 100,
  "searchMaxPages": 100,
  "searchLanguage": "",
  "searchMinLikes": 0,
  "searchExcludeRetweets": false,
  "searchStartDate": "",
  "searchEndDate": "",
  "enableUserProfiles": false,
  "profileUsernames": [],
  "profileUserIds": [],
  "includeAboutAccount": false,
  "enableUserTweets": false,
  "timelineUsernames": [],
  "timelineUserIds": [],
  "includeReplies": false,
  "timelineMaxTweets": 0,
  "timelineMaxPages": 100,
  "enableTweetDetails": false,
  "tweetIds": [],
  "tweetUrls": [],
  "includeConversationReplies": false,
  "repliesSort": "Relevance",
  "repliesMaxPerTweet": 0,
  "bulkMetricsOnly": false,
  "enableEngagers": false,
  "engagerTweetIds": [],
  "engagerTweetUrls": [],
  "engagerType": "both",
  "engagersMaxPerTweet": 0,
  "engagersMaxPages": 100,
  "enableNetwork": false,
  "networkUsernames": [],
  "networkUserIds": [],
  "networkType": "followers",
  "networkMaxUsers": 0,
  "networkMaxPages": 100,
  "networkPageSize": 100,
  "networkMinFollowers": 0,
  "enableFriendship": false,
  "friendshipPairs": [],
  "enableLists": false,
  "listIds": [],
  "listUrls": [],
  "listScrapeType": [
    "details",
    "tweets"
  ],
  "listMaxTweets": 0,
  "listMaxMembers": 0,
  "listMaxPages": 100,
  "enableCommunities": false,
  "communityIds": [],
  "communityUrls": [],
  "communitySearchQueries": [],
  "communityScrapeType": [
    "details",
    "tweets"
  ],
  "communitySortBy": "Recency",
  "communityMaxTweets": 0,
  "communityMaxMembers": 0,
  "communityMaxPages": 100,
  "enableSpaces": false,
  "spaceIds": [],
  "spaceUrls": [],
  "includeStreamUrl": false,
  "enableTranslate": false,
  "translateTweetIds": [],
  "translateTweetUrls": [],
  "translateTargetLang": "en",
  "enableScrapeByUrl": false,
  "scrapeUrls": [],
  "scrapeExtractType": "auto",
  "scrapeIncludeReplies": false,
  "scrapeMaxItems": 0,
  "scrapeMaxPages": 100,
  "enableNotifications": false,
  "enableAnalytics": false,
  "enableDmInbox": false,
  "proxyHost": "",
  "proxyPort": "",
  "notificationsType": "All",
  "notificationsMax": 0,
  "notificationsMaxPages": 100,
  "analyticsFromTime": "",
  "analyticsToTime": "",
  "analyticsGranularity": "Daily",
  "analyticsShowVerifiedFollowers": true,
  "dmScope": "trusted",
  "dmIncludeEncrypted": false,
  "dmConversationIds": [],
  "dmMaxMessages": 0,
  "maxItems": 100000,
  "maxRetries": 5,
  "retryBaseDelayMs": 2000,
  "retryMaxDelayMs": 30000,
  "includeRaw": false,
  "cacheTtlSeconds": 0
}
```

# Actor output Schema

## `results` (type: `string`):

All scraped records (tweets, profiles, followers, engagers, and more), tagged by featureType.

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

Key fields across every record type in a single table.

## `runSummary` (type: `string`):

Per-run metadata: enabled features, record counts, upstream request count, paywall decision (paid vs. free plan), and non-fatal errors.

# 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 = {
    "searchQueries": [],
    "searchTerms": [
        "AI agents"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("b2b_leads/x-real-time-data").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 = {
    "searchQueries": [],
    "searchTerms": ["AI agents"],
}

# Run the Actor and wait for it to finish
run = client.actor("b2b_leads/x-real-time-data").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 '{
  "searchQueries": [],
  "searchTerms": [
    "AI agents"
  ]
}' |
apify call b2b_leads/x-real-time-data --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,b2b_leads/x-real-time-data"
        }
    }
}

```

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/ygGLcaLxdEMkA6LWf/builds/3qmkAbgQc0adKuvdL/openapi.json
