# TikTok Comments Scraper (`thescrapelab/tiktok-comments-scraper`) Actor

Scrape TikTok video comments and replies into clean JSON with author details, engagement counts, timestamps, mentions, hashtags, and video status records.

- **URL**: https://apify.com/thescrapelab/tiktok-comments-scraper.md
- **Developed by:** [Inus Grobler](https://apify.com/thescrapelab) (community)
- **Categories:** Social media, Videos
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, NaN bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.75 / 1,000 tiktok comments

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

Scrape comments from public TikTok videos into clean, analysis-ready JSON. The Actor is built specifically for comment collection: it collects top-level comments, can fetch replies under each comment, deduplicates comment IDs, and streams one dataset row per comment or reply.

This Actor is unofficial and is not affiliated with, endorsed by, or sponsored by TikTok.

### Why use this Actor

- Monitor audience reactions on TikTok videos
- Export comments for sentiment analysis, moderation, or research
- Collect reply threads when you need conversation context
- Track comment counts and per-video scrape status across many videos
- Start quickly with a small default run, then scale to larger comment exports

### What it collects

- Top-level comment text and IDs
- Replies, including parent comment IDs
- Author username, display name, profile URL, avatar URL, user ID, and secUid
- Author profile details when TikTok returns them, including signature, region, language, follower count, following count, heart count, and video count
- Like count, reply count, pin/liked flags, labels, language, IP label, and creation time
- Mentions, hashtags, text entity offsets, comment image URLs, sticker URLs, and share URLs when available
- Source video ID and resolved TikTok video URL
- Per-video status records with scrape status, counts, and errors

### Input

Provide TikTok video URLs or raw numeric video IDs in `videoUrls`. You can paste a full `/video/` URL, a short TikTok URL, or just the numeric video ID.

The main controls are the video list, comment limit, reply collection, and optional cookies. Residential proxy routing, request pacing, retries, and memory-friendly result streaming are tuned automatically.

```json
{
  "videoUrls": [
    "https://www.tiktok.com/@khaby.lame/video/7623088450576633119",
    "7615594654058237206"
  ],
  "maxCommentsPerVideo": 10,
  "includeReplies": false,
  "maxRepliesPerComment": 0
}
````

Runs use Apify Residential Proxy by default. A real TikTok cookie header can improve reliability when TikTok challenges anonymous sessions. Use `cookieHeader` only with cookies you are authorized to use.

Rows are written to the dataset as soon as each comment or reply is found, so long runs can be inspected while they are still running. The Actor does not keep collected comments in memory.

### Output

Dataset items are comment, reply, or video status records. Comment and reply rows are written immediately as they are parsed. Video status rows are written once per input video and are useful when TikTok returns no comments for the current session.

```json
{
  "record_type": "comment",
  "video_id": "7106594312292453678",
  "video_url": "https://www.tiktok.com/@tiktok/video/7106594312292453678",
  "comment_id": "7107000000000000000",
  "parent_comment_id": "",
  "is_reply": false,
  "text": "Example comment text",
  "like_count": 12,
  "reply_count": 2,
  "create_time": "2026-05-28T10:15:00Z",
  "create_time_epoch": 1780000000,
  "author_unique_id": "example_user",
  "author_nickname": "Example User",
  "author_profile_url": "https://www.tiktok.com/@example_user",
  "scraped_at": "2026-05-28T14:30:00Z"
}
```

```json
{
  "record_type": "video_status",
  "video_id": "7623088450576633119",
  "video_url": "https://www.tiktok.com/@khaby.lame/video/7623088450576633119",
  "status": "succeeded",
  "top_level_comments": 10,
  "replies": 0,
  "api_pages": 1,
  "video_metadata_status": "not_loaded",
  "scraped_at": "2026-05-28T14:30:00Z"
}
```

The run summary is stored in `OUTPUT_SUMMARY` and includes per-video counts, failures, API page counts, and the effective settings.

### Python API example

```python
from apify_client import ApifyClient

TOKEN = "YOUR_APIFY_TOKEN"
ACTOR_ID = "thescrapelab/tiktok-comments-scraper"

apify_client = ApifyClient(TOKEN)
actor_client = apify_client.actor(ACTOR_ID)

run_input = {
    "videoUrls": ["https://www.tiktok.com/@khaby.lame/video/7623088450576633119"],
    "maxCommentsPerVideo": 10,
    "includeReplies": False,
    "maxRepliesPerComment": 0,
}

call_result = actor_client.call(run_input=run_input)
if call_result is None:
    raise RuntimeError("Actor run failed")

dataset_client = apify_client.dataset(call_result["defaultDatasetId"])
for item in dataset_client.list_items().items:
    if item.get("record_type") in {"comment", "reply"}:
        print(item["record_type"], item.get("comment_id"), item.get("text"))
    else:
        print(item["record_type"], item.get("video_id"), item.get("status"))
```

### Notes and limitations

TikTok changes its web API and challenge behavior often. The Actor uses residential proxy routing by default, but a cookie header can still be needed for a warmer session. Keep request limits realistic. The Actor only scrapes comments available to the session used for the run.

# Actor input Schema

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

Public TikTok video URLs, short TikTok URLs, or raw numeric video IDs.

## `maxCommentsPerVideo` (type: `integer`):

Maximum number of top-level comments to collect for each video.

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

Fetch replies under each collected top-level comment.

## `maxRepliesPerComment` (type: `integer`):

Maximum number of replies to collect below each top-level comment when Include replies is enabled.

## `cookieHeader` (type: `string`):

Optional TikTok Cookie header copied from an authorized browser session. This can improve reliability when TikTok limits anonymous sessions.

## Actor input object example

```json
{
  "videoUrls": [
    "https://www.tiktok.com/@khaby.lame/video/7623088450576633119"
  ],
  "maxCommentsPerVideo": 10,
  "includeReplies": false,
  "maxRepliesPerComment": 0
}
```

# Actor output Schema

## `datasetItems` (type: `string`):

One JSON item per top-level comment, reply, or video status record.

## `datasetItemsCleanJson` (type: `string`):

Dataset items as clean JSON for downstream processing.

## `outputSummary` (type: `string`):

Run-level summary stored in the default key-value store under OUTPUT\_SUMMARY.

## `runApi` (type: `string`):

Direct API link for this run.

# 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 = {
    "videoUrls": [
        "https://www.tiktok.com/@khaby.lame/video/7623088450576633119"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("thescrapelab/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 = { "videoUrls": ["https://www.tiktok.com/@khaby.lame/video/7623088450576633119"] }

# Run the Actor and wait for it to finish
run = client.actor("thescrapelab/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 '{
  "videoUrls": [
    "https://www.tiktok.com/@khaby.lame/video/7623088450576633119"
  ]
}' |
apify call thescrapelab/tiktok-comments-scraper --silent --output-dataset

```

## MCP server setup

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

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "TikTok Comments Scraper",
        "description": "Scrape TikTok video comments and replies into clean JSON with author details, engagement counts, timestamps, mentions, hashtags, and video status records.",
        "version": "0.1",
        "x-build-id": "S6kWegM3xQQIOgJZY"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/thescrapelab~tiktok-comments-scraper/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-thescrapelab-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/thescrapelab~tiktok-comments-scraper/runs": {
            "post": {
                "operationId": "runs-sync-thescrapelab-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/thescrapelab~tiktok-comments-scraper/run-sync": {
            "post": {
                "operationId": "run-sync-thescrapelab-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 or IDs",
                        "minItems": 1,
                        "maxItems": 100,
                        "type": "array",
                        "description": "Public TikTok video URLs, short TikTok URLs, or raw numeric video IDs.",
                        "items": {
                            "type": "string"
                        }
                    },
                    "maxCommentsPerVideo": {
                        "title": "Max top-level comments per video",
                        "minimum": 1,
                        "maximum": 10000,
                        "type": "integer",
                        "description": "Maximum number of top-level comments to collect for each video.",
                        "default": 10
                    },
                    "includeReplies": {
                        "title": "Include replies",
                        "type": "boolean",
                        "description": "Fetch replies under each collected top-level comment.",
                        "default": false
                    },
                    "maxRepliesPerComment": {
                        "title": "Max replies per comment",
                        "minimum": 0,
                        "maximum": 1000,
                        "type": "integer",
                        "description": "Maximum number of replies to collect below each top-level comment when Include replies is enabled.",
                        "default": 0
                    },
                    "cookieHeader": {
                        "title": "TikTok cookie header",
                        "type": "string",
                        "description": "Optional TikTok Cookie header copied from an authorized browser session. This can improve reliability when TikTok limits anonymous sessions."
                    }
                }
            },
            "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
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
