This release is a pre-release and may not be stable for production use.
Twitch Python Wrapper
A Python wrapper for the Twitch API, EventSub and Authentication SOON.
No need to hassle about WebSockets nor data structures
Installation
pip install twitch-python-wrapper
What this wraps
This wraps around Twitch's
- API,
- EventSub, and
- Authentication SOON
Usage
API
from twitch_python_wrapper.api.client import APIClient
# While you can set the 'access_token' parameter to a user access token,
# those endpoints that can only be used with a user access token are
# not yet supported by this wrapper
client = APIClient(
client_id="CLIENT_ID",
access_token="APP_ACCESS_TOKEN"
)
user = client.users.get_users(login="twitchdev")
# Change the 'id' attribute to get whatever you want!
print(user.id)
EventSub
Using decorators, great for getting just one event in a function
from twitch_python_wrapper.eventsub.client import EventSubClient
from twitch_python_wrapper.eventsub.objects import Metadata
from twitch_python_wrapper.enums import SubscriptionType
# The parameter 'access_token' MUST be a user access token
client = EventSubClient(
client_id="CLIENT_ID",
access_token="USER_ACCESS_TOKEN"
)
# Event triggered when WebSocket Welcome Message is received
@client.on("builtins.message.welcome")
def connected(metadata: Metadata, payload: dict):
print("Connected with EventSub")
# Change the broadcaster_user_id by your own and
# this event should fire everytime you edit your stream info
@client.on(
SubscriptionType.CHANNEL_UPDATE,
"2",
{"broadcaster_user_id": "1337"}
)
def on_channel_update(metadata: Metadata, payload: dict):
# https://dev.twitch.tv/docs/eventsub/eventsub-subscription-types/#channel-update-notification-payload
name = payload["event"]["broadcaster_user_name"]
title = payload["event"]["title"]
language = payload["event"]["language"]
category = payload["event"]["category_name"]
print(f"{name} updated their stream info")
print(f"Stream title -> {title}")
print(f"Stream language -> {language}")
print(f"Stream category -> {category}")
Without decorators, great for getting multiple events to a function
from twitch_python_wrapper.eventsub.client import EventSubClient
from twitch_python_wrapper.eventsub.objects import Metadata
from twitch_python_wrapper.enums import SubscriptionType
# The parameter access_token MUST be a user access token
client = EventSubClient("CLIENT_ID", "USER_ACCESS_TOKEN")
# Event triggered when WebSocket Welcome Message is received
def connected(metadata: Metadata, payload: dict):
print("Connected with EventSub")
# Change the broadcaster_user_id by your own and
# this event should fire everytime you edit your stream info
def on_channel_update(metadata: Metadata, payload: dict):
# https://dev.twitch.tv/docs/eventsub/eventsub-subscription-types/#channel-update-notification-payload
name = payload["event"]["broadcaster_user_name"]
title = payload["event"]["title"]
language = payload["event"]["language"]
category = payload["event"]["category_name"]
print(f"{name} updated their stream info")
print(f"Stream title -> {title}")
print(f"Stream language -> {language}")
print(f"Stream category -> {category}")
client.register(connected, "builtins.message.welcome")
broadcasters = ["1337", "12826", "141981764"]
for broadcaster in broadcasters:
client.register(
on_channel_update,
SubscriptionType.CHANNEL_UPDATE,
"2",
{"broadcaster_user_id": broadcaster}
)
Authentication
SOON
Metadata
Release files for twitch-python-wrapper 1.0.0b0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| twitch_python_wrapper-1.0.0b0.tar.gz | 33.3 kB | Without provenance | Details for twitch_python_wrapper-1.0.0b0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| twitch_python_wrapper-1.0.0b0-py3-none-any.whl | Python 3 | none | any | Details for twitch_python_wrapper-1.0.0b0-py3-none-any.whl |
Total release size: 86.5 kB
Release files / twitch_python_wrapper-1.0.0b0.tar.gz
| Download URL | twitch_python_wrapper-1.0.0b0.tar.gz |
|---|---|
| Size | 33.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8e1c8c76b835cef51669fdfe3b4f2ff3ac8bbaeed26be63d32ba119a5a7db3c1
|
|
BLAKE2b-256 checksum How to use checksums |
cd3f110f754043da77d97abecb401dec214821727c079d43bbd698d45ea5a35e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.2
|
Release files / twitch_python_wrapper-1.0.0b0-py3-none-any.whl
| Download URL | twitch_python_wrapper-1.0.0b0-py3-none-any.whl |
|---|---|
| Size | 53.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8ad0e71fa8d555833f03187b879f75b99cd09d282886ef179153d0ae8dfeb2f0
|
|
BLAKE2b-256 checksum How to use checksums |
6d84b00ac5d3687ebc9868af8bb73c8a5f6ea6e406ead075bd5889246ef04f3b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.2
|
Security for twitch-python-wrapper 1.0.0b0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.