# X Twitter Scraper ($0.15 per 1000 results) (`igolaizola/x-twitter-scraper-ppe`) Actor

Low-cost X.com/Twitter scraper for search and user timelines. Filter by dates, media, replies/retweets/quotes, verified, links, news, safe, and location. Use query, username, or both to search within a user. Export JSON/CSV/XLSX.

- **URL**: https://apify.com/igolaizola/x-twitter-scraper-ppe.md
- **Developed by:** [Iñigo Garcia Olaizola](https://apify.com/igolaizola) (community)
- **Categories:** Social media, News, Developer tools
- **Stats:** 595 total users, 56 monthly users, 90.4% runs succeeded, 4 bookmarks
- **User rating**: 5.00 out of 5 stars

## Pricing

from $0.13 / 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.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
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.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## 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.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## X (Twitter) Scraper — Low-Cost, Reliable Tweet Extraction for Search, Users & Filters

### 🤖 What does X (Twitter) Scraper do?

X (Twitter) Scraper extracts tweets from X.com for social listening, brand monitoring, competitor research, and trend analysis. Search by topic, download a user's tweets, or find matching posts within one account, then export the results as JSON, CSV, or Excel.

Collect tweets at low cost for social listening, monitoring, and research.

- **Tweet content:** Text, publication dates, post links, and reply or retweet context.
- **Author information:** Usernames, display names, profile links, avatars, and verification status.
- **Engagement:** Likes, comments, retweets, quotes, and views when available.
- **Media:** Image URLs, playable video URLs, animated GIFs, and links in posts.
- **Search filters:** Dates, minimum likes, content types, verification, and location.

> SEO keywords: **Twitter scraper**, **X scraper**, **scrape tweets**, **download tweets**, **Twitter search scraper**, **Twitter username scraper**, **Twitter API alternative**.

### 🧠 Scraping modes

#### Search across X

Set `query` to a topic, brand, or hashtag, such as `bitcoin` or `#WorldCup`. Leave `username` empty.

#### Collect a user's tweets

Set `username` to an X handle, such as `nasa`, and leave `query` empty. Add filters to narrow the user's posts.

#### Search within one account

Set both `username` and `query`. For example, `username="nasa"` and `query="mars"` searches for that account's tweets about Mars.

### 🚀 Quick start

1. **Choose your search:** Enter `query`, `username`, or both. Use search text and handles rather than post or profile URLs.
2. **Set your limit:** Choose `maxItems` and add any date, engagement, or content filters.
3. **Run the actor:** Click **Run** in Apify Console, or start a run through Apify's API.
4. **Download your results:** Open the run's **Dataset** tab to preview tweets and export JSON, CSV, or Excel. Choose **All fields** to include fields outside the overview.

### 📝 Configuration and input parameters

Configure these inputs in Apify Console or supply an input object through the API. Provide `maxItems` and at least one of `query` or `username`.

All content filters accept `""` (any), `"only"`, or `"exclude"`. Their default is `""`, which applies no filter. Multiple filters narrow the same search.

**Available Twitter scraper inputs**

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `maxItems` | Integer | Yes | Maximum tweets to save. Minimum `1`; default `10`. This is a limit, not a guaranteed result count. |
| `query` | String | No\* | Search text, such as `bitcoin`. With `username`, searches within that account. Very long queries are shortened automatically. |
| `username` | String | No\* | X handle, such as `nasa`, preferably without `@`. Leave empty for a general search. Do not supply a profile URL. |
| `minDate` | String | No | Lower date bound in `YYYY-MM-DD` format, such as `2024-05-01`. Omit for no lower bound. |
| `maxDate` | String | No | Return tweets before this date (`YYYY-MM-DD`). |
| `minLikes` | Integer | No | Minimum likes per tweet. Minimum `0`; default `0` (no minimum). |
| `replies` | String (enum) | No | Replies. Options: `""` · `"only"` · `"exclude"`; default `""`. |
| `retweets` | String (enum) | No | Retweets (reposts). Options: `""` · `"only"` · `"exclude"`; default `""`. |
| `quotes` | String (enum) | No | Quote tweets. Options: `""` · `"only"` · `"exclude"`; default `""`. |
| `verified` | String (enum) | No | Tweets from verified accounts. Options: `""` · `"only"` · `"exclude"`; default `""`. |
| `links` | String (enum) | No | Tweets containing links. Options: `""` · `"only"` · `"exclude"`; default `""`. |
| `media` | String (enum) | No | Tweets containing media. Options: `""` · `"only"` · `"exclude"`; default `""`. |
| `images` | String (enum) | No | Tweets containing images. Options: `""` · `"only"` · `"exclude"`; default `""`. |
| `videos` | String (enum) | No | Tweets containing videos. Options: `""` · `"only"` · `"exclude"`; default `""`. |
| `nativeVideos` | String (enum) | No | Tweets containing videos uploaded to X. Options: `""` · `"only"` · `"exclude"`; default `""`. |
| `proVideos` | String (enum) | No | Pro Video (Amplify) tweets. Options: `""` · `"only"` · `"exclude"`; default `""`. |
| `news` | String (enum) | No | Tweets classified as news. Options: `""` · `"only"` · `"exclude"`; default `""`. |
| `safe` | String (enum) | No | Tweets classified as safe; `"exclude"` excludes safe content, rather than sensitive content. Options: `""` · `"only"` · `"exclude"`; default `""`. |
| `near` | String | No | Location to search near, such as `Madrid` or `New York`. Omit for no location filter. |

\* **Conditional requirement:** Provide `query` or `username`, or both.

#### Example inputs

Copy an example into the actor's JSON input editor and adjust the search and limit.

##### 1️⃣ Topic search with image and date filters

```json
{
  "maxItems": 50,
  "query": "pizza",
  "images": "only",
  "retweets": "exclude",
  "minDate": "2024-05-01",
  "maxDate": "2024-09-01"
}
```

##### 2️⃣ User timeline

```json
{
  "maxItems": 100,
  "username": "nasa"
}
```

##### 3️⃣ Search within a user, excluding replies and reposts

```json
{
  "maxItems": 100,
  "username": "nasa",
  "query": "mars",
  "replies": "exclude",
  "retweets": "exclude",
  "quotes": "exclude"
}
```

### 📊 Output and results

Each dataset item represents one tweet. The overview shows the main fields; choose **All fields** when exporting to include the full record.

#### Field reference

- **Post identity (strings):** `id` is the tweet ID; `permalink` links to the post.
- **Author (strings):** `userUrl`, `username`, `fullname`, and `avatar` contain the profile link, handle, display name, and avatar URL. `verified` contains the verification type, such as `blue` or `gold`, or an empty string when unavailable.
- **Content (strings):** `text` contains plain text; `html` contains formatted tweet content.
- **Retweet context:** `isRetweet` is a boolean; `retweetedBy` is the retweeter's display text, or an empty string for an original post.
- **Reply context (array of strings):** `replyingTo` lists the handles being replied to when available.
- **Publication time (strings):** `displayTime` is the displayed date and time; `createdAt` is the parsed timestamp.
- **Media and links (arrays of strings):** `images` contains photo URLs; `videos` contains playable MP4 URLs for native videos and animated GIF attachments; `links` contains links found in the content.
- **Engagement (integers):** `comments`, `retweets`, `quotes`, `likes`, and `views` contain the available counters. `views` is the view or impression count.

Media and reply arrays may be `null` when no values are available. Some author details and counters may be unavailable for individual posts; a zero counter does not necessarily confirm that the post received no engagement.

#### Example tweet

This illustrative record shows the output structure. Engagement counts change over time.

```json
{
  "id": "1819469673169408242",
  "permalink": "https://x.com/elonmusk/status/1819469673169408242",
  "userUrl": "https://x.com/elonmusk",
  "username": "elonmusk",
  "fullname": "Elon Musk",
  "avatar": "https://pbs.twimg.com/profile_images/.../kqqe2iWO_bigger.jpg",
  "verified": "blue",
  "text": "I did all my coding with just Diet Coke, burgers & pizza",
  "html": "I did all my coding with just Diet Coke, burgers &amp; pizza",
  "isRetweet": false,
  "retweetedBy": "",
  "replyingTo": [
    "growing_daniel"
  ],
  "displayTime": "Aug 2, 2024 · 8:25 PM UTC",
  "createdAt": "2024-08-02T20:25:00Z",
  "images": null,
  "videos": null,
  "links": null,
  "comments": 430,
  "retweets": 156,
  "quotes": 59,
  "likes": 3890,
  "views": 120000
}
```

### 🧭 Common recipes

- **Original tweets only:** Set `replies="exclude"`, `retweets="exclude"`, and `quotes="exclude"`.
- **Video posts:** Set `videos="only"`, or use `nativeVideos="only"` for videos uploaded to X.
- **News posts:** Set `news="only"`.
- **Verified authors:** Set `verified="only"`.
- **Location search:** Combine `query` with `near="San Francisco"`.
- **Popular posts:** Set `minLikes` to a threshold such as `100`.
- **Event research:** Combine `minDate` and `maxDate` to focus on a date range.

### ⚙️ Best practices

- **Start small:** Test a search with `maxItems=10`, inspect the dataset, then increase the limit.
- **Keep searches focused:** Use concise terms. Very long queries may lose terms when shortened.
- **Avoid conflicting filters:** For example, `media="exclude"` together with `images="only"` can leave no matching posts.
- **Allow for fewer results:** Runs can finish below `maxItems` when no more matching tweets are available.
- **Check dates:** Use valid calendar dates in `YYYY-MM-DD` format. Invalid dates are ignored and reported in the run log.

### ⚖️ Legal & ethical considerations

- **Platform policies:** Respect X's terms of service and applicable rules for accessing and using content.
- **Privacy:** Handle personal data responsibly and comply with applicable privacy requirements, including GDPR and CCPA.
- **Responsible volume:** Keep collection volumes and run frequency appropriate for your use case; avoid abusive traffic.
- **Attribution:** Preserve source links and respect authors' rights when sharing tweets or publishing analysis.

This actor is an independent tool and is **not affiliated with, endorsed by, or sponsored by X Corp.** All trademarks are the property of their respective owners.

### ❓ FAQ

#### Do I need both query and username?

No. Provide either one. When you provide both, the actor searches for matching tweets within that user's account.

#### Can I paste a tweet or profile URL?

No. Use search text in `query` or an X handle in `username`. Direct tweet URL collection is not an input mode.

#### How do I exclude sensitive content?

Set `safe="only"` to request content classified as safe. `safe="exclude"` excludes safe content. Classification does not guarantee that every result is suitable for every audience.

#### Why did I receive fewer tweets than maxItems?

`maxItems` is an upper limit. Narrow date ranges, high like thresholds, or combined filters may produce fewer matches. Try a broader query or remove a filter.

### 🛟 Support

Need a custom field, export, or search workflow? Open an issue from the actor's **Issues** tab in Apify Console, or [contact the developer](https://igolaizola.com/#contact).

# Actor input Schema

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

Maximum number of results to scrape

## `query` (type: `string`):

Search terms used to find matching posts. Very long queries are shortened automatically.

## `username` (type: `string`):

Twitter username to scrape tweets from, if empty a general search will be performed

## `minDate` (type: `string`):

Select min date in format YYYY-MM-DD

## `maxDate` (type: `string`):

Select max date in format YYYY-MM-DD

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

Only include tweets with at least this many likes/favorites

## `replies` (type: `string`):

Select how replies should be handled

## `retweets` (type: `string`):

Select how retweets should be handled

## `quotes` (type: `string`):

Select how quote tweets should be handled

## `verified` (type: `string`):

Select how tweets from verified accounts should be handled

## `links` (type: `string`):

Select how tweets with links should be handled

## `media` (type: `string`):

Select how tweets with media should be handled

## `images` (type: `string`):

Select how tweets with images should be handled

## `videos` (type: `string`):

Select how tweets with videos should be handled

## `nativeVideos` (type: `string`):

Select how tweets with native videos should be handled

## `proVideos` (type: `string`):

Select how Pro Video (Amplify) tweets should be handled

## `news` (type: `string`):

Select how news tweets should be handled

## `safe` (type: `string`):

Include or exclude potentially sensitive content

## `near` (type: `string`):

Location to search near

## Actor input object example

```json
{
  "maxItems": 10,
  "query": "bitcoin",
  "minLikes": 0,
  "replies": "",
  "retweets": "",
  "quotes": "",
  "verified": "",
  "links": "",
  "media": "",
  "images": "",
  "videos": "",
  "nativeVideos": "",
  "proVideos": "",
  "news": "",
  "safe": ""
}
```

# Actor output Schema

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

No description

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "query": "bitcoin",
    "username": "",
    "near": ""
};

// Run the Actor and wait for it to finish
const run = await client.actor("igolaizola/x-twitter-scraper-ppe").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 = {
    "query": "bitcoin",
    "username": "",
    "near": "",
}

# Run the Actor and wait for it to finish
run = client.actor("igolaizola/x-twitter-scraper-ppe").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 '{
  "query": "bitcoin",
  "username": "",
  "near": ""
}' |
apify call igolaizola/x-twitter-scraper-ppe --silent --output-dataset

```

## MCP server setup

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

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/G8hR9sp2nkjI2om8X/builds/y3vIH1uQPps5KAkDp/openapi.json
