# Twitter / X Tweet & Profile Scraper (`morph_coder/twitter-search-scraper`) Actor

Scrape **X (Twitter) posts by ID** and **public profile metrics** without the official Twitter API. No login cookies required.

- **URL**: https://apify.com/morph_coder/twitter-search-scraper.md
- **Developed by:** [Morph Coder](https://apify.com/morph_coder) (community)
- **Categories:** Automation, Social media, Integrations
- **Features:** Limited permissions
- **Stats:** 53 total users, 6 monthly users, 99.3% runs succeeded, 1 bookmarks
- **User rating**: 5.00 out of 5 stars

## Pricing

from $3.50 / 1,000 tweet-fetcheds

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

## Twitter / X Tweet & Profile Scraper

**Actor ID:** [morph_coder/twitter-search-scraper](https://apify.com/morph_coder/twitter-search-scraper)

Scrape **X (Twitter) posts by ID** and **public profile metrics** without the official Twitter API. No login cookies required.

> This Actor is **not affiliated** with X Corp. You are responsible for complying with [X Terms of Service](https://x.com/tos) and applicable laws.

### What you get

| Mode | Input | Output |
|------|--------|--------|
| **Tweet by ID** | Numeric ID **or** full status URL (`x.com/…/status/…`) | Text, likes, retweets, reply count, views, author, URL |
| **Profile** | Username **or** profile URL (`https://x.com/user?lang=ar`) | Followers, following, bio, avatar, verification |

**Not supported:** keyword search, login-based features, full reply/comment thread text (only `replyCount` on tweets).

### Input

| Field | Default | Description |
|-------|---------|-------------|
| `tweetIDs` | one example URL | Tweet IDs **or** status URLs (mix allowed) |
| `profileUsernames` | one example URL | Usernames **or** profile URLs (`?lang=…` OK) |
| `useResidentialProxy` | `true` | Residential proxy (recommended on Apify) |

At least one of `tweetIDs` or `profileUsernames` is required.

#### Example

```json
{
  "tweetIDs": [
    "https://x.com/elonmusk/status/2059299542277697565",
    "2059405563612524869"
  ],
  "profileUsernames": [
    "https://x.com/melbetbang?lang=ar",
    "elonmusk"
  ],
  "useResidentialProxy": true
}
```

### Output

Each dataset row has a `type` field:

#### Tweet (`type: "tweet"`)

```json
{
  "type": "tweet",
  "id": "2059299542277697565",
  "url": "https://x.com/user/status/2059299542277697565",
  "text": "...",
  "likeCount": 1200,
  "retweetCount": 45,
  "replyCount": 89,
  "viewCount": 50000,
  "fetchedVia": "graphql",
  "author": {
    "screenName": "user",
    "name": "Display Name",
    "profilePicture": "https://pbs.twimg.com/..."
  }
}
```

`fetchedVia` is `graphql` or `syndication` (fallback if GraphQL fails).

#### Profile (`type: "profile"`)

```json
{
  "type": "profile",
  "screenName": "elonmusk",
  "followersCount": 100000000,
  "followingCount": 500,
  "description": "...",
  "isVerified": true
}
```

#### Error (`type: "error"`)

Failed IDs/usernames are recorded without stopping the whole run.

### Pricing (pay per event)

| Event | When charged |
|-------|----------------|
| `apify-actor-start` | Each run start (synthetic, set in Console) |
| `tweet-fetched` | Each **successful** tweet row |
| `profile-fetched` | Each **successful** profile row |

Set **`apify-default-dataset-item`** to **$0** (dataset rows are billed via the events above).

**Example** (default prefill: 1 tweet + 1 profile):

- 1× `apify-actor-start` + 1× `tweet-fetched` + 1× `profile-fetched`
- Plus Apify platform usage (compute + proxy) unless you enable “pay per event + usage”

Suggested event prices and Console setup: see [MONETIZATION.md](MONETIZATION.md).

### Requirements

- **Apify account** with access to **residential proxies** when `useResidentialProxy` is `true` (default).
- Tweet IDs must be **public** posts.

### Run on Apify

1. Open the Actor in [Apify Console](https://console.apify.com/).
2. Use the pre-filled input or paste your IDs/usernames.
3. Click **Start** — expect 2–4 dataset rows on success (tweets + profile + any errors).

### Run locally

```bash
npm install
npm run build
cp scripts/test-input.example.json storage/key_value_stores/default/INPUT.json
npx apify run
```

### API

```http
POST https://api.apify.com/v2/acts/morph_coder~twitter-search-scraper/runs?token=YOUR_TOKEN
Content-Type: application/json

{
  "tweetIDs": ["2059299542277697565"],
  "profileUsernames": ["elonmusk"]
}
```

### FAQ

**Can I paste the full tweet URL (Make / Zapier)?**\
Yes. Pass the whole link in `tweetIDs`, e.g. `https://x.com/user/status/1234567890`. Numeric IDs still work. Invalid entries are skipped with a warning; the run continues for valid items.

**Where do I find a tweet ID?**\
From the post URL: `https://x.com/user/status/1234567890` — you can paste either the full URL or just `1234567890`.

**Why residential proxy?**\
X often blocks datacenter IPs. Residential proxy improves reliability on Apify.

**Can I scrape replies?**\
Only the reply **count** on the tweet object, not individual comment texts.

### Maintainer

Internal setup: [MONETIZATION.md](MONETIZATION.md), [DEVELOPMENT.md](DEVELOPMENT.md), [CHECKLIST.md](CHECKLIST.md).

# Actor input Schema

## `tweetIDs` (type: `array`):

Numeric tweet IDs or full status URLs (x.com/…/status/… or twitter.com/…). Mix IDs and URLs in one list — ideal for Make/Zapier automations.

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

Usernames (with or without @) or full profile URLs like https://x.com/melbetbang?lang=ar — query params are ignored.

## `useResidentialProxy` (type: `boolean`):

Recommended for X.com on Apify. Disable only for local experiments.

## Actor input object example

```json
{
  "tweetIDs": [
    "https://x.com/elonmusk/status/2059299542277697565"
  ],
  "profileUsernames": [
    "https://x.com/elonmusk"
  ],
  "useResidentialProxy": true
}
```

# Actor output Schema

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

Dataset items from this run.

# 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 = {
    "tweetIDs": [
        "https://x.com/elonmusk/status/2059299542277697565"
    ],
    "profileUsernames": [
        "https://x.com/elonmusk"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("morph_coder/twitter-search-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 = {
    "tweetIDs": ["https://x.com/elonmusk/status/2059299542277697565"],
    "profileUsernames": ["https://x.com/elonmusk"],
}

# Run the Actor and wait for it to finish
run = client.actor("morph_coder/twitter-search-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 '{
  "tweetIDs": [
    "https://x.com/elonmusk/status/2059299542277697565"
  ],
  "profileUsernames": [
    "https://x.com/elonmusk"
  ]
}' |
apify call morph_coder/twitter-search-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,morph_coder/twitter-search-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/xDxroEtz9idwA99aN/builds/wYM7rXknSikEw4h88/openapi.json
