VodOnDemand.TwitchEverywhere.Rest 0.9.0

dotnet add package VodOnDemand.TwitchEverywhere.Rest --version 0.9.0
                    
NuGet\Install-Package VodOnDemand.TwitchEverywhere.Rest -Version 0.9.0
                    
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="VodOnDemand.TwitchEverywhere.Rest" Version="0.9.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="VodOnDemand.TwitchEverywhere.Rest" Version="0.9.0" />
                    
Directory.Packages.props
<PackageReference Include="VodOnDemand.TwitchEverywhere.Rest" />
                    
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 VodOnDemand.TwitchEverywhere.Rest --version 0.9.0
                    
#r "nuget: VodOnDemand.TwitchEverywhere.Rest, 0.9.0"
                    
#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 VodOnDemand.TwitchEverywhere.Rest@0.9.0
                    
#: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=VodOnDemand.TwitchEverywhere.Rest&version=0.9.0
                    
Install as a Cake Addin
#tool nuget:?package=VodOnDemand.TwitchEverywhere.Rest&version=0.9.0
                    
Install as a Cake Tool

TwitchEverywhere.Rest

TwitchEverywhere.Rest is a .NET library that allows connecting to the Twitch Helix API and making REST calls to it using System.Text.Json.

The goal of this library is to provide a lightweight, strongly typed API for clients so they can avoid parsing raw strings as much as possible.

The library will support the latest LTS version of .NET and non LTS versions IF it is newer than the LTS version. So for example before .NET 8, the library supported .NET 6 (LTS) and 7 but once .NET 8 was released support for 6 and 7 was dropped.

How To Use It

You will need to provide the following values as parameters to the TwitchEverywhere.Core.TwitchConnectionOptions record:

TwitchConnectionOptions options = new(
    Channel: channel,
    AccessToken: accessToken,
    RefreshToken: refreshToken,
    ClientId: clientId,
    ClientSecret: clientSecret,
    ClientName: clientName
);

Then initialize RestClient and pass in the options to the constructor. Finally call the appropriate API:

RestClient restClient = new( options );
GetUsersResponse users = await m_restClient.GetUsersByLogin(
    logins: [ "userLogin" ] 
);

if (users.StatusCode != HttpStatusCode.OK) {
    Console.WriteLine( "Error in GetUsers request with status code: " + users.StatusCode );
    return;
}

And that's it, you have successfully made a call to the Helix API! 🎉

Sample CLI App

There is a sample CLI application here that is included as an example in this repo and you can use it to connect with Twitch – give it a try!

In order to connect you need to create an appsettings.json file in the root of the TwitchEverywhereCLI project with the following parameters:

{
  "AccessToken": "your_twitch_access_token",
  "RefreshToken": "your_twitch_refresh_token",
  "ClientId": "your_client_id",
  "ClientSecret": "your_client_secret",
  "ClientName": "your_client_name_all_lowercase",
  "Channel": "channel_you_want_to_connect_to"
}

Performance

See the README in the TwitchEverywhere.Benchmark project here Note that currently there are no benchmarks for TwitchEverywhere.Rest but they will be added in the future.

Supported Functionality

Twitch Helix API

Users
Endpoint Supported API Link
Get Users https://dev.twitch.tv/docs/api/reference/#get-users
Update User https://dev.twitch.tv/docs/api/reference/#update-user
Get User Block List https://dev.twitch.tv/docs/api/reference/#get-user-block-list
Block User https://dev.twitch.tv/docs/api/reference/#block-user
Videos
Endpoint Supported API Link
Get Videos https://dev.twitch.tv/docs/api/reference/#get-videos
Channels
Endpoint Supported API Link
Get Channel Info https://dev.twitch.tv/docs/api/reference/#get-channel-information
Streams
Endpoint Supported API Link
Get Streams https://dev.twitch.tv/docs/api/reference/#get-streams
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 was computed.  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
0.9.0 239 5/1/2024
0.8.0 222 3/13/2024
0.7.3 179 3/10/2024
0.7.2 204 2/25/2024
0.7.1 177 2/25/2024
0.7.0 185 2/25/2024
0.6.2 184 1/28/2024
0.6.0 181 1/20/2024
0.5.0 181 1/8/2024