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

Extract every comment of TikTok videos, with the replies, and the video details. Returns structured data: comment text, author, likes, reply count, time and replies, plus video stats (views, likes, shares).

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

## Pricing

from $0.04 / 1,000 comments

This Actor is paid per event and usage. You are charged both the fixed price for specific events and for Apify platform usage.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

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 Video Comments Scraper - Comments, Replies and Video Stats

Get the comments of TikTok videos, with their replies, together with the details
and stats of each video. Start with video URLs, or with profile URLs to read the
videos of a profile. Each comment and each reply is one item in the Dataset. Each
video also has one item in the Videos dataset, with its description, author,
music, and counts of views, likes, comments, shares, and saves.

Read a sample of comments or every available comment. Run many videos in one
run.

### Use cases

#### Audience sentiment and topic research

Read what viewers say about a video. Send the comments to your own models.

```json
{
  "videoUrls": ["https://www.tiktok.com/@nasa/video/7700397098994273549"],
  "maxCommentsPerVideo": 0
}
```

Use `text`, `textLanguage`, `likes`, `type`, `repliesToId`, and `createTime` in
the Dataset.

#### Creator engagement

See which comments the creator wrote, pinned, or liked.

```json
{
  "videoUrls": ["https://www.tiktok.com/@nasa/video/7700397098994273549"],
  "maxCommentsPerVideo": 200
}
```

Use `isByCreator`, `isPinned`, `isLikedByCreator`, and `mentions` in the Dataset.

#### Creator and brand monitoring

Track how the videos of a creator grow and what viewers say. Run the same input
on an Apify schedule, and compare the results over time.

```json
{
  "profileUrls": ["https://www.tiktok.com/@nasa"],
  "videosPerProfile": 5,
  "maxCommentsPerVideo": 100
}
```

Use `video.stats.views`, `video.stats.likes`, `video.stats.shares`,
`video.stats.saves`, and `serverTotal` in the Videos dataset. Use the `cid` of
each comment in the Dataset to find new comments.

#### Content performance comparison

Compare several videos in one run.

```json
{
  "videoUrls": [
    "https://www.tiktok.com/@nasa/video/7700397098994273549",
    "https://www.tiktok.com/@mrbeast/video/7296168512408603947"
  ],
  "maxCommentsPerVideo": 50
}
```

Use `video.desc`, `video.author.uniqueId`, `video.stats`, and `serverTotal` in
the Videos dataset. Use `videoId` to join the two datasets.

### Choose what to collect

| Goal                           | Input                                                          | Result                                                        |
| ------------------------------ | -------------------------------------------------------------- | ------------------------------------------------------------- |
| All comments of a video        | `maxCommentsPerVideo` set to `0`                               | Every available comment, with its replies                     |
| A sample of comments           | `maxCommentsPerVideo` set to a number                          | The first comments, in TikTok's own order, with their replies |
| Comments without replies       | `includeReplies` set to `false`                                | No reply items. `replies` still has the reply count           |
| Comments without video details | `includeVideoInfo` set to `false`                              | `video` is `null` in the Videos dataset                       |
| Several videos                 | More than one entry in `videoUrls`                             | The comments of all videos in one Dataset                     |
| The videos of a profile        | `profileUrls`, and `videosPerProfile` for the number of videos | The comments of each video of the profile                     |

### What each comment includes

- Comment: ID (`cid`), text, text language, likes, reply count, and creation
  time
- Commenter: ID, handle, display name, verified flag, and avatar link
- Flags: whether the creator pinned the comment, liked it, or wrote it
- Extras: the users that the text mentions, the images, and the sticker
- Reply: the same fields, with `repliesToId` for the comment that it answers,
  and `repliesToReplyId` when it answers another reply
- Video, in the Videos dataset: ID, description, creation time, hashtags,
  author with follower counts, music, video details, and stats
- Totals, in the Videos dataset: `serverTotal`, the comment count that TikTok
  shows, and `commentCount`, the number of comments saved
- Source: `inputUrl`, the video URL or the profile URL from your input

### Read the comments of a video

Start with one video URL:

```json
{
  "videoUrls": ["https://www.tiktok.com/@nasa/video/7700397098994273549"]
}
```

The Actor saves the video details and every available comment. Set
`maxCommentsPerVideo` to set an upper limit. See
[Input reference](#input-reference).

#### Supported links

Use the full video URL, with `/video/` and the numeric video ID:

`https://www.tiktok.com/@username/video/1234567890123456789`

Other links give an error item. This includes short links, such as
`vm.tiktok.com`, and photo posts. Open the short link, and copy the full URL that
it leads to.

#### Limit the comments

```json
{
  "videoUrls": ["https://www.tiktok.com/@nasa/video/7700397098994273549"],
  "maxCommentsPerVideo": 100
}
```

The Actor stops each video at 100 comments. The replies of those comments do not
count in this number. Comments come in TikTok's own order, not by date. A limit
gives the first comments in that order.

#### Comments without replies

```json
{
  "videoUrls": ["https://www.tiktok.com/@nasa/video/7700397098994273549"],
  "includeReplies": false
}
```

The Dataset has no reply items. `replies` still has the number of replies. This
run is faster.

#### Comments without video details

```json
{
  "videoUrls": ["https://www.tiktok.com/@nasa/video/7700397098994273549"],
  "includeVideoInfo": false
}
```

`video` is `null` in each item of the Videos dataset. The comments,
`serverTotal`, and `commentCount` stay the same.

### Read the comments of a profile

```json
{
  "profileUrls": ["https://www.tiktok.com/@nasa"],
  "videosPerProfile": 5,
  "maxCommentsPerVideo": 50
}
```

The Actor reads the public videos of each profile and collects the comments of
each video like for a video URL. `videosPerProfile` sets the number of videos for
each profile. `0`, the default, reads every public video of the profile, which
can take a long time. Each video has an item in the Videos dataset, and
`inputUrl` holds the profile URL from your input. A profile URL looks like
`https://www.tiktok.com/@handle`. You can use `videoUrls` and `profileUrls` in
the same run.

### How results are ordered and limited

**Order.** Items of different videos can be mixed in the Dataset. Use `videoId`
to tell them apart. Inside one
video, the items come in TikTok's own order, and each reply follows its comment.
The order is not by date or by likes. Sort the items on `createTime` or `likes`
in your own tool.

**Limit.** `maxCommentsPerVideo` applies to each video, not to the complete run.
Replies do not count in it. `videosPerProfile` applies to each profile. A limit
gives the first items in TikTok's own order.

**Same video twice.** The Actor reads a video once. A video that two inputs point
to, such as a video URL and a profile, gives its items once. `inputUrl` names one
of the two inputs.

### Input

Provide at least one video URL or one profile URL.

<details>
<summary>Complete input example</summary>

This example uses every field:

```json
{
  "videoUrls": ["https://www.tiktok.com/@nasa/video/7700397098994273549"],
  "profileUrls": ["https://www.tiktok.com/@mrbeast"],
  "videosPerProfile": 5,
  "maxCommentsPerVideo": 100,
  "includeReplies": true,
  "includeVideoInfo": true,
  "proxyConfiguration": { "useApifyProxy": true }
}
```

</details>

#### Input reference

| Parameter               | Type               | Default                  | Effect                                                                                                                                                                     |
| ----------------------- | ------------------ | ------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **videoUrls**           | string\[]           | empty                    | Full TikTok video URLs. Provide at least one video URL or one profile URL. See [Supported links](#supported-links).                                                        |
| **profileUrls**         | string\[]           | empty                    | TikTok profile URLs. The Actor reads the public videos of each profile and collects their comments. See [Read the comments of a profile](#read-the-comments-of-a-profile). |
| **videosPerProfile**    | integer, 0 or more | `0`                      | Upper limit on the videos that the Actor reads for each profile. `0` removes the limit.                                                                                    |
| **maxCommentsPerVideo** | integer, 0 or more | `0`                      | Upper limit on saved comments for each video. `0` removes the limit. Replies do not count. See [How many comments can I collect?](#how-many-comments-can-i-collect).       |
| **includeReplies**      | boolean            | `true`                   | Adds the replies of each comment as items in the Dataset. When `false`, there are no reply items. Replies add time. See [Are replies included?](#are-replies-included).    |
| **includeVideoInfo**    | boolean            | `true`                   | Adds the video details to each item of the Videos dataset. When `false`, `video` is `null`.                                                                                |
| **proxyConfiguration**  | object             | `{"useApifyProxy":true}` | Connection settings for the run. Keep the default.                                                                                                                         |

- Use full URLs. A video URL looks like
  `https://www.tiktok.com/@handle/video/<ID>`. A profile URL looks like
  `https://www.tiktok.com/@handle`.
- A value that is not a URL stops the run before collection.
- Unknown input fields are ignored.

### Output

The Actor writes three datasets. The Dataset holds the comments and the replies.
The Videos dataset holds one item for each video. The Errors dataset holds the
error items. The Output tab of the run links to all three. The Export button of
the run exports only the Dataset.

Every documented field is present in every comment item. When a value is not
available, the field is `null`, or an empty list for `mentions` and `images`. A
comment without text has an empty `text`. A count that TikTok does not give is
`0`.

#### Sample items

These Dataset items are from a real run. They show a comment with one of its
replies. The values of the commenters are removed.

<details>
<summary>Open the Dataset items</summary>

```json
[
  {
    "cid": "7703127890549162774",
    "type": "comment",
    "text": "HASHMAP is always the right answer!",
    "createTime": "1793524282",
    "likes": 508,
    "replies": 1,
    "repliesToId": null,
    "repliesToReplyId": null,
    "textLanguage": "en",
    "isPinned": false,
    "isLikedByCreator": false,
    "isByCreator": false,
    "mentions": [],
    "images": [],
    "sticker": null,
    "author": {
      "id": "[user ID]",
      "uniqueId": "[handle]",
      "nickname": "[display name]",
      "verified": false,
      "avatar": "[link removed]"
    },
    "videoId": "7702751743095901471",
    "videoUrl": "https://www.tiktok.com/@jomatech/video/7702751743095901471",
    "inputUrl": "https://www.tiktok.com/@jomatech/video/7702751743095901471"
  },
  {
    "cid": "7704918280176141076",
    "type": "reply",
    "text": "applies to everything even on pizza",
    "createTime": "1793941102",
    "likes": 0,
    "replies": null,
    "repliesToId": "7703127890549162774",
    "repliesToReplyId": null,
    "textLanguage": "en",
    "isPinned": null,
    "isLikedByCreator": false,
    "isByCreator": false,
    "mentions": [],
    "images": [],
    "sticker": null,
    "author": {
      "id": "[user ID]",
      "uniqueId": "[handle]",
      "nickname": "[display name]",
      "verified": false,
      "avatar": "[link removed]"
    },
    "videoId": "7702751743095901471",
    "videoUrl": "https://www.tiktok.com/@jomatech/video/7702751743095901471",
    "inputUrl": "https://www.tiktok.com/@jomatech/video/7702751743095901471"
  }
]
```

A comment that mentions a user has the user in `mentions`:

```json
"mentions": [{ "id": "7270025193438397483", "name": "MrBeast" }]
```

</details>

This item of the Videos dataset is from the same run. The links are removed.

<details>
<summary>Open the Videos dataset item</summary>

```json
{
  "videoId": "7702751743095901471",
  "videoUrl": "https://www.tiktok.com/@jomatech/video/7702751743095901471",
  "inputUrl": "https://www.tiktok.com/@jomatech/video/7702751743095901471",
  "video": {
    "desc": "How to prepare for your interviews ",
    "descLanguage": "en",
    "createTime": "1793436711",
    "locationCreated": "SG",
    "categories": [
      "Professional Personal Development",
      "Education",
      "Culture & Education & Technology"
    ],
    "hashtags": [],
    "mentions": [],
    "effects": [],
    "isAd": false,
    "isAiGenerated": false,
    "isPinned": null,
    "duetEnabled": true,
    "stitchEnabled": true,
    "shareEnabled": true,
    "captionLanguages": ["eng-US"],
    "images": [],
    "video": {
      "duration": 69,
      "width": 768,
      "height": 576,
      "ratio": "540p",
      "definition": "540p",
      "format": "mp4",
      "codec": "h264",
      "bitrate": 395381,
      "size": null,
      "cover": "[link removed]",
      "originCover": "[link removed]",
      "dynamicCover": "[link removed]"
    },
    "author": {
      "id": "144381841154658304",
      "uniqueId": "jomatech",
      "nickname": "Joma Tech",
      "verified": false,
      "signature": "📍NYC\nbusiness@joma.io",
      "createTime": "1474766028",
      "private": false,
      "seller": false,
      "avatar": "[link removed]",
      "followers": 202100,
      "following": 8,
      "likes": 2600000,
      "videos": 28,
      "likesGiven": 162
    },
    "stats": {
      "views": 257400,
      "likes": 29800,
      "comments": 139,
      "shares": 2340,
      "saves": 5406,
      "reposts": 0
    },
    "music": {
      "id": "7702752012924488478",
      "title": "original sound",
      "author": "Joma Tech",
      "album": null,
      "duration": 69,
      "playUrl": "[link removed]",
      "cover": "[link removed]"
    }
  },
  "serverTotal": 139,
  "commentCount": 50
}
```

</details>

#### Comment fields

| Field              | Type and contents                                                                                                                     |
| ------------------ | ------------------------------------------------------------------------------------------------------------------------------------- |
| `cid`              | string. The ID of the comment or reply.                                                                                               |
| `type`             | string. `comment` or `reply`.                                                                                                         |
| `text`             | string. The text. It is empty when the comment has no text, for example a sticker.                                                    |
| `createTime`       | string or `null`. The creation time in Unix seconds, such as `"1793524282"`.                                                          |
| `likes`            | number. The likes of the comment or reply.                                                                                            |
| `replies`          | number or `null`. For a comment, the reply count that TikTok shows. It can differ from the number of reply items. `null` for a reply. |
| `repliesToId`      | string or `null`. For a reply, the `cid` of its comment. `null` for a comment.                                                        |
| `repliesToReplyId` | string or `null`. For a reply that answers another reply, the `cid` of that reply. Otherwise `null`.                                  |
| `textLanguage`     | string or `null`. The language code of the text, such as `en`. `un` means that TikTok does not know the language.                     |
| `isPinned`         | boolean or `null`. `true` for the comment that the creator pinned. `null` for a reply.                                                |
| `isLikedByCreator` | boolean or `null`. `true` when the creator liked the comment.                                                                         |
| `isByCreator`      | boolean or `null`. `true` when the creator of the video wrote the comment.                                                            |
| `mentions`         | object\[]. The users that the text mentions. Empty when there are none.                                                                |
| `mentions[].id`    | string. The ID of the mentioned user.                                                                                                 |
| `mentions[].name`  | string. The name as the commenter wrote it after the `@`. It is a display name, so it can contain spaces.                             |
| `images`           | string\[]. The links of the images in the comment. The links expire.                                                                   |
| `sticker`          | string or `null`. The link of the sticker in the comment. The link expires.                                                           |
| `author.id`        | string. The ID of the commenter.                                                                                                      |
| `author.uniqueId`  | string. The handle of the commenter, without `@`.                                                                                     |
| `author.nickname`  | string. The display name of the commenter.                                                                                            |
| `author.verified`  | boolean or `null`. Whether the commenter is verified.                                                                                 |
| `author.avatar`    | string or `null`. A link to the avatar image. The link expires.                                                                       |
| `videoId`          | string. The ID of the video.                                                                                                          |
| `videoUrl`         | string. The link to the video.                                                                                                        |
| `inputUrl`         | string. The URL from your input that led to the comment: the video URL, or the profile URL.                                           |

#### Videos dataset fields

The Videos dataset holds one item for each video that the Actor read. The item
holds the IDs, the counts, and `video`. The object `video` holds the details,
and `video.video` holds the file details of the video.

| Field                    | Type and contents                                                                                                         |
| ------------------------ | ------------------------------------------------------------------------------------------------------------------------- |
| `videoId`                | string. The ID of the video.                                                                                              |
| `videoUrl`               | string. The link to the video.                                                                                            |
| `inputUrl`               | string. The URL from your input that led to the video: the video URL, or the profile URL.                                 |
| `video`                  | object or `null`. `null` when `includeVideoInfo` is `false`, or when the details could not be read.                       |
| `serverTotal`            | number. The comment count that TikTok shows for the video. See [the limits](#why-is-commentcount-lower-than-servertotal). |
| `commentCount`           | number. The number of comments saved for the video. Replies are not in this number.                                       |
| `video.desc`             | string. The description. It is empty when the video has none.                                                             |
| `video.descLanguage`     | string or `null`. The language code of the description, such as `en`.                                                     |
| `video.createTime`       | string or `null`. The creation time in Unix seconds, such as `"1793436711"`.                                              |
| `video.locationCreated`  | string or `null`. The country code where the video was made. Filled only for a video URL.                                 |
| `video.categories`       | string\[]. The topic labels of the video. Filled only for a video URL.                                                     |
| `video.hashtags`         | string\[]. The hashtags of the description, without `#`.                                                                   |
| `video.mentions`         | string\[]. The accounts that the description mentions, without `@`.                                                        |
| `video.effects`          | string\[]. The names of the effects that the video uses.                                                                   |
| `video.isAd`             | boolean or `null`. `true` for a paid ad.                                                                                  |
| `video.isAiGenerated`    | boolean or `null`. `true` when the video is marked as AI generated. Filled only for a video URL.                          |
| `video.isPinned`         | boolean or `null`. `true` for a video that the creator pinned. Filled only for the videos of a profile.                   |
| `video.duetEnabled`      | boolean or `null`. Whether other users can make a duet with the video.                                                    |
| `video.stitchEnabled`    | boolean or `null`. Whether other users can stitch the video.                                                              |
| `video.shareEnabled`     | boolean or `null`. Whether the video can be shared.                                                                       |
| `video.captionLanguages` | string\[]. The caption languages that the video offers, such as `eng-US`.                                                  |
| `video.images`           | string\[]. The image links of a photo post. Empty for a video.                                                             |

**`video.video`**

| Field                      | Type and contents                                                       |
| -------------------------- | ----------------------------------------------------------------------- |
| `video.video.duration`     | number. The duration in seconds.                                        |
| `video.video.width`        | number or `null`. The width in pixels.                                  |
| `video.video.height`       | number or `null`. The height in pixels.                                 |
| `video.video.ratio`        | string or `null`. The resolution label, such as `540p`.                 |
| `video.video.definition`   | string or `null`. The quality label, such as `540p`.                    |
| `video.video.format`       | string or `null`. The file format, such as `mp4`.                       |
| `video.video.codec`        | string or `null`. The video codec, such as `h264`.                      |
| `video.video.bitrate`      | number or `null`. The bitrate in bits per second.                       |
| `video.video.size`         | number or `null`. The file size in bytes. It is `null` for a video URL. |
| `video.video.cover`        | string or `null`. A link to the cover image. The link expires.          |
| `video.video.originCover`  | string or `null`. A link to the original cover image. The link expires. |
| `video.video.dynamicCover` | string or `null`. A link to the animated cover. The link expires.       |

**`video.author`**

| Field                     | Type and contents                                                                         |
| ------------------------- | ----------------------------------------------------------------------------------------- |
| `video.author.id`         | string. The account ID.                                                                   |
| `video.author.uniqueId`   | string. The handle, without `@`.                                                          |
| `video.author.nickname`   | string. The display name.                                                                 |
| `video.author.verified`   | boolean or `null`. Whether the account is verified.                                       |
| `video.author.signature`  | string or `null`. The bio.                                                                |
| `video.author.createTime` | string or `null`. The account creation time in Unix seconds. Filled only for a video URL. |
| `video.author.private`    | boolean or `null`. Whether the account is private.                                        |
| `video.author.seller`     | boolean or `null`. Whether the account sells in TikTok Shop. Filled only for a video URL. |
| `video.author.avatar`     | string or `null`. A link to the avatar image. The link expires.                           |
| `video.author.followers`  | number or `null`. The follower count.                                                     |
| `video.author.following`  | number or `null`. The count of accounts that the author follows.                          |
| `video.author.likes`      | number or `null`. The total likes that the account received.                              |
| `video.author.videos`     | number or `null`. The video count of the account.                                         |
| `video.author.likesGiven` | number or `null`. The count of videos that the account liked.                             |

**`video.stats`**

| Field                  | Type and contents                               |
| ---------------------- | ----------------------------------------------- |
| `video.stats.views`    | number. The play count.                         |
| `video.stats.likes`    | number. The like count.                         |
| `video.stats.comments` | number. The comment count.                      |
| `video.stats.shares`   | number. The share count.                        |
| `video.stats.saves`    | number. The count of users who saved the video. |
| `video.stats.reposts`  | number. The repost count.                       |

**`video.music`**

| Field                  | Type and contents                                    |
| ---------------------- | ---------------------------------------------------- |
| `video.music.id`       | string or `null`. The sound ID.                      |
| `video.music.title`    | string or `null`. The sound title.                   |
| `video.music.author`   | string or `null`. The name of the sound author.      |
| `video.music.album`    | string or `null`. The album, when the sound has one. |
| `video.music.duration` | number or `null`. The duration in seconds.           |
| `video.music.playUrl`  | string or `null`. A link to the audio file.          |
| `video.music.cover`    | string or `null`. A link to the sound cover image.   |

- The values in `video.stats` are the values at the time of the run. They change
  over time.
- TikTok rounds large counts, such as `video.author.followers` of `202100`.
- Links to avatars, covers, images, and stickers expire. A comment avatar link
  lasts about one day. A cover link or the avatar link of a video author lasts
  about two days. An image or sticker link of a comment lasts about 30 days.
  Download what you need soon after the run.

#### Which fields are empty for which input

Some fields of the Videos dataset are empty for the videos of a profile. The
Actor still saves the video and sets the field to `null` or an empty list. A
filled field can still be empty for one video, for example when the video has no
captions. The comment fields do not depend on the input.

| Field                                                                                                                | `profileUrls`     | `videoUrls` |
| -------------------------------------------------------------------------------------------------------------------- | ----------------- | ----------- |
| `video.locationCreated`, `video.categories`, `video.isAiGenerated`, `video.author.createTime`, `video.author.seller` | Empty             | Filled      |
| `video.isPinned`                                                                                                     | `true` or `false` | `null`      |
| `video.video.size`                                                                                                   | Filled            | `null`      |

`video.hashtags` and `video.mentions` are filled for both inputs.

#### Error items

An input URL that the Actor cannot read gives one error item in the Errors
dataset. The run goes on with the next URL.

```json
{
  "inputUrl": "https://www.tiktok.com/@nasa/video/7000000000000000001",
  "error": "The video is removed or private.",
  "errorCode": "VIDEO_UNAVAILABLE"
}
```

An error item has three fields:

| Field       | Type and contents                                   |
| ----------- | --------------------------------------------------- |
| `inputUrl`  | string. The entry from your input.                  |
| `error`     | string. A short sentence that says what went wrong. |
| `errorCode` | string. One of the codes below.                     |

| `errorCode`           | Meaning                                                                                                                                    |
| --------------------- | ------------------------------------------------------------------------------------------------------------------------------------------ |
| `NOT_A_VIDEO_URL`     | The entry of `videoUrls` has no `/video/` and video ID, or it is not a TikTok URL.                                                         |
| `NOT_A_PROFILE_URL`   | The entry of `profileUrls` is not a profile URL such as `https://www.tiktok.com/@handle`.                                                  |
| `VIDEO_UNAVAILABLE`   | The video is removed or private.                                                                                                           |
| `PROFILE_UNAVAILABLE` | The profile does not exist or is not available.                                                                                            |
| `COMMENTS_OFF`        | The creator switched the comments off for this video. This is a result, not a failure. The Videos dataset still has the item of the video. |
| `READ_FAILED`         | The video or profile could not be read. Try again later.                                                                                   |

`COMMENTS_OFF` appears for a video in `videoUrls`. A video of a profile with the
comments off gives its Videos dataset item with `commentCount` set to `0`, and no
error item.

### Limits and field notes

#### How many comments can I collect?

`maxCommentsPerVideo` is an upper limit, not a required count. With `0`, the
Actor saves every available comment. Each comment and each reply is its own
item. A video with thousands of comments takes minutes, so set a limit when you
need only a sample. See [How fast is a run?](#how-fast-is-a-run).

A video with no comments is a result, not a failure. It gives a Videos dataset
item with `commentCount` set to `0`, and no error item.

#### Are replies included?

Yes, by default. Each reply is an item in the Dataset, right after its comment.
Its `type` is `reply`, and `repliesToId` holds the `cid` of the comment.
`replies` in the comment item is the reply count that TikTok shows. It can
differ from the number of reply items, because the count can include replies
that are not available. Replies come in TikTok's own order, which is not
strictly by date.

Set `includeReplies` to `false` to save only the comments. A run without replies
is faster.

#### How do I tell comments from replies?

Use `type`. A comment has `type` set to `comment` and `repliesToId` set to
`null`. A reply has `type` set to `reply`, and `repliesToId` holds the `cid` of
its comment. A reply to another reply also has `repliesToReplyId`. In a
spreadsheet, filter on `type`. To build a thread, group the reply items on
`repliesToId`. Each reply follows its comment in the Dataset.

#### Does each comment appear once?

Yes. The Actor keeps each `cid` once in the whole Dataset.

#### Why is `commentCount` lower than `serverTotal`?

Both fields are in the Videos dataset. `serverTotal` is the comment count that
TikTok shows for the video. `commentCount` is the number of comments that the
Actor saved. TikTok can show a higher count than the number of comments and
replies that are available. So `commentCount` can be lower, even when you set no
limit.

In two test runs without a limit and with replies:

| Video                      | `serverTotal` | Comments saved | Replies saved |
| -------------------------- | ------------- | -------------- | ------------- |
| A small video              | 139           | 112            | 9             |
| A video with a long thread | 2,992         | 1,157          | 1,354         |

#### How fast is a run?

A run with replies is slower than a run without them. The time can change from
run to run. In test runs, the small video
took 8 to 14 seconds with replies. The video with a long thread took 52 to 82
seconds with replies. A video with 10,744 reported comments gave 1,500 comments
in 27 to 36 seconds without replies. Set `maxCommentsPerVideo` for a faster run.

A video or a profile that does not exist gives its error item within seconds.

#### Why are some fields empty?

TikTok does not give every detail for every video or comment. Then the field is
`null` or an empty list. See
[Which fields are empty for which input](#which-fields-are-empty-for-which-input). A
comment without text has an empty `text`, and its `images` or `sticker` hold the
content. The `name` in `mentions` is the name as the commenter typed it.

#### What happens when a video fails?

The Actor retries before it gives up. When a video cannot be read in full, the
Actor saves the comments that it has for that video. It writes a warning in the
run log and goes on with the next video. When the replies of a comment cannot be
read, it saves the replies that it has and writes a warning. `commentCount` shows
how many comments it saved. When the video details fail, `video` is `null` and
the comments still follow. A video that cannot be read at all gives an error
item.

If no video and no profile can be read, the run fails with the message "No video
or profile could be read. Check the URLs and try again." The error items stay in
the Errors dataset. A profile with no public videos is not a failure. Invalid input also
fails the run with a message that names the problem.

#### Can a comment disappear after I collect it?

Yes. Viewers and creators can delete comments at any time. Run the Actor again to
get the current comments, and compare the `cid` values.

### Similar Actors

- [TikTok Videos Scraper](https://apify.com/kaix/tiktok-videos-scraper). The
  videos of TikTok profiles, hashtags, and sounds, with their stats.
- [YouTube Scraper](https://apify.com/kaix/youtube-scraper). YouTube videos,
  channels, playlists, comments, captions, and live chat.
- [Reddit Comments Scraper](https://apify.com/kaix/reddit-comments-scraper). A
  Reddit post and every comment on it, from the post URL.
- [Reddit Scraper](https://apify.com/kaix/reddit-scraper). Reddit posts by
  keyword, subreddit, or user, subreddit discovery, and post comments.
- [Google Maps Reviews Scraper](https://apify.com/kaix/google-maps-reviews-scraper).
  Google Maps reviews with place context, from place URLs or Place IDs.
- [Glassdoor Reviews Scraper](https://apify.com/kaix/glassdoor-reviews-scraper).
  Glassdoor company reviews with ratings, pros and cons, and employer responses.

# Actor input Schema

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

List of TikTok video URLs, for example https://www.tiktok.com/@nasa/video/7700397098994273549. The URL must contain /video/ and the video ID, so short links do not work. The comments of each video are collected.

## `profileUrls` (type: `array`):

List of TikTok profile URLs, for example https://www.tiktok.com/@nasa. Every public video of each profile is read, and its comments are collected like for a video URL.

## `videosPerProfile` (type: `integer`):

Maximum number of videos to read per profile. Set to 0 for no limit (every public video). It does not apply to video URLs.

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

Maximum number of comments to collect per video. Set to 0 for no limit (every available comment). Replies do not count in this number.

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

Collect the replies to each comment. When true, each reply is its own item in the Dataset, and repliesToId holds the cid of its comment. When false, only the reply count of each comment is shown.

## `includeVideoInfo` (type: `boolean`):

Add the details of each video (description, hashtags, author, music, stats) to its item in the Videos dataset. When false, the item holds the IDs and the comment counts only.

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

Connection settings. The default works for most runs.

## Actor input object example

```json
{
  "videoUrls": [
    "https://www.tiktok.com/@jomatech/video/7702751743095901471"
  ],
  "profileUrls": [],
  "videosPerProfile": 10,
  "maxCommentsPerVideo": 50,
  "includeReplies": true,
  "includeVideoInfo": true,
  "proxyConfiguration": {
    "useApifyProxy": true
  }
}
```

# Actor output Schema

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

No description

## `videos` (type: `string`):

No description

## `errors` (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 = {
    "videoUrls": [
        "https://www.tiktok.com/@jomatech/video/7702751743095901471"
    ],
    "profileUrls": [],
    "videosPerProfile": 10,
    "maxCommentsPerVideo": 50,
    "proxyConfiguration": {
        "useApifyProxy": true
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("kaix/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/@jomatech/video/7702751743095901471"],
    "profileUrls": [],
    "videosPerProfile": 10,
    "maxCommentsPerVideo": 50,
    "proxyConfiguration": { "useApifyProxy": True },
}

# Run the Actor and wait for it to finish
run = client.actor("kaix/tiktok-comments-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 '{
  "videoUrls": [
    "https://www.tiktok.com/@jomatech/video/7702751743095901471"
  ],
  "profileUrls": [],
  "videosPerProfile": 10,
  "maxCommentsPerVideo": 50,
  "proxyConfiguration": {
    "useApifyProxy": true
  }
}' |
apify call kaix/tiktok-comments-scraper --silent --output-dataset

```

## MCP server setup

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