# X/Twitter Post Scraper — Text, Author & Engagement Metrics (`axery/x-twitter-post-detail-scraper`) Actor

Scrape a single X/Twitter post - text, author, like count, reply count, hashtags, mentions, media. No login, no API key.

- **URL**: https://apify.com/axery/x-twitter-post-detail-scraper.md
- **Developed by:** [Axery](https://apify.com/axery) (community)
- **Categories:** Social media, News, Videos
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $1.00 / 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?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.
Actors are written with capital "A".

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.
The best way to integrate Actors is as follows.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).

# README

## X (Twitter) Post Detail Scraper

Scrapes a single X/Twitter post — text, author, like count, reply count, hashtags, mentions, media. No login, no API key.

Useful for tracking specific posts (announcements, PR crises, viral moments), embedding post data into a dashboard, and archival/citation research.

### What makes this different

**Uses X's own public embed backend**, not a scraped HTML page — the same endpoint every "embedded tweet" widget on the web calls to render a post for a viewer with no X account at all. That makes it considerably more stable than parsing rendered HTML, which changes shape often and is generally login-gated for anything beyond a single post view.

**A withdrawn post is reported, not silently returned as empty.** X's own API answers a deleted, protected, or otherwise unavailable post with HTTP 200 and a differently-shaped payload (a "tombstone") rather than an error status. A scraper that doesn't check for that shape would emit a row that looks like a real, empty post instead of correctly reporting "this post is gone."

**No token-guessing.** The embed endpoint's `token` parameter is required, but this Actor doesn't attempt to derive whatever validation X applies to it — that would mean reverse-engineering a value meant to gate the endpoint, not reading something the page hands over freely. If a post can't be retrieved, that's reported plainly as a failure for that post rather than worked around.

### Input

| Field | Type | Notes |
|---|---|---|
| `posts` | array | Full x.com/twitter.com status URLs, or bare numeric post IDs. |
| `proxyConfiguration` | object | Not normally needed. |

### Output

```json
{
  "post_id": "x.com:20",
  "text": "just setting up my twttr",
  "author_name": "jack",
  "author_screen_name": "jack",
  "like_count": 308827,
  "reply_count": 17988,
  "created_at": "2006-03-21T20:50:14.000Z",
  "url": "https://x.com/jack/status/20"
}
```

Field presence follows the content of the post itself — `hashtags`, `mentions`, `media_urls`, `retweet_count` and `quote_count` are null when a post genuinely has none of those, not because they were missed. A post that's deleted, protected, or otherwise withdrawn fails with a clear message for that post rather than returning a hollow row. Each run also writes a `RUN_COVERAGE` record to the key-value store with what was requested, what came back, and any per-post failures.

### Local development

```bash
pip install -r requirements.txt
python test_local.py 20 --out sample_output.json
python test_local.py https://x.com/jack/status/20
```

`sample_output.json` is real output from a live run.

# Actor input Schema

## `posts` (type: `array`):

Full x.com/twitter.com status URLs or bare numeric post IDs. Each is fetched independently into the same dataset.

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

Not normally needed - this is X's own public embed backend, the same one every embedded-tweet widget on the web calls.

## Actor input object example

```json
{
  "posts": [
    "https://x.com/jack/status/20"
  ],
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}
```

# Actor output Schema

## `posts` (type: `string`):

One row per post: text, author, engagement counts, hashtags, mentions, media.

# 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 = {
    "posts": [
        "https://x.com/jack/status/20"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("axery/x-twitter-post-detail-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 = { "posts": ["https://x.com/jack/status/20"] }

# Run the Actor and wait for it to finish
run = client.actor("axery/x-twitter-post-detail-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 '{
  "posts": [
    "https://x.com/jack/status/20"
  ]
}' |
apify call axery/x-twitter-post-detail-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,axery/x-twitter-post-detail-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/nWAJMlP3XWjk7z8Yd/builds/v3hMyDawyJZ4ttzoa/openapi.json
