Skip to main content

A modern, async-first Python SDK for the Synchra API v2.0.

Project description

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 asyncio using aiohttp.
  • 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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

synchra_py-0.3.0.tar.gz (25.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

synchra_py-0.3.0-py3-none-any.whl (27.5 kB view details)

Uploaded Python 3

File details

Details for the file synchra_py-0.3.0.tar.gz.

File metadata

  • Download URL: synchra_py-0.3.0.tar.gz
  • Upload date:
  • Size: 25.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for synchra_py-0.3.0.tar.gz
Algorithm Hash digest
SHA256 196f1e710f488a1afb3d3ee9ab07b4d2ef20c5bcc40f61a3d0d44fd12fd25f5b
MD5 563abb997498a71fcc6a0358f1ddd457
BLAKE2b-256 c9c263709e90d2066bff16d1bf5907ecaa20156a5df991f50e86697958b38933

See more details on using hashes here.

File details

Details for the file synchra_py-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: synchra_py-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 27.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for synchra_py-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6c5c9e9dc517d1aa74a68d5e365b42da46f2622e925ff1f4437f1c5014cc703b
MD5 7cd8d7ccfb0a9c8aef0c6b344ef9d7ec
BLAKE2b-256 ccf52d09312b8dd62eeb4d7b0742c8a306cf5bf0a45cf97fb9eb901b8c5e9ce3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page