# Tiktok Comment Scraper (`sociavault/tiktok-comment-scraper`) Actor

Scrape comments from TikTok videos with automatic pagination support. Extract user comments, engagement metrics, and interaction data.

- **URL**: https://apify.com/sociavault/tiktok-comment-scraper.md
- **Developed by:** [SociaVault](https://apify.com/sociavault) (community)
- **Categories:** Social media, Videos, Developer tools
- **Stats:** 17 total users, 3 monthly users, 100.0% runs succeeded, 1 bookmarks
- **User rating**: No ratings yet

## Pricing

$1.50 / 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 Comment Scraper

Scrape comments from TikTok videos using the SociaVault API. This actor retrieves detailed comment information including comment text, user details, likes, replies, and timestamps with automatic pagination support.

### Features

- **Multiple Videos**: Scrape comments from multiple TikTok videos in one run
- **Automatic Pagination**: Automatically fetches multiple pages to get the exact number of comments you specify
- **Detailed Comment Data**: Returns comprehensive information for each comment
- **Rate Limiting**: Built-in delays to prevent API rate limiting
- **Error Handling**: Graceful error handling with detailed logging

### Input Parameters

| Parameter | Type | Required | Default | Description |
|-----------|------|----------|---------|-------------|
| `videoIds` | Array | Yes | - | List of TikTok video IDs |
| `maxCommentsPerVideo` | Integer | No | 20 | Number of comments to retrieve per video |

#### Example Input

```json
{
  "videoIds": ["7488736374602927402", "7123456789012345678"],
  "maxCommentsPerVideo": 100
}
```

**Note**: If you specify `maxCommentsPerVideo: 100` with 2 video IDs, the scraper will fetch 100 comments for EACH video (200 total comments).

### Output

For each video, the actor returns:

| Field | Type | Description |
|-------|------|-------------|
| `success` | Boolean | Whether the request was successful |
| `videoId` | String | The TikTok video ID that was scraped |
| `totalComments` | Number | Total number of comments the video has |
| `commentCount` | Number | Number of comments retrieved (up to maxCommentsPerVideo) |
| `comments` | Array | Array of comment objects |

#### Comment Object

Each comment in the `comments` array contains:

- `aweme_id`: Video ID the comment belongs to
- `text`: Comment text content
- `user`: User object with profile information
  - `unique_id`: TikTok username
  - `nickname`: Display name
  - `uid`: Unique user ID
  - `sec_uid`: Secondary unique ID
  - `avatar_thumb`: Profile picture URLs
- `create_time`: Unix timestamp of when comment was created
- `digg_count`: Number of likes on the comment
- `reply_comment_total`: Number of replies to this comment
- `comment_language`: Language of the comment (e.g., "en")

#### Example Output

```json
{
  "success": true,
  "videoId": "7488736374602927402",
  "totalComments": 925,
  "commentCount": 100,
  "comments": [
    {
      "aweme_id": "7488736374602927402",
      "text": "This is awesome!",
      "user": {
        "unique_id": "cooluser123",
        "nickname": "Cool User",
        "uid": "7151557610473800750",
        "sec_uid": "MS4wLjABAAAA...",
        "avatar_thumb": { ... }
      },
      "create_time": 1743795517,
      "digg_count": 784,
      "reply_comment_total": 3,
      "comment_language": "en"
    }
  ]
}
```

### Performance

- **Sequential Processing**: Videos are processed one at a time (not in parallel) due to pagination requirements
- **Pagination Delays**: 500ms delay between pagination requests
- **Video Delays**: 1 second delay between different videos
- **Rate Limiting**: Automatic delays prevent API rate limiting

### Limitations

- Maximum comments per request is determined by `maxCommentsPerVideo` parameter
- Comments are returned in chronological order (newest first typically)
- Nested replies are not included (only top-level comments)
- Some videos may have comments disabled

### Use Cases

- **Sentiment Analysis**: Analyze comment sentiment for brand monitoring
- **Engagement Metrics**: Track comment patterns and user engagement
- **Content Research**: Understand audience reactions to content
- **Trend Analysis**: Identify trending topics in comments
- **Influencer Analysis**: Study comment engagement for influencer evaluation
- **Community Management**: Monitor and analyze community feedback

### Error Handling

The actor includes comprehensive error handling:

- Invalid API key → Error with clear message
- No video IDs provided → Error with instructions
- API request failures → Logged and continued with other videos
- Empty results → Logged with explanation

Failed videos return an error object in the dataset:

```json
{
  "success": false,
  "videoId": "invalidvideoid",
  "error": "Error message"
}
```

***

**Built with ❤️ by [SociaVault](https://sociavault.com)**

# Actor input Schema

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

List of TikTok video URLs to scrape comments from (e.g., https://www.tiktok.com/@username/video/1234567890)

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

Number of comments to retrieve per video (automatically paginates to get exact count)

## Actor input object example

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

# 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/@stoolpresidente/video/7251387037834595630"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("sociavault/tiktok-comment-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/@stoolpresidente/video/7251387037834595630"] }

# Run the Actor and wait for it to finish
run = client.actor("sociavault/tiktok-comment-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/@stoolpresidente/video/7251387037834595630"
  ]
}' |
apify call sociavault/tiktok-comment-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,sociavault/tiktok-comment-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/edJV3LRdNK4JRvnq3/builds/5oZtrDvzuAqTcx0QA/openapi.json
