# 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:** 138 total users, 29 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/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

## 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("💾 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 '{
  "urls": [
    "https://www.threads.com/@zuck/post/DRSYei3El47"
  ]
}' |
apify call trantus/threads-post-scraper --silent --output-dataset

```

## MCP server setup

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

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "Threads Post Scraper",
        "description": "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.",
        "version": "0.0",
        "x-build-id": "Ypcfma71xQ8rqhRxq"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/trantus~threads-post-scraper/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-trantus-threads-post-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/trantus~threads-post-scraper/runs": {
            "post": {
                "operationId": "runs-sync-trantus-threads-post-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/trantus~threads-post-scraper/run-sync": {
            "post": {
                "operationId": "run-sync-trantus-threads-post-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",
                "properties": {
                    "urls": {
                        "title": "Post URLs (multiple)",
                        "uniqueItems": true,
                        "type": "array",
                        "description": "List of Threads post URLs to scrape.",
                        "items": {
                            "type": "string"
                        }
                    },
                    "url": {
                        "title": "Single post URL",
                        "type": "string",
                        "description": "If you only want to scrape one post, use this instead of 'urls'."
                    },
                    "raw": {
                        "title": "Include raw data",
                        "type": "boolean",
                        "description": "If true, output will include the original raw JSON objects for debugging.",
                        "default": false
                    },
                    "timeoutMs": {
                        "title": "Request timeout (ms)",
                        "minimum": 1000,
                        "maximum": 60000,
                        "type": "integer",
                        "description": "HTTP request timeout for fetching the post page.",
                        "default": 15000
                    }
                }
            },
            "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
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
