# TikTok Comments Scraper — Threads, Replies, Sentiment-Ready (`funny_ground/tiktok-comments-scraper`) Actor

Extract every comment from any TikTok video, including reply threads, author info, like counts, and timestamps. Pay-per-result $0.50 / 1K comments — the cheapest in the category. Sentiment-analysis and spam-detection ready. Callable as a tool via Apify MCP Server

- **URL**: https://apify.com/funny\_ground/tiktok-comments-scraper.md
- **Developed by:** [Coor Yu](https://apify.com/funny_ground) (community)
- **Categories:** Social media, Videos
- **Stats:** 2 total users, 2 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.10 / 1,000 results

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

## TikTok Comments Scraper · Apify Actor

Extract every comment from any TikTok video — including reply threads, author info,
like counts, pinned status, and timestamps. Sentiment-analysis and spam-detection ready.

**$0.50 / 1,000 comments** — cheapest in the category (head actor: $0.50–$0.70 / 1K).
Pay-per-result, failed requests are free.

---

### 中文说明

输入一个或多个 TikTok 视频链接，抓取每条视频的**全部评论**（含回复线程、作者信息、点赞数、置顶状态、时间戳）。

**工作原理（可靠的签名翻页）**：用真实浏览器打开视频页，让 TikTok 自身先成功发出一次 API 请求以预热 `msToken`/会话；随后捕获或构造 `comment/list` 请求模板，每页只换 `cursor`，用页面内置签名函数 `byted_acrawler.frontierSign` 重新签名（`X-Bogus`），跟随 `has_more` 翻页。回复线程通过把模板改写为 `comment/list/reply` 接口（换 `item_id`+`comment_id`）同样签名翻页。默认使用 Apify Proxy `DEFAULT` 非住宅代理池，不会自动切到住宅代理；如果用户手动选择 `RESIDENTIAL`，则尊重该输入。

**输入**：`videoUrls`（视频链接，必填）、`commentsPerVideo`（每视频最多评论数，0=全部）、`includeReplies`（是否抓回复）、`repliesPerComment`、`proxy`（默认 Apify Proxy `DEFAULT` 非住宅池）、`maxConcurrency`、`maxRequestRetries`。
**输出**：每行一条评论（顶层或回复），含 `commentId`/`text`/`author`/`diggCount`/`replyCount`/`isReply`/`parentCommentId`/`isPinned`/`createTimeISO` 等。
**计费**：按结果 $0.50 / 1000 条；失败请求不收费。

---

### Why this actor

| Feature | This actor | Typical alternatives |
| --- | --- | --- |
| Extraction surface | **Signed API pagination** — re-signs each `/api/comment/list/*` request with TikTok's own in-page signer | Reverse-engineering rotating signatures every week |
| Reply threads | Yes (configurable depth + per-thread cap) | Often top-level only |
| Output fields | 18 (incl. `isAuthorLiked`, `isPinned`, `mentionedUsers`, `depth`) | 8–12 |
| MCP-compatible | Yes — discoverable via `mcp.apify.com` | Most are not |
| Pricing | $0.50 / 1K comments | $0.50–$0.70 / 1K |
| Proxy | Non-residential DEFAULT proxy by default; explicit RESIDENTIAL is respected | Often residential-only or datacenter-only |

---

### Input

```json
{
  "videoUrls": [
    "https://www.tiktok.com/@khaby.lame/video/7321234567890123456",
    "https://www.tiktok.com/@charlidamelio/video/7345678901234567890"
  ],
  "commentsPerVideo": 200,
  "includeReplies": true,
  "repliesPerComment": 20,
  "proxy": {
    "useApifyProxy": true
  },
  "maxConcurrency": 2,
  "maxRequestRetries": 2
}
````

Full schema → [`.actor/input_schema.json`](./.actor/input_schema.json).

***

### Output (one row per comment)

```json
{
  "commentId": "7398234567890",
  "videoId": "7321234567890123456",
  "videoUrl": "https://www.tiktok.com/@khaby.lame/video/7321234567890123456",
  "text": "lmao 💀 you nailed it",
  "createTimeISO": "2026-05-12T15:01:22.000Z",
  "isReply": false,
  "parentCommentId": null,
  "depth": 0,
  "diggCount": 4231,
  "replyCount": 12,
  "isAuthorLiked": true,
  "isPinned": false,
  "author": {
    "id": "6912345678",
    "uniqueId": "fan_name",
    "nickname": "Fan Name",
    "verified": false,
    "avatar": "https://...",
    "isVideoAuthor": false
  },
  "mentionedUsers": [],
  "scrapedAt": "2026-05-19T07:34:18.012Z"
}
```

Replies appear in the same dataset with `isReply=true` and `parentCommentId` populated.
Full schema → [`.actor/dataset_schema.json`](./.actor/dataset_schema.json).

***

### Pricing — Pay per result

| Event | Charge |
| --- | --- |
| `comment-scraped` | $0.50 / 1,000 comments (top-level OR reply) |

Failed requests and retries are free.

***

### How it works (extraction strategy)

1. **Open the video page** with Playwright using fingerprint randomisation + Apify Proxy DEFAULT non-residential pool by default.
2. **Sniff XHR responses** that match `/api/comment/list/*` — these are TikTok's own signed
   requests, so we never need to compute `X-Bogus` / `msToken` ourselves.
3. **Scroll briefly or build a synthetic comment template** when the page never fires its own comment request.
4. **(Optional)** click "View replies" affordances so reply-thread XHRs fire too.
5. **De-dup → trim to limits → push → charge.**

This is the same architecture used by the top-rated TikTok scrapers — robust to weekly
signature rotations, since the page does the signing for us.

***

### Local dev & deploy

```bash
npm install
mkdir -p storage/key_value_stores/default
cat > storage/key_value_stores/default/INPUT.json <<'JSON'
{
  "videoUrls": ["https://www.tiktok.com/@khaby.lame/video/7321234567890123456"],
  "commentsPerVideo": 50
}
JSON
npm start
```

Push to Apify:

```bash
npm install -g apify-cli
apify login
cd apify-tiktok-comments-scraper
apify push
```

After upload, set monetization to **Pay per result** → bind `comment-scraped` event → $0.50 / 1K.

***

### Using this actor via MCP (Claude / Cursor / ChatGPT)

The actor is auto-exposed as a tool by **Apify MCP Server** at `https://mcp.apify.com/`.

#### Cursor / Claude Desktop config

```json
{
  "mcpServers": {
    "apify": {
      "url": "https://mcp.apify.com/",
      "transport": "streamable-http",
      "headers": {
        "Authorization": "Bearer apify_api_xxxxxxxx"
      }
    }
  }
}
```

Then, in chat:

> "Use the tiktok-comments-scraper actor to grab the 200 most-liked comments on
> https://www.tiktok.com/@khaby.lame/video/7321234567890123456 — include replies."

Apify MCP Server reads the `input_schema.json` to build the tool definition and the
`dataset_schema.json` to advertise the **output shape** to the LLM, so the agent knows
what fields to expect back.

***

### License & disclaimer

MIT. Scrape only public data and respect TikTok's terms. You are responsible for
compliance with applicable laws and platform policies.

# Actor input Schema

## `videoUrls` (type: `array`):

Full TikTok video URLs. Format: https://www.tiktok.com/@username/video/{id}

## `commentsPerVideo` (type: `integer`):

Max top-level comments to return for each video. 0 = unlimited (until end of thread).

## `includeReplies` (type: `boolean`):

If true, expand each top-level comment and scrape its reply thread. Increases cost — replies are billed as comments too.

## `repliesPerComment` (type: `integer`):

Max replies per top-level comment (only used when includeReplies=true). 0 = unlimited.

## `proxy` (type: `object`):

Proxy settings. By default the actor uses Apify Proxy DEFAULT pool, which is non-residential, and never automatically switches to RESIDENTIAL. If you explicitly select RESIDENTIAL, that choice is respected.

## `headless` (type: `boolean`):

Run Playwright headless. Set false only when debugging locally.

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

Max simultaneous browser pages.

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

Retries per video when TikTok returns no usable comments. Lower values reduce cost on non-residential IPs.

## `requestTimeoutSecs` (type: `integer`):

Per-request navigation timeout in seconds. Lower = faster failover on stuck pages.

## Actor input object example

```json
{
  "videoUrls": [
    "https://www.tiktok.com/@khaby.lame/video/7321234567890123456"
  ],
  "commentsPerVideo": 100,
  "includeReplies": false,
  "repliesPerComment": 20,
  "proxy": {
    "useApifyProxy": true
  },
  "headless": true,
  "maxConcurrency": 2,
  "maxRequestRetries": 2,
  "requestTimeoutSecs": 45
}
```

# 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 = {
    "proxy": {
        "useApifyProxy": true
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("funny_ground/tiktok-comments-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 = { "proxy": { "useApifyProxy": True } }

# Run the Actor and wait for it to finish
run = client.actor("funny_ground/tiktok-comments-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 '{
  "proxy": {
    "useApifyProxy": true
  }
}' |
apify call funny_ground/tiktok-comments-scraper --silent --output-dataset

```

## MCP server setup

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

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "TikTok Comments Scraper — Threads, Replies, Sentiment-Ready",
        "description": "Extract every comment from any TikTok video, including reply threads, author info, like counts, and timestamps. Pay-per-result $0.50 / 1K comments — the cheapest in the category. Sentiment-analysis and spam-detection ready. Callable as a tool via Apify MCP Server",
        "version": "1.0",
        "x-build-id": "kq6wICIwVKqIcXLeT"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/funny_ground~tiktok-comments-scraper/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-funny_ground-tiktok-comments-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/funny_ground~tiktok-comments-scraper/runs": {
            "post": {
                "operationId": "runs-sync-funny_ground-tiktok-comments-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/funny_ground~tiktok-comments-scraper/run-sync": {
            "post": {
                "operationId": "run-sync-funny_ground-tiktok-comments-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": [
                    "videoUrls"
                ],
                "properties": {
                    "videoUrls": {
                        "title": "TikTok video URLs",
                        "minItems": 1,
                        "uniqueItems": true,
                        "type": "array",
                        "description": "Full TikTok video URLs. Format: https://www.tiktok.com/@username/video/{id}",
                        "default": [],
                        "items": {
                            "type": "string"
                        }
                    },
                    "commentsPerVideo": {
                        "title": "Comments per video",
                        "minimum": 0,
                        "maximum": 5000,
                        "type": "integer",
                        "description": "Max top-level comments to return for each video. 0 = unlimited (until end of thread).",
                        "default": 100
                    },
                    "includeReplies": {
                        "title": "Include replies",
                        "type": "boolean",
                        "description": "If true, expand each top-level comment and scrape its reply thread. Increases cost — replies are billed as comments too.",
                        "default": false
                    },
                    "repliesPerComment": {
                        "title": "Replies per comment",
                        "minimum": 0,
                        "maximum": 500,
                        "type": "integer",
                        "description": "Max replies per top-level comment (only used when includeReplies=true). 0 = unlimited.",
                        "default": 20
                    },
                    "proxy": {
                        "title": "Proxy configuration",
                        "type": "object",
                        "description": "Proxy settings. By default the actor uses Apify Proxy DEFAULT pool, which is non-residential, and never automatically switches to RESIDENTIAL. If you explicitly select RESIDENTIAL, that choice is respected."
                    },
                    "headless": {
                        "title": "Headless browser",
                        "type": "boolean",
                        "description": "Run Playwright headless. Set false only when debugging locally.",
                        "default": true
                    },
                    "maxConcurrency": {
                        "title": "Max concurrency",
                        "minimum": 1,
                        "maximum": 15,
                        "type": "integer",
                        "description": "Max simultaneous browser pages.",
                        "default": 2
                    },
                    "maxRequestRetries": {
                        "title": "Max request retries",
                        "minimum": 0,
                        "maximum": 5,
                        "type": "integer",
                        "description": "Retries per video when TikTok returns no usable comments. Lower values reduce cost on non-residential IPs.",
                        "default": 2
                    },
                    "requestTimeoutSecs": {
                        "title": "Request timeout (s)",
                        "minimum": 10,
                        "maximum": 300,
                        "type": "integer",
                        "description": "Per-request navigation timeout in seconds. Lower = faster failover on stuck pages.",
                        "default": 45
                    }
                }
            },
            "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
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
