# Douyin Live Scraper (`toolzerhub/douyin-live-scraper`) Actor

Check whether a Douyin account is broadcasting from its numeric user ID, and fetch a live room's title, host, viewer count, stream URLs, and cover from a room ID, webcast ID, or Douyin profile URL. Also collect the room's top gifters or the products pinned for sale in it.

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

## Pricing

from $2.40 / 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 Live Scraper

Check whether a Douyin account is broadcasting right now, then pull the room's title, host, viewer count, stream URLs, and cover once it is. Also collect a live room's top gifters, or the products pinned for sale in it. This is a live-room Actor, not a shop or product-catalogue scraper — it reads what is happening inside a broadcast, not a seller's storefront. Pick a mode with `scraperType`.

### Modes

| `scraperType` | Returns | Needs |
|---|---|---|
| `liveStatus` (default) | Whether the account is broadcasting, and the room id if it is | `uid` |
| `liveRoom` | Room title, host, viewer count, stream URLs, cover | `room_id`, `webcast_id`, or `sec_user_id` |
| `liveGiftRanking` | Top gifters in a live room, ranked | `room_id` or `webcast_id` |
| `liveProducts` | Products pinned for sale in a live room | `room_id` + `author_id`, or `webcast_id` |

### Input

| Field | Use it for |
|---|---|
| **`uid`** | The account's numeric user ID. Required for `liveStatus`. |
| **`sec_user_id`** | A profile URL or sec\_user\_id. One of three ways into `liveRoom`. |
| **`room_id`** | A live room's numeric ID. Used by `liveRoom`, `liveGiftRanking`, `liveProducts`. |
| **`webcast_id`** | The `web_rid` from a live room's URL. Resolves to a room id and host id internally, so it alone is enough for `liveGiftRanking` and `liveProducts`. |
| **`author_id`** | The host's numeric uid. Needed alongside `room_id` for `liveProducts` — skip both and pass `webcast_id` instead. |
| **`maxItems`** | Caps `liveGiftRanking` and `liveProducts`. Default `100`. Set `0` for no limit. |

```json
{
  "scraperType": "liveStatus",
  "uid": "2557909361237356"
}
```

### Output

| Field | Mode | Contents |
|---|---|---|
| **`uid`**, **`live_status`**, **`user_live`** | `liveStatus` | Whether the account is live, and the raw live-status entry |
| **`id_str`**, **`status`**, **`title`**, **`owner`**, **`stream_url`**, **`cover`**, **`stats`**, **`user_count_str`**, **`start_time`**, **`share_url`** | `liveRoom` | Room detail and stream addresses |
| **`rank`**, **`score`**, **`user`** | `liveGiftRanking` | One gifter and their rank on the leaderboard |
| **`source_room_id`**, **`source_author_id`** | `liveProducts` | The room and host this row was requested for |
| **`source_room_id`**, **`source_webcast_id`**, **`source_sec_user_id`** | Matching mode | What this row was collected from |

```json
{
  "uid": "2557909361237356",
  "live_status": 0,
  "user_live": []
}
```

### Questions

**What happens if I check an account that isn't currently broadcasting?**
`liveStatus` still returns one row — `live_status: 0` and an empty `user_live` array. That's a normal, successful run, not an error. `liveRoom` behaves differently on an offline account depending on which ID you use: through `sec_user_id` it can fall back to echoing the plain profile instead of a room, so treat a `liveRoom` result without `stream_url` as "not currently live" rather than a broken lookup.

**Does `liveProducts` actually return products?**
Treat it as unproven. Every real room tested while building this Actor — an education livestream, a phone brand's own room, a factory livestream, and a major e-commerce anchor — came back either with a request error or a `null` payload carrying an upstream "not logged in" or risk-control message. The endpoint is real and wired up, but nothing has confirmed it returning actual product rows end to end. Try it, but don't build a pipeline that assumes it works.

**Why can't I choose which gift ranking to view?**
Only the source's own default ranking works. Every other value tested against a live room came back as an error on the same room, so that control isn't exposed as input — `liveGiftRanking` always returns the source's default leaderboard.

**Why does `liveGiftRanking` stop well short of `maxItems`?**
It isn't paginated. The source returns one fixed snapshot list per request, which this Actor slices to `maxItems` rather than paging further — raising the limit past what one snapshot holds won't pull more rows.

### Related Actors

| Actor | Purpose |
|---|---|
| [Douyin Profile Scraper](https://apify.com/toolzerhub/douyin-profile-scraper) | Resolve a handle or URL to the `uid` or `sec_user_id` this Actor needs |
| [Douyin Account Analytics Scraper](https://apify.com/toolzerhub/douyin-account-analytics-scraper) | Follower growth and audience demographics once you know an account is active |

### Support

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

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

# Actor input Schema

## `scraperType` (type: `string`):

Choose the dataset for this run.

## `uid` (type: `string`):

A profile's numeric ID. There's no page on Douyin that shows this directly — copy it from another run of this Actor's output, or use the profile link field above instead.

## `room_id` (type: `string`):

The room's internal numeric ID, only needed if you already have it from another run. For a room that's currently live, use the live room link field above instead.

## `webcast_id` (type: `string`):

Paste the live room's link (live.douyin.com/...) while it's on air, or just the ID at the end of it.

## `sec_user_id` (type: `string`):

Paste the profile's Douyin page link (douyin.com/user/...), or just the sec\_user\_id part of it.

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

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

## `author_id` (type: `string`):

The live room host's numeric user ID. Prefer looking the room up by its host's profile link where that option is offered.

## Actor input object example

```json
{
  "scraperType": "liveStatus",
  "uid": "2557909361237356",
  "sec_user_id": "https://www.douyin.com/user/MS4wLjABAAAAY3J1P0y5w7hzttTyvZiLjhMu3iOzF-1yFi6yNtXVHzkmVGFIx7T8s-nRmGNusfh1",
  "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 = {
    "uid": "2557909361237356",
    "room_id": "",
    "webcast_id": "",
    "sec_user_id": "https://www.douyin.com/user/MS4wLjABAAAAY3J1P0y5w7hzttTyvZiLjhMu3iOzF-1yFi6yNtXVHzkmVGFIx7T8s-nRmGNusfh1",
    "maxItems": 20,
    "author_id": ""
};

// Run the Actor and wait for it to finish
const run = await client.actor("toolzerhub/douyin-live-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 = {
    "uid": "2557909361237356",
    "room_id": "",
    "webcast_id": "",
    "sec_user_id": "https://www.douyin.com/user/MS4wLjABAAAAY3J1P0y5w7hzttTyvZiLjhMu3iOzF-1yFi6yNtXVHzkmVGFIx7T8s-nRmGNusfh1",
    "maxItems": 20,
    "author_id": "",
}

# Run the Actor and wait for it to finish
run = client.actor("toolzerhub/douyin-live-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 '{
  "uid": "2557909361237356",
  "room_id": "",
  "webcast_id": "",
  "sec_user_id": "https://www.douyin.com/user/MS4wLjABAAAAY3J1P0y5w7hzttTyvZiLjhMu3iOzF-1yFi6yNtXVHzkmVGFIx7T8s-nRmGNusfh1",
  "maxItems": 20,
  "author_id": ""
}' |
apify call toolzerhub/douyin-live-scraper --silent --output-dataset

```

## MCP server setup

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