33[ ![ PyPI] ( https://img.shields.io/pypi/v/kickcom.py )] ( https://pypi.org/project/kickcom.py )
44[ ![ Documentation] ( https://img.shields.io/badge/docs-GitHub%20Pages-blue )] ( https://predaaa.github.io/kickcom.py )
55
6- Async library for Kick.com API and webhooks
6+ Modern async Python wrapper for the Kick.com API. OAuth 2.1 PKCE, typed models, webhook server with signature verification, and full coverage of chat, channels, livestreams, moderation, and rewards.
77
8- [ Documentation] ( https://predaaa.github.io/kickcom.py ) | [ Kick API Reference] ( https://docs.kick.com/ )
8+ ## Features
9+
10+ - Full coverage of the [ Kick Public API] ( https://docs.kick.com/ ) (users, channels, livestreams, categories, chat, moderation, rewards, KICKs, events)
11+ - ** OAuth 2.1 + PKCE** authentication with built-in browser flow and automatic token refresh
12+ - ** Webhook server** with cryptographic signature verification for real-time events
13+ - Fully typed dataclass models for all API responses and webhook payloads
14+ - Optional speed extras (` orjson ` , ` aiodns ` , ` Brotli ` ) for faster serialization and networking
15+ - Async/await powered by [ aiohttp] ( https://docs.aiohttp.org/ )
916
1017## Installation
1118
@@ -21,14 +28,12 @@ pip install kickcom.py[speed]
2128
2229## Quick Start
2330
24- ### App Access Token (Bot / Server-side)
25-
2631``` python
2732import asyncio
2833from kickpy import KickClient
2934
3035async def main ():
31- client = KickClient(" KICK_CLIENT_ID " , " KICK_CLIENT_SECRET " )
36+ client = KickClient(" CLIENT_ID " , " CLIENT_SECRET " )
3237
3338 user = await client.fetch_user(4377088 )
3439 print (user.name)
@@ -41,171 +46,11 @@ async def main():
4146asyncio.run(main())
4247```
4348
44- ### User Access Token (OAuth 2.1 + PKCE)
45-
46- Some endpoints require a user token. The library handles the full OAuth flow with a built-in local callback server:
47-
48- ``` python
49- import asyncio
50- from kickpy import KickClient, Scope
51-
52- async def main ():
53- client = KickClient(" KICK_CLIENT_ID" , " KICK_CLIENT_SECRET" )
54-
55- # Opens browser, captures callback on localhost, exchanges code for tokens
56- await client.authenticate(
57- scopes = [Scope.CHAT_WRITE , Scope.MODERATION_BAN ],
58- port = 3000 , # redirect URI must be http://127.0.0.1:3000/callback in your Kick app settings
59- )
60-
61- # User token endpoints are now available
62- await client.send_chat_message(" Hello from kickcom.py!" , broadcaster_user_id = 4377088 )
63-
64- await client.close()
65-
66- asyncio.run(main())
67- ```
68-
69- If you handle OAuth externally, you can inject tokens directly:
70-
71- ``` python
72- client.set_user_token(
73- access_token = " ..." ,
74- refresh_token = " ..." ,
75- expires_in = 3600 ,
76- scope = " chat:write moderation:ban" ,
77- )
78- ```
79-
80- ## API Reference
81-
82- ### Users
83-
84- | Method | Description | Token |
85- | --------| -------------| -------|
86- | ` fetch_user(user_id) ` | Get a user by ID | App |
87-
88- ### Channels
89-
90- | Method | Description | Token |
91- | --------| -------------| -------|
92- | ` fetch_channel(user_id?, slug?) ` | Get a channel by broadcaster ID or slug | App |
93- | ` update_channel(category_id?, stream_title?, custom_tags?) ` | Update channel metadata | User (` channel:write ` ) |
94-
95- ### Livestreams
96-
97- | Method | Description | Token |
98- | --------| -------------| -------|
99- | ` fetch_livestream(broadcaster_user_id) ` | Get a single livestream | App |
100- | ` fetch_livestreams(broadcaster_user_id?, category_id?, language?, limit?, sort?) ` | Get multiple livestreams | App |
101- | ` fetch_livestream_stats() ` | Get global livestream stats | App |
102-
103- ### Categories
104-
105- | Method | Description | Token |
106- | --------| -------------| -------|
107- | ` fetch_categories(query?, name?, tag?, category_id?, cursor?, limit?) ` | Search categories (v2) | App |
108-
109- ### Chat
110-
111- | Method | Description | Token |
112- | --------| -------------| -------|
113- | ` send_chat_message(content, message_type?, broadcaster_user_id?, reply_to_message_id?) ` | Send a chat message | User (` chat:write ` ) |
114- | ` delete_chat_message(message_id) ` | Delete a chat message | User (` moderation:chat_message:manage ` ) |
115-
116- ### Moderation
117-
118- | Method | Description | Token |
119- | --------| -------------| -------|
120- | ` ban_user(broadcaster_user_id, user_id, duration?, reason?) ` | Ban or timeout a user | User (` moderation:ban ` ) |
121- | ` unban_user(broadcaster_user_id, user_id) ` | Unban a user | User (` moderation:ban ` ) |
122-
123- ### Channel Rewards
124-
125- | Method | Description | Token |
126- | --------| -------------| -------|
127- | ` fetch_channel_rewards() ` | List channel point rewards | User (` channel:rewards:read ` ) |
128- | ` create_channel_reward(cost, title, ...) ` | Create a reward | User (` channel:rewards:write ` ) |
129- | ` update_channel_reward(reward_id, ...) ` | Update a reward | User (` channel:rewards:write ` ) |
130- | ` delete_channel_reward(reward_id) ` | Delete a reward | User (` channel:rewards:write ` ) |
131- | ` fetch_reward_redemptions(reward_id?, status?, ids?, cursor?) ` | Get redemptions | User (` channel:rewards:read ` ) |
132- | ` accept_reward_redemptions(ids) ` | Accept pending redemptions | User (` channel:rewards:write ` ) |
133- | ` reject_reward_redemptions(ids) ` | Reject pending redemptions | User (` channel:rewards:write ` ) |
134-
135- ### KICKs
136-
137- | Method | Description | Token |
138- | --------| -------------| -------|
139- | ` fetch_kicks_leaderboard(top?) ` | Get KICKs leaderboard | User (` kicks:read ` ) |
140-
141- ### Events / Subscriptions
142-
143- | Method | Description | Token |
144- | --------| -------------| -------|
145- | ` fetch_events_subscriptions() ` | List event subscriptions | App |
146- | ` subscribe_to_event(event_type, user_id) ` | Subscribe to a webhook event | App |
147- | ` unsubscribe_from_event(subscription_id) ` | Unsubscribe from an event | App |
148-
149- ### Other
150-
151- | Method | Description | Token |
152- | --------| -------------| -------|
153- | ` fetch_public_key() ` | Get the Kick public key for webhook verification | App |
154-
155- ## OAuth Scopes
156-
157- ``` python
158- from kickpy import Scope
159-
160- Scope.USER_READ # user:read
161- Scope.CHANNEL_READ # channel:read
162- Scope.CHANNEL_WRITE # channel:write
163- Scope.CHANNEL_REWARDS_READ # channel:rewards:read
164- Scope.CHANNEL_REWARDS_WRITE # channel:rewards:write
165- Scope.CHAT_WRITE # chat:write
166- Scope.STREAMKEY_READ # streamkey:read
167- Scope.EVENTS_SUBSCRIBE # events:subscribe
168- Scope.MODERATION_BAN # moderation:ban
169- Scope.MODERATION_CHAT_MESSAGE_MANAGE # moderation:chat_message:manage
170- Scope.KICKS_READ # kicks:read
171- ```
172-
173- ## Webhook Server
49+ ## Documentation
17450
175- Receive and process webhook events from Kick:
176-
177- ``` python
178- import asyncio
179- from kickpy import KickClient, WebhookEvent, WebhookServer
180- from kickpy.models.webhooks.chat_message import ChatMessage
181-
182- def on_chat_message (payload : ChatMessage):
183- print (f " { payload.sender.username} : { payload.content} " )
184-
185- async def main ():
186- client = KickClient(" KICK_CLIENT_ID" , " KICK_CLIENT_SECRET" )
187- server = WebhookServer(client, callback_route = " /webhooks/kick" )
188- server.dispatcher.listen(WebhookEvent.CHAT_MESSAGE_SENT , on_chat_message)
189-
190- await server.listen(host = " localhost" , port = 3000 , access_log = None )
191-
192- loop = asyncio.new_event_loop()
193- asyncio.set_event_loop(loop)
194- loop.run_until_complete(main())
195- loop.run_forever()
196- ```
51+ For full guides and API reference, visit the ** [ documentation] ( https://predaaa.github.io/kickcom.py ) ** .
19752
198- ### Webhook Events
199-
200- | Event | Enum |
201- | -------| ------|
202- | ` chat.message.sent ` | ` WebhookEvent.CHAT_MESSAGE_SENT ` |
203- | ` channel.followed ` | ` WebhookEvent.CHANNEL_FOLLOWED ` |
204- | ` channel.subscription.new ` | ` WebhookEvent.CHANNEL_SUB_NEW ` |
205- | ` channel.subscription.gifts ` | ` WebhookEvent.CHANNEL_SUB_GIFTS ` |
206- | ` channel.subscription.renewal ` | ` WebhookEvent.CHANNEL_SUB_RENEWAL ` |
207- | ` livestream.status.updated ` | ` WebhookEvent.LIVESTREAM_STATUS_UPDATED ` |
208- | ` livestream.metadata.updated ` | ` WebhookEvent.LIVESTREAM_METADATA_UPDATED ` |
209- | ` channel.moderation.user_banned ` | ` WebhookEvent.MODERATION_USER_BANNED ` |
210- | ` kicks.gifted ` | ` WebhookEvent.KICKS_GIFTED ` |
211- | ` channel.reward.redemption.updated ` | ` WebhookEvent.CHANNEL_REWARD_REDEMPTION_UPDATED ` |
53+ - [ Getting Started] ( https://predaaa.github.io/kickcom.py/getting-started/ ) - Install and make your first API call
54+ - [ Authentication] ( https://predaaa.github.io/kickcom.py/authentication/ ) - App tokens, user tokens, and OAuth flow
55+ - [ API Reference] ( https://predaaa.github.io/kickcom.py/api/client/ ) - All client methods, models, enums, and errors
56+ - [ Webhooks] ( https://predaaa.github.io/kickcom.py/webhooks/setup/ ) - Set up a webhook server and handle real-time events
0 commit comments