# Threads Post Scraper (`trantus/threads-post-scraper`) Actor

Scrape any public Threads post, including full media, text, mentions, links, and all nested comments. Supports multiple URLs, raw JSON mode, and reliable HTML parsing without login. Outputs structured data to Dataset and SUMMARY.json.

- **URL**: https://apify.com/trantus/threads-post-scraper.md
- **Developed by:** [Tran Tu](https://apify.com/trantus) (community)
- **Categories:** Social media
- **Stats:** 187 total users, 26 monthly users, 100.0% runs succeeded, 2 bookmarks
- **User rating**: 5.00 out of 5 stars

## Pricing

from $2.00 / 1,000 posts

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?

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

## Threads Post Scraper

Search and extract **public Threads posts** (by post URL) and export **thread-level results** (root post + nested comments) to your Apify Dataset and `SUMMARY.json` in Key-Value Store.

***

### What this actor does

- Accepts one or more Threads **post URLs** and fetches the HTML page.
- Parses nodes into a **root post** and **nested comments** (top-level comment + replies).
- Emits one dataset item per parsed post page (`post_with_comments_nested`) containing:

  - `root_post` (normalized or raw depending on `raw`)
  - `comments` (array of `{ comment, replies: [] }`)
- Saves a run summary to `SUMMARY.json`.

> Works only on **public** content (no login). Use a post URL like `https://www.threads.net/@username/post/CODE`.

***

### Input

#### Example (single URL, normalized)

```json
{
  "url": "https://www.threads.net/@quachthihang/post/DR3ioaSEjx8",
}
```

#### Example (multiple URLs, raw)

```json
{
  "urls": [
    "https://www.threads.net/@user/post/ABC",
    "https://www.threads.net/@user/post/DEF"
  ],
}
```

#### Input fields

| Field       |    Type | Required | Notes                                                                                   |
| ----------- | ------: | -------: | --------------------------------------------------------------------------------------- |
| `url`       |  string |      No\* | Single Threads post URL. If provided, `urls` may be omitted.                            |
| `urls`      |   array |      No\* | Multiple Threads post URLs (preferred for batch runs).                                  |
| `raw`       | boolean |       No | `false` = normalized output (default). `true` = include original raw JSON in each post. |
| `timeoutMs` | integer |       No | HTTP request timeout in milliseconds (default `15000`).                                 |

- At least one of `url` or `urls` must be provided.

***

### Output

- Dataset items: one item per processed post page with `type: "post_with_comments_nested"`.
- Key-Value Store: `SUMMARY.json`.

#### Normalized item (example)

```json
{
  "type": "post_with_comments_nested",
  "url": "https://www.threads.net/@quachthihang/post/DR3ioaSEjx8",
  "ok": true,
  "root_post": {
    "id": "3780642722781740156_67808873631",
    "pk": "3780642722781740156",
    "user": {
      "id": "67808873631",
      "username": "quachthihang",
      "full_name": "Thanh Hằng",
      "profile_pic_url": "https://...jpg/",
      "is_verified": false
    },
    "text": "chưa gì mà đã cuống hết cả lên thế này rồi",
    "images": [
      { "url": "https://...jpg/", "width": 640, "height": 1136 }
    ],
    "taken_at": 1764907754,
    "like_count": 9156,
    "code": "DR3ioaSEjx8"
  },
  "comments": [
    {
      "comment": { "id": "...", "text": "link...", "reply_to_post": "378064272..." },
      "replies": [
        { "id": "...", "text": "reply to comment", "reply_to_comment": "..." }
      ]
    }
  ],
  "total_nodes_found": 10,
  "total_top_comments": 3,
  "collectedAt": "2025-12-06T..."
}
```

#### Raw item (example)

When `raw: true`, `root_post` and comment objects include the original `raw` JSON from Threads (the rest of normalized fields are still present).

***

### SUMMARY.json

Example (normalized):

```json
{
  "input": {
    "urls": ["https://www.threads.net/@user/post/ABC"],
    "raw": false
  },
  "processed": [
    { "url": "https://www.threads.net/@user/post/ABC", "ok": true, "top_comments": 4 }
  ],
  "collectedAt": "2025-12-06T..."
}
```

Example (raw):

```json
{
  "input": { "urls": ["..."], "raw": true },
  "processed": [
    { "url": "...", "ok": true, "top_comments": 4 }
  ],
  "collectedAt": "2025-12-06T..."
}
```

***

### Quick start (no code)

1. Open this actor in the Apify console.
2. Click **Run**.
3. Paste your `input.json` (see examples above).
4. Start the run.
5. Check results:

   - **Dataset** → items (`post_with_comments_nested`)
   - **Key-Value Store** → `SUMMARY.json`

***

### CLI / API examples

#### Run with `apify` CLI

```bash
apify run --input-file=input.json
```

#### Start a run via Apify API (curl)

```bash
curl -X POST "https://api.apify.com/v2/acts/trantus~threads-post-scraper/runs?token=YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"urls":["https://www.threads.net/@user/post/ABC"], "raw": false}'
```

#### Fetch dataset (last run)

```bash
curl "https://api.apify.com/v2/acts/YOUR_ACCOUNT~threads-post-scraper/runs/last/dataset/items?token=YOUR_TOKEN"
```

***

### Notes & tips

- Provide full post URLs (`https://www.threads.net/@user/post/CODE`) — the actor extracts JSON embedded in the page.
- If you get network errors (DNS / ENOTFOUND), try running with the `url` content copied into `relayJson` offline (not supported in this actor build) or resolve DNS connectivity.
- Increase `timeoutMs` for slow connections or heavy pages.

***

### Changelog

- **1.0.0**

  - Initial release

# Actor input Schema

## `urls` (type: `array`):

List of Threads post URLs to scrape.

## `url` (type: `string`):

If you only want to scrape one post, use this instead of 'urls'.

## `raw` (type: `boolean`):

If true, output will include the original raw JSON objects for debugging.

## `timeoutMs` (type: `integer`):

HTTP request timeout for fetching the post page.

## Actor input object example

```json
{
  "urls": [
    "https://www.threads.com/@zuck/post/DRSYei3El47"
  ],
  "raw": false,
  "timeoutMs": 15000
}
```

# 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 = {
    "urls": [
        "https://www.threads.com/@zuck/post/DRSYei3El47"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("trantus/threads-post-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 = { "urls": ["https://www.threads.com/@zuck/post/DRSYei3El47"] }

# Run the Actor and wait for it to finish
run = client.actor("trantus/threads-post-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 '{
  "urls": [
    "https://www.threads.com/@zuck/post/DRSYei3El47"
  ]
}' |
apify call trantus/threads-post-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,trantus/threads-post-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/DfC23U58BBIKr90R2/builds/Ypcfma71xQ8rqhRxq/openapi.json
