# Tweet X Scraper (`qaseemiqbal/tweet-x-scraper`) Actor

Collect public X/Twitter tweets from usernames, from:username queries, tweet URLs, and tweet IDs. Export clean tweet text, author info, engagement metrics, media, links, and run summaries without X login.

- **URL**: https://apify.com/qaseemiqbal/tweet-x-scraper.md
- **Developed by:** [Muhammad Qaseem Iqbal](https://apify.com/qaseemiqbal) (community)
- **Categories:** Social media
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.15 / 1,000 tweets

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

## Tweet X Scraper 🚀

Collect clean, ready-to-use public tweet data from X/Twitter without needing an X login. Tweet X Scraper currently focuses on public usernames, `from:username` queries, tweet URLs, and tweet IDs, then saves the results in a clear Apify dataset you can export, analyze, or send to your own tools. ✨

Use it for social listening, brand monitoring, market research, trend discovery, journalism, lead research, AI training datasets, RAG pipelines, and automated reporting. 📊

> Tweet X Scraper works with public data only. It cannot access private or protected accounts, and it does not bypass X/Twitter permissions. Generic keyword, hashtag, mention, cashtag, and advanced search are reported as unsupported while X public search rejects guest requests. 🔒

### 🌟 What Can You Do With Tweet X Scraper?

- 👤 Collect tweets from public usernames using simple profile inputs.
- 🔎 Use simple `from:username` queries such as `from:apify` or `from:elonmusk`.
- 🔗 Fetch exact tweets from tweet URLs or tweet IDs.
- 🧹 Remove duplicate tweets when searches overlap.
- 📈 Capture useful engagement data such as likes, replies, reposts, quotes, bookmarks, and views when available.
- 🧑‍💼 Include author details such as username, display name, profile URL, verification signals, and follower counts when available.
- 🖼️ Detect media, links, hashtags, mentions, and cashtags.
- 🧠 Add optional local enrichments such as engagement score, simple sentiment, entities, and topics.
- 🧾 Save a friendly run summary in `OUTPUT` so you can quickly see what happened.
- ⚠️ Optionally save structured error records for unavailable tweets or failed lookups.
- 💸 Run with cost-saving defaults from the first click.

### ✅ Popular Use Cases

#### 📣 Brand Monitoring

Track posts from public accounts you care about, such as your brand, executives, competitors, partners, or industry voices.

Example sources:

- `from:openai`
- `from:apify`
- `openai` in `fromUsers`
- Exact tweet URLs from X/Twitter

#### 🧭 Market Research

Discover what people are saying about products, industries, events, public figures, or fast-moving topics.

Great for:

- 🧪 Product research
- 🗣️ Voice-of-customer analysis
- 🏁 Competitor monitoring
- 📊 Trend reports
- 📰 Newsroom research

#### 🤖 AI & Data Pipelines

Export clean JSON records for:

- 🧠 LLM research datasets
- 🔍 Retrieval-augmented generation
- 📚 Knowledge bases
- 📈 Dashboards
- 🧪 Data science notebooks
- 🛠️ Internal automation

#### ⏰ Scheduled Monitoring

Run the Actor every hour, day, or week to watch new posts appear over time. Use `monitoringMode`, `lookbackMinutes`, and `stateKey` to keep recurring jobs organized. 🔁

### 🏁 Quick Start

1. Open the Actor on Apify.
2. Choose one or more working sources: username, `from:username` query, tweet URL, or tweet ID.
3. Set the maximum number of tweets you want.
4. Click **Start**.
5. Download results from the Apify dataset as JSON, CSV, Excel, XML, RSS, or HTML. 🎉

### 🧪 Simple Input Examples

#### 👤 Tweets From A Public User

```json
{
  "fromUsers": ["openai"],
  "maxItems": 100,
  "sort": "latest"
}
````

#### 🔎 Use A from:username Query

```json
{
  "queries": ["from:apify"],
  "maxItems": 50
}
```

#### 📣 Brand Account Monitoring

```json
{
  "fromUsers": ["AcmeBank", "AcmeSupport"],
  "includeReplies": true,
  "includeRetweets": false,
  "maxItems": 1000
}
```

#### ⚠️ Unsupported Keyword Search Diagnostic

```json
{
  "queries": ["openai"],
  "includeErrors": true
}
```

#### 🔗 Fetch Specific Tweet URLs

```json
{
  "tweetUrls": ["https://x.com/elonmusk/status/1846846285917131130"],
  "includeAuthorDetails": true
}
```

#### 📅 Scheduled User Monitoring

```json
{
  "fromUsers": ["openai"],
  "monitoringMode": true,
  "lookbackMinutes": 60,
  "stateKey": "openai-hourly",
  "maxItems": 5000
}
```

#### ⏰ Hourly Monitoring

```json
{
  "fromUsers": ["AcmeBank"],
  "monitoringMode": true,
  "lookbackMinutes": 60,
  "stateKey": "acme-bank-hourly",
  "maxItems": 500
}
```

### 🧰 Input Options In Plain English

| Input | What it means | Example |
|---|---|---|
| `queries` 🔎 | Simple `from:username` queries. Generic keyword search is currently reported as unsupported. | `from:apify`, `from:openai` |
| `advancedQuery` 🧠 | Currently unsupported for public guest scraping | Leave empty |
| `tweetIds` 🆔 | Exact tweet/status IDs to fetch | `"1846846285917131130"` |
| `tweetUrls` 🔗 | Exact tweet links from `x.com` or `twitter.com` | `https://x.com/user/status/...` |
| `fromUsers` 👤 | Public accounts to search from | `openai`, `elonmusk` |
| `hashtags` 🏷️ | Currently unsupported for public guest scraping | Leave empty |
| `mentions` 📣 | Currently unsupported for public guest scraping | Leave empty |
| `cashtags` 💹 | Currently unsupported for public guest scraping | Leave empty |
| `maxItems` 🎯 | Maximum tweet records to save | `50`, `1000`, `5000` |
| `sort` 🧭 | Result style where supported | `latest`, `top`, `mixed` |
| `startTime` / `endTime` 📅 | Reserved for search-style sources; not required for username/tweet URL lookups | ISO timestamps |
| `language` 🌍 | Prefer tweets in one language | `en`, `es`, `fr` |
| `outputProfile` 📦 | How much detail to save | `minimal`, `standard`, `full` |
| `includeErrors` ⚠️ | Save error rows for failed lookups | `true` or `false` |
| `proxyConfiguration` 🌐 | Optional Apify proxy settings | Off by default |

### 📦 What Data Do You Get?

Tweet X Scraper saves results into the default Apify dataset. Each row is either a tweet record or, if enabled, an error record.

#### 🐦 Tweet Records

Depending on the selected output profile and what X/Twitter makes available, tweet records can include:

- 🆔 Tweet ID
- 🔗 X URL and Twitter URL
- 📝 Tweet text
- 📅 Created date and UNIX timestamp
- 🌍 Language
- 📱 Source client when available
- 👤 Author profile details
- 📈 Reply, repost, like, quote, view, and bookmark counts
- 🧵 Conversation and reply information
- 🖼️ Media details
- 🔗 Links
- 🏷️ Hashtags, mentions, and cashtags
- 🚩 Flags such as retweet, quote, pinned, sensitive, or conversation-controlled
- 🔎 Search metadata showing which input produced the tweet
- 🧠 Optional enrichment fields
- ⏱️ Scrape timestamp

#### ⚠️ Error Records

When `includeErrors` is turned on, the Actor can save clear error rows for cases such as:

- A tweet was deleted.
- A tweet is private, protected, or unavailable.
- A source could not be reached.
- A request was blocked or timed out.

This is useful when you need a full audit trail of what happened during the run. 🧾

### 🧾 Sample Tweet Output

```json
{
  "recordType": "tweet",
  "id": "1846846285917131130",
  "url": "https://x.com/elonmusk/status/1846846285917131130",
  "twitterUrl": "https://twitter.com/elonmusk/status/1846846285917131130",
  "text": "True",
  "createdAt": "2024-10-17T09:30:41.000Z",
  "lang": "en",
  "author": {
    "username": "elonmusk",
    "name": "Elon Musk",
    "url": "https://x.com/elonmusk",
    "isBlueVerified": true
  },
  "metrics": {
    "replyCount": 3480,
    "retweetCount": 18171,
    "likeCount": 85815,
    "quoteCount": 264,
    "viewCount": 10913296,
    "bookmarkCount": 1426
  },
  "entities": {
    "hashtags": [],
    "mentions": [],
    "urls": [],
    "cashtags": []
  },
  "media": [],
  "scrapedAt": "2026-06-15T08:00:00.000Z"
}
```

### ⚠️ Sample Error Output

```json
{
  "recordType": "error",
  "input": "0000000000000000004",
  "operation": "tweetLookup",
  "errorCode": "TWEET_UNAVAILABLE",
  "errorMessage": "Tweet or source could not be found, is deleted, private, protected, or temporarily unavailable.",
  "httpStatus": 404,
  "retryCount": 0,
  "scrapedAt": "2026-06-15T09:30:51.685Z"
}
```

### 💸 Built To Run Cheaply

Tweet X Scraper is configured to avoid surprise costs by default. The standard settings are intentionally conservative:

- 💾 `outputProfile` starts at `minimal` to reduce dataset size.
- 🎯 `maxItems` starts at `50` for small trial runs.
- 📄 `maxPagesPerQuery` starts at `1` so runs do not automatically crawl deep result pages.
- ⚠️ `includeErrors` starts at `false` so failed lookups do not add extra dataset rows unless you ask for them.
- 🌐 Apify Proxy is off by default to avoid proxy charges unless you enable it.
- 🔁 Retries are limited by default to avoid long, expensive failed runs.
- 🧠 Deduplication is on, but persistent dedupe storage is off by default to reduce key-value store writes.
- 🧮 The Actor supports low-memory runs starting at `256 MB`.

For larger or more difficult jobs, you can increase limits, enable proxy, add retries, or use `standard` / `full` output. In short: start small, scale only when you need to. 🚦

### 📅 Reliable Username Monitoring

For recurring jobs, schedule the Actor with `fromUsers`, `monitoringMode`, `lookbackMinutes`, and a stable `stateKey`. This keeps runs small, predictable, and easier to compare over time. 🧩

### 🧠 Optional Enrichments

Tweet X Scraper can add lightweight local analysis fields without calling outside AI services:

- 📈 Engagement score
- 🙂 Basic sentiment
- 🏷️ Entities
- 🧵 Topics
- 🗂️ Custom topic labels

These enrichments are optional. Keep them off for the smallest, fastest output. Turn them on when you want more analysis-ready data. ✨

### 🔌 API Usage Example

You can run the Actor through the Apify API and receive dataset items back.

```bash
curl --request POST \
  "https://api.apify.com/v2/acts/qaseemiqbal~tweet-x-scraper/run-sync-get-dataset-items?token=YOUR_APIFY_TOKEN" \
  --header "Content-Type: application/json" \
  --data '{
    "fromUsers": ["openai"],
    "maxItems": 100,
    "sort": "latest",
    "outputProfile": "minimal"
  }'
```

Replace `YOUR_APIFY_TOKEN` with your Apify API token. 🔑

### 🛡️ Important Notes

- 🔒 Public data only: this Actor does not access private or protected accounts.
- 🚫 No X login required: you do not need to provide X/Twitter credentials.
- 🌦️ Availability can vary: X/Twitter may limit, throttle, omit, or change public profile results.
- 🧪 Empty runs return no fake tweet records.
- ⚠️ Generic keyword, hashtag, mention, cashtag, and advanced search inputs are reported as unsupported while public X search rejects guest requests.
- ⚠️ If a tweet is deleted or unavailable, it cannot be recovered by the Actor.
- 🌐 Proxy can improve reliability for difficult runs, but it may increase cost.

### 🧯 Troubleshooting

#### 😕 I got no results. What should I try?

Try a public username, a `from:username` query, a tweet URL, or a tweet ID. Also remove strict filters such as `includeImages`, `includeVideos`, `verifiedOnly`, or high minimum engagement values.

#### 📉 I expected more historical tweets.

Increase `maxItems` or split large username collections into separate runs. Public X availability can vary by account and by what the logged-out web app exposes.

#### 🌐 Should I enable proxy?

Proxy is off by default to keep costs low. Enable Apify Proxy when reliability matters more than the cheapest possible run, especially for larger jobs or blocked requests.

#### 🧾 Why do I see error records?

You turned on `includeErrors`. Error records help you see which inputs failed and why. Turn it off if you only want successful tweet records.

#### 💾 My dataset is too large.

Use `outputProfile: "minimal"`, keep `includeRawData` disabled, and collect fewer items per run.

#### 🔁 I see duplicate-looking results.

Keep `deduplicate` enabled. Overlap can happen when a tweet URL, tweet ID, and username timeline point to the same tweet.

### ❓ FAQ

#### Do I need an X/Twitter account? 🔐

No. Tweet X Scraper is designed for public data and does not require your X/Twitter login.

#### Can it scrape protected accounts? 🔒

No. Protected/private content is not available.

#### Can I search by hashtag, keyword, mention, and cashtag? 🏷️

Not reliably through public guest access right now. The Actor reports these inputs as unsupported instead of spending requests on X search endpoints that currently return 404. Username timelines, `from:username` queries, tweet URLs, and tweet IDs are the supported paths.

#### Can I schedule it? ⏰

Yes. Use Apify schedules with `monitoringMode`, `lookbackMinutes`, and a stable `stateKey`.

#### Can I export the data? 📤

Yes. Apify datasets can be downloaded in common formats such as JSON, CSV, Excel, XML, RSS, and HTML.

#### Does it return fake data when nothing is found? 🧪

No. Empty runs produce zero tweet records and a summary explaining what happened.

#### What is the cheapest way to start? 💸

Start with `maxItems: 50`, `outputProfile: "minimal"`, Apify Proxy disabled, and one focused username. Increase limits only after confirming the results look useful.

### 🧑‍💻 Local Development

Install dependencies:

```bash
npm install
```

Run tests:

```bash
npm test
```

Run locally with Apify CLI:

```bash
apify run
```

Start the Node entrypoint:

```bash
npm start
```

### 🗓️ Changelog

#### 0.1.0

- 🎉 Initial production-ready JavaScript Actor.
- 🧾 Added Apify manifest, input schema, output schema, and dataset schema.
- 🐦 Added public X/Twitter tweet lookup and search support.
- 💸 Added low-cost defaults for smaller trial runs.
- 🧪 Added automated tests and Docker support.

# Actor input Schema

## `queries` (type: `array`):

Use simple from:username queries, for example from:apify. Generic keyword, hashtag, mention, cashtag, and advanced X search are currently reported as unsupported because X public search endpoints reject guest requests.

## `advancedQuery` (type: `string`):

Currently unsupported for public guest scraping. Use fromUsers, from:username queries, tweet URLs, or tweet IDs.

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

Tweet/status IDs to fetch directly.

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

Tweet URLs from x.com or twitter.com.

## `fromUsers` (type: `array`):

Usernames or profile URLs to collect public tweets from.

## `hashtags` (type: `array`):

Currently unsupported for public guest scraping because X public search rejects guest requests.

## `mentions` (type: `array`):

Currently unsupported for public guest scraping because X public search rejects guest requests.

## `cashtags` (type: `array`):

Currently unsupported for public guest scraping because X public search rejects guest requests.

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

Maximum tweet records to output. Error records may be added in addition when includeErrors is enabled.

## `sort` (type: `string`):

Search result type to request where supported.

## `startTime` (type: `string`):

ISO 8601 start time, for example 2026-06-01T00:00:00Z. Converted internally to UNIX timestamp windows.

## `endTime` (type: `string`):

ISO 8601 end time, for example 2026-06-15T00:00:00Z. Converted internally to UNIX timestamp windows.

## `lookbackMinutes` (type: `integer`):

For scheduled monitoring, collect tweets from the last N minutes when explicit times are not supplied.

## `timeWindowMinutes` (type: `integer`):

Reserved for search-style sources. Generic public search is currently unsupported, so this setting is usually not needed.

## `adaptiveTimeWindows` (type: `boolean`):

Reserved for search-style sources. Disabled by default to minimize request count.

## `minTimeWindowMinutes` (type: `integer`):

Reserved for search-style sources.

## `language` (type: `string`):

Optional tweet language code such as en, es, fr, de, or ja.

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

Include reply tweets.

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

Include native retweets/reposts where available.

## `includeQuotes` (type: `boolean`):

Include quote tweets.

## `includeImages` (type: `boolean`):

Only return tweets with images where supported by the source.

## `includeVideos` (type: `boolean`):

Only return tweets with videos where supported by the source.

## `includeLinks` (type: `boolean`):

Only return tweets with links where supported by the source.

## `includeMedia` (type: `boolean`):

Only return tweets with any media where supported by the source.

## `verifiedOnly` (type: `boolean`):

Only return tweets from verified authors when available.

## `blueVerifiedOnly` (type: `boolean`):

Only return tweets from blue verified authors when available.

## `safeOnly` (type: `boolean`):

Apply safe-content search filter where supported.

## `minLikes` (type: `integer`):

Post-filter tweets below this like count.

## `minRetweets` (type: `integer`):

Post-filter tweets below this retweet/repost count.

## `minReplies` (type: `integer`):

Post-filter tweets below this reply count.

## `minViews` (type: `integer`):

Post-filter tweets below this view count when views are available.

## `outputProfile` (type: `string`):

Choose how many fields to include. Minimal is the cheapest default because it reduces storage size.

## `includeAuthorDetails` (type: `boolean`):

Include detailed author profile fields in each tweet record when available.

## `includeRawData` (type: `boolean`):

Include raw source payload for debugging and advanced users. This can significantly increase dataset size.

## `includeErrors` (type: `boolean`):

Push structured error records for unavailable tweets, invalid inputs, or failed work items. Disabled by default to avoid extra dataset items on failed lookups.

## `deduplicate` (type: `boolean`):

Avoid pushing duplicate tweets with the same tweet ID.

## `persistDedupeState` (type: `boolean`):

Store seen tweet IDs in the key-value store for resume-heavy runs. Disabled by default to reduce key-value store writes.

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

Apify proxy configuration. Disabled by default for the lowest possible cost; enable proxy groups when reliability matters more than cost.

## `maxConcurrency` (type: `integer`):

Maximum number of parallel work items.

## `maxPagesPerQuery` (type: `integer`):

Maximum result pages to request where pagination is supported. The default is 1 for lowest cost.

## `maxRequestRetries` (type: `integer`):

Maximum retries per request or work item.

## `requestTimeoutSecs` (type: `integer`):

Timeout per request in seconds.

## `sessionRotation` (type: `boolean`):

Rotate sessions and proxy IPs when requests fail or blocking is detected. Disabled by default to reduce SessionPool overhead.

## `monitoringMode` (type: `boolean`):

Use persisted state for scheduled recurring monitoring.

## `stateKey` (type: `string`):

Key-value store key used to persist last successful monitoring timestamp.

## `enrichments` (type: `object`):

Optional deterministic analytics enrichments. Engagement scoring, sentiment, entities, and topics run locally in the Actor.

## `webhookPayloadMode` (type: `string`):

Controls what summary fields are prepared for downstream webhooks.

## Actor input object example

```json
{
  "queries": [
    "from:apify"
  ],
  "advancedQuery": "",
  "tweetIds": [],
  "tweetUrls": [],
  "fromUsers": [
    "elonmusk"
  ],
  "hashtags": [],
  "mentions": [],
  "cashtags": [],
  "maxItems": 50,
  "sort": "latest",
  "startTime": "",
  "endTime": "",
  "lookbackMinutes": 60,
  "timeWindowMinutes": 240,
  "adaptiveTimeWindows": false,
  "minTimeWindowMinutes": 30,
  "language": "",
  "includeReplies": true,
  "includeRetweets": false,
  "includeQuotes": true,
  "includeImages": false,
  "includeVideos": false,
  "includeLinks": false,
  "includeMedia": false,
  "verifiedOnly": false,
  "blueVerifiedOnly": false,
  "safeOnly": false,
  "minLikes": 0,
  "minRetweets": 0,
  "minReplies": 0,
  "minViews": 0,
  "outputProfile": "minimal",
  "includeAuthorDetails": true,
  "includeRawData": false,
  "includeErrors": false,
  "deduplicate": true,
  "persistDedupeState": false,
  "proxyConfiguration": {
    "useApifyProxy": false
  },
  "maxConcurrency": 5,
  "maxPagesPerQuery": 1,
  "maxRequestRetries": 1,
  "requestTimeoutSecs": 30,
  "sessionRotation": false,
  "monitoringMode": false,
  "stateKey": "default-monitor",
  "enrichments": {
    "engagementScore": false,
    "sentiment": false,
    "entities": false,
    "topics": false,
    "topicLabels": []
  },
  "webhookPayloadMode": "summary"
}
```

# Actor output Schema

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

No description

## `summary` (type: `string`):

No description

## `diagnostics` (type: `string`):

No description

## `failedInputs` (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 = {
    "queries": [
        "from:apify"
    ],
    "fromUsers": [
        "elonmusk"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("qaseemiqbal/tweet-x-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 = {
    "queries": ["from:apify"],
    "fromUsers": ["elonmusk"],
}

# Run the Actor and wait for it to finish
run = client.actor("qaseemiqbal/tweet-x-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 '{
  "queries": [
    "from:apify"
  ],
  "fromUsers": [
    "elonmusk"
  ]
}' |
apify call qaseemiqbal/tweet-x-scraper --silent --output-dataset

```

## MCP server setup

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

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "Tweet X Scraper",
        "description": "Collect public X/Twitter tweets from usernames, from:username queries, tweet URLs, and tweet IDs. Export clean tweet text, author info, engagement metrics, media, links, and run summaries without X login.",
        "version": "0.1",
        "x-build-id": "fLCl3qSj2pqPhpq8k"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/qaseemiqbal~tweet-x-scraper/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-qaseemiqbal-tweet-x-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/qaseemiqbal~tweet-x-scraper/runs": {
            "post": {
                "operationId": "runs-sync-qaseemiqbal-tweet-x-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/qaseemiqbal~tweet-x-scraper/run-sync": {
            "post": {
                "operationId": "run-sync-qaseemiqbal-tweet-x-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": {
                    "queries": {
                        "title": "from:username queries",
                        "type": "array",
                        "description": "Use simple from:username queries, for example from:apify. Generic keyword, hashtag, mention, cashtag, and advanced X search are currently reported as unsupported because X public search endpoints reject guest requests.",
                        "default": [],
                        "items": {
                            "type": "string"
                        }
                    },
                    "advancedQuery": {
                        "title": "Advanced raw search query",
                        "type": "string",
                        "description": "Currently unsupported for public guest scraping. Use fromUsers, from:username queries, tweet URLs, or tweet IDs.",
                        "default": ""
                    },
                    "tweetIds": {
                        "title": "Tweet IDs",
                        "type": "array",
                        "description": "Tweet/status IDs to fetch directly.",
                        "default": [],
                        "items": {
                            "type": "string"
                        }
                    },
                    "tweetUrls": {
                        "title": "Tweet URLs",
                        "type": "array",
                        "description": "Tweet URLs from x.com or twitter.com.",
                        "default": [],
                        "items": {
                            "type": "string"
                        }
                    },
                    "fromUsers": {
                        "title": "Tweets from users",
                        "type": "array",
                        "description": "Usernames or profile URLs to collect public tweets from.",
                        "default": [],
                        "items": {
                            "type": "string"
                        }
                    },
                    "hashtags": {
                        "title": "Hashtags",
                        "type": "array",
                        "description": "Currently unsupported for public guest scraping because X public search rejects guest requests.",
                        "default": [],
                        "items": {
                            "type": "string"
                        }
                    },
                    "mentions": {
                        "title": "Mentions",
                        "type": "array",
                        "description": "Currently unsupported for public guest scraping because X public search rejects guest requests.",
                        "default": [],
                        "items": {
                            "type": "string"
                        }
                    },
                    "cashtags": {
                        "title": "Cashtags",
                        "type": "array",
                        "description": "Currently unsupported for public guest scraping because X public search rejects guest requests.",
                        "default": [],
                        "items": {
                            "type": "string"
                        }
                    },
                    "maxItems": {
                        "title": "Maximum tweets",
                        "minimum": 1,
                        "maximum": 1000000,
                        "type": "integer",
                        "description": "Maximum tweet records to output. Error records may be added in addition when includeErrors is enabled.",
                        "default": 50
                    },
                    "sort": {
                        "title": "Sort mode",
                        "enum": [
                            "latest",
                            "top",
                            "mixed"
                        ],
                        "type": "string",
                        "description": "Search result type to request where supported.",
                        "default": "latest"
                    },
                    "startTime": {
                        "title": "Start time",
                        "type": "string",
                        "description": "ISO 8601 start time, for example 2026-06-01T00:00:00Z. Converted internally to UNIX timestamp windows.",
                        "default": ""
                    },
                    "endTime": {
                        "title": "End time",
                        "type": "string",
                        "description": "ISO 8601 end time, for example 2026-06-15T00:00:00Z. Converted internally to UNIX timestamp windows.",
                        "default": ""
                    },
                    "lookbackMinutes": {
                        "title": "Lookback minutes",
                        "minimum": 1,
                        "maximum": 525600,
                        "type": "integer",
                        "description": "For scheduled monitoring, collect tweets from the last N minutes when explicit times are not supplied.",
                        "default": 60
                    },
                    "timeWindowMinutes": {
                        "title": "Search time window size",
                        "minimum": 1,
                        "maximum": 1440,
                        "type": "integer",
                        "description": "Reserved for search-style sources. Generic public search is currently unsupported, so this setting is usually not needed.",
                        "default": 240
                    },
                    "adaptiveTimeWindows": {
                        "title": "Adaptive time windows",
                        "type": "boolean",
                        "description": "Reserved for search-style sources. Disabled by default to minimize request count.",
                        "default": false
                    },
                    "minTimeWindowMinutes": {
                        "title": "Minimum adaptive window size",
                        "minimum": 1,
                        "maximum": 1440,
                        "type": "integer",
                        "description": "Reserved for search-style sources.",
                        "default": 30
                    },
                    "language": {
                        "title": "Language",
                        "type": "string",
                        "description": "Optional tweet language code such as en, es, fr, de, or ja.",
                        "default": ""
                    },
                    "includeReplies": {
                        "title": "Include replies",
                        "type": "boolean",
                        "description": "Include reply tweets.",
                        "default": true
                    },
                    "includeRetweets": {
                        "title": "Include reposts / native retweets",
                        "type": "boolean",
                        "description": "Include native retweets/reposts where available.",
                        "default": false
                    },
                    "includeQuotes": {
                        "title": "Include quote tweets",
                        "type": "boolean",
                        "description": "Include quote tweets.",
                        "default": true
                    },
                    "includeImages": {
                        "title": "Require images",
                        "type": "boolean",
                        "description": "Only return tweets with images where supported by the source.",
                        "default": false
                    },
                    "includeVideos": {
                        "title": "Require videos",
                        "type": "boolean",
                        "description": "Only return tweets with videos where supported by the source.",
                        "default": false
                    },
                    "includeLinks": {
                        "title": "Require links",
                        "type": "boolean",
                        "description": "Only return tweets with links where supported by the source.",
                        "default": false
                    },
                    "includeMedia": {
                        "title": "Require any media",
                        "type": "boolean",
                        "description": "Only return tweets with any media where supported by the source.",
                        "default": false
                    },
                    "verifiedOnly": {
                        "title": "Verified authors only",
                        "type": "boolean",
                        "description": "Only return tweets from verified authors when available.",
                        "default": false
                    },
                    "blueVerifiedOnly": {
                        "title": "Blue verified authors only",
                        "type": "boolean",
                        "description": "Only return tweets from blue verified authors when available.",
                        "default": false
                    },
                    "safeOnly": {
                        "title": "Safe content only",
                        "type": "boolean",
                        "description": "Apply safe-content search filter where supported.",
                        "default": false
                    },
                    "minLikes": {
                        "title": "Minimum likes",
                        "minimum": 0,
                        "type": "integer",
                        "description": "Post-filter tweets below this like count.",
                        "default": 0
                    },
                    "minRetweets": {
                        "title": "Minimum retweets",
                        "minimum": 0,
                        "type": "integer",
                        "description": "Post-filter tweets below this retweet/repost count.",
                        "default": 0
                    },
                    "minReplies": {
                        "title": "Minimum replies",
                        "minimum": 0,
                        "type": "integer",
                        "description": "Post-filter tweets below this reply count.",
                        "default": 0
                    },
                    "minViews": {
                        "title": "Minimum views",
                        "minimum": 0,
                        "type": "integer",
                        "description": "Post-filter tweets below this view count when views are available.",
                        "default": 0
                    },
                    "outputProfile": {
                        "title": "Output profile",
                        "enum": [
                            "minimal",
                            "standard",
                            "full"
                        ],
                        "type": "string",
                        "description": "Choose how many fields to include. Minimal is the cheapest default because it reduces storage size.",
                        "default": "minimal"
                    },
                    "includeAuthorDetails": {
                        "title": "Include author details",
                        "type": "boolean",
                        "description": "Include detailed author profile fields in each tweet record when available.",
                        "default": true
                    },
                    "includeRawData": {
                        "title": "Include raw source data",
                        "type": "boolean",
                        "description": "Include raw source payload for debugging and advanced users. This can significantly increase dataset size.",
                        "default": false
                    },
                    "includeErrors": {
                        "title": "Include error records",
                        "type": "boolean",
                        "description": "Push structured error records for unavailable tweets, invalid inputs, or failed work items. Disabled by default to avoid extra dataset items on failed lookups.",
                        "default": false
                    },
                    "deduplicate": {
                        "title": "Deduplicate tweets",
                        "type": "boolean",
                        "description": "Avoid pushing duplicate tweets with the same tweet ID.",
                        "default": true
                    },
                    "persistDedupeState": {
                        "title": "Persist dedupe state",
                        "type": "boolean",
                        "description": "Store seen tweet IDs in the key-value store for resume-heavy runs. Disabled by default to reduce key-value store writes.",
                        "default": false
                    },
                    "proxyConfiguration": {
                        "title": "Proxy configuration",
                        "type": "object",
                        "description": "Apify proxy configuration. Disabled by default for the lowest possible cost; enable proxy groups when reliability matters more than cost.",
                        "default": {
                            "useApifyProxy": false
                        }
                    },
                    "maxConcurrency": {
                        "title": "Maximum concurrency",
                        "minimum": 1,
                        "maximum": 100,
                        "type": "integer",
                        "description": "Maximum number of parallel work items.",
                        "default": 5
                    },
                    "maxPagesPerQuery": {
                        "title": "Maximum pages per query",
                        "minimum": 1,
                        "maximum": 100,
                        "type": "integer",
                        "description": "Maximum result pages to request where pagination is supported. The default is 1 for lowest cost.",
                        "default": 1
                    },
                    "maxRequestRetries": {
                        "title": "Maximum request retries",
                        "minimum": 0,
                        "maximum": 20,
                        "type": "integer",
                        "description": "Maximum retries per request or work item.",
                        "default": 1
                    },
                    "requestTimeoutSecs": {
                        "title": "Request timeout",
                        "minimum": 10,
                        "maximum": 300,
                        "type": "integer",
                        "description": "Timeout per request in seconds.",
                        "default": 30
                    },
                    "sessionRotation": {
                        "title": "Session rotation",
                        "type": "boolean",
                        "description": "Rotate sessions and proxy IPs when requests fail or blocking is detected. Disabled by default to reduce SessionPool overhead.",
                        "default": false
                    },
                    "monitoringMode": {
                        "title": "Monitoring mode",
                        "type": "boolean",
                        "description": "Use persisted state for scheduled recurring monitoring.",
                        "default": false
                    },
                    "stateKey": {
                        "title": "Monitoring state key",
                        "type": "string",
                        "description": "Key-value store key used to persist last successful monitoring timestamp.",
                        "default": "default-monitor"
                    },
                    "enrichments": {
                        "title": "Analytics enrichments",
                        "type": "object",
                        "description": "Optional deterministic analytics enrichments. Engagement scoring, sentiment, entities, and topics run locally in the Actor.",
                        "default": {
                            "engagementScore": false,
                            "sentiment": false,
                            "entities": false,
                            "topics": false,
                            "topicLabels": []
                        }
                    },
                    "webhookPayloadMode": {
                        "title": "Webhook payload mode",
                        "enum": [
                            "summary",
                            "datasetUrl"
                        ],
                        "type": "string",
                        "description": "Controls what summary fields are prepared for downstream webhooks.",
                        "default": "summary"
                    }
                }
            },
            "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
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
