# X (Twitter) Profile Tweets Scraper (`buy-it/x-profile-tweets-scraper`) Actor

Scrape recent public posts from any X profile by @handle or URL. Get text, likes, retweets, replies, media and author stats. No login. Export CSV, JSON or Excel, or use the API.

- **URL**: https://apify.com/buy-it/x-profile-tweets-scraper.md
- **Developed by:** [Ioannis Kokkinis](https://apify.com/buy-it) (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.30 / 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/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 Profile Tweets Scraper

Scrape recent public tweets from any X (Twitter) profile by @handle or URL. No login.

### What you get per result

| Field | Description |
|---|---|
| `id` / `url` | Tweet id and link |
| `text` | Full tweet text |
| `createdAt` | Posted time (Twitter format) |
| `likeCount` / `retweetCount` / `replyCount` / `quoteCount` | Engagement as numbers |
| `isRetweet` / `isReply` / `isQuote` | Flags |
| `authorHandle` / `authorName` / `authorFollowers` / `authorVerified` | Author |
| `mediaUrls` / `hashtags` / `urls` | Attachments and entities |
| `scrapedAt` | ISO timestamp |

Failed profiles are not charged. They are listed under key-value store key `FAILED_PROFILES`.

### How to use

1. Paste one or more @handles or profile URLs.
2. Optionally cap `maxItems` / turn off retweets.
3. Download the dataset as JSON, CSV or Excel.

### Input

| Field | Required | Description |
|---|---|---|
| `handles` | yes | @handles or `x.com/…` / `twitter.com/…` URLs |
| `maxItems` | no | Total tweet cap (default 100) |
| `maxItemsPerProfile` | no | Per-profile cap |
| `includeRetweets` | no | Default true |
| `includeReplies` | no | Default false |

### Pricing

Pay per tweet returned. Actor start is a tiny fixed fee. Failures are free. Set a max spend on the run to cap cost.

### Notes

- Uses X's public syndication profile timeline (same data as the embed). It returns the recent posts available there (typically up to about 20–100); it is not a full historical archive.
- Private or suspended accounts return no tweets.
- Use in line with X's terms.

### Related actors

More scrapers from the same publisher:

- [TikTok Profile Scraper](https://apify.com/buy-it/tiktok-profile-scraper) — Followers, likes, bio and avatar
- [YouTube Channel Videos Scraper](https://apify.com/buy-it/youtube-channel-videos-scraper) — list videos from a YouTube channel

# Actor input Schema

## `handles` (type: `array`):

X (Twitter) profiles as @handle or profile URL, one per line. For example @NASA or https://x.com/NASA.

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

Stop after this many tweets in total across all profiles.

## `maxItemsPerProfile` (type: `integer`):

Cap how many tweets to take from each profile. The public syndication feed usually returns up to about 20–100 recent posts.

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

Keep retweets in the results. Turn off to return only original posts.

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

Keep replies in the results. Off by default because the syndication feed is mostly timeline posts.

## Actor input object example

```json
{
  "handles": [
    "@NASA"
  ],
  "maxItems": 100,
  "maxItemsPerProfile": 100,
  "includeRetweets": true,
  "includeReplies": false
}
```

# Actor output Schema

## `tweets` (type: `string`):

One row per tweet. Download as JSON, CSV or Excel.

# 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 = {
    "handles": [
        "@NASA"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("buy-it/x-profile-tweets-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 = { "handles": ["@NASA"] }

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

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

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

```

## CLI example

```bash
echo '{
  "handles": [
    "@NASA"
  ]
}' |
apify call buy-it/x-profile-tweets-scraper --silent --output-dataset

```

## MCP server setup

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

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

## OpenAPI specification

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