MiniTwitch.Helix 0.4.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.4.0-prerelease                
NuGet\Install-Package MiniTwitch.Helix -Version 0.4.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.4.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.4.0-prerelease                
#r "nuget: MiniTwitch.Helix, 0.4.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.4.0-prerelease&prerelease

// Install MiniTwitch.Helix as a Cake Tool
#tool nuget:?package=MiniTwitch.Helix&version=0.4.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()

[!IMPORTANT]
You may notice that some requests have missing parameters. This is because the user ID is supplied by the library to requests that require the user ID of the provided token

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", 987654321);

        var chatters = await GetAllChatters(12345678);
    }

    private static async Task<List<string>> GetAllChatters(long broadcasterId)
    {
        List<string> usernames = [];
        HelixResult<Chatters> chatters = await Helix.GetChatters(broadcasterId, first: 1000);

        if (!chatters.Success)
        {
            return [];
        }

        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
        while (await chatters.Paginate() is { Success: 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 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. 
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.4.2-prerelease 33 8/5/2024
0.4.1-prerelease 136 7/12/2024
0.4.0-prerelease 37 7/11/2024
0.3.1-prerelease 116 4/26/2024
0.3.0-prerelease 61 4/24/2024
0.2.3-prerelease 81 1/27/2024
0.2.2-prerelease 99 1/10/2024
0.2.1-prerelease 148 11/14/2023
0.2.0-prerelease 75 11/6/2023
0.1.0-prerelease 74 11/1/2023

This changelog is available at: https://github.com/Foretack/MiniTwitch/blob/master/MiniTwitch.Helix/CHANGELOG.md

# MiniTwitch.Helix Changelog

## 0.4.0-prerelease

### Breaking changes
- `SortedHelixWrapper` has been removed (#110)

### Minor Changes
- Changing the token of `HelixWrapper` is now possible through `HelixWrapper.Client.ChangeToken()` (#110)
- Added `Warn Chat User` endpoint (#111)
- Error messages are now provided from Helix responses rather than scraped data (#115)

### Fixes
- Fixed an exception that occurs when empty strings are provided to SnakeCase.ConvertToCase
- Fixed an exception that occurs when calling `GetChatSettings()` on a channel that does not have any special modes enabled
- The HttpResponseMessage from making calls with HttpClient now gets disposed (#118)

****

## 0.3.0-prerelease

### Minor changes
- Added `Get User Emotes` endpoint (#83)
- Added Conduit endpoints (#87)
- Added `Get Unban Requests` endpoint (#91)
- Added `Resolve Unban Requests` endpoint (#93)

### Fixes
- Fixed NullReferenceException when attempting to validate certain token types

### Development changes
- Updated naming policy used for (de)serialization

****

## 0.2.3-prerelease

### Minor changes

- Added "Send Chat Message" endpoint

****

## 0.2.2-prerelease

### Minor changes

- Added "Get Moderated Channels" endpoint
- Added a semaphore lock to token validation to ensure consistency

### Fixes

- [Updated "Get Ad Schedule" response](https://dev.twitch.tv/docs/change-log/#:~:text=2023%E2%80%9112%E2%80%9111)