MiniTwitch.PubSub 2.1.1

There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package MiniTwitch.PubSub --version 2.1.1
                    
NuGet\Install-Package MiniTwitch.PubSub -Version 2.1.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="MiniTwitch.PubSub" Version="2.1.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="MiniTwitch.PubSub" Version="2.1.1" />
                    
Directory.Packages.props
<PackageReference Include="MiniTwitch.PubSub" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add MiniTwitch.PubSub --version 2.1.1
                    
#r "nuget: MiniTwitch.PubSub, 2.1.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package MiniTwitch.PubSub@2.1.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=MiniTwitch.PubSub&version=2.1.1
                    
Install as a Cake Addin
#tool nuget:?package=MiniTwitch.PubSub&version=2.1.1
                    
Install as a Cake Tool

MiniTwitch.PubSub

MiniTwitch.PubSub is the component responsible for interaction with the Twitch PubSub service. The usage of this package revolves around the PubSubClient class and the Topics static class.

Features

  • Package code is fully documented with XML comments
  • Exposes documented & undocumented PubSub topics
  • Uses System.Text.Json under the hood; Fast, efficient and without unnecessary dependencies
  • Exposes events with Func<T1, .., ValueTask> delegates, making asynchronous handling very easy
  • Automatically reconnects upon disconnection & automatically re-listens to topics
  • Simplistic; Events have clear descriptions on what they do and how to get them invoked
  • Multi-token support; You're not limited to 1 auth token per PubSubClient
  • Comes with a built-in logger, which can be disabled or replaced easily
  • Events return the topic parameters as ChannelId or UserId, making them easily distinguishable

Getting Started

here is an example usage of the PubSubClient class:

using MiniTwitch.PubSub;
using MiniTwitch.PubSub.Interfaces;
using MiniTwitch.PubSub.Models;
using MiniTwitch.PubSub.Payloads;

namespace MiniTwitchExample;

public class Program
{
    static async Task Main()
    {
        PubSubClient client = new("my token");

        await client.ConnectAsync();
        var playbackResponse = await client.ListenTo(Topics.VideoPlayback(36175310));
        if (playbackResponse.IsSuccess)
            Console.WriteLine($"Listened to {playbackResponse.TopicKey} successfully!");

        var responses =  await client.ListenTo(Topics.Following(783267696) | Topics.ChatroomsUser(754250938, "a different token"));
        foreach (var response in responses)
        {
            if (!response.IsSuccess)
                Console.WriteLine($"Failed to listen to {response.TopicKey}! Error: {response.Error}");
        }

        client.OnStreamUp += OnStreamUp;
        client.OnFollow += OnFollow;
        client.OnTimedOut += OnTimedOut;

        _ = Console.ReadLine();
    }

    private static ValueTask OnStreamUp(ChannelId channelId, IStreamUp stream)
    {
        Console.WriteLine($"Channel ID {channelId} just went live! (Stream delay: {stream.PlayDelay})");
        return ValueTask.CompletedTask;
    }

    private static ValueTask OnFollow(ChannelId channelId, Follower follower)
    {
        Console.WriteLine($"{follower.Name} just followed you!");
        return ValueTask.CompletedTask;
    }

    private static ValueTask OnTimedOut(UserId userId, ITimeOutData timeout)
    {
        Console.WriteLine(
            $"Your other account (ID: {userId}) has been timed out for {timeout.ExpiresInMs}ms in channel ID {timeout.ChannelId}");
        return ValueTask.CompletedTask;
    }
}

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  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 was computed.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
2.1.2-ts.1756287314 30 8/27/2025
2.1.2-ts.1754153336 24 8/2/2025
2.1.2-ts.1754152294 22 8/2/2025
2.1.1 199 6/16/2025
2.1.1-ts.1752555669 118 7/15/2025
2.1.1-ts.1750917467 120 6/26/2025
2.1.1-ts.1750693592 127 6/23/2025
2.1.1-ts.1750676392 120 6/23/2025
2.1.0 362 1/31/2025
2.0.0 350 11/19/2024
1.0.4 269 8/10/2024
1.0.3 386 1/10/2024
1.0.2 236 11/14/2023
1.0.1 161 10/12/2023
1.0.0 180 9/23/2023