# YouTube Live Chat Scraper (`crawlerbros/youtube-live-chat-scraper`) Actor

Scrape public active live chat or replay chat using the correct YouTube continuation endpoint without cookies or API credentials.

- **URL**: https://apify.com/crawlerbros/youtube-live-chat-scraper.md
- **Developed by:** [Crawler Bros](https://apify.com/crawlerbros) (community)
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $1.00 / 1,000 results

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

## YouTube Live Chat Scraper

Scrape public live chat and replay chat from YouTube live streams. `auto` mode detects whether the video is an active stream (`get_live_chat`) or a replay (`get_live_chat_replay`); explicit `active` and `replay` modes are available when the surface is known.

### What this actor does

- **Live and replay chat:** works on active streams and finished streams with replay chat
- **Message metadata:** author, channel, timestamp, message type, and text
- **High volume:** hundreds of messages per stream
- **Bulk videos:** multiple streams per run
- **Empty fields are omitted** — records only contain values that are actually populated.

### Output

Each message row contains `videoId`, `videoUrl`, `messageId`, `messageText`, `messageType`, `authorName`, `authorExternalChannelId`, `authorPhotoUrl`, `authorBadges[]`, `amountText`, `timestampText`, `timestampUsec`, `replayOffsetText`, `chatMode`, and `sourceEndpoint`. Unavailable chats produce a structured status row with the reason.

### Input

| Field | Type | Required | Default | Description |
|-------|------|----------|---------|-------------|
| `videoUrls` | string\[] | No | - | Live stream URLs or video IDs |
| `videoIds` | string\[] | No | - | Raw 11-character video IDs |
| `mode` | string | No | `"auto"` | `auto`, `active`, or `replay` |
| `maxMessages` | integer | No | 1000 | Max chat messages (1-100000) |
| `maxPages` | integer | No | 10 | Max continuation pages (1-1000) |
| `includeMetadata` | boolean | No | true | Include stream metadata in the output |

#### Example input

```json
{
  "videoUrls": ["https://www.youtube.com/watch?v=FQbNtLOVlwU"],
  "mode": "replay",
  "maxMessages": 500
}
```

### Examples

#### Example: one live stream

```json
{
  "videoUrls": ["https://www.youtube.com/watch?v=jfKfPfyJRdk"],
  "maxMessages": 100
}
```

#### Example: multiple streams

```json
{
  "videoUrls": [
    "https://www.youtube.com/watch?v=jfKfPfyJRdk",
    "https://www.youtube.com/watch?v=21X5lGlDOfg"
  ],
  "maxMessages": 50
}
```

### Use cases

- **Sentiment analysis** — analyse live audience reactions in real time or after the stream
- **Moderation research** — study chat patterns and message types
- **Creator analytics** — measure engagement during premieres and streams
- **Event monitoring** — archive chat from live events

### FAQ

**Does it work on finished streams?**

Yes — if the stream has replay chat enabled, the actor can collect the chat history.

**Why are messages missing for some streams?**

Some creators disable live chat or replay chat; a status message explains when the chat is unavailable.

**Do I need cookies?**

No. The actor reads the public chat replay.

**How many messages can I get?**

Set `maxMessages` per video; the actor collects up to that cap.

### YouTube Scraper Suite

This actor is part of a complete YouTube data extraction toolkit. Explore the full suite:

| Actor | Description |
|-------|-------------|
| [YouTube Ads Scraper](https://apify.com/crawlerbros/youtube-ads-scraper) | Google Ads Transparency ads by advertiser, keyword, and country |
| [YouTube Channel Profile Scraper](https://apify.com/crawlerbros/youtube-channel-profile-scraper) | Full channel profiles with About data, playlists, and community posts |
| [YouTube Channel Scraper](https://apify.com/crawlerbros/youtube-channel-scraper) | Channel metadata, subscriber counts, and full video catalogs |
| [YouTube Channel Scraper Fast](https://apify.com/crawlerbros/youtube-channel-scraper-fast) | Streamlined channel scraper for high-volume and speed-sensitive workflows |
| [YouTube Comment Scraper](https://apify.com/crawlerbros/youtube-comment-scraper) | Comments, replies, likes, author info, and pinned/hearted status |
| [YouTube Community Posts Scraper](https://apify.com/crawlerbros/youtube-community-posts-scraper) | Community posts with images, polls, video attachments, and comments |
| [YouTube Email Scraper](https://apify.com/crawlerbros/youtube-email-scraper) | Creator contact emails from channel pages, Instagram, TikTok, and Linktree |
| [YouTube Hashtag Scraper](https://apify.com/crawlerbros/youtube-hashtag-scraper) | Videos and Shorts tagged with specific hashtags |
| [YouTube Playlist Scraper](https://apify.com/crawlerbros/youtube-playlist-scraper) | Videos from playlists plus channel playlist discovery |
| [YouTube Search Scraper](https://apify.com/crawlerbros/youtube-search-scraper) | Search results including videos, channels, and playlists |
| [YouTube Search Suggestions Scraper](https://apify.com/crawlerbros/youtube-search-suggestions-scraper) | Autocomplete keyword suggestions with ready search URLs |
| [YouTube Shorts Scraper](https://apify.com/crawlerbros/youtube-shorts-scraper) | Shorts from channels or hashtags with full view and like metadata |
| [YouTube SponsorBlock Segments Scraper](https://apify.com/crawlerbros/youtube-sponsorblock-scraper) | SponsorBlock segments (sponsor, intro, outro, and more) for any video |
| [YouTube Transcript Scraper](https://apify.com/crawlerbros/youtube-transcript-scraper) | Timed transcripts and captions with optional Whisper AI fallback |
| [YouTube Trending Scraper](https://apify.com/crawlerbros/youtube-trending-scraper) | Ranked trending videos by category — Gaming, Music, News, Movies |
| [YouTube Video Details Scraper](https://apify.com/crawlerbros/youtube-video-details-scraper) | Comprehensive video metadata, chapters, endscreen, captions, and comments |
| [YouTube Video Downloader](https://apify.com/crawlerbros/youtube-video-downloader) | Download videos, playlists, and channels in any quality with metadata |

# Actor input Schema

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

Public YouTube watch URLs. At least one URL or video ID is required; a public replay fixture is used if both are omitted.

## `videoIds` (type: `array`):

Public 11-character YouTube video IDs.

## `mode` (type: `string`):

Select automatic detection, active live chat, or replay chat endpoint behavior.

## `maxMessages` (type: `integer`):

Maximum unique public chat messages across all continuation pages.

## `maxPages` (type: `integer`):

Maximum continuation requests used to bound active/replay chat collection.

## `includeMetadata` (type: `boolean`):

Repeat public video title, channel, and live-content metadata on each message row.

## Actor input object example

```json
{
  "videoUrls": [
    "https://www.youtube.com/watch?v=FQbNtLOVlwU"
  ],
  "mode": "auto",
  "maxMessages": 100,
  "maxPages": 3,
  "includeMetadata": true
}
```

# Actor output Schema

## `messages` (type: `string`):

Dataset containing all scraped live and replay chat message rows.

# 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.youtube.com/watch?v=FQbNtLOVlwU"
    ],
    "maxMessages": 100,
    "maxPages": 3,
    "includeMetadata": true
};

// Run the Actor and wait for it to finish
const run = await client.actor("crawlerbros/youtube-live-chat-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.youtube.com/watch?v=FQbNtLOVlwU"],
    "maxMessages": 100,
    "maxPages": 3,
    "includeMetadata": True,
}

# Run the Actor and wait for it to finish
run = client.actor("crawlerbros/youtube-live-chat-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.youtube.com/watch?v=FQbNtLOVlwU"
  ],
  "maxMessages": 100,
  "maxPages": 3,
  "includeMetadata": true
}' |
apify call crawlerbros/youtube-live-chat-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,crawlerbros/youtube-live-chat-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/dVcUCd4EpRcEJrPMT/builds/4bhWCw3BdLuxdPqK7/openapi.json
