BlushyFace.Twitch.API documentation

BlushyFace.Twitch.API documentation

BlushyFaceBlushyFace Member, Administrator, Moderator, Contributor, Developer Posts: 32
edited December 2019 in BlushyFace.Twitch #1

Summary
BlushyFace.Twitch is a C# library based on https://dev.twitch.tv/docs/ that aims to provide various functions that helps making tools that uses the Twitch API and / or chat easier.

Note: this is a rewrite of the larger BlushyFace library but split into smaller ones such as BlushyFace.Twitch and not every endpoint is be available as of writing this post but I'm adding them when I have time, if you have a request what you want to have me add specifically let me know.

Examples of various community projects that uses BlushyFace.Twitch
Various community projects can be found here to show what can be made: http://support.configurationerror.com/categories/examples

Namespaces
BlushyFace.Twitch - under this falls various Twitch related functions.

BlushyFace.Twitch.API - functions for various endpoints.
BlushyFace.Twitch.API.Auth - provides authentication functions such as creating / refreshing / revoking an access token with user defined scopes.
BlushyFace.Twitch.API.Kraken - functions for Kraken (v5) endpoints.
BlushyFace.Twitch.API.Helix - functions for Helix endpoints.
BlushyFace.Twitch.API.Undocumented - functions for undocumented endpoints.
BlushyFace.Twitch.API.Helpers - various helper / utility functions.
BlushyFace.Twitch.Chat - provides support for Twitch chat
BlushyFace.Twitch.Chat.Helpers - various misc helper functions such as parsing chat / cheer emotes

Comments

  • BlushyFaceBlushyFace Member, Administrator, Moderator, Contributor, Developer Posts: 32
    edited December 2019 #2

    How to use BlushyFace.Twitch.API
    Include BlushyFace.Twitch as reference in your c# project and follow the below examples (not complete).
    For each endpoints you can supply (optional) parameters such as limit results to 10 etc, this is done by adding a key/pair value in Parameter. To check available parameters you can hover the methods to see what it accepts.

    There are also various settings you can change such as:
    Settings.RequireValidTokenScopesCheck (bool, default true) when true it validates the scopes from the token with the required scope(s) that are required to use said endpoints.

    Auth
    To generate a token you need to set up your own (local) server for the redirect URL or alternatively follow the OAuth2 flow manually to get the code and then generate the token. A self hosted Twitch API tester example that does this can be found here: support.configurationerror.com/discussion/27/example-self-hosted-twitch-api-tester#latest

    Generate token

    var token = new BlushyFace.Twitch.API.Auth.Auth().GenerateToken(...);
    

    Validate token

    var token = new BlushyFace.Twitch.API.Auth.Auth().ValidateToken(...);
    

    Refresh token

    var token = new BlushyFace.Twitch.API.Auth.Auth().RefreshToken(...);
    

    Revoke token

    new BlushyFace.Twitch.API.Auth.Auth().RevokeToken(...);
    

    Helix

    Get user id by user name

    BlushyFace.Twitch.API.Helix.Users.GetUserIdByName("blushyface");
    

    Get bits leaderboard

    var parameters= new List();
    BlushyFace.Twitch.API.Helix.Bits.Leaderboard(parameters);
    

    Get latest 50 channel following

    var parameters= new List();
    parameters.Add(new Parameter("from_id", "...")
    parameters.Add(new Parameter("maxresults", "50")
    var following = BlushyFace.Twitch.API.Helix.Users.GetFollows(parameters);
    

    Get all channel followers

    var parameters = new List();
    parameters.Add(new Parameter("to_id", "...")
    var followers = BlushyFace.Twitch.API.Helix.Users.GetFollows(parameters);
    

    Check if user follows channel

    var parameters = new List();
    parameters.Add(new Parameter("from_id", "...")
    parameters.Add(new Parameter("to_id", "...")
    var followers = BlushyFace.Twitch.API.Helix.Users.GetFollows(parameters);
    

    Get all game info

    var topGames = BlushyFace.Twitch.API.Helix.Games.GetTopGames(parameters);
    

    Get top 15 games info

    parameters.Add(new Parameter("maxresults", "15"));
    var topGames = BlushyFace.Twitch.API.Helix.Games.GetTopGames(parameters);
    

    Get specific game info

    parameters.Add(new Parameter("name", "StarCraft II"));
    var games = BlushyFace.Twitch.API.Helix.Games.GetGames(parameters);
    

    Get top 150 viewed live channels
    Note: this call can take several minutes to complete depending on whether you want the complete list of live channels.

    parameters.Add(new Parameter("maxresults", "150"));
    var streams = BlushyFace.Twitch.API.Helix.Streams.GetStreams(parameters);
    

    Kraken

  • BlushyFaceBlushyFace Member, Administrator, Moderator, Contributor, Developer Posts: 32
    edited December 2019 #3

    Added a bunch of Kraken API calls to BlushyFace.Twitch.API.Kraken not 100% complete so if you require a call that is not added yet let me know.

    To know more about each specific call you can hover the method name.

    Channels endpoint

               var channel = new BlushyFace.Twitch.API.Kraken.Channels().GetChannel();
               var channels = new BlushyFace.Twitch.API.Kraken.Channels().GetChannelById(channelId);
               var channelEditors = new BlushyFace.Twitch.API.Kraken.Channels().GetChannelEditors(channelId);
               var channelFollows = new BlushyFace.Twitch.API.Kraken.Channels().GetChannelFollows(channelId);
               var channelTeams = new BlushyFace.Twitch.API.Kraken.Channels().GetChannelTeams(channelId);
               var channelSubscribers = new BlushyFace.Twitch.API.Kraken.Channels().GetChannelSubscriptions(channelId);
               var channelSubscriber = new BlushyFace.Twitch.API.Kraken.Channels().GetChannelSubscriptionByUser(channelId, channelId2);
               var channelVideos = new BlushyFace.Twitch.API.Kraken.Channels().GetChannelVideos(channelId);
    
               parameters.Add(new Parameter("game", "overwatch"));
               new BlushyFace.Twitch.API.Kraken.Channels().UpdateChannel(channelId, parameters);
               parameters.Clear();
    
               parameters.Add(new Parameter("length", "30"));
               new BlushyFace.Twitch.API.Kraken.Channels().StartCommercial(channelId);
               parameters.Clear();
    

    Chat endpoint

               var chatBadges = new BlushyFace.Twitch.API.Kraken.Chat().GetChatBadgesByChannel(channelId);
    
               parameters.Add(new Parameter("emotesets", "19151"));
               var chatEmoticons = new BlushyFace.Twitch.API.Kraken.Chat().GetChannelEmoteSets(parameters);
               parameters.Clear();
    

    User endpoint

               var follow = new BlushyFace.Twitch.API.Kraken.User().FollowChannel(channelId, channelId2);
               var unfollow = new BlushyFace.Twitch.API.Kraken.User().UnfollowChannel(channelId, channelId2);
    

    Ingest endpoint

    var ingestServers = new BlushyFace.Twitch.API.Kraken.Ingests().GetIngestServers();
    

    Games endpoint

    var gamesTop = new BlushyFace.Twitch.API.Kraken.Games().GetTopGames();
    
Sign In or Register to comment.