An asynchronous client for the Chaturbate Events API.
Project description
CB Events
Async Python client for the Chaturbate Events API with real-time event streaming.
Installation
$ uv pip install cb-events
Usage
import asyncio
import os
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")
@router.on(EventType.CHAT_MESSAGE)
async def handle_chat(event: Event) -> None:
if event.user and event.message:
print(f"{event.user.username}: {event.message.message}")
async def main():
username = os.getenv("CB_USERNAME")
token = os.getenv("CB_TOKEN")
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_PURCHASECHAT_MESSAGE,PRIVATE_MESSAGEUSER_ENTER,USER_LEAVE,FOLLOW,UNFOLLOWBROADCAST_START,BROADCAST_STOP,ROOM_SUBJECT_CHANGE
Configuration
Environment variables:
export CB_USERNAME="username"
export CB_TOKEN="api_token"
Direct instantiation:
from cb_events import EventClient, EventClientConfig
client = EventClient("username", "token")
Configuration options (defaults shown):
from cb_events import EventClient, EventClientConfig
client = EventClient(
username="your_username",
token="your_api_token",
config=EventClientConfig(
timeout=10, # Timeout for API requests in seconds
use_testbed=False, # Use testbed API endpoint
retry_attempts=8, # Maximum retry attempts for failed requests
retry_backoff=1.0, # Initial backoff time in seconds
retry_factor=2.0, # Exponential backoff multiplier
retry_max_delay=30.0, # Maximum delay between retries in seconds
)
)
Note: The config parameter must be passed as a keyword argument.
Error Handling
from cb_events import AuthError, EventsError, RouterError
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 RouterError as e:
# Handler execution failed
print(f"Handler '{e.handler_name}' failed on {e.event_type}")
except EventsError as e:
# API errors (HTTP errors, network issues)
if e.status_code:
print(f"API error {e.status_code}: {e.message}")
Handler exceptions are caught, logged, and re-raised as RouterError with context.
Automatic retry on 429, 5xx, and Cloudflare error codes. No retry on authentication errors.
Requirements
- Python ≥3.11
- aiohttp, pydantic, aiolimiter
$ uv pip compile pyproject.toml -o requirements.txt
License
MIT licensed. See LICENSE.
Disclaimer
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cb_events-3.0.2.tar.gz.
File metadata
- Download URL: cb_events-3.0.2.tar.gz
- Upload date:
- Size: 199.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5fe8dca9e8737a65b72545e7c3b2962bcd1c3ba47d2bc31a6ce59c6ae96e1431
|
|
| MD5 |
7c50c3129330fbf82226a567cf3bdb13
|
|
| BLAKE2b-256 |
5613919c4206eef7424f338a05339b109c6ce407fd707c2f4c25a567a2919ad7
|
Provenance
The following attestation bundles were made for cb_events-3.0.2.tar.gz:
Publisher:
ci-cd.yml on MountainGod2/cb-events
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
cb_events-3.0.2.tar.gz -
Subject digest:
5fe8dca9e8737a65b72545e7c3b2962bcd1c3ba47d2bc31a6ce59c6ae96e1431 - Sigstore transparency entry: 601031747
- Sigstore integration time:
-
Permalink:
MountainGod2/cb-events@fc8a98ac2b07433aa15f1935d1d8fc1387dc9322 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/MountainGod2
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci-cd.yml@fc8a98ac2b07433aa15f1935d1d8fc1387dc9322 -
Trigger Event:
push
-
Statement type:
File details
Details for the file cb_events-3.0.2-py3-none-any.whl.
File metadata
- Download URL: cb_events-3.0.2-py3-none-any.whl
- Upload date:
- Size: 16.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0a478d2eead28c4ed23e0fa50b2fb22d9e3e223ad2f3b37e9b0f3d6f70dcf7a6
|
|
| MD5 |
481207e84298d0b2ebf3b9aed0224c74
|
|
| BLAKE2b-256 |
6b69ad5a1bde22a40302c304abdddee975d95e2b4ac62c673dd1b1f91ec2d454
|
Provenance
The following attestation bundles were made for cb_events-3.0.2-py3-none-any.whl:
Publisher:
ci-cd.yml on MountainGod2/cb-events
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
cb_events-3.0.2-py3-none-any.whl -
Subject digest:
0a478d2eead28c4ed23e0fa50b2fb22d9e3e223ad2f3b37e9b0f3d6f70dcf7a6 - Sigstore transparency entry: 601031755
- Sigstore integration time:
-
Permalink:
MountainGod2/cb-events@fc8a98ac2b07433aa15f1935d1d8fc1387dc9322 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/MountainGod2
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci-cd.yml@fc8a98ac2b07433aa15f1935d1d8fc1387dc9322 -
Trigger Event:
push
-
Statement type: