# Twitter ( X ) Comment Scraper (`datapilot/twitter-x-comment-scraper`) Actor

It captures comment text, user info, likes, retweets, replies, and timestamps. Uses residential proxies, auto-scrolls to load more comments, and outputs clean, structured data.

- **URL**: https://apify.com/datapilot/twitter-x-comment-scraper.md
- **Developed by:** [Data Pilot](https://apify.com/datapilot) (community)
- **Categories:** Other, Videos
- **Stats:** 61 total users, 0 monthly users, 100.0% runs succeeded, 1 bookmarks
- **User rating**: 4.00 out of 5 stars

## Pricing

from $3.00 / 1,000 scraped results

This Actor is paid per event and usage. You are charged both the fixed price for specific events and for Apify platform usage.

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

## Twitter/X Comment Scraper

🚀 Twitter/X Comment Scraper is an advanced Apify Actor designed to scrape Twitter/X Comment data from tweet URLs using browser automation. This tool provides comprehensive Twitter/X Comment information, including comment texts, user details, timestamps, and engagement metrics like likes and retweets. Whether you're analyzing Twitter/X Comment sentiment, conducting social media research, or monitoring Twitter/X Comment trends, the Twitter/X Comment Scraper delivers detailed Twitter/X Comment data efficiently.

With browser-based scraping using **Playwright**, the Twitter/X Comment Scraper ensures accurate extraction of dynamic Twitter/X Comment content that may not be available through simple API calls. It focuses on key Twitter/X Comment metrics like user profiles and engagement data, making it an essential tool for Twitter/X Comment analysis and social media research.

***

### 🔥 Features

- **Comprehensive Twitter/X Comment Extraction** – Scrapes detailed Twitter/X Comment data, including comment texts, user information, timestamps, and engagement metrics for any tweet URL.
- **Browser Automation** – Uses Playwright for headless browser navigation to access fully loaded Twitter/X Comment sections.
- **Advanced Comment Loading** – Scrolls and waits to load more Twitter/X Comment content for complete extraction.
- **API Response Parsing** – Intercepts Twitter/X Comment data from GraphQL API responses for accurate Twitter/X Comment retrieval.
- **Batch Processing** – Processes multiple tweet URLs in a single run for efficient Twitter/X Comment data collection.
- **Residential Proxy Support** – Utilizes Apify's residential proxies to bypass restrictions and improve success rates for Twitter/X Comment scraping.
- **Error Handling** – Robust logging and fallback mechanisms for failed Twitter/X Comment scrapes.
- **Dataset Integration** – Automatically uploads Twitter/X Comment data to your Apify dataset for easy export and analysis.

***

### ⚙️ How It Works

The Twitter/X Comment Scraper takes a tweet URL as input and uses Playwright to launch a headless browser, navigate to the URL, and intercept Twitter/X Comment data from API responses. It performs scrolling actions to load more Twitter/X Comment content, then parses the data to extract comment texts, user profiles, and engagement metrics. The scraper returns structured Twitter/X Comment data on success or error details on failure, providing a reliable way to gather Twitter/X Comment data for research and analysis.

**Key Processing Steps:**

1. **URL Validation** – Parse and validate tweet URL
2. **Browser Launch** – Initialize headless browser
3. **Page Navigation** – Navigate to tweet URL
4. **API Interception** – Intercept GraphQL API responses
5. **Comment Loading** – Scroll and load more comments
6. **Data Extraction** – Parse comment text, user info, metrics
7. **Data Compilation** – Aggregate comment data
8. **Export** – Push results to dataset in JSON format

**Key benefits for Twitter/X Comment analysis:**

- Access Twitter/X Comment data including user profiles and engagement metrics.
- Analyze Twitter/X Comment sentiment and trends.
- Build Twitter/X Comment databases for social media research.
- Track engagement patterns and user responses.
- Monitor conversation trends and topics.

***

### 📥 Input

The scraper accepts the following input parameters:

| Field | Type | Default | Description |
|-------|------|---------|-------------|
| `tweetUrl` | string | *(required)* | The tweet URL to scrape Twitter/X Comment from (e.g., `"https://x.com/user/status/123"`). |
| `useApifyProxy` | boolean | `true` | Enable residential proxies for Twitter/X Comment scraping. |
| `apifyProxyGroups` | array | `["RESIDENTIAL"]` | Proxy groups to use (e.g., `["RESIDENTIAL"]`). |

**Example input JSON:**

```json
{
  "tweetUrl": "https://x.com/example/status/123456789",
  "useApifyProxy": true,
  "apifyProxyGroups": ["RESIDENTIAL"]
}
```

***

### 📤 Output

The scraper outputs detailed Twitter/X Comment data in JSON format for each comment. Each record includes:

| Field | Type | Description |
|-------|------|-------------|
| `id` | string | Unique ID of the Twitter/X Comment. |
| `text` | string | Text content of the Twitter/X Comment. |
| `user` | object | Twitter/X Comment user details object. |
| `date` | object | Twitter/X Comment date information object. |
| `stats` | object | Twitter/X Comment engagement metrics object. |
| `replyTo` | string | Username the comment is replying to (if applicable). |

**User Object Fields:**

| Field | Type | Description |
|-------|------|-------------|
| `username` | string | Twitter/X username. |
| `fullName` | string | Full name of the user. |
| `followers` | integer | Follower count of the user. |
| `verified` | boolean | Verification status of the user. |

**Date Object Fields:**

| Field | Type | Description |
|-------|------|-------------|
| `formatted` | string | Formatted date (`YYYY-MM-DD HH:MM:SS`). |
| `initial` | string | Initial date string format. |

**Stats Object Fields:**

| Field | Type | Description |
|-------|------|-------------|
| `likes` | integer | Like count for the comment. |
| `retweets` | integer | Retweet count for the comment. |
| `replies` | integer | Reply count for the comment. |

**Example output for Twitter/X Comment:**

```json
{
  "id": "1234567890",
  "text": "This is a great example comment!",
  "user": {
    "username": "example_user",
    "fullName": "Example User",
    "followers": 1500,
    "verified": true
  },
  "date": {
    "formatted": "2026-08-31 12:00:00",
    "initial": "Mon Aug 31 12:00:00 +0000 2026"
  },
  "stats": {
    "likes": 25,
    "retweets": 5,
    "replies": 3
  },
  "replyTo": null
}
```

**Example error response:**

```json
{
  "tweetUrl": "https://x.com/invalid/status/invalid",
  "no_comments_found": true,
  "error": "Tweet URL not accessible or has no comments",
  "scraped_at": "2026-08-31T12:00:00Z"
}
```

***

### 🧰 Technical Stack

- **Browser Automation:** Playwright (Chromium)
- **API Interception:** GraphQL API response parsing
- **Data Parsing:** JSON parsing and data extraction
- **Proxy Support:** Apify Proxy with `RESIDENTIAL` support for reliability
- **Platform:** Apify Actor – serverless, scalable, integrated with Dataset and Key-Value Store
- **Deployment:** One-click run on Apify Console or via REST API

***

### 🎯 Use Cases

- **Sentiment Analysis** – Analyze comment sentiment and emotional tone.
- **Trend Analysis** – Identify trending topics and discussions.
- **Social Media Research** – Conduct comprehensive social media research.
- **Engagement Analysis** – Analyze engagement patterns and user interactions.
- **Competitive Analysis** – Research competitor tweets and community responses.
- **Brand Monitoring** – Monitor brand mentions and sentiment in comments.
- **Influencer Analysis** – Analyze influencer engagement and audience responses.
- **Crisis Management** – Monitor and track crisis-related comments and sentiment.
- **Market Research** – Research market reactions and consumer feedback.
- **User Research** – Understand user opinions and preferences.
- **Content Analysis** – Analyze what types of content generate engagement.
- **Academic Research** – Collect Twitter/X comment data for research studies.
- **Dataset Building** – Build comment databases for machine learning.
- **Customer Feedback** – Gather customer feedback and responses.

***

### 🚀 Quick Start

1. **Open in Apify Console** – visit the Actor page and click **Try for free**.
2. **Enter tweet URL** – provide a Twitter/X tweet URL with comments.
3. **Enable proxies** – enabled by default for reliable scraping.
4. **Click Start** – the Actor will scrape tweet comments using browser automation.
5. **View Results** – check the dataset for extracted comment data.
6. **Analyze Comments** – examine user details, engagement metrics, timestamps.
7. **Export Data** – download the results as JSON, CSV, or Excel.

***

### 💎 Why This Scraper?

| Feature | Benefit |
|---------|---------|
| ✅ Browser automation | Access fully rendered tweet content and comments. |
| ✅ API interception | Extract data from Twitter/X's GraphQL API. |
| ✅ Comment scrolling | Load more comments through smart scrolling. |
| ✅ User profiles | Get detailed user information with each comment. |
| ✅ Engagement metrics | Receive likes, retweets, and reply counts. |
| ✅ Residential proxies | Improve access reliability against restrictions. |
| ✅ Error handling | Robust fallback mechanisms. |
| ✅ Apify ecosystem | Seamless integration with other Actors, triggers, and webhooks. |

***

### 📦 Changelog

#### v1.0.0

- Initial release of Twitter/X Comment Scraper
- Browser automation with Playwright for comment extraction
- GraphQL API response interception for accurate data
- Comment text, user profile, and engagement metric extraction
- Dynamic comment loading through scrolling
- Batch processing for multiple tweet URLs
- Residential proxy support for reliability
- Verified user status detection
- Timestamp extraction and formatting
- Engagement metrics (likes, retweets, replies)
- Reply-to relationship tracking
- Error handling with detailed error messages
- Automatic dataset integration
- Full Apify Actor integration

***

### 🧑‍💻 Support & Feedback

- **Issues & Ideas:** Open a ticket on the Apify Actor issue tracker
- **Documentation:** Visit Apify Docs for comprehensive platform guides
- **Community:** Join the Apify community forum for discussions and support
- **Bug Reports:** Submit detailed bug reports through the issue tracker
- **Feature Requests:** Suggest new features to improve the scraper

***

### 📄 License & Legal

**Terms of Use:**

- Scrape Twitter/X comments for legitimate research and analysis
- Respect Twitter/X's Terms of Service
- Don't republish comments without proper attribution
- Comply with applicable laws and regulations
- Respect copyright and intellectual property rights

**Disclaimer:**
Twitter/X Comment Scraper is provided as-is for research and analysis purposes. Users are responsible for ensuring their usage complies with Twitter/X's policies and applicable laws.

***

### 🎉 Get Started Today

Begin scraping Twitter/X comments now!

**Use Twitter/X Comment Scraper for:**

- 💬 Comment Analysis
- 📊 Sentiment Research
- 🔍 Social Listening
- 📈 Engagement Tracking
- 🎯 Trend Analysis

**Perfect for:**

- Social Media Researchers
- Sentiment Analysts
- Brand Monitors
- Content Strategists
- Analysts

***

### 📚 Related Tools

For comprehensive Twitter/X analysis and research, explore other tools in this suite:

- Twitter/X Tweet Scraper
- Twitter/X Video Downloader
- All-in-One Media Downloader
- YouTube Comment Scraper
- TikTok Comments Scraper

# Actor input Schema

## `tweetUrl` (type: `string`):

Enter the full Twitter/X tweet URL (e.g., https://x.com/username/status/1234567890).

## `useApifyProxy` (type: `boolean`):

Highly recommended for Twitter/X to prevent blocks.

## `apifyProxyGroups` (type: `array`):

Residential proxies are selected by default.

## Actor input object example

```json
{
  "tweetUrl": "https://x.com/elonmusk/status/1234567890",
  "useApifyProxy": true,
  "apifyProxyGroups": [
    "RESIDENTIAL"
  ]
}
```

# 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 = {
    "tweetUrl": "https://x.com/elonmusk/status/1234567890"
};

// Run the Actor and wait for it to finish
const run = await client.actor("datapilot/twitter-x-comment-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 = { "tweetUrl": "https://x.com/elonmusk/status/1234567890" }

# Run the Actor and wait for it to finish
run = client.actor("datapilot/twitter-x-comment-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 '{
  "tweetUrl": "https://x.com/elonmusk/status/1234567890"
}' |
apify call datapilot/twitter-x-comment-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,datapilot/twitter-x-comment-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/m2yGezjjPmm4bOvax/builds/DUdt7nGS1IpJEfOq8/openapi.json
