### Install KickLib via Package Managers Source: https://github.com/bukk94/kicklib/blob/master/KickLib.Api.Unofficial/README_UnofficialAPI.md Instructions on how to install the KickLib NuGet package using either the NuGet Package Manager Console or the .NET Command Line Interface (CLI). ```PM PM> Install-Package KickLib ``` ```.NET dotnet add package KickLib ``` -------------------------------- ### Install KickLib via NuGet Package Manager Console Source: https://github.com/bukk94/kicklib/blob/master/README.md This command installs the KickLib package into a .NET project using the NuGet Package Manager Console. It adds the necessary library references to the project, making KickLib functionalities available for use. ```PowerShell PM> Install-Package KickLib ``` -------------------------------- ### Install KickLib via .NET Command-Line Interface Source: https://github.com/bukk94/kicklib/blob/master/README.md This command installs the KickLib package into a .NET project using the .NET Command-Line Interface. It serves as an alternative to the NuGet Package Manager Console for adding package references to your project. ```.NET CLI dotnet add package KickLib ``` -------------------------------- ### Perform Authenticated API Calls with 2FA in C# Source: https://github.com/bukk94/kicklib/blob/master/KickLib.Api.Unofficial/README_UnofficialAPI.md This C# example demonstrates how to authenticate with the unofficial Kick API using a username, password, and a pre-obtained 2FA authorization code. After successful authentication, it shows how to send a message to a specified chat ID. This process requires prior 2FA setup on the Kick platform. ```csharp IUnofficialKickApi kickApi = new KickUnofficialApi(); var authSettings = new AuthenticationSettings("username", "password") { TwoFactorAuthCode = "A123BCDEFGIJFKLM" }; await kickApi.AuthenticateAsync(authSettings); await kickApi.Messages.SendMessageAsync(123456, "My message"); ``` -------------------------------- ### Initialize KickApi with Custom IApiCaller in C# Source: https://github.com/bukk94/kicklib/blob/master/KickLib.Api.Unofficial/README_UnofficialAPI.md This C# example shows how to integrate a custom `IApiCaller` implementation into the `KickApi` instance. By passing an object of `MyOwnDownloader` to the `KickUnofficialApi` constructor, the library will use the custom logic for all subsequent API calls. ```csharp var myDownloader = new MyOwnDownloader(); IUnofficialKickApi kickApi = new KickUnofficialApi(myDownloader); ``` -------------------------------- ### Listen to Kick Chat Messages with Unofficial KickClient (C#) Source: https://github.com/bukk94/kicklib/blob/master/README.md This C# example illustrates how to use the unofficial `KickClient` to connect to a Kick chatroom and receive real-time messages. It demonstrates instantiating `IKickClient`, subscribing to the `OnMessage` event to process incoming chat messages, and initiating the connection and listening process for a specified chatroom ID. It notes that this uses an undocumented API and may be subject to change. ```csharp IKickClient client = new KickClient(); var chatroomId = 123456; // This ID can be obtained by using IUnofficialKickApi or by manually extracting from web netwowk tab. client.OnMessage += delegate(object sender, ChatMessageEventArgs e) { Console.WriteLine($"Received message: {e.Data.Content}"); }; await client.ListenToChatRoomAsync(chatroomId); await client.ConnectAsync(); // TODO: Make sure this is in endless loop and program won't exit immediately // otherwise you won't be able to receive messages. ``` -------------------------------- ### Retrieve Kick API Information Source: https://github.com/bukk94/kicklib/blob/master/KickLib.Api.Unofficial/README_UnofficialAPI.md Example showcasing how to use the IUnofficialKickApi interface to fetch various types of information from the Kick API, including user details, channel information, livestream status, and channel clips. ```C# IUnofficialKickApi kickApi = new KickUnofficialApi(); var userName = "channelUsername"; // Get information about user var user = await kickApi.Users.GetUserAsync(userName); // Get information about channel var channelInfo = await kickApi.Channels.GetChannelInfoAsync(userName); // Gets detailed information about current livestream var liveInfo = await kickApi.Livestream.GetLivestreamInfoAsync(userName); // Get clips var channelClips = await kickApi.Clips.GetClipsAsync(); ``` -------------------------------- ### Send Chat Message to Kick Channel (C#) Source: https://github.com/bukk94/kicklib/blob/master/README.md This example illustrates how to send a chat message to a specified Kick channel as a user. It involves configuring API settings with refresh token, client ID, and client secret, then retrieving channel information to get the broadcaster ID before sending the message. ```csharp var settings = new ApiSettings { RefreshToken = "ZZZZZZZZZZZZZZZZ", ClientId = "XXXXXX", ClientSecret = "YYYYYYYYYYYYYY" }; var api = KickApi.Create(settings); var channelInfo = await api.Channels.GetChannelAsync("foo"); var broadcasterId = channelInfo.Value.BroadcasterUserId; await api.Chat.SendMessageAsUserAsync(broadcasterId, "Hello World"); ``` -------------------------------- ### Register KickLib with Puppeteer Client in .NET DI Source: https://github.com/bukk94/kicklib/blob/master/Breaking Changes - Migration Guide.md This C# code snippet illustrates how to register KickLib with a specific client implementation (PuppeteerClient) using the .NET dependency injection container. It demonstrates the fluent API for configuring KickLib services. ```C# serviceCollection .AddKickLib() .WithPuppeteerClient(); ``` -------------------------------- ### Refresh Kick API Access Token (C#) Source: https://github.com/bukk94/kicklib/blob/master/README.md This example illustrates how to refresh an expired access token using a long-lived refresh token. It's essential for maintaining continuous authenticated access to the Kick API without requiring the user to re-authenticate. New access and refresh tokens are returned upon successful refresh. ```csharp var clientId = "01AAAAA0EXAMPLE66YG2HD9R"; var clientSecret = "aaac0000EXAMPLE8ebe4dc223d0c45187"; var refreshToken = "NAAAAAAY5YZQ00REFRESHTOKEN000ZZTFHM2I1NJLK"; var authGenerator = new KickOAuthGenerator(); var exchangeResults = await authGenerator.RefreshAccessTokenAsync( refreshToken, clientId, clientSecret); // After every successful refresh, you will receive new access and refresh tokens if (exchangeResults.IsSuccess) { Console.WriteLine($"Access Token: {exchangeResults.Value.AccessToken}"); Console.WriteLine($"Refresh Token: {exchangeResults.Value.RefreshToken}"); } ``` -------------------------------- ### Configure KickLib with Dependency Injection Source: https://github.com/bukk94/kicklib/blob/master/KickLib.Api.Unofficial/README_UnofficialAPI.md Demonstrates how to integrate KickLib into an application using Dependency Injection. The .AddUnofficialKickLib() extension method registers services with a Scoped lifetime, and .WithPuppeteerClient() is used to configure a client. ```C# serviceCollection .AddKickLib() .WithPuppeteerClient(); ``` -------------------------------- ### Listen to Real-time Kick Chat Messages Source: https://github.com/bukk94/kicklib/blob/master/KickLib.Api.Unofficial/README_UnofficialAPI.md Demonstrates how to use IKickClient to connect to a Kick chatroom and listen for real-time messages. The OnMessage event handler processes incoming chat messages. ```C# IKickClient client = new KickClient(); client.OnMessage += delegate(object sender, ChatMessageEventArgs e) { Console.WriteLine(e.Data.Content); }; await client.ListenToChatRoomAsync(123456); await client.ConnectAsync(); ``` -------------------------------- ### Configure KickLib for Automatic Access Token Refresh (C#) Source: https://github.com/bukk94/kicklib/blob/master/README.md This C# code snippet demonstrates how to initialize `ApiSettings` in KickLib with a refresh token, client ID, and client secret to enable automatic access token refreshing. It also shows how to subscribe to `RefreshTokenChanged` and `AccessTokenChanged` events to handle token updates, emphasizing the need to store the new refresh token for continued use. ```csharp var settings = new ApiSettings { RefreshToken = "XXXXXXXXXXXXXXXX", ClientId = "YYYYYYYYYYYYYYYY", ClientSecret = "ZZZZZZZZZZZZZZZZ" }; settings.RefreshTokenChanged += (sender, args) => { Console.WriteLine($"Refresh token changed! New value: {args.NewToken}"); }; settings.AccessTokenChanged += (sender, args) => { Console.WriteLine($"Access token changed! New value: {args.NewToken}"); }; var api = KickApi.Create(settings); // TODO: use `api` for calling endpoints ``` -------------------------------- ### KickLib Client and API Feature Reference Source: https://github.com/bukk94/kicklib/blob/master/README.md This comprehensive reference outlines the functionalities provided by KickLib, categorized into real-time client event processing (chatroom and channel events) and various API interactions for managing categories, clips, channels, emotes, livestreams, messages, users, and videos on the Kick.com platform. ```APIDOC Client: Reading Chatroom events: New message received Message deleted User banned / unbanned New subscriptions Subscriptions gifts Stream host changes New pinned message Pinned message deleted Reading Channel events: Followers status updated Stream state detection Gifts leaderboards updated API: Categories: Get all main (root) categories Get specific main category Get top categories Get sub-categories (paged) Get all sub-categories (list all) Get specific sub-category Get subcategory clips (paged) Clips: Get all Kick clips Get clip information Download clip Channels: Get messages Get channel information Get channel chatroom information Get channel chatroom rules Get channel polls Get channel clips Get channel links Get channel videos Get channel latest video Get channel leaderboards Get latest subscriber (Requires Authentication) Get followers count Emotes: Get channel emotes Livestreams: Is streamer live? Get livestream information Message: Send message to chatroom (Requires Authentication) Users: Get user information Videos: Get video ``` -------------------------------- ### Implement Custom IApiCaller Interface in C# Source: https://github.com/bukk94/kicklib/blob/master/KickLib.Api.Unofficial/README_UnofficialAPI.md This C# snippet illustrates the basic structure for implementing a custom downloader client. By inheriting from the `IApiCaller` interface, developers can provide their own logic for handling API requests and responses, overriding the default client behavior. ```csharp public class MyOwnDownloader : IApiCaller { // Implementation } ``` -------------------------------- ### KickLib Unofficial API Features Overview Source: https://github.com/bukk94/kicklib/blob/master/KickLib.Api.Unofficial/README_UnofficialAPI.md A comprehensive list of features provided by the KickLib library, categorized into Client-side functionalities for real-time event handling and API-side functionalities for data retrieval and interaction with various Kick endpoints. ```APIDOC Client: - Reading Chatroom events - New message received - Message deleted - User banned / unbanned - New subscriptions - Subscriptions gifts - Stream host changes - New pinned message - Pinned message deleted - Reading Channel events - Followers status updated - Stream state detection - Gifts leaderboards updated API: - Categories - Get all main (root) categories - Get specific main category - Get top categories - Get sub-categories (paged) - Get all sub-categories (list all) - Get specific sub-category - Get subcategory clips (paged) - Clips - Get all Kick clips - Get clip information - Download clip - Channels - Get messages - Get channel information - Get channel chatroom information - Get channel chatroom rules - Get channel polls - Get channel clips - Get channel links - Get channel videos - Get channel latest video - Get channel leaderboards - Get latest subscriber (Requires Authentication) - Get followers count - Emotes - Get channel emotes - Livestreams - Is streamer live? - Get livestream information - Message - Send message to chatroom (Requires Authentication) - Users - Get user information - Videos - Get video ``` -------------------------------- ### Register KickLib Services using Dependency Injection Source: https://github.com/bukk94/kicklib/blob/master/README.md This C# extension method facilitates the easy registration of all KickLib-related services into a .NET application's Dependency Injection container. Services are configured with a Scoped lifetime, simplifying their management and usage throughout the application. ```C# .AddKickLib() ``` -------------------------------- ### Generate OAuth Authorization URL and Exchange Code for Tokens (C#) Source: https://github.com/bukk94/kicklib/blob/master/README.md This snippet demonstrates the initial steps of the OAuth 2.1 flow using KickLib. It shows how to generate an authorization URI for user consent and subsequently exchange the received authorization code for access and refresh tokens. Proper handling of client ID, client secret, and callback URL is crucial. ```csharp var callbackUrl = "https://localhost:5001/auth/kick/callback"; var clientId = "01AAAAA0EXAMPLE66YG2HD9R"; var clientSecret = "aaac0000EXAMPLE8ebe4dc223d0c45187"; var authGenerator = new KickOAuthGenerator(); var url = authGenerator.GetAuthorizationUri( callbackUrl, clientId, new List { KickScopes.UserRead, KickScopes.ChannelWrite }, out var verifier); // TODO: Perform URL redirect for the user and pass OAuth process // By using callback URL, you will receive code and state, which can be used for Token exchange. var code = "NAAAAAAY5YZQ00STATE000ZZTFHM2I1NJLK"; var state = "ZXhhbXBsZSB2YWx1ZQ=="; var exchangeResults = await authGenerator.ExchangeCodeForTokenAsync( code, clientId, clientSecret, callbackUrl, state); if (exchangeResults.IsSuccess) { Console.WriteLine($"Access Token: {exchangeResults.Value.AccessToken}"); Console.WriteLine($"Refresh Token: {exchangeResults.Value.RefreshToken}"); // TODO: Store access and refresh token for further use // Keep in mind: Access token is short lived, while refresh token is long lived (and should be stored) } ``` -------------------------------- ### Subscribe to Kick Webhook Events (C#) Source: https://github.com/bukk94/kicklib/blob/master/README.md This snippet demonstrates how to subscribe to various Kick events, such as chat messages or channel follows, via webhooks. It highlights the necessity of a public webhook URL and the 'EventsSubscribe' scope for the access token. Successful subscriptions will deliver event payloads to the configured webhook URL. ```csharp var api = KickApi.Create(new ApiSettings { AccessToken = "XXXXXXXXXX" }); // Subscript to events (webhooks) for chat messages and channel follow events var result = await api.EventSubscriptions.SubscribeToEventsAsync( new List { EventType.ChatMessageSent, EventType.ChannelFollowed }); // Each event will be assigned own SubscriptionId // Events will be delivered to your **public** webhook URL (set up in [Kick settings](https://kick.com/settings/developer)). ``` -------------------------------- ### Retrieve Kick Category Details by ID (C#) Source: https://github.com/bukk94/kicklib/blob/master/README.md This snippet demonstrates how to fetch specific category details from the Kick API using its unique identifier. It shows the instantiation of the KickApi client and making an authenticated call to retrieve category information. ```csharp var api = KickApi.Create(); var accessToken = "XXXXXXXXXX"; // Get specific category by ID var category = await api.Categories.GetCategoryAsync(28, accessToken); ``` -------------------------------- ### Paginate Data with KickLib Cursor Source: https://github.com/bukk94/kicklib/blob/master/KickLib.Api.Unofficial/README_UnofficialAPI.md Illustrates how to retrieve historical messages from a Kick channel's chat using the Cursor property for pagination. This pattern allows fetching data in chunks until all available pages are processed. ```C# IUnofficialKickApi kickApi = new KickUnofficialApi(); var channelInfo = await kickApi.Channels.GetChannelInfoAsync("channelUsername"); var channelId = channelInfo.Id; KickLib.Models.Response.v2.Channels.Messages.MessagesResponse response = null; do { response = await kickApi.Channels.GetChannelMessagesAsync(90876, response?.Cursor); // Process page response } while (response.Cursor != null); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.