Synchra Python SDK (v2.0)
A modern, async-first Python SDK for the Synchra API, providing robust access to channel management, real-time events, and multi-platform moderation.
Features
- Async Native: Built from the ground up for
asynciousingaiohttp. - Full Type Safety: Comprehensive Pydantic v2 models for all API resources and WebSocket events.
- WebSocket Client: Real-time event subscription and dispatcher with automatic reconnection.
- Provider Support: Specialized API groups for Twitch, YouTube, and Kick.
- OAuth2 Ready: Support for both manual access tokens and full OAuth2 refresh flows.
Installation
pip install synchra
Quick Start
HTTP API Client
import asyncio
from synchra import SynchraClient
async def main():
# Initialize client (with token or OAuth credentials)
client = SynchraClient(access_token="YOUR_ACCESS_TOKEN")
# List channels
channels = await client.channels.list()
for channel in channels:
print(f"Channel: {channel.display_name} ({channel.id})")
# Get channel providers
providers = await client.channels.list_providers(channels[0].id)
for p in providers:
print(f"Provider: {p.provider} ({p.provider_channel_name})")
await client.close()
asyncio.run(main())
WebSocket Real-time Events
import asyncio
from synchra import SynchraClient
async def main():
client = SynchraClient(access_token="YOUR_ACCESS_TOKEN")
# Register an event handler
@client.ws.on("activity")
async def on_activity(event):
data = event['data']
print(f"[{event['type']}] New {data['type']} from {data['viewer_display_name']}")
# Connect and subscribe
await client.connect()
await client.ws.subscribe("activity", channel_id="YOUR_CHANNEL_UUID")
# Keep the client running
try:
while True:
await asyncio.sleep(1)
except KeyboardInterrupt:
await client.close()
asyncio.run(main())
Development & Testing
The SDK includes a full test suite using pytest.
# Install dev dependencies
pip install "synchra[dev]"
# Run tests
python -m pytest tests/
API Groups
client.channels: Main channel operations, provider listings, and Invite/Access Management.client.twitch: Twitch-specific features (Ban, Unban, Raid, Shoutout, Emulation).client.youtube: YouTube broadcasts and moderation.client.kick: Kick-specific moderation tools.client.user: Manage current user profile and linked accounts.client.chat: Send and broadcast chat messages across platforms.
Supported Platforms
- Twitch: Full moderation, raids, shoutouts, and EventSub emulation.
- YouTube: Broadcast management and moderation.
- Kick: Ban/Unban support.
- TikTok: Stream monitoring (experimental).
- Discord/Spotify: Integration support.
Invite & Access Management
Synchra v2.0 supports sophisticated member management for your channels:
from synchra import Synchra
from synchra.models import AccessLevel
# List current active invites
invites = await client.channels.list_invites(channel_id)
# Create a new Moderator invite
new_invite = await client.channels.create_invite(channel_id, access_level=AccessLevel.MOD)
print(f"Invite Link: {new_invite.invite_link}")
# List users who already have access
staff = await client.channels.list_user_access(channel_id)
# Upgrade a user to Admin
await client.channels.update_user_access(channel_id, staff[0].id, AccessLevel.ADMIN)
# Revoke an invite
await client.channels.delete_invite(channel_id, invites[0].id)
Documentation
For full API documentation and endpoint details, refer to the Synchra OpenAPI Spec.
License
MIT
Metadata
Release files for synchra.py 0.4.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 | |
|---|---|---|---|
| synchra_py-0.4.1.tar.gz | 25.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| synchra_py-0.4.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 53.1 kB
Release files / synchra_py-0.4.1.tar.gz
| Download URL | synchra_py-0.4.1.tar.gz |
|---|---|
| Size | 25.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4ddc27783ccebc3818dbc61e06ddd3018dc6396711f57934426e50ef607a8416
|
|
BLAKE2b-256 checksum How to use checksums |
574fa8f4d9ed93ab3cfbcb1679789e46c16dc097e10eb0c23e5f460ca3b9a34b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|
Release files / synchra_py-0.4.1-py3-none-any.whl
| Download URL | synchra_py-0.4.1-py3-none-any.whl |
|---|---|
| Size | 27.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0945701774ce25f14291322c9d7d4a93d50a4451c5ddae2bb8f9a5fd67ae8132
|
|
BLAKE2b-256 checksum How to use checksums |
95f8f9167b356bb39074ca3316ede8c5dc536ba879324c6b62d60cf6cdd474a2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|