# Threads Scraper (`lukaku/threads-scraper`) Actor

- **URL**: https://apify.com/lukaku/threads-scraper.md
- **Developed by:** [Khánh Chung](https://apify.com/lukaku) (community)
- **Categories:**
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

Pay per usage

This Actor is paid per platform usage. The Actor is free to use, and you only pay for the Apify platform usage, which gets cheaper the higher subscription plan you have.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-usage

## 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

An Apify Actor that accepts public Threads post/share URLs and writes one structured dataset item per input URL.

### What it extracts

- Post text and outbound URLs embedded in the post
- Social metrics: likes, replies, reposts, quotes, shares, and views (when Threads exposes them)
- Author ID, username, full name, avatar, verification and privacy status
- Publication time, language, images and videos
- An explicit `failed` item if a URL cannot be scraped after retries

The Actor listens for Threads JSON API responses and also inspects JSON embedded in the rendered page. It deliberately does not depend on a hard-coded GraphQL `doc_id`.

### Input

```json
{
  "input": [
    {
      "url": "https://www.threads.com/@thanhdi2002/post/Dc4GCkdiccs"
    },
    {
      "url": "https://www.threads.com/share/BASb4UxkrU/"
    }
  ],
  "includeRaw": false,
  "maxConcurrency": 3,
  "maxRequestRetries": 2,
  "proxyConfiguration": {
    "useApifyProxy": true
  }
}
```

Only public `threads.com` and `threads.net` post/share URLs are accepted. A share URL is followed to its final post before extraction.

### Output

```json
{
  "type": "post",
  "status": "succeeded",
  "sourceUrl": "https://www.threads.com/share/BASb4UxkrU/",
  "url": "https://www.threads.com/@thanhdi2002/post/Dc4GCkdiccs",
  "id": "3978956835650127660",
  "shortcode": "Dc4GCkdiccs",
  "text": "Post content",
  "urls": ["https://example.com/resource"],
  "metrics": {
    "likes": 945,
    "replies": 91,
    "reposts": 105,
    "quotes": 0,
    "shares": 190,
    "views": null
  },
  "author": {
    "id": "45688886992",
    "username": "thanhdi2002",
    "fullName": "Ngô Thanh Di",
    "profileUrl": "https://www.threads.com/@thanhdi2002",
    "profilePictureUrl": "https://cdn.example/avatar.jpg",
    "isVerified": false,
    "isPrivate": false
  },
  "postedAt": "2024-12-20T12:00:00.000Z",
  "language": "vi",
  "media": []
}
```

Metric values can be `null` when Threads does not expose them to a logged-out session. CDN media URLs are signed and can expire; consume or download them soon after a run.

### Run locally

```bash
npm install
apify run
```

Without the Apify CLI, place the input in `storage/key_value_stores/default/INPUT.json` and run `npm start`. Results are written under `storage/datasets/default/`.

### Deploy to Apify

```bash
npx apify-cli login
npx apify-cli push
```

The first command authenticates your account; `push` creates/updates the Actor from `.actor/actor.json`, uploads the source and starts its cloud build.

### Operational notes

- Public pages only; this Actor does not bypass authentication or account privacy.
- Threads can change its internal response format. The recursive post detector tolerates wrapper changes, but field renames may require updating `src/extract.js`.
- Use Apify residential proxy groups if requests from datacenter IPs are rate-limited.
- Keep concurrency conservative. The default of 3 favors reliability over peak throughput.

# Actor input Schema

## `input` (type: `array`):

Public Threads post or share URLs to scrape.

## `includeRaw` (type: `boolean`):

Include the selected raw Threads post object in each successful result. This can make dataset items much larger.

## `maxConcurrency` (type: `integer`):

Maximum number of browser pages processed at once.

## `maxRequestRetries` (type: `integer`):

How many times to retry a URL after a navigation or extraction failure.

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

Apify Proxy or custom proxy settings. Residential proxies generally reduce blocking.

## Actor input object example

```json
{
  "input": [
    {
      "url": "https://www.threads.com/@zuck/post/CuV_UY4J32j"
    }
  ],
  "includeRaw": false,
  "maxConcurrency": 3,
  "maxRequestRetries": 2,
  "proxyConfiguration": {
    "useApifyProxy": true
  }
}
```

# Actor output Schema

## `results` (type: `string`):

Successful post results and explicit failure records.

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

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

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

```

## MCP server setup

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