├── src ├── types │ ├── types.ts │ ├── video.ts │ ├── channels.ts │ ├── events.ts │ └── client.ts ├── index.ts ├── core │ ├── websocket.ts │ ├── requestHelper.ts │ ├── messageHandling.ts │ └── kickApi.ts ├── utils │ └── utils.ts └── client │ └── client.ts ├── .gitignore ├── .eslintignore ├── .prettierrc ├── .prettierignore ├── examples ├── .env.example └── basic-bot.ts ├── tsup.config.ts ├── .changeset ├── config.json └── README.md ├── .github ├── ISSUE_TEMPLATE │ ├── feature_request.md │ └── bug_report.md └── workflows │ └── release.yml ├── tsconfig.json ├── LICENSE ├── CHANGELOG.md ├── .eslintrc.cjs ├── package.json ├── README.md └── pnpm-lock.yaml /src/types/types.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | dist 3 | release 4 | .env -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | dist/* 2 | .cache 3 | public 4 | node_modules 5 | *.esm.js 6 | -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "semi": true, 3 | "trailingComma": "all", 4 | "printWidth": 80, 5 | "tabWidth": 2 6 | } 7 | -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | cache 2 | .cache 3 | package.json 4 | package-lock.json 5 | public 6 | CHANGELOG.md 7 | .yarn 8 | dist 9 | node_modules 10 | .next 11 | build 12 | .contentlayer -------------------------------------------------------------------------------- /src/index.ts: -------------------------------------------------------------------------------- 1 | import { createClient } from "./client/client"; 2 | import type { MessageData } from "./types/events.js"; 3 | 4 | export { createClient }; 5 | export type { MessageData }; 6 | -------------------------------------------------------------------------------- /examples/.env.example: -------------------------------------------------------------------------------- 1 | USERNAME="" 2 | PASSWORD="" 3 | OTP_SECRET="" 4 | 5 | 6 | # for a OTP secret, you need to go to https://kick.com/settings/security and enable Two-Factor Authentication and copy the secret from there -------------------------------------------------------------------------------- /tsup.config.ts: -------------------------------------------------------------------------------- 1 | import { defineConfig } from "tsup"; 2 | 3 | export default defineConfig({ 4 | entryPoints: ["src/index.ts"], 5 | format: ["cjs", "esm"], 6 | dts: true, 7 | outDir: "dist", 8 | clean: true, 9 | }); 10 | -------------------------------------------------------------------------------- /.changeset/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://unpkg.com/@changesets/config@3.0.3/schema.json", 3 | "changelog": "@changesets/cli/changelog", 4 | "commit": true, 5 | "fixed": [], 6 | "linked": [], 7 | "access": "public", 8 | "baseBranch": "main", 9 | "updateInternalDependencies": "patch", 10 | "ignore": [] 11 | } 12 | -------------------------------------------------------------------------------- /.changeset/README.md: -------------------------------------------------------------------------------- 1 | # Changesets 2 | 3 | Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works 4 | with multi-package repos, or single-package repos to help you version and publish your code. You can 5 | find the full documentation for it [in our repository](https://github.com/changesets/changesets) 6 | 7 | We have a quick list of common questions to get you started engaging with this project in 8 | [our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md) 9 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: "[Feature Request]" 5 | labels: enhancement 6 | assignees: "" 7 | --- 8 | 9 | **Is your feature request related to a problem? Please describe.** 10 | A clear and concise description of what the problem is. 11 | 12 | **Describe the solution you'd like** 13 | A clear and concise description of what you want to happen. 14 | 15 | **Additional context** 16 | Add any other context or screenshots about the feature request here. 17 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | /* Base Options: */ 4 | "esModuleInterop": true, 5 | "skipLibCheck": true, 6 | "target": "es2022", 7 | "allowJs": true, 8 | "resolveJsonModule": true, 9 | "moduleDetection": "force", 10 | "isolatedModules": true, 11 | "verbatimModuleSyntax": true, 12 | 13 | /* Strictness */ 14 | "strict": true, 15 | "noUncheckedIndexedAccess": true, 16 | "noImplicitOverride": true, 17 | 18 | /* If transpiling with TypeScript: */ 19 | "module": "Preserve", 20 | 21 | /* might be deleted later */ 22 | 23 | // "lib": ["es2022"], 24 | 25 | /* This is cause tsup is enabled */ 26 | "noEmit": true 27 | }, 28 | "exclude": ["node_modules", "examples", "dist"] 29 | } 30 | -------------------------------------------------------------------------------- /src/core/websocket.ts: -------------------------------------------------------------------------------- 1 | import WebSocket from "ws"; 2 | import { URLSearchParams } from "url"; 3 | 4 | const BASE_URL = "wss://ws-us2.pusher.com/app/32cbd69e4b950bf97679"; 5 | 6 | export const createWebSocket = (chatroomId: number): WebSocket => { 7 | const urlParams = new URLSearchParams({ 8 | protocol: "7", 9 | client: "js", 10 | version: "8.4.0", 11 | flash: "false", 12 | }); 13 | const url = `${BASE_URL}?${urlParams.toString()}`; 14 | 15 | const socket = new WebSocket(url); 16 | 17 | socket.on("open", () => { 18 | const connect = JSON.stringify({ 19 | event: "pusher:subscribe", 20 | data: { auth: "", channel: `chatrooms.${chatroomId}.v2` }, 21 | }); 22 | socket.send(connect); 23 | }); 24 | 25 | return socket; 26 | }; 27 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: "" 5 | labels: bug 6 | assignees: retconned 7 | --- 8 | 9 | **Describe the bug** 10 | A clear and concise description of what the bug is. 11 | 12 | **To Reproduce** 13 | Steps to reproduce the behavior: 14 | 15 | 1. Go to '...' 16 | 2. Click on '....' 17 | 3. Scroll down to '....' 18 | 4. See error 19 | 20 | **Expected behavior** 21 | A clear and concise description of what you expected to happen. 22 | 23 | **Screenshots** 24 | If applicable, add screenshots to help explain your problem. 25 | 26 | **System (please complete the following information):** 27 | 28 | - OS: [e.g. Windows, Linux, Mac] 29 | - Runtime [e.g. Node, Bun] 30 | - Runtime Version [e.g. 22] 31 | 32 | **Additional context** 33 | Add any other context about the problem here. 34 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 retconned 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: Release 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | workflow_dispatch: 8 | 9 | jobs: 10 | release: 11 | runs-on: ubuntu-latest 12 | permissions: 13 | contents: write 14 | pull-requests: write 15 | id-token: write 16 | 17 | steps: 18 | - name: Checkout repo 19 | uses: actions/checkout@v4 20 | 21 | - name: Setup Node.js 22 | uses: actions/setup-node@v4 23 | with: 24 | node-version: 20 25 | registry-url: "https://registry.npmjs.org/" 26 | 27 | - name: Setup pnpm 28 | uses: pnpm/action-setup@v4 29 | with: 30 | version: 10 31 | 32 | - name: Install dependencies 33 | run: pnpm install --frozen-lockfile 34 | 35 | - name: Run project checks 36 | run: pnpm run checks 37 | 38 | - name: Create Release PR or Publish 39 | uses: changesets/action@v1 40 | with: 41 | version: pnpm run release:version 42 | publish: pnpm run release:publish 43 | env: 44 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 45 | NPM_TOKEN: ${{ secrets.NPM_TOKEN }} 46 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # @retconned/kickjs 2 | 3 | ## 0.5.4 4 | 5 | ### Patch Changes 6 | 7 | - 0741467: updates ws url version 8 | 9 | ## 0.5.3 10 | 11 | ### Patch Changes 12 | 13 | - fda33e9: adds xsrf to sendMessage headers 14 | 15 | ## 0.5.2 16 | 17 | ### Patch Changes 18 | 19 | - f0de3f0: fixes sendMessages and viewport issues 20 | 21 | ## 0.5.1 22 | 23 | ### Patch Changes 24 | 25 | - ac3e959: fixes readme 26 | 27 | ## 0.5.0 28 | 29 | ### Minor Changes 30 | 31 | - 3d46ec4: adds token auth, fixes sending messages 32 | 33 | ## 0.4.5 34 | 35 | ### Patch Changes 36 | 37 | - 7ce0119: improves auth error handling 38 | 39 | ## 0.4.4 40 | 41 | ### Patch Changes 42 | 43 | - 26bed3d: fixes div timeout 44 | 45 | ## 0.4.3 46 | 47 | ### Patch Changes 48 | 49 | - cea93c2: adds polls, leaderboard, timeouts support, cloudflare error handling 50 | 51 | ## 0.4.2 52 | 53 | ### Patch Changes 54 | 55 | - 6e9408c: fixes example code in readme 56 | 57 | ## 0.4.1 58 | 59 | ### Patch Changes 60 | 61 | - 2c07d86: minor publishing misshap 62 | 63 | ## 0.4.0 64 | 65 | ### Minor Changes 66 | 67 | - 59e5f76: authentication implementation 68 | 69 | ## 0.3.0 70 | 71 | ### Minor Changes 72 | 73 | - d96ca4b: adds a vods data feature 74 | 75 | ## 0.2.0 76 | 77 | ### Minor Changes 78 | 79 | - b59672c: missing type fix & updated readme 80 | 81 | ## 0.1.2 82 | 83 | ### Patch Changes 84 | 85 | - 9106a7d: basic functionality implemented 86 | 87 | ## 0.1.1 88 | 89 | ### Patch Changes 90 | 91 | - 66750c2: Initial release 92 | -------------------------------------------------------------------------------- /src/utils/utils.ts: -------------------------------------------------------------------------------- 1 | import type { AuthenticationSettings, LoginOptions } from "../types/client"; 2 | 3 | export const parseJSON = (json: string): T => JSON.parse(json) as T; 4 | 5 | export const validateCredentials = (options: LoginOptions) => { 6 | const { type, credentials } = options; 7 | switch (type) { 8 | case "login": 9 | if (!credentials.username || typeof credentials.username !== "string") { 10 | throw new Error("Username is required and must be a string"); 11 | } 12 | if (!credentials.password || typeof credentials.password !== "string") { 13 | throw new Error("Password is required and must be a string"); 14 | } 15 | if ( 16 | !credentials.otp_secret || 17 | typeof credentials.otp_secret !== "string" 18 | ) { 19 | throw new Error("OTP secret is required and must be a string"); 20 | } 21 | break; 22 | case "tokens": 23 | if ( 24 | !credentials.bearerToken || 25 | typeof credentials.bearerToken !== "string" 26 | ) { 27 | throw new Error("bearerToken is required and must be a string"); 28 | } 29 | if (!credentials.xsrfToken || typeof credentials.xsrfToken !== "string") { 30 | throw new Error("xsrfToken is required and must be a string"); 31 | } 32 | if (!credentials.cookies || typeof credentials.cookies !== "string") { 33 | throw new Error("cookies are required and must be a string"); 34 | } 35 | break; 36 | 37 | default: 38 | throw new Error("Invalid login type"); 39 | } 40 | }; 41 | -------------------------------------------------------------------------------- /.eslintrc.cjs: -------------------------------------------------------------------------------- 1 | // eslint-disable-next-line @typescript-eslint/no-var-requires 2 | const path = require("path"); 3 | 4 | /** @type {import("eslint").Linter.Config} */ 5 | const config = { 6 | overrides: [ 7 | { 8 | extends: [ 9 | "plugin:@typescript-eslint/recommended-requiring-type-checking", 10 | ], 11 | files: ["*.ts"], 12 | parserOptions: { 13 | project: path.join(__dirname, "tsconfig.json"), 14 | }, 15 | }, 16 | ], 17 | parser: "@typescript-eslint/parser", 18 | parserOptions: { 19 | project: path.join(__dirname, "tsconfig.json"), 20 | }, 21 | plugins: ["@typescript-eslint"], 22 | extends: ["plugin:@typescript-eslint/recommended"], 23 | rules: { 24 | "@typescript-eslint/consistent-type-imports": [ 25 | "warn", 26 | { 27 | prefer: "type-imports", 28 | fixStyle: "inline-type-imports", 29 | }, 30 | ], 31 | "@typescript-eslint/no-unused-vars": ["warn", { argsIgnorePattern: "^_" }], 32 | "@typescript-eslint/no-misused-promises": [ 33 | 2, 34 | { 35 | checksVoidReturn: { attributes: false }, 36 | }, 37 | ], 38 | "@typescript-eslint/naming-convention": [ 39 | "warn", 40 | { 41 | selector: ["parameter"], 42 | leadingUnderscore: "require", 43 | format: ["camelCase"], 44 | modifiers: ["unused"], 45 | }, 46 | ], 47 | }, 48 | ignorePatterns: [ 49 | "temp.js", 50 | "config/*", 51 | "dist/*", 52 | ".cache", 53 | "public", 54 | "node_modules", 55 | "*.esm.js", 56 | ], 57 | }; 58 | 59 | module.exports = config; 60 | -------------------------------------------------------------------------------- /src/core/requestHelper.ts: -------------------------------------------------------------------------------- 1 | import axios, { type AxiosResponse } from "axios"; 2 | 3 | import { AxiosHeaders } from "axios"; 4 | 5 | export interface ApiHeaders extends AxiosHeaders { 6 | accept: string; 7 | authorization: string; 8 | "content-type": string; 9 | "x-xsrf-token": string; 10 | cookie: string; 11 | Referer: string; 12 | } 13 | 14 | export interface RequestConfig { 15 | bearerToken: string; 16 | xsrfToken: string; 17 | cookies: string; 18 | channelSlug: string; 19 | } 20 | 21 | export const createHeaders = ({ 22 | bearerToken, 23 | cookies, 24 | channelSlug, 25 | }: RequestConfig): AxiosHeaders => { 26 | const headers = new AxiosHeaders(); 27 | 28 | headers.set("accept", "application/json"); 29 | headers.set("accept-language", "en-US,en;q=0.9"); 30 | headers.set("authorization", `Bearer ${bearerToken}`); 31 | headers.set("cache-control", "max-age=0"); 32 | headers.set("cluster", "v2"); 33 | headers.set("content-type", "application/json"); 34 | headers.set("priority", "u=1, i"); 35 | headers.set("cookie", cookies); 36 | headers.set("Referer", `https://kick.com/${channelSlug}`); 37 | headers.set("Referrer-Policy", "strict-origin-when-cross-origin"); 38 | 39 | return headers; 40 | }; 41 | 42 | export const makeRequest = async ( 43 | method: "get" | "post" | "put" | "delete", 44 | url: string, 45 | headers: AxiosHeaders, 46 | data?: unknown, 47 | ): Promise => { 48 | try { 49 | const response: AxiosResponse = await axios({ 50 | method, 51 | url, 52 | headers, 53 | data, 54 | }); 55 | 56 | if (response.status === 200) { 57 | return response.data; 58 | } 59 | console.error(`Request failed with status: ${response.status}`); 60 | return null; 61 | } catch (error) { 62 | console.error(`Request error for ${url}:`, error); 63 | return null; 64 | } 65 | }; 66 | -------------------------------------------------------------------------------- /src/types/video.ts: -------------------------------------------------------------------------------- 1 | export type VideoInfo = { 2 | id: number; 3 | live_stream_id: number; 4 | slug: null; 5 | thumb: null; 6 | s3: null; 7 | trading_platform_id: null; 8 | created_at: Date; 9 | updated_at: Date; 10 | uuid: string; 11 | views: number; 12 | deleted_at: null; 13 | source: string; 14 | livestream: Livestream; 15 | }; 16 | 17 | export type Livestream = { 18 | id: number; 19 | slug: string; 20 | channel_id: number; 21 | created_at: Date; 22 | session_title: string; 23 | is_live: boolean; 24 | risk_level_id: null; 25 | start_time: Date; 26 | source: null; 27 | twitch_channel: null; 28 | duration: number; 29 | language: string; 30 | is_mature: boolean; 31 | viewer_count: number; 32 | thumbnail: string; 33 | channel: Channel; 34 | categories: CategoryElement[]; 35 | }; 36 | 37 | export type CategoryElement = { 38 | id: number; 39 | category_id: number; 40 | name: string; 41 | slug: string; 42 | tags: string[]; 43 | description: null; 44 | deleted_at: null; 45 | viewers: number; 46 | category: CategoryCategory; 47 | }; 48 | 49 | export type CategoryCategory = { 50 | id: number; 51 | name: string; 52 | slug: string; 53 | icon: string; 54 | }; 55 | 56 | export type Channel = { 57 | id: number; 58 | user_id: number; 59 | slug: string; 60 | is_banned: boolean; 61 | playback_url: string; 62 | name_updated_at: null; 63 | vod_enabled: boolean; 64 | subscription_enabled: boolean; 65 | followersCount: number; 66 | user: User; 67 | can_host: boolean; 68 | verified: Verified; 69 | }; 70 | 71 | export type User = { 72 | profilepic: string; 73 | bio: string; 74 | twitter: string; 75 | facebook: string; 76 | instagram: string; 77 | youtube: string; 78 | discord: string; 79 | tiktok: string; 80 | username: string; 81 | }; 82 | 83 | export type Verified = { 84 | id: number; 85 | channel_id: number; 86 | created_at: Date; 87 | updated_at: Date; 88 | }; 89 | -------------------------------------------------------------------------------- /examples/basic-bot.ts: -------------------------------------------------------------------------------- 1 | import { createClient, type MessageData } from "@retconned/kick-js"; 2 | import "dotenv/config"; 3 | 4 | const client = createClient("xqc", { logger: true, readOnly: false }); 5 | 6 | // client.login({ 7 | // type: "login", 8 | // credentials: { 9 | // username: process.env.USERNAME!, 10 | // password: process.env.PASSWORD!, 11 | // otp_secret: process.env.OTP_SECRET!, 12 | // }, 13 | // }); 14 | 15 | client.login({ 16 | type: "tokens", 17 | credentials: { 18 | bearerToken: process.env.BEARER_TOKEN!, 19 | xsrfToken: process.env.XSRF_TOKEN!, 20 | cookies: process.env.COOKIES!, 21 | }, 22 | }); 23 | 24 | client.on("ready", () => { 25 | console.log(`Bot ready & logged into ${client.user?.tag}!`); 26 | }); 27 | 28 | client.on("ChatMessage", async (message: MessageData) => { 29 | console.log(`${message.sender.username}: ${message.content}`); 30 | 31 | if (message.content.match("!ping")) { 32 | client.sendMessage(Math.random().toString(36).substring(7)); 33 | } 34 | 35 | if (message.content.match("!slowmode on")) { 36 | const splitMessage = message.content.split(" "); 37 | const duration = splitMessage[1]; 38 | if (duration) { 39 | const durationInSeconds = parseInt(duration); 40 | client.slowMode("on", durationInSeconds); 41 | } 42 | } 43 | if (message.content.match("!slowmode off")) { 44 | client.slowMode("off"); 45 | } 46 | }); 47 | 48 | client.on("Subscription", async (subscription) => { 49 | console.log(`New subscription 💰 : ${subscription.username}`); 50 | }); 51 | 52 | // get information about a vod 53 | const { title, duration, thumbnail, views } = await client.vod("your-video-id"); 54 | 55 | // to get the current poll in a channel in the channel the bot is in 56 | const poll = await client.getPoll(); 57 | // or you can pass a specific channel to get the poll in that channel. 58 | // example: const poll = await client.getPoll("xqc"); 59 | 60 | // get leaderboards for the channel the bot is in 61 | const leaderboards = await client.getLeaderboards(); 62 | // or you can pass a specific channel to get the leaderboards in that channel. 63 | // example: const leaderboards = await client.getLeaderboards("xqc"); 64 | -------------------------------------------------------------------------------- /src/types/channels.ts: -------------------------------------------------------------------------------- 1 | import type { Livestream } from "./video"; 2 | 3 | export interface KickChannelInfo { 4 | id: number; 5 | user_id: number; 6 | slug: string; 7 | is_banned: boolean; 8 | playback_url: string; 9 | vod_enabled: boolean; 10 | subscription_enabled: boolean; 11 | followers_count: number; 12 | subscriber_badges: SubscriberBadge[]; 13 | banner_image: BannerImage; 14 | livestream: Livestream | null; 15 | role: null; 16 | muted: boolean; 17 | follower_badges: unknown[]; 18 | offline_banner_image: null; 19 | verified: boolean; 20 | recent_categories: RecentCategory[]; 21 | can_host: boolean; 22 | user: User; 23 | chatroom: Chatroom; 24 | } 25 | export interface BannerImage { 26 | url: string; 27 | } 28 | 29 | export interface Chatroom { 30 | id: number; 31 | chatable_type: string; 32 | channel_id: number; 33 | created_at: Date; 34 | updated_at: Date; 35 | chat_mode_old: string; 36 | chat_mode: string; 37 | slow_mode: boolean; 38 | chatable_id: number; 39 | followers_mode: boolean; 40 | subscribers_mode: boolean; 41 | emotes_mode: boolean; 42 | message_interval: number; 43 | following_min_duration: number; 44 | } 45 | 46 | export interface RecentCategory { 47 | id: number; 48 | category_id: number; 49 | name: string; 50 | slug: string; 51 | tags: string[]; 52 | description: null; 53 | deleted_at: null; 54 | viewers: number; 55 | banner: Banner; 56 | category: Category; 57 | } 58 | 59 | export interface Banner { 60 | responsive: string; 61 | url: string; 62 | } 63 | 64 | export interface Category { 65 | id: number; 66 | name: string; 67 | slug: string; 68 | icon: string; 69 | } 70 | 71 | export interface SubscriberBadge { 72 | id: number; 73 | channel_id: number; 74 | months: number; 75 | badge_image: BadgeImage; 76 | } 77 | 78 | export interface BadgeImage { 79 | srcset: string; 80 | src: string; 81 | } 82 | export interface User { 83 | id: number; 84 | username: string; 85 | agreed_to_terms: boolean; 86 | email_verified_at: Date; 87 | bio: string; 88 | country: null; 89 | state: null; 90 | city: null; 91 | instagram: string; 92 | twitter: string; 93 | youtube: string; 94 | discord: string; 95 | tiktok: string; 96 | facebook: string; 97 | profile_pic: string; 98 | } 99 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@retconned/kick-js", 3 | "version": "0.5.4", 4 | "description": "A typescript bot interface for kick.com", 5 | "keywords": [ 6 | "Kick.com", 7 | "Kick Streaming", 8 | "Livestream", 9 | "Kick Chat", 10 | "Kick Bot", 11 | "Kick Api", 12 | "Kick Api Wrapper", 13 | "Kick library" 14 | ], 15 | "homepage": "https://github.com/retconned/kick-js", 16 | "bugs": { 17 | "url": "https://github.com/retconned/kick-js/issues" 18 | }, 19 | "author": "retconned ", 20 | "repository": { 21 | "type": "git", 22 | "url": "git+https://github.com/retconned/kick-js.git" 23 | }, 24 | "files": [ 25 | "dist" 26 | ], 27 | "type": "module", 28 | "license": "MIT", 29 | "main": "dist/index.js", 30 | "scripts": { 31 | "build": "tsup", 32 | "format:fix": "prettier --write \"src/**/*.{ts,tsx}\"", 33 | "format:check": "prettier --check \"src/**/*.{ts,tsx}\"", 34 | "lint:ts": "tsc", 35 | "lint:check": "eslint \"src/**/*.{ts,js}\"", 36 | "lint:fix": "eslint --fix \"src/**/*.{ts,js}\"", 37 | "check-exports": "attw --pack . --ignore-rules=cjs-resolves-to-esm", 38 | 39 | "dev": "vitest", 40 | 41 | "checks": "npm run format:fix && npm run lint:ts && npm run check-exports && npm run build", 42 | 43 | "release:version": "changeset version", 44 | "release:publish": "changeset publish", 45 | "release:local": "npm run release:version && npm run release:publish", 46 | 47 | "prepublishOnly": "npm run checks" 48 | }, 49 | "exports": { 50 | "./package.json": "./package.json", 51 | ".": { 52 | "import": "./dist/index.js", 53 | "default": "./dist/index.cjs" 54 | } 55 | }, 56 | "devDependencies": { 57 | "@arethetypeswrong/cli": "^0.15.4", 58 | "@changesets/cli": "^2.27.8", 59 | "@types/ws": "^8.5.12", 60 | "@typescript-eslint/eslint-plugin": "^8.4.0", 61 | "@typescript-eslint/parser": "^8.4.0", 62 | "eslint": "8", 63 | "eslint-config-prettier": "^9.1.0", 64 | "prettier": "^3.3.3", 65 | "tsup": "^8.2.4", 66 | "tsx": "^4.19.1", 67 | "typescript": "^5.5.4", 68 | "vitest": "^2.1.1" 69 | }, 70 | "dependencies": { 71 | "axios": "^1.7.7", 72 | "otplib": "^12.0.1", 73 | "puppeteer": "^23.3.0", 74 | "puppeteer-extra": "3.3.6", 75 | "puppeteer-extra-plugin-stealth": "2.11.2", 76 | "ws": "^8.18.0" 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /src/types/events.ts: -------------------------------------------------------------------------------- 1 | export interface MessageEvent { 2 | event: string; 3 | data: string; 4 | channel: string; 5 | } 6 | 7 | export interface MessageData { 8 | id: string; 9 | chatroom_id: number; 10 | content: string; 11 | type: string; 12 | created_at: string; 13 | sender: { 14 | id: number; 15 | username: string; 16 | slug: string; 17 | identity: { color: string; badges: unknown }; 18 | }; 19 | metadata?: { 20 | original_sender: { id: string; username: string }; 21 | original_message: { 22 | id: string; 23 | content: string; 24 | }; 25 | }; 26 | } 27 | 28 | export interface SubscriptionData { 29 | username: string; 30 | months: number; 31 | } 32 | 33 | export interface ChatMessage { 34 | id: string; 35 | chatroom_id: number; 36 | content: string; 37 | type: string; 38 | created_at: string; 39 | sender: { 40 | id: number; 41 | username: string; 42 | slug: string; 43 | identity: { color: string; badges: unknown }; 44 | }; 45 | } 46 | 47 | export interface Subscription { 48 | chatroom_id: number; 49 | username: string; 50 | months: number; 51 | } 52 | 53 | export interface GiftedSubscriptionsEvent { 54 | chatroom_id: number; 55 | gifted_usernames: string[]; 56 | gifter_username: string; 57 | } 58 | 59 | export interface StreamHostEvent { 60 | chatroom_id: number; 61 | optional_message: string; 62 | number_viewers: number; 63 | host_username: string; 64 | } 65 | 66 | export interface MessageDeletedEvent { 67 | id: string; 68 | message: { 69 | id: string; 70 | }; 71 | } 72 | 73 | export interface UserBannedEvent { 74 | id: string; 75 | user: { 76 | id: number; 77 | username: string; 78 | slug: string; 79 | }; 80 | 81 | banned_by: { 82 | id: number; 83 | username: string; 84 | slug: string; 85 | }; 86 | 87 | expires_at?: Date; 88 | } 89 | 90 | export interface UserUnbannedEvent { 91 | id: string; 92 | user: { 93 | id: number; 94 | username: string; 95 | slug: string; 96 | }; 97 | unbanned_by: { 98 | id: number; 99 | username: string; 100 | slug: string; 101 | }; 102 | } 103 | 104 | export interface PinnedMessageCreatedEvent { 105 | message: { 106 | id: string; 107 | chatroom_id: number; 108 | content: string; 109 | type: string; 110 | created_at: Date; 111 | sender: { 112 | id: number; 113 | username: string; 114 | slug: string; 115 | identity: { 116 | color: string; 117 | badges: Array<{ 118 | type: string; 119 | text: string; 120 | count?: number; 121 | }>; 122 | }; 123 | }; 124 | metadata: null; 125 | }; 126 | duration: string; 127 | } 128 | -------------------------------------------------------------------------------- /src/types/client.ts: -------------------------------------------------------------------------------- 1 | import type { Channel, Livestream } from "./video"; 2 | 3 | export type EventHandler = (data: T) => void; 4 | 5 | export interface ClientOptions { 6 | plainEmote?: boolean; 7 | logger?: boolean; 8 | readOnly?: boolean; 9 | } 10 | 11 | export interface Video { 12 | id: number; 13 | title: string; 14 | thumbnail: string; 15 | duration: number; 16 | live_stream_id: number; 17 | start_time: Date; 18 | created_at: Date; 19 | updated_at: Date; 20 | uuid: string; 21 | views: number; 22 | stream: string; 23 | language: string; 24 | livestream: Livestream; 25 | channel: Channel; 26 | } 27 | 28 | export interface KickClient { 29 | on: (event: string, listener: (...args: any[]) => void) => void; 30 | vod: (video_id: string) => Promise