Async Python client for the Chaturbate Events API.
Project description
CB Events
Async Python client for the Chaturbate Events API.
Installation
pip install cb-events
With uv (recommended):
uv add cb-events
Quick Start
import asyncio
from cb_events import EventClient, Router, EventType, Event
router = Router()
username = "your_username"
token = "your_api_token"
@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())
mountaingod2 tipped 100 tokens
For usage examples, see the examples folder.
Generate an API token at https://chaturbate.com/statsapi/authtoken/ with
Events APIscope.
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, # Server long-poll timeout (seconds)
use_testbed=False, # Use testbed endpoint with test tokens
strict_validation=False, # False skips & logs invalid events; True raises.
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)
next_url_allowed_hosts=None, # None = API host only; tuple adds extra hosts
)
client = EventClient(username, token, config=config)
Rate Limiting
Default: 2000 requests/60s per client.
Shared limiter:
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
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
AuthError is a subclass of EventsError — except EventsError catches both. Put AuthError first if you need to distinguish them.
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) — never retried
pass
except EventsError as e:
# All other API/network errors — check e.status_code, e.response_text
pass
Retries: 429, 5xx, Cloudflare 521-524. Not retriable: 401/403.
Handlers: Sequential execution. Errors logged but don't stop processing.
Logging
Set the logger to DEBUG for verbose polling data:
import logging
logging.getLogger("cb_events").setLevel(logging.DEBUG)
Example output:
DEBUG:cb_events.client:Polling https://eventsapi.chaturbate.com/events/user/************************/?timeout=10
DEBUG:cb_events.client:Received 1 events for user
DEBUG:cb_events.router:Dispatching chatMessage event 1775683684418-0 to 2 handlers
Requirements
Python 3.10+
License
MIT
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-7.1.1.tar.gz.
File metadata
- Download URL: cb_events-7.1.1.tar.gz
- Upload date:
- Size: 263.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
157d82e521c59e7ad2a122e6b078145d429bb20ee2f7032da331ec66708a84df
|
|
| MD5 |
19c86e2f5b8f538d2bddb1459e5099e6
|
|
| BLAKE2b-256 |
a7f22e868d45f0c51c8a1ea4a1952c71c7ef196afac805fa8bb50d25a455db2f
|
Provenance
The following attestation bundles were made for cb_events-7.1.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-7.1.1.tar.gz -
Subject digest:
157d82e521c59e7ad2a122e6b078145d429bb20ee2f7032da331ec66708a84df - Sigstore transparency entry: 1282407006
- Sigstore integration time:
-
Permalink:
MountainGod2/cb-events@51eac6c5d9f1c268a58dc58931f51808b5e44491 -
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@51eac6c5d9f1c268a58dc58931f51808b5e44491 -
Trigger Event:
push
-
Statement type:
File details
Details for the file cb_events-7.1.1-py3-none-any.whl.
File metadata
- Download URL: cb_events-7.1.1-py3-none-any.whl
- Upload date:
- Size: 22.1 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 |
e610bb509eaf02a70b2626de0b5cfb5ab38ee896fbaa92c20964f7dc976a17bf
|
|
| MD5 |
7ad912b8dbfb7e6df56947046b14a4df
|
|
| BLAKE2b-256 |
d5e2aaeaeee7d90e699b97856f8bbef3b8f1c7df62f7455033938d7e044badde
|
Provenance
The following attestation bundles were made for cb_events-7.1.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-7.1.1-py3-none-any.whl -
Subject digest:
e610bb509eaf02a70b2626de0b5cfb5ab38ee896fbaa92c20964f7dc976a17bf - Sigstore transparency entry: 1282407052
- Sigstore integration time:
-
Permalink:
MountainGod2/cb-events@51eac6c5d9f1c268a58dc58931f51808b5e44491 -
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@51eac6c5d9f1c268a58dc58931f51808b5e44491 -
Trigger Event:
push
-
Statement type: