# TikTok Live Comments & Events Scraper — Unlimited (`ben-belaouedj/tiktok-live-comments`) Actor

Capture every real-time event from any TikTok LIVE: comments, gifts, likes, joins, follows, shares, subscriptions, Q\&A, polls, host & co-host tracking — zero message limits, truly unlimited. Cookies required for full access. Set duration to 0 for non-stop capture.

- **URL**: https://apify.com/ben-belaouedj/tiktok-live-comments.md
- **Developed by:** [Ben Belaouedj](https://apify.com/ben-belaouedj) (community)
- **Categories:** Social media, Developer tools, Automation
- **Stats:** 9 total users, 3 monthly users, 60.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

Pay per usage

This Actor is paid per platform usage. The Actor is free to use, and you only pay for the Apify platform usage, which gets cheaper the higher subscription plan you have.

Learn more: https://docs.apify.com/platform/actors/running/actors-in-store#pay-per-usage

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
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.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — 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 Live Comments — Unlimited Events Scraper

Capture every real-time event from any TikTok live stream with zero message limits. Comments, gifts, likes, joins, follows, shares, subscriptions, Q\&A, polls, pinned messages, LinkMic battles, and live viewer stats — all streamed instantly into your Dataset as they happen.

### What it does

- Connects directly to an active TikTok live stream via WebSocket.
- Captures every event in real time: comments, gifts, likes, joins, follows, shares, subscriptions, Q\&A questions, polls, pinned messages, and LinkMic battles.
- Polls the LinkMic API every 15 seconds to detect and track active hosts and co-hosts.
- Enriches each event with full user metadata: user ID, unique ID, sec UID, nickname, avatar URL, follower/following counts, subscriber badge, moderator flag, gifter level, and pay grade.
- Runs until the stream ends or your configured duration limit is reached — no caps, no pagination, no sampling.

### Input

| Field | Type | Required | Description |
|---|---|---|---|
| `username` | string | Yes | TikTok creator username without `@` |
| `cookies` | array | No | TikTok session cookies exported as JSON (strongly recommended) |
| `max_duration_seconds` | integer | No | Maximum capture duration in seconds. `0` = unlimited (default: `0`) |
| `poll_interval_seconds` | integer | No | LinkMic host polling interval in seconds (default: `15`) |

#### Example input

```json
{
  "username": "cristiano",
  "max_duration_seconds": 0,
  "poll_interval_seconds": 15
}
```

### Output

Each record in the Dataset represents one event from the live stream.

#### Common fields

| Field | Description |
|---|---|
| `event_type` | Type of event: `comment`, `gift`, `like`, `join`, `follow`, `share`, `subscribe`, `question`, `poll`, `pin`, `battle`, `viewer_count`, `host` |
| `timestamp` | ISO 8601 timestamp of the event |
| `username` | Streamer username |
| `user_id` | Event sender user ID |
| `unique_id` | Event sender unique ID (handle) |
| `nickname` | Event sender display name |
| `text` | Comment or question text (when applicable) |
| `gift_name` | Gift name (for `gift` events) |
| `diamond_count` | Gift diamond value (for `gift` events) |
| `viewer_count` | Current viewer count (for `viewer_count` events) |

### How to use cookies

1. Log in to TikTok in Chrome or Firefox.
2. Install the **Cookie-Editor** browser extension.
3. On tiktok.com, open Cookie-Editor and click **Export → JSON**.
4. Paste the JSON array into the `cookies` input field.

Cookies are strongly recommended to avoid rate limits, access HD streams, and unlock full user metadata.

### Notes

- Set `max_duration_seconds` to `0` for truly unlimited capture — the Actor stops when the stream ends naturally.
- If the creator is not yet live, the Actor waits and retries automatically.
- All events are pushed to the Apify Dataset in real time.

### Categories

Automation · Developer tools · Social media

# Actor input Schema

## `username` (type: `string`):

The TikTok creator's username whose live stream you want to scrape (without the @ prefix). Example: cristiano

## `cookies` (type: `array`):

Your TikTok session cookies exported as a JSON array from your browser. Required to avoid rate-limits, access private/restricted streams, and unlock full user metadata.

How to get your cookies:

1. Log in to TikTok in Chrome or Firefox
2. Install the 'Cookie-Editor' browser extension
3. On tiktok.com, open Cookie-Editor and click Export → JSON
4. Copy the full JSON array and paste it here

The cookies are stored locally and never shared. Key cookies: sessionid, sid\_tt, odin\_tt, ttwid.

## `sign_api_key` (type: `string`):

Optional API key to sign TikTok WebSocket requests. Leave empty to use the default built-in key.

## `max_duration_seconds` (type: `integer`):

Stop collecting events after this many seconds. Set to 0 to run until the live stream ends naturally — truly unlimited.

## `fetch_country` (type: `boolean`):

Resolve the country of each commenter via an external lookup. Adds latency per event. Disable for maximum speed.

## `collect_comments` (type: `boolean`):

Capture all live chat messages including @mention reply threads and input type metadata.

## `collect_gifts` (type: `boolean`):

Capture gifts sent during the stream: gift name, diamond value, repeat/streak count, and recipient.

## `collect_joins` (type: `boolean`):

Capture events when viewers enter the live room, including their member count rank.

## `collect_likes` (type: `boolean`):

Capture like events with per-event count and running total.

## `collect_follows` (type: `boolean`):

Capture follow events triggered during the live stream.

## `collect_shares` (type: `boolean`):

Capture share events when viewers share the stream.

## `collect_subscriptions` (type: `boolean`):

Capture subscription events including subscription month and status.

## `collect_questions` (type: `boolean`):

Capture questions submitted through the live Q\&A feature.

## `collect_battles` (type: `boolean`):

Capture LinkMic battle events between the streamer and co-hosts.

## `collect_polls` (type: `boolean`):

Capture poll creation and result events.

## `collect_pins` (type: `boolean`):

Capture pinned message events in the live room.

## `collect_viewers` (type: `boolean`):

Capture real-time viewer count, total user count, and popularity score updates.

## `collect_hosts` (type: `boolean`):

Poll the TikTok LinkMic API every 15 seconds to detect who is currently host or co-host on the stream. Each new host/co-host detected is emitted as a 'host' event with role (host/co-host), user\_id, unique\_id, and nickname.

## Actor input object example

```json
{
  "max_duration_seconds": 0,
  "fetch_country": false,
  "collect_comments": true,
  "collect_gifts": true,
  "collect_joins": true,
  "collect_likes": true,
  "collect_follows": true,
  "collect_shares": true,
  "collect_subscriptions": true,
  "collect_questions": true,
  "collect_battles": true,
  "collect_polls": true,
  "collect_pins": true,
  "collect_viewers": true,
  "collect_hosts": true
}
```

# 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 = {};

// Run the Actor and wait for it to finish
const run = await client.actor("ben-belaouedj/tiktok-live-comments").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 = {}

# Run the Actor and wait for it to finish
run = client.actor("ben-belaouedj/tiktok-live-comments").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 '{}' |
apify call ben-belaouedj/tiktok-live-comments --silent --output-dataset

```

## MCP server setup

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

```

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/PI35z4s4Rq4Im7A8d/builds/t3dGc0ePEBmfzogeM/openapi.json
