# twitch.py
[](https://pypi.org/project/twitch.py)
[](https://pypi.org/project/twitch.py)
An async Python wrapper for Twitch that handles real-time events via WebSocket EventSub and integrates with the Helix API.
## Key Features
* Async/await support throughout
* Complete Twitch Helix API integration
* WebSocket EventSub for real-time events
* Built-in authentication and token management
## Installing
To install the library, you can just run the following command:
```bash
# Linux/macOS
python3 -m pip install -U twitch.py
# Windows
py -3 -m pip install -U twitch.py
```
For the development version:
```bash
git clone https://github.com/mrsnifo/twitch.py
cd twitch.py
python3 -m pip install -U .
```
## Quick Example
```python
from twitch import App
async def main():
async with App('CLIENT_ID', 'CLIENT_SECRET') as app:
emotes = await app.application.get_global_emotes()
print(f'Found {len(emotes)} global emotes')
import asyncio
asyncio.run(main())
```
## Client App Example
```python
from twitch.eventsub import ClientApp, Event, ChannelChatMessageEvent
client = ClientApp('CLIENT_ID', 'CLIENT_SECRET')
@client.event
async def on_chat_message_v1(message: Event[ChannelChatMessageEvent]):
print(message.event.message)
@client.event
async def on_ready():
user = await client.add_user('ACCESS_TOKEN')
await client.eventsub.channel_chat_message(broadcaster_user_id=user.id, user_id=user.id)
# Switches between shards if one fails. For multi-sharding use MultiShardClientApp.
client.run('CONDUIT_ID', shard_ids=(0,))
```
## Client User Example
```python
from twitch.eventsub import ClientUser, Event, ChannelFollowEvent
client = ClientUser('CLIENT_ID', 'CLIENT_SECRET')
@client.event
async def on_ready():
print('Client is ready!')
await client.eventsub.channel_follow()
@client.event
async def on_channel_follow_v2(message: Event[ChannelFollowEvent]):
print(f'{message.event.user.name} just followed!')
client.run('ACCESS_TOKEN')
```
More usage examples available in the examples folder.
## Links
- [Documentation](https://twitchpy.readthedocs.io/latest/)
- [Twitch API](https://discord.gg/UFTkgnse7d)
Raw data
{
"_id": null,
"home_page": null,
"name": "twitch.py",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.11.0",
"maintainer_email": null,
"keywords": "twitch, api, eventsub, websocket, helix, conduit",
"author": null,
"author_email": "Snifo <Snifo@mail.com>",
"download_url": "https://files.pythonhosted.org/packages/62/e8/9672ea72baaea6ee960f0e2f2298c36a3402eebd958bc9caeda94d471f9f/twitch_py-4.0.0.tar.gz",
"platform": null,
"description": "# twitch.py\n[](https://pypi.org/project/twitch.py)\n[](https://pypi.org/project/twitch.py)\n\nAn async Python wrapper for Twitch that handles real-time events via WebSocket EventSub and integrates with the Helix API.\n\n## Key Features\n* Async/await support throughout\n* Complete Twitch Helix API integration\n* WebSocket EventSub for real-time events\n* Built-in authentication and token management\n\n## Installing\nTo install the library, you can just run the following command:\n```bash\n# Linux/macOS\npython3 -m pip install -U twitch.py\n# Windows\npy -3 -m pip install -U twitch.py\n```\n\nFor the development version:\n```bash\ngit clone https://github.com/mrsnifo/twitch.py\ncd twitch.py\npython3 -m pip install -U .\n```\n\n## Quick Example\n```python\nfrom twitch import App\n\nasync def main():\n async with App('CLIENT_ID', 'CLIENT_SECRET') as app:\n emotes = await app.application.get_global_emotes()\n print(f'Found {len(emotes)} global emotes')\n\nimport asyncio\nasyncio.run(main())\n```\n\n## Client App Example\n```python\nfrom twitch.eventsub import ClientApp, Event, ChannelChatMessageEvent\n\nclient = ClientApp('CLIENT_ID', 'CLIENT_SECRET')\n\n@client.event\nasync def on_chat_message_v1(message: Event[ChannelChatMessageEvent]):\n print(message.event.message)\n\n@client.event\nasync def on_ready():\n user = await client.add_user('ACCESS_TOKEN')\n await client.eventsub.channel_chat_message(broadcaster_user_id=user.id, user_id=user.id)\n\n# Switches between shards if one fails. For multi-sharding use MultiShardClientApp.\nclient.run('CONDUIT_ID', shard_ids=(0,))\n```\n\n## Client User Example\n```python\nfrom twitch.eventsub import ClientUser, Event, ChannelFollowEvent\n\nclient = ClientUser('CLIENT_ID', 'CLIENT_SECRET')\n\n@client.event\nasync def on_ready():\n print('Client is ready!')\n await client.eventsub.channel_follow()\n\n@client.event\nasync def on_channel_follow_v2(message: Event[ChannelFollowEvent]):\n print(f'{message.event.user.name} just followed!')\n\nclient.run('ACCESS_TOKEN')\n```\n\nMore usage examples available in the examples folder.\n\n## Links\n- [Documentation](https://twitchpy.readthedocs.io/latest/)\n- [Twitch API](https://discord.gg/UFTkgnse7d)\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Async Python wrapper for Twitch EventSub and Helix API",
"version": "4.0.0",
"project_urls": {
"Discord": "https://discord.gg/UFTkgnse7d",
"Documentation": "https://twitchpy.readthedocs.io/latest/",
"Homepage": "https://github.com/mrsnifo/twitch.py",
"Issue tracker": "https://github.com/mrsnifo/twitch.py/issues",
"Repository": "https://github.com/mrsnifo/twitch.py"
},
"split_keywords": [
"twitch",
" api",
" eventsub",
" websocket",
" helix",
" conduit"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "89bf4579d6d47b228fe4d5a0db61166d73f0210a6cc50084b41c608ea46c806c",
"md5": "826c264415626d1f62b29a76ada4f04f",
"sha256": "75894f6e1fbc72f096c79a7ea8ab880eec7f569c27febd0e8eff75ab08ebaab4"
},
"downloads": -1,
"filename": "twitch_py-4.0.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "826c264415626d1f62b29a76ada4f04f",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.11.0",
"size": 142879,
"upload_time": "2025-08-17T18:27:37",
"upload_time_iso_8601": "2025-08-17T18:27:37.371002Z",
"url": "https://files.pythonhosted.org/packages/89/bf/4579d6d47b228fe4d5a0db61166d73f0210a6cc50084b41c608ea46c806c/twitch_py-4.0.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "62e89672ea72baaea6ee960f0e2f2298c36a3402eebd958bc9caeda94d471f9f",
"md5": "f3112deca68500894e1511cd40a711f1",
"sha256": "dc78b110565a4deb6c4e23ce1b599d82554fca225ea71f50866fc9b82174aab9"
},
"downloads": -1,
"filename": "twitch_py-4.0.0.tar.gz",
"has_sig": false,
"md5_digest": "f3112deca68500894e1511cd40a711f1",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.11.0",
"size": 128419,
"upload_time": "2025-08-17T18:27:38",
"upload_time_iso_8601": "2025-08-17T18:27:38.351439Z",
"url": "https://files.pythonhosted.org/packages/62/e8/9672ea72baaea6ee960f0e2f2298c36a3402eebd958bc9caeda94d471f9f/twitch_py-4.0.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-08-17 18:27:38",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "mrsnifo",
"github_project": "twitch.py",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [
{
"name": "aiohttp",
"specs": [
[
"<",
"4"
],
[
">=",
"3.10.6"
]
]
}
],
"lcname": "twitch.py"
}