Async Python client for the Chaturbate Events API.
Project description
CB Events
Async Python client for the Chaturbate Events API.
Installation
uv pip install cb-events
Quick Start
import asyncio
from cb_events import EventClient, Router, EventType, Event
router = Router()
@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")
# Any async callable (functions, functools.partial wrappers, async callable objects)
# can be registered with the router.
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 ClientConfig
config = ClientConfig(
timeout=10, # Request timeout (seconds)
use_testbed=False, # Use testbed endpoint with test tokens
strict_validation=True, # Raise on invalid events vs. skip
retry_attempts=8, # Total attempts (initial + retries)
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. Pass config as a keyword argument.
Rate Limiting
Default: 2000 requests per 60 seconds per client. Share a rate limiter across multiple 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 for incompatible event types or invalid data:
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 - check e.status_code, e.response_text
pass
Retries: Automatic on 429, 5xx, and Cloudflare errors. Auth errors don't retry.
Handlers: Run sequentially. Non-cancellation errors are logged but don't stop other handlers; cancellations propagate.
Logging
import logging
logging.getLogger('cb_events').setLevel(logging.DEBUG)
Requirements
Python ≥3.12 - See 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
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-5.5.1.tar.gz.
File metadata
- Download URL: cb_events-5.5.1.tar.gz
- Upload date:
- Size: 198.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
59ed3f198fbf243efa6e29f1b52f00ad435151bf7d868e32344f4a8dcaf161a8
|
|
| MD5 |
dd1f3a9fcb400c0779dc0d82c1e98d99
|
|
| BLAKE2b-256 |
7b4af53fee7502b7f6d8c34aa8f6564e671f2d4a94da7e1f4fa9d13c8571aec2
|
Provenance
The following attestation bundles were made for cb_events-5.5.1.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-5.5.1.tar.gz -
Subject digest:
59ed3f198fbf243efa6e29f1b52f00ad435151bf7d868e32344f4a8dcaf161a8 - Sigstore transparency entry: 702114249
- Sigstore integration time:
-
Permalink:
MountainGod2/cb-events@d760ef6c835d54e085f7372d5ebdbdf678e1477c -
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@d760ef6c835d54e085f7372d5ebdbdf678e1477c -
Trigger Event:
push
-
Statement type:
File details
Details for the file cb_events-5.5.1-py3-none-any.whl.
File metadata
- Download URL: cb_events-5.5.1-py3-none-any.whl
- Upload date:
- Size: 15.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bff92271c5aa4ca4f53a3c6502e12f8f4224c354c46578f3ae2e13a87671f7ca
|
|
| MD5 |
4ad737737b65016e40653e79bc4efc05
|
|
| BLAKE2b-256 |
13f753faf71c16d619e71bffb3ece18b3b4d4788bc6a016941fba77aafc6bafe
|
Provenance
The following attestation bundles were made for cb_events-5.5.1-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-5.5.1-py3-none-any.whl -
Subject digest:
bff92271c5aa4ca4f53a3c6502e12f8f4224c354c46578f3ae2e13a87671f7ca - Sigstore transparency entry: 702114250
- Sigstore integration time:
-
Permalink:
MountainGod2/cb-events@d760ef6c835d54e085f7372d5ebdbdf678e1477c -
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@d760ef6c835d54e085f7372d5ebdbdf678e1477c -
Trigger Event:
push
-
Statement type: