Skip to main content

Async library for Kick.com API and webhooks

Project description

kickcom.py

PyPI Documentation

Async library for Kick.com API and webhooks

Documentation | Kick API Reference

Installation

pip install kickcom.py

Optional speed extras:

pip install kickcom.py[speed]

Quick Start

App Access Token (Bot / Server-side)

import asyncio
from kickpy import KickClient

async def main():
    client = KickClient("KICK_CLIENT_ID", "KICK_CLIENT_SECRET")

    user = await client.fetch_user(4377088)
    print(user.name)

    channel = await client.fetch_channel(slug="kickbot")
    print(channel.stream_title)

    await client.close()

asyncio.run(main())

User Access Token (OAuth 2.1 + PKCE)

Some endpoints require a user token. The library handles the full OAuth flow with a built-in local callback server:

import asyncio
from kickpy import KickClient, Scope

async def main():
    client = KickClient("KICK_CLIENT_ID", "KICK_CLIENT_SECRET")

    # Opens browser, captures callback on localhost, exchanges code for tokens
    await client.authenticate(
        scopes=[Scope.CHAT_WRITE, Scope.MODERATION_BAN],
        port=3000,  # redirect URI must be http://127.0.0.1:3000/callback in your Kick app settings
    )

    # User token endpoints are now available
    await client.send_chat_message("Hello from kickcom.py!", broadcaster_user_id=4377088)

    await client.close()

asyncio.run(main())

If you handle OAuth externally, you can inject tokens directly:

client.set_user_token(
    access_token="...",
    refresh_token="...",
    expires_in=3600,
    scope="chat:write moderation:ban",
)

API Reference

Users

Method Description Token
fetch_user(user_id) Get a user by ID App

Channels

Method Description Token
fetch_channel(user_id?, slug?) Get a channel by broadcaster ID or slug App
update_channel(category_id?, stream_title?, custom_tags?) Update channel metadata User (channel:write)

Livestreams

Method Description Token
fetch_livestream(broadcaster_user_id) Get a single livestream App
fetch_livestreams(broadcaster_user_id?, category_id?, language?, limit?, sort?) Get multiple livestreams App
fetch_livestream_stats() Get global livestream stats App

Categories

Method Description Token
fetch_categories(query?, name?, tag?, category_id?, cursor?, limit?) Search categories (v2) App

Chat

Method Description Token
send_chat_message(content, message_type?, broadcaster_user_id?, reply_to_message_id?) Send a chat message User (chat:write)
delete_chat_message(message_id) Delete a chat message User (moderation:chat_message:manage)

Moderation

Method Description Token
ban_user(broadcaster_user_id, user_id, duration?, reason?) Ban or timeout a user User (moderation:ban)
unban_user(broadcaster_user_id, user_id) Unban a user User (moderation:ban)

Channel Rewards

Method Description Token
fetch_channel_rewards() List channel point rewards User (channel:rewards:read)
create_channel_reward(cost, title, ...) Create a reward User (channel:rewards:write)
update_channel_reward(reward_id, ...) Update a reward User (channel:rewards:write)
delete_channel_reward(reward_id) Delete a reward User (channel:rewards:write)
fetch_reward_redemptions(reward_id?, status?, ids?, cursor?) Get redemptions User (channel:rewards:read)
accept_reward_redemptions(ids) Accept pending redemptions User (channel:rewards:write)
reject_reward_redemptions(ids) Reject pending redemptions User (channel:rewards:write)

KICKs

Method Description Token
fetch_kicks_leaderboard(top?) Get KICKs leaderboard User (kicks:read)

Events / Subscriptions

Method Description Token
fetch_events_subscriptions() List event subscriptions App
subscribe_to_event(event_type, user_id) Subscribe to a webhook event App
unsubscribe_from_event(subscription_id) Unsubscribe from an event App

Other

Method Description Token
fetch_public_key() Get the Kick public key for webhook verification App

OAuth Scopes

from kickpy import Scope

Scope.USER_READ                       # user:read
Scope.CHANNEL_READ                    # channel:read
Scope.CHANNEL_WRITE                   # channel:write
Scope.CHANNEL_REWARDS_READ            # channel:rewards:read
Scope.CHANNEL_REWARDS_WRITE           # channel:rewards:write
Scope.CHAT_WRITE                      # chat:write
Scope.STREAMKEY_READ                  # streamkey:read
Scope.EVENTS_SUBSCRIBE                # events:subscribe
Scope.MODERATION_BAN                  # moderation:ban
Scope.MODERATION_CHAT_MESSAGE_MANAGE  # moderation:chat_message:manage
Scope.KICKS_READ                      # kicks:read

Webhook Server

Receive and process webhook events from Kick:

import asyncio
from kickpy import KickClient, WebhookEvent, WebhookServer
from kickpy.models.webhooks.chat_message import ChatMessage

def on_chat_message(payload: ChatMessage):
    print(f"{payload.sender.username}: {payload.content}")

async def main():
    client = KickClient("KICK_CLIENT_ID", "KICK_CLIENT_SECRET")
    server = WebhookServer(client, callback_route="/webhooks/kick")
    server.dispatcher.listen(WebhookEvent.CHAT_MESSAGE_SENT, on_chat_message)

    await server.listen(host="localhost", port=3000, access_log=None)

loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
loop.run_until_complete(main())
loop.run_forever()

Webhook Events

Event Enum
chat.message.sent WebhookEvent.CHAT_MESSAGE_SENT
channel.followed WebhookEvent.CHANNEL_FOLLOWED
channel.subscription.new WebhookEvent.CHANNEL_SUB_NEW
channel.subscription.gifts WebhookEvent.CHANNEL_SUB_GIFTS
channel.subscription.renewal WebhookEvent.CHANNEL_SUB_RENEWAL
livestream.status.updated WebhookEvent.LIVESTREAM_STATUS_UPDATED
livestream.metadata.updated WebhookEvent.LIVESTREAM_METADATA_UPDATED
channel.moderation.user_banned WebhookEvent.MODERATION_USER_BANNED
kicks.gifted WebhookEvent.KICKS_GIFTED
channel.reward.redemption.updated WebhookEvent.CHANNEL_REWARD_REDEMPTION_UPDATED

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

kickcom_py-1.0.0.tar.gz (28.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

kickcom_py-1.0.0-py3-none-any.whl (28.7 kB view details)

Uploaded Python 3

File details

Details for the file kickcom_py-1.0.0.tar.gz.

File metadata

  • Download URL: kickcom_py-1.0.0.tar.gz
  • Upload date:
  • Size: 28.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.32.4

File hashes

Hashes for kickcom_py-1.0.0.tar.gz
Algorithm Hash digest
SHA256 8cd0a536f6d83d1380c92be4a9e55093ef8410018fc6a690e87566604a0c4c84
MD5 58ffb52806df0c958c1d640072646eb8
BLAKE2b-256 840c396076bdec4e3e0fbe7963d61b6e2e7edc051e67adddcd5c3d896358a356

See more details on using hashes here.

File details

Details for the file kickcom_py-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: kickcom_py-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 28.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.32.4

File hashes

Hashes for kickcom_py-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f3e68ea0a14da1338f05692a03a3a1ed889c08734d289a176c2ba14ca4ffcef8
MD5 5d21bd47d3150e8eb7ea6374a282d0aa
BLAKE2b-256 9ddea9b8a14a4518483a394bab1ff3c629c88853084b7a92c6ff06cc71e841d0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page