# Douyin Danmaku Scraper (`toolzerhub/douyin-video-danmaku-scraper`) Actor

Collect the scrolling on-video comments (danmaku) Douyin viewers post while watching, from any public Douyin video's URL or ID. Each row returns the danmaku text, its timestamp in the video, like count, and poster's user ID. Most videos carry none -- an empty result is normal, not a failure.

- **URL**: https://apify.com/toolzerhub/douyin-video-danmaku-scraper.md
- **Developed by:** [ToolzerHub](https://apify.com/toolzerhub) (community)
- **Categories:** Social media, Automation, For creators
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $1.60 / 1,000 results

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.
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?

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

## Douyin Danmaku Scraper

Collect the scrolling on-video comments (danmaku) Douyin viewers post while watching, timestamped to the moment they appear, from a public video's URL or ID.

### Input

| Field | Type | Default | What it does |
|---|---|---|---|
| `aweme_id` | string | — | **Required.** A Douyin video URL or numeric ID. |
| `duration` | integer | — | Video length in milliseconds. Leave it empty and the Actor looks it up for you — one extra request. |
| `start_time` | integer | `0` | Start of the danmaku window, in milliseconds. |
| `end_time` | integer | — | End of the danmaku window, in milliseconds. Defaults to the video's full duration. |
| `maxItems` | integer | `100` | Rows to save. `0` collects the whole window. |

```json
{ "aweme_id": "https://www.douyin.com/video/7448118827402972455" }
```

### Output

| Field | Contents |
|---|---|
| `danmaku_id` | Danmaku comment ID |
| `text` | Danmaku text |
| `offset_time` | Position in the video this danmaku appears at, milliseconds |
| `digg_count` | Likes on this danmaku |
| `user_id` | Poster's account ID |
| `source_aweme_id` | The video this row was collected from |

### Questions

**Why did my run return zero rows?**
Most Douyin videos carry no danmaku at all — an ordinary video tested live returned nothing across its entire duration. A zero-row dataset here is a normal, successful run, not a fault. Danmaku shows up mainly on videos with a large, actively engaged audience: a video with about 1.4 million likes returned 743 danmaku in the same test, 594 of them in the first ~32-second window alone. Try a video with high engagement before assuming the Actor is broken.

**Why does the run make an extra request before it collects any danmaku?**
Douyin's danmaku endpoint requires the video's `duration` in milliseconds, but a normal caller rarely has that number to hand. When you don't supply `duration`, the Actor fetches it from the video's own detail first — one extra request, billed the same as any other. Pass `duration` yourself, for example from a prior [Douyin Video Scraper](https://apify.com/toolzerhub/douyin-video-scraper) run, to skip it.

**How wide is one danmaku "window", and why does that matter for `start_time`/`end_time`?**
Douyin serves a fixed roughly-32-second slice per call no matter how wide an `end_time` you request, so the Actor loops windows internally to cover `start_time` through `end_time` (or the full video, when `end_time` is left empty). You don't need to manage the windowing yourself — just set the range you want covered.

### Related Actors

| Actor | Use when |
|---|---|
| [Douyin Comments Scraper](https://apify.com/toolzerhub/douyin-comments-scraper) | You want the actual comment section, a different thing from danmaku |
| [Douyin Video Scraper](https://apify.com/toolzerhub/douyin-video-scraper) | You want the video's `duration` up front, to skip this Actor's extra lookup |
| [Douyin Video Downloader](https://apify.com/toolzerhub/douyin-video-downloader) | You want a playable URL for the video itself |

### Support

Questions, bugs, or feature requests: **contact@toolzerhub.com**

Browse the rest: [apify.com/toolzerhub](https://apify.com/toolzerhub)

# Actor input Schema

## `aweme_id` (type: `string`):

Paste the video's Douyin link (douyin.com/video/...), or just the number at the end of it.

## `duration` (type: `integer`):

The video's length in milliseconds. Leave empty and this Actor reads it from the video itself before collecting.

## `start_time` (type: `integer`):

Where in the video to start collecting on-screen comments from, in milliseconds. Leave at 0 to start from the beginning.

## `end_time` (type: `integer`):

Where in the video to stop collecting on-screen comments, in milliseconds. Leave empty to go to the end.

## `maxItems` (type: `integer`):

Maximum rows to save. Set 0 to keep collecting until the source is exhausted.

## Actor input object example

```json
{
  "aweme_id": "https://www.douyin.com/video/7448118827402972455",
  "start_time": 0,
  "maxItems": 20
}
```

# Actor output Schema

## `dataset` (type: `string`):

Every record collected during 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 = {
    "aweme_id": "https://www.douyin.com/video/7448118827402972455",
    "maxItems": 20
};

// Run the Actor and wait for it to finish
const run = await client.actor("toolzerhub/douyin-video-danmaku-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 = {
    "aweme_id": "https://www.douyin.com/video/7448118827402972455",
    "maxItems": 20,
}

# Run the Actor and wait for it to finish
run = client.actor("toolzerhub/douyin-video-danmaku-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 '{
  "aweme_id": "https://www.douyin.com/video/7448118827402972455",
  "maxItems": 20
}' |
apify call toolzerhub/douyin-video-danmaku-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,toolzerhub/douyin-video-danmaku-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/i2KTZHmq0AjXSkHLm/builds/gWkkAABaw1aoqRgBg/openapi.json
