
Product
Introducing Socket Firewall Enterprise: Flexible, Configurable Protection for Modern Package Ecosystems
Socket Firewall Enterprise is now available with flexible deployment, configurable policies, and expanded language support.
yt-chat-signaler
Advanced tools
A client for connecting to the YouTube Live Chat signaler service to receive real-time events.
A Node.js client for connecting to the YouTube Live Chat signaler service to receive real-time events.
It is designed to be the backbone for bots, chat archives, or any application that needs to listen to YouTube live chat messages programmatically.
npm install yt-chat-signaler
Here's a simple example of how to connect to a YouTube live chat and listen for events.
import { YtChatSignaler } from "yt-chat-signaler";
// The video ID of the YouTube live stream.
const videoId = 'YOUR_YOUTUBE_LIVE_VIDEO_ID';
const client = new YtChatSignaler({
chats: [videoId],
});
client.on('connected', (chatData) => {
console.log(`Successfully connected to chat for video: ${chatData.chatId}`);
});
client.on('data', ({ data, chatData }) => {
console.log(`Received data from ${chatData.chatId}:`, JSON.stringify(data));
// This is where you would parse the 'data' payload to extract chat messages.
});
client.on('connectionError', (error) => {
console.error('An error occurred:', error);
});
client.on('reconnecting', ({ attempts, waitTime }) => {
console.log(`Attempting to reconnect... (Attempt #${attempts}, waiting ${waitTime}ms)`);
});
// Start the client
client.start();
// To stop listening to a specific chat
// client.stop(videoId);
You can pass an options object to the Client constructor to customize its behavior.
new Client(options)
| Option | Type | Default | Description |
|---|---|---|---|
chats | string[] | [] | Required. An array of YouTube video IDs for the live chats you want to join. |
apiKey | string | (Internal YouTube Key) | A custom YouTube API key. |
userAgent | string | (Chrome on Linux User-Agent) | A custom User-Agent string for HTTP requests. |
maxReconnectAttempts | number | 5 | Maximum number of reconnection attempts. Set to 0 or a negative number for infinite retries. |
initialReconnectDelayMs | number | 1000 | The initial time in milliseconds to wait before the first reconnection attempt. |
maxReconnectWaitMs | number | 30000 | The maximum time in milliseconds to wait between reconnection attempts. Caps the exponential backoff. |
The client is an EventEmitter and will emit various events to notify you about the connection status.
connected: (chatData: Chat)
chatData contains session information.data: (payload: { data: any, chatData: Chat, ... })
data property contains the raw event payload from YouTube, which you can parse to get chat messages, new members, etc.reconnecting: (payload: { attempts: number, waitTime: number })
connectionError: (error: Error)
part: (chatData: Chat)
client.stop() is called.ping: (payload: { tms: any, chatData: Chat })
gsessoinId: (gsessionid: string)
gsessionid from YouTube's servers.sid: (sidData: ConnectRPCData)
SID).refreshCreds: (payload: { gsessionid: string, key: string, chatData: Chat })
Directly using this package in a browser (e.g., in a React or Vue application) will not work due to CORS (Cross-Origin Resource Sharing) restrictions on YouTube's servers. These APIs are not designed for public, client-side access.
The correct way to use this package for a web application is to run it in a server-side proxy.
yt-chat-signaler and connects to YouTube.This architecture is more secure and is the standard way to work with such APIs.
FAQs
A client for connecting to the YouTube Live Chat signaler service to receive real-time events.
The npm package yt-chat-signaler receives a total of 5 weekly downloads. As such, yt-chat-signaler popularity was classified as not popular.
We found that yt-chat-signaler demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Socket Firewall Enterprise is now available with flexible deployment, configurable policies, and expanded language support.

Security News
Open source dashboard CNAPulse tracks CVE Numbering Authorities’ publishing activity, highlighting trends and transparency across the CVE ecosystem.

Product
Detect malware, unsafe data flows, and license issues in GitHub Actions with Socket’s new workflow scanning support.