KickLib is a C# library that allows for interaction with both official and unofficial (undocumented) Kick API (https://kick.com) and WebSocket. KickLib eases implementation for various chatbots by providing simple to use methods.
- OAuth 2.1 flow
- Real-time chat reading
- Stream state detection
- Authentication flow
- Message sending
- API Endpoint calls
Click here to see Complete Features List
- 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
- 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
KickLib provides support for unofficial API calls via IKickUnofficialApi
interface.
Documentation for unofficial API can be found here.
First, install NuGet. Then, install KickLib from the package manager console:
PM> Install-Package KickLib
Or from the .NET CLI as:
dotnet add package KickLib
If you are using Dependency Injection, you can easily add KickLib via extension method
.AddKickLib()
, that will register all related services with Scoped lifetime.
Simple OAuth flow using KickLib OAuth generator.
NOTE: If no state is provided, it will automatically generate state for you as base64 encoded verifier code!
var callbackUrl = "https://localhost:5001/auth/kick/callback";
var clientId = "01AAAAA0EXAMPLE66YG2HD9R";
var clientSecret = "aaac0000EXAMPLE8ebe4dc223d0c45187";
var url = KickOAuthGenerator.GetAuthorizationUri(
callbackUrl,
clientId,
new List<string>
{
"user:read",
"channel:read"
}, out var verifier);
// TODO: Perform URL redirect for user and pass OAuth process
// Via callback URL, you will receive code and state
var code = "NAAAAAAY5YZQ00STATE000ZZTFHM2I1NJLK";
var state = "ZXhhbXBsZSB2YWx1ZQ==";
var exchangeResults = await KickOAuthGenerator.ExchangeCodeForTokenAsync(
state,
clientId,
clientSecret,
callbackUrl,
state);
var clientId = "01AAAAA0EXAMPLE66YG2HD9R";
var clientSecret = "aaac0000EXAMPLE8ebe4dc223d0c45187";
var refreshToken = "NAAAAAAY5YZQ00REFRESHTOKEN000ZZTFHM2I1NJLK";
var exchangeResults = await KickOAuthGenerator.RefreshAccessTokenAsync(
refreshToken,
clientId,
clientSecret);
IKickApi api = new KickApi(new ApiSettings
{
AccessToken = accessToken
});
// Get specific category by ID
var category = await kickApi.Categories.GetCategoryAsync(28);
IKickClient client = new KickClient();
client.OnMessage += delegate(object sender, ChatMessageEventArgs e)
{
Console.WriteLine(e.Data.Content);
};
await client.ListenToChatRoomAsync(123456);
await client.ConnectAsync();
All calls require authentication. Kick officially supports OAuth 2.1 flow.
KickLib provides tools for generating OAuth URLs, exchanging code for tokens, and refreshing tokens.
To perform calls with authentication, set AccessToken
in settings object or pass it via method call.
IKickApi api = new KickApi(new ApiSettings
{
AccessToken = accessToken
}, logger);
var category = await kickApi.Categories.GetCategoryAsync(28);
For a long time, Kick didn't have any official API. Most of the functionality in KickLib was researched and reversed-engineered from their website.
With new released API support, this library will be adjusted accordingly, removing all unofficial endpoints and methods. Those methods will be replaced with proper official API calls (once we have all of them).
KickLib is meant to be used for education purposes. Don't use it for heavy scraping or other harmful actions against Kick streaming platform. I don't take responsibility for any KickLib misuse and I strongly advice against such actions.
@Robertsmania for helping with OTP generation, library improvements, and extensive testing.
See MIT License.