Skip to main content

Crate kick_api

Crate kick_api 

Source
Expand description

§kick-api

Rust client for the Kick.com API.

Covers channels, users, chat, moderation, rewards, event subscriptions, and live chat over WebSocket. Handles OAuth 2.1 (PKCE) authentication and automatic retry on rate limits (429).

§Live Chat (no auth required)

use kick_api::LiveChatClient;

// Connect by username
let mut chat = LiveChatClient::connect_by_username("xqc").await?;

// Or connect by chatroom ID directly
// let mut chat = LiveChatClient::connect(668).await?;

while let Some(msg) = chat.next_message().await? {
    println!("{}: {}", msg.sender.username, msg.content);
}

§REST API (requires OAuth token)

use kick_api::{KickApiClient, SendMessageRequest};

let client = KickApiClient::with_token("your_oauth_token".to_string());

// Channels
let channel = client.channels().get("xqc").await?;

// Users
let me = client.users().get_me().await?;

// Chat
let msg = SendMessageRequest {
    r#type: "user".to_string(),
    content: "Hello chat!".to_string(),
    broadcaster_user_id: Some(12345),
    reply_to_message_id: None,
};
client.chat().send_message(msg).await?;

§Authentication

Kick uses OAuth 2.1 with PKCE. Use KickOAuth to handle the flow:

use kick_api::KickOAuth;

// Load from KICK_CLIENT_ID, KICK_CLIENT_SECRET, KICK_REDIRECT_URI
let oauth = KickOAuth::from_env()?;
let scopes = vec!["chat:write", "user:read", "channel:read"];
let (auth_url, csrf_token, pkce_verifier) = oauth.get_authorization_url(scopes);
// Send the user to auth_url, then exchange the code:
// let token = oauth.exchange_code(code, pkce_verifier).await?;

Structs§

BadgeImage
Image URLs for a subscriber badge.
BanRequest
Request body for banning a user
Category
Stream category information
Channel
Channel information
ChannelInfo
Public channel information from Kick’s v2 API.
ChannelReward
Channel reward structure
ChannelRewardRedemption
Channel reward redemption
ChannelUser
Broadcaster’s user profile.
ChannelsApi
Channels API - handles all channel-related endpoints
ChatApi
Chat API - handles chat message endpoints
ChatBadge
A badge displayed next to a user’s name in chat
ChatIdentity
Visual identity information for a chat sender
ChatMessageMetadata
Metadata attached to a reply message
ChatSender
Sender information for a live chat message
ChatroomInfo
Chatroom settings for a channel.
CreateRewardRequest
Request body for creating a new reward
EventSubscription
An active event subscription
EventsApi
Events API - handles webhook/event subscription endpoints
FailedRedemption
Failed redemption (when batch operations fail)
KickApiClient
Main Kick API client
KickOAuth
Holds OAuth credentials and client for Kick.com
LiveChatClient
Client for receiving live chat messages over Kick’s Pusher WebSocket.
LiveChatMessage
A live chat message received over the Pusher WebSocket
LivestreamCategory
Category information for a livestream.
LivestreamInfo
Current livestream information.
ManageRedemptionsRequest
Request body for accepting/rejecting redemptions
ManageRedemptionsResponse
Response when accepting/rejecting redemptions
ModerationApi
Moderation API - handles ban/unban endpoints
OAuthTokenResponse
OAuth token response from Kick
OriginalMessage
The content of the message being replied to
OriginalSender
The sender of the message being replied to
PusherEvent
A raw Pusher event received from the WebSocket.
RedemptionUser
User information in a redemption
RewardsApi
Rewards API - handles all channel reward endpoints
SendMessageRequest
Request body for sending a chat message
SendMessageResponse
Response from sending a chat message
Stream
Live stream information
SubscribeEvent
A single event to subscribe to
SubscribeRequest
Request body for creating event subscriptions
SubscribeResult
Result of a single event subscription attempt
SubscriberBadge
A subscriber badge tier for a channel.
TokenIntrospection
Token introspection response
UnbanRequest
Request body for unbanning a user
UpdateRewardRequest
Request body for updating a reward
User
User information
UsersApi
Users API - handles all user-related endpoints

Enums§

FailureReason
Reasons why a redemption operation failed
KickApiError
RedemptionStatus
Redemption status

Functions§

fetch_channel_info
Fetch public channel information from Kick’s v2 API.

Type Aliases§

Result