Python Kick API
A full implementation of the Kick API and EventSub in Python 3.9+.
Heavily inspired on pyTwitchAPI. My mission is to maintain parity with the twitchAPI library for an easier manipulation of both libraries in any project.
[!NOTE] The library was intended to be called
kickAPIto have parity with twitchAPI, but the name is already taken. So the library was re-branded tokick_api.Update:
PyPI didn't likekick_api, a friend of mine recommended mebetterKickAPI, and I liked it. So, re-branded tobetterKickAPI.
[!TIP] Also try kickpython that includes its own WebSocket implementation!
Installation
Install using pip:
pip install betterKickAPI
Install using uv:
uv add betterKickAPI
Usage
Basic API calls
Setting up an instance of the Kick API and get your User ID.
from betterKickAPI.kick import Kick
from betterKickAPI.helper import first
import asyncio
async def kick_example():
# Initialize the kick instance, this will by default also create an app authentication for you
kick = await Kick('APP_ID', 'APP_SECRET')
users = await kick.get_users(slug='your_kick_user')
# print the ID of your user
print(user[0].broadcaster_user_id)
# run this example
asyncio.run(kick_example())
Authentication
The Kick API knows 2 different authentications. App and User Authentication. Which one you need (or if one at all) depends on what calls you want to use.
App Authentication
from betterKickAPI.kick import Kick
kick = await Kick('APP_ID', 'APP_SECRET')
User Authentication
To get a user auth token, the user has to explicitly click "Allow access" on the Kick website. The library includes an Authenticator. Just remember to add http://localhost:36571 in your redirect URIs in the dev settings tab.
from betterKickAPI.kick import Kick
from betterKickAPI.oauth import UserAuthenticator
from betterKickAPI.type import OAuthScope
kick = await Kick('APP_ID', 'APP_SECRET')
target_scope = [OAuthScope.CHANNEL_READ]
auth = UserAuthenticator(kick, target_scope, force_verify=False)
# this will open your default browser and prompt you with the kick auth website
token, refresh_token = await auth.authenticate()
await kick.set_user_authentication(token, target_scope, refresh_token)
You can reuse this token and use the refresh_token to renew it:
from betterKickAPI.oauth import refresh_access_token
new_token, new_refresh_token = await refresh_access_token('refresh_token', 'APP_ID', 'APP_SECRET')
AuthToken refresh callback
Optionally you can set a callback for both user access token refresh and app access token refresh.
from betterKickAPI.kick import Kick
async def app_refresh(token: str):
print(f'my new ap token is:{token}')
async def user_refresh(token: str, refresh_token: str):
print(f'my new user token is: {token}')
kick = await Kick('APP_ID', 'APP_SECRET')
kick.app_auth_refresh_callback = app_refresh
kick.user_auth_refresh_callback = user_refresh
EventSub
EventSub lets you listen for events that happen on Kick.
The EventSub client runs in its own process, calling the given callback function whenever an event happens.
[!IMPORTANT] At the moment, the Kick API offers Webhook as the only method to use EventSub. But there's already plans on adding WebSockets.
TODO
- Considering getting rid of socketify because of linux dependencies.
- Add documentation.
- Add EventSub WebSockets when available.
Acknowledges
- pyTwitchAPI: A Python 3.7 compatible implementation of the Twitch API, EventSub and Chat.
- KickPython: Kick.com Python Public API Wrapper
Metadata
Release files for betterKickAPI 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| betterkickapi-1.0.1.tar.gz | 33.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| betterkickapi-1.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 73.0 kB
Release files / betterkickapi-1.0.1.tar.gz
| Download URL | betterkickapi-1.0.1.tar.gz |
|---|---|
| Size | 33.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8bec340006a3bcf774512369e5f8f8fe157282a15a4edd9c65bcbf86fee4d13b
|
|
BLAKE2b-256 checksum How to use checksums |
c09128d2c9588bb1591b3f12e8e35d957aab8655d28c680580a82112a2066a56
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.7
|
Release files / betterkickapi-1.0.1-py3-none-any.whl
| Download URL | betterkickapi-1.0.1-py3-none-any.whl |
|---|---|
| Size | 39.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5a6d93ac53faf57dccd371715b8a35cc87d7fa70c108eb88ae725abc57381b2f
|
|
BLAKE2b-256 checksum How to use checksums |
5efd0326c06643e950936ad1c58db45cab362fbc0e57a93235b317055c9d4e20
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.7
|