This project is not affiliated with or endorsed by Kick.com API. This is an independent, community-driven library for interacting with the Kick.com API.
A modern TypeScript library for the Kick.com API with real-time WebSocket chat support.
- ๐ง Zero Dependencies - Built with Node.js native APIs
- ๐ Full TypeScript Support - Complete type definitions
- ๐ OAuth 2.1 + PKCE - Automatic token management
- ๐๏ธ Modular Design - Organized API endpoints
- ๐ Production Ready - Comprehensive error handling
- ๐ฌ Real-time Chat - WebSocket connection to Kick.com chat events
- ๐ Auto-reconnection - Automatic WebSocket reconnection with retry logic
- ๐ฏ Multi-chat Support - Connect to multiple chat rooms simultaneously
- ๐ก๏ธ Cloudflare Bypass - Automatic handling of Kick.com's protection
npm install @gbrlstr/kick-flowimport { KickFlow } from '@gbrlstr/kick-flow';
const client = new KickFlow({
clientId: 'your-client-id',
clientSecret: 'your-client-secret',
});
// Get channel information
const channel = await client.channels.getChannel('gbrldev');
console.log(`${channel.user.username} has ${channel.followers_count} followers`);
// Get top live streams
const streams = await client.livestreams.getLivestreams({
sort: 'viewer_count',
limit: 10
});// Connect to chat using channel name
const chatWS = await client.chat.connectToChatByChannel('gbrldev');
// Listen for messages
chatWS.on('message', (message) => {
console.log(`${message.sender.username}: ${message.content}`);
});
// Connect to WebSocket
await chatWS.connect();We provide comprehensive examples for different use cases:
๐ฅ Simple API Usage
Basic demonstration of all API endpoints:
pnpm tsx examples/simple-api.ts๐ฌ WebSocket Chat
Real-time chat monitoring with automatic channel lookup:
pnpm tsx examples/websocket-simple.tsโก Direct WebSocket
Fast connection using direct chatroom IDs:
pnpm tsx examples/websocket-direct.ts๐ง Advanced API
Error handling, batch operations, and analytics:
pnpm tsx examples/advanced-api.ts๐ก Pro tip: Start with simple-api.ts to understand the basics, then try websocket-simple.ts for real-time chat!
const client = new KickFlow({
clientId: 'your-client-id',
clientSecret: 'your-client-secret',
});const client = new KickFlow({
clientId: 'your-client-id',
clientSecret: 'your-client-secret',
redirectUri: 'http://localhost:3000/callback',
});
// Generate auth URL
const pkceParams = client.generatePKCEParams();
const authUrl = client.getAuthorizationUrl(pkceParams, ['public', 'chat:write']);
// Exchange code for token
const token = await client.exchangeCodeForToken({
code: authorizationCode,
codeVerifier: pkceParams.codeVerifier,
});// Get channel information (includes followers, live status, etc.)
const channel = await client.channels.getChannel('username');
// Get multiple channels
const channels = await client.channels.getChannels({
slug: ['user1', 'user2']
});// Search categories
const categories = await client.categories.getCategories({ q: 'gaming' });
// Get specific category
const category = await client.categories.getCategory(1);// Get live streams with filters
const streams = await client.livestreams.getLivestreams({
category_id: 1,
language: 'en',
sort: 'viewer_count',
limit: 20
});// Automatically gets chatroom ID and connects
const chatWS = await client.chat.connectToChatByChannel('channelname');
// Listen for events
chatWS.on('message', (message) => {
console.log(`${message.sender.username}: ${message.content}`);
});
chatWS.on('user_joined', (user) => {
console.log(`${user.username} joined!`);
});
chatWS.on('subscription', (sub) => {
console.log(`${sub.username} subscribed for ${sub.months} months!`);
});
// Connect
await chatWS.connect();// Connect using known chatroom ID (faster, no API call)
const chatWS = client.chat.connectToChat(12345678);
await chatWS.connect();If you prefer direct connections, you can find chatroom IDs manually:
- Open kick.com in your browser
- Navigate to a channel (e.g., kick.com/xqc)
- Open Developer Tools (F12)
- Go to Network tab
- Look for WebSocket connections or API calls
- Extract the chatroom ID from the response
Or run: pnpm tsx examples/websocket-direct.ts guide
The library provides specific error types for different scenarios:
import {
KickFlow,
KickOAuthError,
KickNotFoundError,
KickRateLimitError,
} from '@gbrlstr/kick-flow';
try {
const result = await client.categories.getCategories({ q: 'gaming' });
} catch (error) {
if (error instanceof KickOAuthError) {
console.log('OAuth failed:', error.responseBody);
} else if (error instanceof KickNotFoundError) {
console.log('Resource not found');
} else if (error instanceof KickRateLimitError) {
console.log('Rate limited, retry after:', error.retryAfter, 'seconds');
}
}interface KickFlowConfig {
clientId: string; // Kick app client ID
clientSecret: string; // Kick app client secret
redirectUri?: string; // OAuth redirect URI (optional for bot mode)
baseUrl?: string; // API base URL (default: https://api.kick.com)
oauthUrl?: string; // OAuth URL (default: https://id.kick.com)
debug?: boolean; // Enable debug logging (default: false)
}The WebSocket client supports all Kick.com chat events:
message- Chat messages (includes replies, emotes)user_joined/user_left- User presencesubscription- New subscriptionsgift_subscription- Gift subscriptionschatroom_updated- Chat settings changesconnect/disconnect- Connection statuserror- Connection errors
- Node.js >= 18.0.0
- TypeScript >= 5.0.0 (for development)
- Chrome/Chromium (automatically downloaded by Puppeteer)
MIT License - see LICENSE file for details.