Chaturbate Poller is a Python library for interacting with the Chaturbate API. It allows you to poll events asynchronously, handle various event types, and optionally store event data in InfluxDB for further analysis or monitoring.
- Event Polling: Fetch events from the Chaturbate API using Python's asyncio.
- Error Handling: Includes retry logic for basic error handling during polling.
- Optional Logging: Configurable logging to keep track of polling activity.
- InfluxDB Support: Optionally store events in InfluxDB if data storage is required.
Make sure you have Python 3.11 or later installed, then install the package:
pip install chaturbate-poller
To get started, create a .env
file in the root of your project directory. This file will store your API credentials and (if applicable) InfluxDB connection details:
CB_USERNAME="your_chaturbate_username"
CB_TOKEN="your_chaturbate_token"
INFLUXDB_URL="http://influxdb:8086"
INFLUXDB_TOKEN="your_influxdb_token"
INFLUXDB_ORG="chaturbate-poller"
INFLUXDB_BUCKET="your_bucket"
USE_DATABASE="true" # Enable if you plan to use InfluxDB
Note
To create an API token, click here: https://chaturbate.com/statsapi/authtoken/
Important
Ensure you have the "Events API" permission selected before generating
You run Chaturbate Poller directly from the command line:
python -m chaturbate_poller --username <your_username> --token <your_token>
For more options:
python -m chaturbate_poller --help
To run Chaturbate Poller in a Docker container:
docker pull ghcr.io/mountaingod2/chaturbate_poller:latest
docker run \
-e CB_USERNAME="your_chaturbate_username" \
-e CB_TOKEN="your_chaturbate_token" \
ghcr.io/mountaingod2/chaturbate_poller:latest --verbose --testbed
You can also import it into your programs. Here’s a simple example of how to fetch events in a loop using the library asynchronously:
import asyncio
from chaturbate_poller import ChaturbateClient
async def main():
async with ChaturbateClient("your_username", "your_token") as client:
url = None
while True:
response = await client.fetch_events(url)
for event in response.events:
# Do something with the received events
print(event.dict())
url = response.next_url
if __name__ == "__main__":
asyncio.run(main())
-
Clone the repository:
git clone https://github.com/MountainGod2/chaturbate_poller.git cd chaturbate_poller
-
Install dependencies using uv:
uv venv .venv uv pip install . -e
Contributions are welcome! If you'd like to contribute:
- Fork the repository.
- Create a new feature branch.
- Submit a pull request.
Please ensure that any changes pass tests and follow coding guidelines.
This project is licensed under the MIT License. See the LICENSE file for more information.