Skip to main content

Async Python client for the Chaturbate Events API.

Project description

CB Events

Async Python client for the Chaturbate Events API.

PyPI Python License

Installation

uv pip install cb-events

Quick Start

import asyncio
from cb_events import EventClient, EventRouter, EventType, Event

router = EventRouter()

@router.on(EventType.TIP)
async def handle_tip(event: Event) -> None:
    if event.user and event.tip:
        print(f"{event.user.username} tipped {event.tip.tokens} tokens")

async def main():
    async with EventClient(username, token) as client:
        async for event in client:
            await router.dispatch(event)

asyncio.run(main())

Event Types

TIP · FANCLUB_JOIN · MEDIA_PURCHASE · CHAT_MESSAGE · PRIVATE_MESSAGE · USER_ENTER · USER_LEAVE · FOLLOW · UNFOLLOW · BROADCAST_START · BROADCAST_STOP · ROOM_SUBJECT_CHANGE

Configuration

from cb_events import EventClientConfig

config = EventClientConfig(
    timeout=10,              # Request timeout (seconds)
    use_testbed=False,       # Use testbed endpoint
    retry_attempts=8,        # Max retry attempts
    retry_backoff=1.0,       # Initial backoff (seconds)
    retry_factor=2.0,        # Backoff multiplier
    retry_max_delay=30.0,    # Max retry delay (seconds)
)

client = EventClient(username, token, config=config)

Note: Config is immutable after creation. config parameter must be passed as keyword argument.

Rate Limiting

Default: 2000 requests/60s per client. Share rate limiter across clients:

from aiolimiter import AsyncLimiter

limiter = AsyncLimiter(max_rate=2000, time_period=60)
client1 = EventClient(username1, token1, rate_limiter=limiter)
client2 = EventClient(username2, token2, rate_limiter=limiter)

Event Properties

Properties return None on incompatible event types:

event.user          # User object (most events)
event.tip           # Tip object (TIP only)
event.message       # Message object (CHAT_MESSAGE, PRIVATE_MESSAGE)
event.room_subject  # RoomSubject object (ROOM_SUBJECT_CHANGE)
event.broadcaster   # Broadcaster username string

Error Handling

from cb_events import AuthError, EventsError

try:
    async with EventClient(username, token) as client:
        async for event in client:
            await router.dispatch(event)
except AuthError:
    # Authentication failed (401/403)
    pass
except EventsError as e:
    # API/network errors - e.status_code, e.response_text
    pass

Retries: Automatic on 429, 5xx, Cloudflare errors. No retry on auth errors.

Handlers: Execute sequentially. If a handler raises an exception, it propagates immediately and stops subsequent handlers.

Logging

import logging

## Error Handling

```python
from cb_events import AuthError, EventsError

try:
    async with EventClient(username, token) as client:
        async for event in client:
            await router.dispatch(event)
except AuthError:
    # Authentication failed (401/403)
    pass
except EventsError as e:
    # API/network errors - e.status_code, e.response_text
    pass

Retries: Automatic on 429, 5xx, Cloudflare errors. No retry on auth errors.

Handlers: Execute sequentially. If a handler raises an exception, it propagates immediately and stops subsequent handlers.

Logging

import logging

logging.getLogger('cb_events').setLevel(logging.DEBUG)

Requirements

Python ≥3.12 - Dependencies

License

MIT - See LICENSE


Not affiliated with Chaturbate.

Project details


Release history Release notifications | RSS feed

Download files

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

Source Distribution

cb_events-4.7.1.tar.gz (186.9 kB view details)

Uploaded Source

Built Distribution

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

cb_events-4.7.1-py3-none-any.whl (15.8 kB view details)

Uploaded Python 3

File details

Details for the file cb_events-4.7.1.tar.gz.

File metadata

  • Download URL: cb_events-4.7.1.tar.gz
  • Upload date:
  • Size: 186.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for cb_events-4.7.1.tar.gz
Algorithm Hash digest
SHA256 9c9ff1bb94133251013c178a4549e331d869ea14841be21a3f713d3fac900b1f
MD5 cbfea544668e86eb4480938213e3da1b
BLAKE2b-256 ac585a89dbb2abb6aa03b55297a0629c59869d3ef2c6b79bd80801cdfc1e4ab0

See more details on using hashes here.

Provenance

The following attestation bundles were made for cb_events-4.7.1.tar.gz:

Publisher: ci-cd.yml on MountainGod2/cb-events

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cb_events-4.7.1-py3-none-any.whl.

File metadata

  • Download URL: cb_events-4.7.1-py3-none-any.whl
  • Upload date:
  • Size: 15.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for cb_events-4.7.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5bc386ef755422a0b4c9280b2291856daff7fc4087a0202df85589427825a768
MD5 dfe7f60045b669c8dbc5dfc787c38705
BLAKE2b-256 2447d6dbd3b755d5c9e4ed32f8132c112168768146ef7fa534f2438c008924c0

See more details on using hashes here.

Provenance

The following attestation bundles were made for cb_events-4.7.1-py3-none-any.whl:

Publisher: ci-cd.yml on MountainGod2/cb-events

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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