Skip to content

Repository files navigation

KickPy

KickPy is a powerful and flexible Python library designed to interact with the Kick API. It provides an event-driven interface to fetch user, channel, and stream data, post messages, manage moderation (ban/timeout), and subscribe to real-time events. The library includes a built-in caching mechanism to optimize performance and reduce redundant API calls.

🚀 Features

  • ✅ OAuth2 authentication flow with token caching
  • 🔁 Real-time event subscription system
  • 💬 Post and receive chat messages
  • 👤 Fetch user and channel information
  • 📺 Monitor livestreams and metadata
  • 🛠️ Moderate users (ban, timeout)
  • 🗂️ Access categories and streams
  • 🧠 Caching layer for efficient API usage

📦 Installation

pip install kickpy

🔧 Usage Example

fromkickpyimport (
KickClient,
Scopes,
Events,
Message,
Broadcaster,
Subscription,
Gift,
Stream,
Ban,
Timeout,
__version__asversion
)
client=KickClient(
client_id="YOUR_CLIENT_ID",
client_secret="YOUR_CLIENT_SECRET",
scopes=[
Scopes.USER_READ,
Scopes.EVENTS_SUBSCRIBE,
Scopes.CHANNEL_READ
],
)
@client.on(Events.ON_READY)asyncdefon_ready():
print(f"Logged in as {client.me.name} (ID: {client.me.user_id})")
@client.on(Events.ON_MESSAGE)asyncdefon_message(message: Message):
sender=awaitmessage.sender.get_or_resolve()
print(f"{sender.name}: {message.content}")
@client.on(Events.ON_FOLLOW)asyncdefon_follow(broadcaster: Broadcaster, follower: Broadcaster):
print(f"{follower.name} followed {broadcaster.name}")
@client.on(Events.ON_SUBSCRIPTION)asyncdefon_subscription(subscription: Subscription):
print(f"{subscription.subscriber.name} subscribed to {subscription.broadcaster.name}")
@client.on(Events.ON_SUBSCRIPTION_GIFT)asyncdefon_subscription_gift(gift: Gift):
gifter=gift.gifter.nameifnotgift.gifter.is_anonymouselse"Anonymous"print(f"{gifter} gifted {len(gift.subscriptions)} subscriptions to {gift.broadcaster.name}")
@client.on(Events.ON_LIVESTREAM_STARTED)asyncdefon_livestream_started(stream: Stream):
broadcaster=awaitstream.broadcaster.get_or_resolve()
print(f"{broadcaster.name} started streaming: {stream.stream_title}")
@client.on(Events.ON_MODERATION_BAN)asyncdefon_moderation_ban(moderation: Ban):
print(f"{moderation.user.name} was banned by {moderation.moderator.name} for: {moderation.reason}")
@client.on(Events.ON_MODERATION_TIMEOUT)asyncdefon_moderation_timeout(moderation: Timeout):
print(f"{moderation.user.name} was timed out by {moderation.moderator.name} until {moderation.expires_at}")
if__name__=="__main__":
print(f"Starting Kick {version} client...")
client.run()

⚙️ Client Configuration Options

ParameterDescriptionDefault
client_idYour Kick application client IDRequired
client_secretYour Kick application client secretRequired
scopesOAuth2 scopes for API accessNone
developmentEnable development modeFalse
web_app_urlWeb application URL for redirect/webhook"http://0.0.0.0:8000"
oauth_redirect_hostHostname for the redirect server"localhost"
webhook_callback_endpointWebhook callback endpoint"webhook"
oauth_redirect_endpointOAuth redirect endpoint"oauth/callback"
cache_oauthCache the OAuth token locallyTrue
oauth_fileFile to cache OAuth tokens".oauth"
prefetch_meAutomatically fetch authenticated user infoTrue
loopCustom asyncio event loopNone
http_client_clsCustom HTTP client implementationlib._http.KickHttpClient

📡 Available Events

Event NameDescription
ON_READYRaised when the client successfully connects and authentication completes.
ON_MESSAGERaised when a chat message is received in the connected channel.
ON_FOLLOWRaised when a user follows the connected channel.
ON_SUBSCRIPTIONRaised when a user subscribes to the channel.
ON_SUBSCRIPTION_GIFTRaised when a user gifts one or more subscriptions.
ON_LIVESTREAM_STARTEDRaised when the channel starts a livestream.
ON_LIVESTREAM_ENDEDRaised when a livestream ends.
ON_LIVESTREAM_UPDATEDRaised when livestream metadata (title, category, etc.) is updated.
ON_MODERATION_BANRaised when a user is banned from the channel.
ON_MODERATION_TIMEOUTRaised when a user is timed out from the channel.
ON_OAUTH_URLRaised when an OAuth URL is generated for user authentication.
ON_ERRORRaised when an unhandled internal error occurs during event processing.

📜 License

This project is licensed under the MIT License. See the LICENSE file for details.

🤝 Contributing

Contributions are welcome! If you encounter bugs, need a feature, or want to help, feel free to open an issue or submit a pull request.

📫 Contact

For questions, issues, or ideas, open a GitHub issue or contact the maintainer.

About

A powerful and flexible Python library designed to interact with the Kick API

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Contributors

Languages