Agash.YTLiveChat.DependencyInjection
4.2.0-dev1
See the version list below for details.
dotnet add package Agash.YTLiveChat.DependencyInjection --version 4.2.0-dev1
NuGet\Install-Package Agash.YTLiveChat.DependencyInjection -Version 4.2.0-dev1
<PackageReference Include="Agash.YTLiveChat.DependencyInjection" Version="4.2.0-dev1" />
<PackageVersion Include="Agash.YTLiveChat.DependencyInjection" Version="4.2.0-dev1" />
<PackageReference Include="Agash.YTLiveChat.DependencyInjection" />
paket add Agash.YTLiveChat.DependencyInjection --version 4.2.0-dev1
#r "nuget: Agash.YTLiveChat.DependencyInjection, 4.2.0-dev1"
#:package Agash.YTLiveChat.DependencyInjection@4.2.0-dev1
#addin nuget:?package=Agash.YTLiveChat.DependencyInjection&version=4.2.0-dev1&prerelease
#tool nuget:?package=Agash.YTLiveChat.DependencyInjection&version=4.2.0-dev1&prerelease
YTLiveChat
Unofficial .NET library for reading YouTube live chat via InnerTube (the same web-facing surface YouTube uses), without Data API quotas or OAuth setup.
Targets
net10.0netstandard2.1netstandard2.0
Install
Core package:
dotnet add package Agash.YTLiveChat
With DI helpers:
dotnet add package Agash.YTLiveChat.DependencyInjection
What You Get
Chat messages
- Chat messages (
ChatReceived) — text, emoji, images - Super Chats / Super Stickers with parsed amount + currency
- Membership events — new join, milestone, gift purchase, gift redemption (
MembershipDetails.EventType) - Ticker support (
addLiveChatTickerItemAction) — paid messages, membership items, gift purchase announcements; ticker items include author channel ID, author thumbnail, andAuthor.ChannelHandle(the@handle) when available - Viewer leaderboard rank extraction via
ChatItem.ViewerLeaderboardRank(YouTube points crown tags like#1)
Moderation & lifecycle
- Message deleted (
ChatItemDeleted) — single item removed - Author banned/cleared (
ChatItemsDeletedByAuthor) — all messages from a channel removed - Message replaced (
ChatItemReplaced) — slow-mode or placeholder resolution
Polls
PollUpdated— fires when a new poll opens (Poll.IsNew == true) and on every vote-count update (IsNew == false); carries structured choices and vote ratiosPollClosed— fires when the poll panel is dismissed; usePollIdto correlate with the precedingPollUpdatedevents- After
PollClosed,EngagementMessageReceivedfires withMessageType == PollResultcarrying the final text summary that appears in chat (not required for poll lifecycle tracking)
Banners
BannerAdded— fires with aBannerItemsubclass; pattern-match to distinguish:PinnedMessageBannerItem— pinned chat message; carriesAuthor,Message,PinnedBy,Timestamp, and role flags (IsOwner,IsModerator,IsVerified)CrossChannelRedirectBannerItem— redirect to another stream; carriesRedirectChannelHandle(the@handle) andRedirectVideoId(null when no specific video is provided, e.g. Squad streaming join notifications)
BannerRemoved— banner dismissed;TargetActionIdmatches the precedingBannerAdded'sActionId
System / engagement messages
EngagementMessageReceived— YouTube-generated notices in the chat feed:CommunityGuidelines— welcome/guidelines reminder at stream startSubscribersOnly— subscribers-only mode noticePollResult— formatted poll result summary (see Polls above)
Raw access
RawActionReceived— every InnerTube action including unsupported ones- Async streaming APIs (
StreamChatItemsAsync,StreamRawActionsAsync)
Important Caveats
- This is an unofficial parser over YouTube’s internal schema. Payloads can change at any time.
- This library reads chat only (no sending messages).
- Respect request frequency to avoid rate limits or temporary blocks.
Beta API Notice
Continuous livestream monitor mode is currently BETA/UNSUPPORTED and can change or break at any time:
YTLiveChatOptions.EnableContinuousLivestreamMonitorYTLiveChatOptions.LiveCheckFrequencyIYTLiveChat.LivestreamStartedIYTLiveChat.LivestreamEndedIYTLiveChat.LivestreamInaccessible
These members intentionally emit compiler warnings via [Obsolete] to signal unstable API status.
Monitor note: channel/watch page resolution is fetched via stateless (no-cookie) requests inside the library to reduce consent-interstitial loops during long-running monitor sessions.
Quick Start (DI)
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using YTLiveChat.Contracts;
using YTLiveChat.Contracts.Services;
using YTLiveChat.DependencyInjection;
HostApplicationBuilder builder = Host.CreateApplicationBuilder(args);
builder.Services.AddYTLiveChat(builder.Configuration);
builder.Services.Configure<YTLiveChatOptions>(options =>
{
options.RequestFrequency = 1000;
options.DebugLogReceivedJsonItems = true;
options.DebugLogFilePath = "logs/ytlivechat_debug.json";
});
builder.Services.AddHostedService<ChatWorker>();
await builder.Build().RunAsync();
Worker example:
using YTLiveChat.Contracts.Models;
using YTLiveChat.Contracts.Services;
public sealed class ChatWorker(IYTLiveChat chat) : IHostedService
{
public Task StartAsync(CancellationToken ct)
{
chat.InitialPageLoaded += (_, e) => Console.WriteLine($"Loaded: {e.LiveId}");
chat.ChatReceived += (_, e) => HandleChat(e.ChatItem);
chat.RawActionReceived += (_, e) =>
{
if (e.ParsedChatItem is null)
{
// Unsupported action still available here
Console.WriteLine("RAW action received.");
}
};
chat.ChatStopped += (_, e) => Console.WriteLine($"Stopped: {e.Reason}");
chat.ErrorOccurred += (_, e) => Console.WriteLine($"Error: {e.GetException().Message}");
chat.Start(handle: "@channelHandle");
return Task.CompletedTask;
}
public Task StopAsync(CancellationToken ct)
{
chat.Stop();
return Task.CompletedTask;
}
private static void HandleChat(ChatItem item)
{
// inspect item.Superchat, item.MembershipDetails, item.ViewerLeaderboardRank, item.IsTicker
// for ticker events: item.Author.ChannelId, item.Author.Thumbnail, item.Author.ChannelHandle
}
}
Async Streaming APIs
await foreach (ChatItem item in chat.StreamChatItemsAsync(handle: "@channel", cancellationToken: ct))
{
Console.WriteLine($"{item.Author.Name}: {string.Join("", item.Message.Select(ToText))}");
}
await foreach (RawActionReceivedEventArgs raw in chat.StreamRawActionsAsync(liveId: "videoId", cancellationToken: ct))
{
if (raw.ParsedChatItem is null)
{
Console.WriteLine(raw.RawAction.ToString());
}
}
static string ToText(MessagePart part) => part switch
{
TextPart t => t.Text,
EmojiPart e => e.EmojiText ?? e.Alt ?? "",
_ => ""
};
Raw JSON Capture for Schema Analysis
Enable:
options.DebugLogReceivedJsonItems = true;
options.DebugLogFilePath = "logs/ytlivechat_debug.json";
The file is written as a valid JSON array, so it is directly parseable by tools/scripts.
Example App
YTLiveChat.Example includes:
- UTF-8 console setup for multilingual output
- colorized one-line TUI rendering
- rank/ticker/membership/superchat tagging
- unsupported raw action hints
- optional raw JSON capture prompt
- optional continuous monitor mode prompt (beta)
Current Schema Coverage Gaps
- Creator goals are not mapped yet (awaiting enough stable raw samples).
- Membership tier upgrades are not mapped yet (observed in the wild but shape is not confirmed).
Contributing
Bug reports and raw payload samples are highly valuable.
If you add parser support for new payloads, include:
- response model updates in
YTLiveChat/Models/Response/LiveChatResponse.cs - parser updates in
YTLiveChat/Helpers/Parser.cs - tests + fixtures in
YTLiveChat.Tests
Acknowledgements
- WolfwithSword — testing and feedback
License
MIT. See LICENSE.txt.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 is compatible. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Agash.YTLiveChat (>= 4.2.0-dev1)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.3)
- Microsoft.Extensions.Hosting.Abstractions (>= 10.0.3)
- Microsoft.Extensions.Http (>= 10.0.3)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.3)
- Microsoft.Extensions.Options (>= 10.0.3)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 10.0.3)
-
.NETStandard 2.1
- Agash.YTLiveChat (>= 4.2.0-dev1)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.3)
- Microsoft.Extensions.Hosting.Abstractions (>= 10.0.3)
- Microsoft.Extensions.Http (>= 10.0.3)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.3)
- Microsoft.Extensions.Options (>= 10.0.3)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 10.0.3)
-
net10.0
- Agash.YTLiveChat (>= 4.2.0-dev1)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.3)
- Microsoft.Extensions.Hosting.Abstractions (>= 10.0.3)
- Microsoft.Extensions.Http (>= 10.0.3)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.3)
- Microsoft.Extensions.Options (>= 10.0.3)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 10.0.3)
-
net9.0
- Agash.YTLiveChat (>= 4.2.0-dev1)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.3)
- Microsoft.Extensions.Hosting.Abstractions (>= 10.0.3)
- Microsoft.Extensions.Http (>= 10.0.3)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.3)
- Microsoft.Extensions.Options (>= 10.0.3)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 10.0.3)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 4.2.0-dev3 | 287 | 4/17/2026 |
| 4.2.0-dev2 | 100 | 4/15/2026 |
| 4.2.0-dev1 | 132 | 4/14/2026 |
| 4.1.0 | 188 | 4/6/2026 |
| 4.1.0-dev3 | 281 | 3/27/2026 |
| 4.1.0-dev2 | 116 | 3/27/2026 |
| 4.1.0-dev1 | 115 | 2/22/2026 |
| 4.0.0 | 172 | 2/16/2026 |
| 3.0.2 | 351 | 5/9/2025 |