# X (Twitter) Thread & Reply Scraper (`krazee_kaushik/x-thread-scraper`) Actor

Scrape X threads and nested replies with full conversation structure, including hierarchical paths and parent-child relationships. Control depth to capture exactly who replied to whom. Fast, reliable, and no API key required

- **URL**: https://apify.com/krazee\_kaushik/x-thread-scraper.md
- **Developed by:** [Krazee](https://apify.com/krazee_kaushik) (community)
- **Categories:** AI, Lead generation, Social media
- **Stats:** 13 total users, 6 monthly users, 96.0% runs succeeded, NaN bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.30 / 1,000 x(twitter) reply scrapeds

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/platform/actors/running/actors-in-store#pay-per-event

## What's an Apify Actor?

Actors are a software tools running on the Apify platform, for all kinds of web data extraction and automation use cases.
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.

In JavaScript/TypeScript projects, use official [JavaScript/TypeScript client](https://docs.apify.com/api/client/js.md):

```bash
npm install apify-client
```

In Python projects, use official [Python client library](https://docs.apify.com/api/client/python.md):

```bash
pip install apify-client
```

In shell scripts, use [Apify CLI](https://docs.apify.com/cli/docs.md):

````bash
# MacOS / Linux
curl -fsSL https://apify.com/install-cli.sh | bash
# Windows
irm https://apify.com/install-cli.ps1 | iex
```bash

In AI frameworks, you might use the [Apify MCP server](https://docs.apify.com/platform/integrations/mcp.md).

If your project is in a different language, use 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) Reply & Thread Scraper

Scrape X(Twitter) replies and threads with full conversation structure and depth control.

X(Twitter) Reply & Thread Scraper extracts twitter replies, threads, and nested conversations with full reply relationships and conversation paths. It captures who replied to whom, enabling accurate reconstruction of complete conversation trees instead of flat reply lists.

Built for AI datasets, RAG pipelines, sentiment analysis, and research workflows, this Twitter scraper delivers structured, context-rich data as a reliable alternative to the X.com API — without requiring authentication.

---

### 🌳 Features of the X(Twitter) Scraper

- Nested replies across multiple levels  
- Conversation paths for full lineage tracking  
- Parent-child relationships for each reply  
- Depth-controlled extraction  
- JSON export with rich metadata  
- Optimized rate-limit handling  

---

### 🔍 How to Scrape X(Twitter) Nested Replies

1. **Paste Tweet URL**  
   Enter the link to the starting X (Twitter) post or thread.

2. **Configure Depth**  
   Set your limit such as Depth 1 for surface replies, Depth 2 or more for nested conversations, or full thread for complete extraction.

3. **Run and Export**  
   Start the actor and download structured data in JSON, CSV, or Excel with the conversation hierarchy preserved.

---

### 📦 Output Example

Each record represents a tweet with full conversation context preserved.

```json
 {
    "tweetId": "2040690162049421496",
    "tweetUrl": "https://x.com/OriginalMrP/status/2040690162049421496",
    "text": "Gen X enters the chat...",
    "createdAt": "Apr 5, 2026 · 7:17 AM UTC",
    "author": {
      "username": "OriginalMrP",
      "name": "Mark",
      "profileUrl": "https://x.com/OriginalMrP",
      "profileImage": "https://pbs.twimg.com/profile_images/1710182794544947200/-s-0Vfj1_bigger.jpg",
      "isVerified": false
    },
    "engagement": {
      "replies": 0,
      "retweets": 0,
      "likes": 1,
      "views": 1137
    },
    "media": [
      {
        "type": "gif",
        "url": "https://pic/video.twimg.com/tweet_video/HFH84gYXUAEj6EF.mp4"
      }
    ],
    "media_count": 1,   
    "conversationId": "2040267557048127522",
    "conversation": {
      "parentId": "2040609094193893482",
      "depth": 2,
      "path": [
        "2040267557048127522",
        "2040609094193893482",
        "2040690162049421496"
      ]
    },
    "conversation_depth": 2
  }
````

***

### 📦 Key Output Fields

Each tweet includes structured data along with conversation context:

- `tweetId`, `text`, `createdAt`\
  Core tweet data

- `author`\
  Username, name, and profile details

- `engagement`\
  Likes, replies, retweets, and views

- `conversation.parentId`\
  Identifies which tweet this is replying to

- `conversation.depth`\
  Indicates how deep the reply is in the thread

- `conversation.path`\
  Full lineage from root to this reply, enabling complete conversation structure

***

### 🎯 Use Cases

- 🤖 **AI and LLM Training**\
  Build structured conversation trees for high-fidelity RAG pipelines and prompt grounding

- 📈 **Conversation Analysis**\
  Map how discussions evolve across multi-level reply chains and depth levels

- 🧠 **Contextual Sentiment**\
  Track stances and opinions within full thread context and retain reasoning behind replies

- ⚡ **Branching Analysis**\
  Identify viral replies that drive deeper discussions and form sub-threads

- 🛠 **Data Enrichment**\
  Integrate structured Twitter/X conversation data into analytics workflows

***

### ❓ FAQ

#### What is a conversation path in a Twitter reply scraper?

A conversation path is a sequence of tweet IDs representing the full reply chain from the root tweet to a specific reply (for example: Root → Parent → Reply). This allows the Twitter scraper to reconstruct complete conversation trees instead of returning flat replies.

***

#### Can this Twitter scraper extract nested replies and full threads?

Yes. This Twitter reply and thread scraper supports depth-controlled extraction. You can scrape direct replies (Depth 1), nested replies (Depth 2+), or entire conversation threads with full hierarchy preserved.

***

#### How do I scrape Twitter replies with depth control?

You can configure the depth parameter before running the scraper. This allows you to control how many levels of replies are extracted — from surface-level replies to deep nested conversations.

***

#### Is this a Twitter API alternative for scraping replies and threads?

Yes. This tool works as a Twitter (X.com) API alternative and allows you to scrape replies, threads, and conversation data without requiring API access or authentication.

***

#### Does this scraper preserve reply relationships (who replied to whom)?

Yes. Unlike basic Twitter scrapers, this tool maintains parent-child relationships between tweets, allowing you to understand who replied to whom and analyze conversation structure accurately.

***

#### How to scrape Twitter threads without API?

You can use this Twitter reply and thread scraper to extract replies and full conversation threads without relying on the official API. It uses optimized scraping techniques to collect structured conversation data without authentication.

***

#### What is the best way to scrape Twitter replies for AI training?

The best way to scrape Twitter replies for AI training is to collect structured conversation data with full context. This scraper extracts nested replies, conversation paths, and reply relationships, making it ideal for RAG pipelines, LLM training, and contextual sentiment analysis.

# Actor input Schema

## `tweetUrls` (type: `array`):

List of X (Twitter) post URLs to extract full conversation threads from.

## `maxReplies` (type: `integer`):

Maximum number of replies to extract per tweet (across all levels).

## `depth` (type: `string`):

How deep to explore replies.

## Actor input object example

```json
{
  "tweetUrls": [
    "https://x.com/elonmusk/status/2034168476559118401"
  ],
  "maxReplies": 100,
  "depth": "1"
}
```

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

// Run the Actor and wait for it to finish
const run = await client.actor("krazee_kaushik/x-thread-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 = { "tweetUrls": ["https://x.com/elonmusk/status/2034168476559118401"] }

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

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

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

```

## CLI example

```bash
echo '{
  "tweetUrls": [
    "https://x.com/elonmusk/status/2034168476559118401"
  ]
}' |
apify call krazee_kaushik/x-thread-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=krazee_kaushik/x-thread-scraper",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "X (Twitter) Thread & Reply Scraper",
        "description": "Scrape X threads and nested replies with full conversation structure, including hierarchical paths and parent-child relationships. Control depth to capture exactly who replied to whom. Fast, reliable, and no API key required",
        "version": "0.0",
        "x-build-id": "0Ggj0GbonQlyKQTAv"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/krazee_kaushik~x-thread-scraper/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-krazee_kaushik-x-thread-scraper",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        },
        "/acts/krazee_kaushik~x-thread-scraper/runs": {
            "post": {
                "operationId": "runs-sync-krazee_kaushik-x-thread-scraper",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor and returns information about the initiated run in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/runsResponseSchema"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/acts/krazee_kaushik~x-thread-scraper/run-sync": {
            "post": {
                "operationId": "run-sync-krazee_kaushik-x-thread-scraper",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "inputSchema": {
                "type": "object",
                "required": [
                    "tweetUrls"
                ],
                "properties": {
                    "tweetUrls": {
                        "title": "Tweet URLs",
                        "type": "array",
                        "description": "List of X (Twitter) post URLs to extract full conversation threads from.",
                        "items": {
                            "type": "string"
                        }
                    },
                    "maxReplies": {
                        "title": "Max replies",
                        "minimum": 10,
                        "type": "integer",
                        "description": "Maximum number of replies to extract per tweet (across all levels).",
                        "default": 100
                    },
                    "depth": {
                        "title": "Reply depth",
                        "enum": [
                            "1",
                            "2",
                            "3",
                            "full"
                        ],
                        "type": "string",
                        "description": "How deep to explore replies.",
                        "default": "1"
                    }
                }
            },
            "runsResponseSchema": {
                "type": "object",
                "properties": {
                    "data": {
                        "type": "object",
                        "properties": {
                            "id": {
                                "type": "string"
                            },
                            "actId": {
                                "type": "string"
                            },
                            "userId": {
                                "type": "string"
                            },
                            "startedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "finishedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "status": {
                                "type": "string",
                                "example": "READY"
                            },
                            "meta": {
                                "type": "object",
                                "properties": {
                                    "origin": {
                                        "type": "string",
                                        "example": "API"
                                    },
                                    "userAgent": {
                                        "type": "string"
                                    }
                                }
                            },
                            "stats": {
                                "type": "object",
                                "properties": {
                                    "inputBodyLen": {
                                        "type": "integer",
                                        "example": 2000
                                    },
                                    "rebootCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "restartCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "resurrectCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "computeUnits": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "options": {
                                "type": "object",
                                "properties": {
                                    "build": {
                                        "type": "string",
                                        "example": "latest"
                                    },
                                    "timeoutSecs": {
                                        "type": "integer",
                                        "example": 300
                                    },
                                    "memoryMbytes": {
                                        "type": "integer",
                                        "example": 1024
                                    },
                                    "diskMbytes": {
                                        "type": "integer",
                                        "example": 2048
                                    }
                                }
                            },
                            "buildId": {
                                "type": "string"
                            },
                            "defaultKeyValueStoreId": {
                                "type": "string"
                            },
                            "defaultDatasetId": {
                                "type": "string"
                            },
                            "defaultRequestQueueId": {
                                "type": "string"
                            },
                            "buildNumber": {
                                "type": "string",
                                "example": "1.0.0"
                            },
                            "containerUrl": {
                                "type": "string"
                            },
                            "usage": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "integer",
                                        "example": 1
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "usageTotalUsd": {
                                "type": "number",
                                "example": 0.00005
                            },
                            "usageUsd": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "number",
                                        "example": 0.00005
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
