MiniTwitch.Helix 0.1.0-prerelease

This is a prerelease version of MiniTwitch.Helix.
There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package MiniTwitch.Helix --version 0.1.0-prerelease
NuGet\Install-Package MiniTwitch.Helix -Version 0.1.0-prerelease
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.Helix" Version="0.1.0-prerelease" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add MiniTwitch.Helix --version 0.1.0-prerelease
#r "nuget: MiniTwitch.Helix, 0.1.0-prerelease"
#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.
// Install MiniTwitch.Helix as a Cake Addin
#addin nuget:?package=MiniTwitch.Helix&version=0.1.0-prerelease&prerelease

// Install MiniTwitch.Helix as a Cake Tool
#tool nuget:?package=MiniTwitch.Helix&version=0.1.0-prerelease&prerelease

MiniTwitch.Helix (Pre-release)

MiniTwitch.Helix conveniently wraps the Twitch Helix API and exposes them through the HelixWrapper and SortedHelixWrapper classes. The difference between the two classes is that HelixWrapper exposes all endpoints as methods directly on the class, while SortedHelixWrapper exposes them through categories (i.e HelixWrapper.BanUser() vs SortedHelixWrapper.Moderation.BanUser())

Features

  • Contains all generally available and beta Helix API endpoints

  • Virtually no dependencies

  • Returns meaningful information about responses with HelixResult:

    • HelixResult.Success: Whether the request was successful
    • HelixResult.StatusCode: Status code of the response
    • HelixResult.Message: Contains a message clarifying the meaning of the status code
    • HelixResult.Elapsed: The amount of time the request took to get a response
    • HelixResult.RateLimit.Limit: Maximum amount of requests that can be made in a period
    • HelixResult.RateLimit.Remaining: The amount of requests that can be made before the ratelimit resets
    • HelixResult.RateLimit.ResetsIn: The amount of time before the ratelimit resets
  • Validates access tokens & warns before their expiry

  • Easy pagination API for HelixResult<T>:

    • HelixResult.CanPaginate: Determines whether the next page of content can be requested
    • HelixResult.Paginate(): Fetches the next page of content

Getting Started

This example demonstrates the usage of HelixWrapper and HelixResult<T>.Paginate()

using MiniTwitch.Helix;
using MiniTwitch.Helix.Models;
using MiniTwitch.Helix.Responses;

namespace MiniTwitchExample;

public class Program
{
    public static HelixWrapper Helix { get; set; }

    static async Task Main()
    {
        Helix = new HelixWrapper("Access token", "Client ID");

        await GetFirst1000Usernames(12345678, 12345678);
        await GetAllUsernames(12345678, 12345678);
    }

    private static async Task<IReadOnlyList<string>> GetFirst1000Usernames(long broadcasterId, long moderatorId)
    {
        List<string> usernames = new();
        HelixResult<Chatters> chatters = await Helix.GetChatters(broadcasterId, moderatorId, first: 1000);

        // Make sure the result is a success and the value contains data
        if (!chatters.Success || !chatters.Value.HasContent) return Array.Empty<string>();

        foreach (var chatter in chatters.Value.Data)
        {
            usernames.Add(chatter.Username);
        }

        return usernames;
    }

    private static async Task<IReadOnlyList<string>> GetAllUsernames(long broadcasterId, long moderatorId)
    {
        List<string> usernames = new();
        HelixResult<Chatters> chatters = await Helix.GetChatters(broadcasterId, moderatorId, first: 1000);
        
        if (!chatters.Success || !chatters.Value.HasContent) return Array.Empty<string>();

        foreach (var chatter in chatters.Value.Data)
        {
            usernames.Add(chatter.Username);
        }

        // No more users - return what we got
        if (!chatters.CanPaginate) return usernames;

        // Continue paginating if the result is a success and there is content
        while (await chatters.Paginate() is { Success: true, Value.HasContent: true } next)
        {
            foreach (var chatter in next.Value.Data)
            {
                usernames.Add(chatter.Username);
            }

            // Return when pagination is no longer possible
            if (!next.CanPaginate) return usernames;

            chatters = next;
        }

        return usernames;
    }
}
Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  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 is compatible.  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. 
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
0.3.1-prerelease 106 4/26/2024
0.3.0-prerelease 55 4/24/2024
0.2.3-prerelease 76 1/27/2024
0.2.2-prerelease 93 1/10/2024
0.2.1-prerelease 137 11/14/2023
0.2.0-prerelease 67 11/6/2023
0.1.0-prerelease 68 11/1/2023