# TikTok Comments & Replies Scraper (API Direct) (`a.actors/tiktok-comments-replies-scraper`) Actor

Scrape comments and their reply threads from public TikTok videos and photo posts with your own API Direct key (free tier available). Each reply links to its parent comment; videos that cannot be read are reported free.

- **URL**: https://apify.com/a.actors/tiktok-comments-replies-scraper.md
- **Developed by:** [ApifyActors](https://apify.com/a.actors) (community)
- **Categories:** Social media
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 0.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.20 / 1,000 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/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
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.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

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

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## TikTok Comments & Replies Scraper (API Direct)

Export top-level comments on public TikTok videos, and optionally the replies under them, to an Apify dataset with your own API Direct key. Give the Actor a list of video URLs or decimal video IDs. It requests comments from API Direct in TikTok's default order and writes one row per unique comment or reply, with every reply linked to its comment. Download the dataset as CSV or JSON from the run's **Storage** tab.

### What you need

An API Direct key from [apidirect.io](https://apidirect.io). API Direct gives every account 50 free requests per endpoint each month, with no card on file, and bills its own usage to your key after that (see **Pricing**). The key goes into the input form's secret field, which Apify stores encrypted.

### Run a first check

Open the Actor's input form, paste your API Direct key into the secret field, add one full video link, and set **Maximum comments per video** to 2. To verify your result, open **Output → Comments and replies** and compare the IDs and text with a known sample. **Per-video summary** shows what happened to each video.

Example input (replace the sample key in the form):

```json
{
  "videos": ["https://www.tiktok.com/@bbcnews/video/7690902917741726979"],
  "maxCommentsPerVideo": 2,
  "apiKey": "YOUR_API_DIRECT_KEY"
}
```

Supply 1–100 IDs or full video links; photo posts (`/photo/` links) are accepted too. URL variants of the same video are collected once. Short share links (`vm.tiktok.com`) and profile links are not accepted: open the video and copy its full link. A link the Actor cannot read stops the run before any request is made, and the run's status names that link. The default limit is 50 unique comments per video, configurable from 1 to 450. The provider describes roughly 450 as the accessible depth and may return fewer. Reply counts are included where available.

#### Replies

Replies are off by default. Turn on **Include replies** to also export each comment's thread. The Actor then requests the replies of every comment whose reply count is above zero, one request per comment, up to **Maximum replies per comment** (default 50, up to 1000). API Direct bills only the pages of 50 a thread actually fills, so a higher cap costs more only on longer threads. The cap, not the comment's reply count, sets how far the Actor reads: TikTok's count can be lower than the thread. Comments without replies cost nothing extra. Each reply is its own row, linked to its comment by `parentCommentId`. Threads are requested five at a time.

```json
{
  "videos": ["https://www.tiktok.com/@bbcnews/video/7690902917741726979"],
  "maxCommentsPerVideo": 50,
  "includeReplies": true,
  "maxRepliesPerComment": 50,
  "apiKey": "YOUR_API_DIRECT_KEY"
}
```

### Output

A comment, and a reply to it:

```json
{
  "videoId": "7690902917741726979",
  "commentId": "7516998696283505430",
  "parentCommentId": null,
  "text": "Example comment",
  "author": "example_user",
  "likes": 12,
  "replyCount": 2,
  "createdAtUnix": 1750187654,
  "images": []
}
```

```json
{
  "videoId": "7690902917741726979",
  "commentId": "7517173688660394774",
  "parentCommentId": "7516998696283505430",
  "text": "Example reply",
  "author": "another_user",
  "likes": 3,
  "replyCount": null,
  "createdAtUnix": 1750228407,
  "images": []
}
```

IDs are decimal strings. Timestamps are Unix seconds. Unavailable metrics remain null. `parentCommentId` is null on a top-level comment; on a reply it holds the ID of the comment the reply belongs to, and the reply's own `replyCount` is null.

#### When something cannot be collected

A video or a reply thread that cannot be collected still gets a row, so a problem never looks like silence. These status rows are free. They have `commentId: null` and a `status` with a `message`; `parentCommentId` is set when the row is about one comment's replies.

```json
{
  "videoId": "7690902917741726979",
  "commentId": null,
  "parentCommentId": null,
  "status": "no_rows_returned",
  "message": "API Direct reported 40 comments on this video but returned none."
}
```

| `status` | Meaning |
|---|---|
| `empty` | API Direct returned no comments and reported none. Either the video has no comments, or the video is deleted, private or a wrong ID: API Direct answers these the same way, so check the link if you expected comments. For a reply thread: no replies. |
| `unavailable` | API Direct answered 404. Collection continues. |
| `no_rows_returned` | API Direct reported comments (or replies) but returned none. Worth a retry later. |
| `failed` | A provider error: the key was refused, the credit ran out, or API Direct kept answering 429/5xx after three retries. The Actor stops sending requests and the run ends as failed. |
| `credit_exhausted` | API Direct answered 402: your key's free requests or credit for that endpoint are used up. Free requests are counted per endpoint, so when only replies run out, comments keep coming and only the remaining threads get this status. Add credit and run what is left again. |
| `not_attempted` | Not requested because an earlier request failed. |
| `charge_limit_reached` | Not requested because the run reached your maximum charge. |

An empty, deleted or unavailable video or comment does not fail the run, and neither does running out of API Direct credit or reaching your maximum charge; only a provider error does. Rate limits (HTTP 429) and server errors are retried with a pause before the Actor gives up. Comment rows filter out cleanly: keep the rows whose `commentId` is not null.

The SUMMARY record in the default key-value store (**Per-video summary**) lists every input video after deduplication with its status, the number of comments exported and the provider's reported page and comment totals. With replies on, each video also gets a `replies` block: threads requested, the replies their comments reported against the replies exported, a count per status, threads cut by the cap, and the comment ID and reason for every thread that was not collected. A video's reported total counts replies too, so it is higher than its number of top-level comments.

If Apify restarts a run on another server, the Actor reuses every answer it already saved, so nothing is requested or charged twice. A request that was in flight at that moment is sent once more, which can bill one page twice on your API Direct key.

### Pricing

You pay two parties:

- **This Actor:** $0.20 per 1,000 rows, the same for comments and replies (events `comment` and `reply`, $0.0002 each), plus Apify's standard $0.00005 per run start. Status rows are free. The run stops sending requests once your maximum charge is reached, and asks API Direct only for as many comments as can still be charged.
- **API Direct, billed to your key:** $0.006 per page of up to 50 comments or replies, after the free 50 requests per endpoint per month. Each video costs `ceil(maxCommentsPerVideo / 50)` pages at most. With replies on, every comment that has replies adds at least one page, plus one page per further 50 replies. Check API Direct's dashboard for actual charges. [Comments endpoint](https://apidirect.io/endpoints/tiktok-video-comments) · [Replies endpoint](https://apidirect.io/endpoints/tiktok-comment-replies)

Examples, both parties together:

| Video | API Direct | This Actor | Total |
|---|---|---|---|
| 450 comments, replies off | 9 pages, $0.054 | $0.090 | $0.144 |
| 89 comments and 21 replies in 7 threads | 2 + 7 pages, $0.054 | $0.022 | $0.076 |
| 450 comments and 600 replies in 150 threads | 9 + 150 pages, $0.954 | $0.210 | $1.164 |

Replies are the expensive part because API Direct bills each thread as its own request.

### Limits

- API Direct reaches up to roughly 450 top-level comments per video, in TikTok's default order. On a video showing 1,503 comments (replies included), a run at the 450 limit returned 375 unique top-level comments.
- A comment's `replyCount` comes from TikTok and can differ slightly from the replies API Direct returns (hidden or deleted replies, replies added since). SUMMARY shows both numbers per video.
- API Direct allows 10 simultaneous requests per key and endpoint. One run uses up to 5; more than two runs at once on the same key can be slowed by rate limits, which the Actor retries.
- Comment authors are returned as usernames only; profile data is outside this Actor's scope.

# Actor input Schema

## `videos` (type: `array`):

Enter 1–100 full TikTok video or photo-post links, or decimal video IDs, one per line. Repeated video IDs are collected once. Short share links (vm.tiktok.com) are not accepted: open them and copy the full link.

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

Request up to this many top-level comments per video. API Direct charges by pages of up to 50.

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

Also export the replies under each comment. Costs one extra API Direct request for every comment that has replies; comments without replies cost nothing extra.

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

Used only when Include replies is on. Replies are read in pages of 50 up to this cap. API Direct bills only the pages a thread fills, so a higher cap costs more only on longer threads.

## `apiKey` (type: `string`):

Your key for apidirect.io. Provider usage is billed to this key. For local runs you can use the API_DIRECT_KEY environment secret instead.

## Actor input object example

```json
{
  "videos": [
    "https://www.tiktok.com/@bbcnews/video/7690902917741726979"
  ],
  "maxCommentsPerVideo": 50,
  "includeReplies": false,
  "maxRepliesPerComment": 50
}
```

# Actor output Schema

## `comments` (type: `string`):

No description

## `summary` (type: `string`):

No description

# 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 = {
    "videos": [
        "https://www.tiktok.com/@bbcnews/video/7690902917741726979"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("a.actors/tiktok-comments-replies-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 = { "videos": ["https://www.tiktok.com/@bbcnews/video/7690902917741726979"] }

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

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,a.actors/tiktok-comments-replies-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/Us3xc1YVkkOrIzab8/builds/xqLTiv6rKrkYGJte4/openapi.json
