Skip to main content

Poller for the Chaturbate events API.

Project description

Chaturbate Poller

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.

Read the Docs Codecov Coverage CodeFactor Grade Workflow Status License Python Version Version

Features

  • 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.

Installation

Make sure you have Python 3.11 or later installed, then install the package:

pip install chaturbate-poller

Configuration

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

Usage

Command-Line Tool

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

Docker Usage

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

Library Example

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())

Development Setup

  1. Clone the repository:

    git clone https://github.com/MountainGod2/chaturbate_poller.git
    cd chaturbate_poller
    
  2. Install dependencies using uv:

    uv venv .venv
    uv pip install . -e
    

Contributing

Contributions are welcome! If you'd like to contribute:

  1. Fork the repository.
  2. Create a new feature branch.
  3. Submit a pull request.

Please ensure that any changes pass tests and follow coding guidelines.

License

This project is licensed under the MIT License. See the LICENSE file for more information.

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

chaturbate_poller-0.13.2.tar.gz (132.2 kB view details)

Uploaded Source

Built Distribution

chaturbate_poller-0.13.2-py3-none-any.whl (20.6 kB view details)

Uploaded Python 3

File details

Details for the file chaturbate_poller-0.13.2.tar.gz.

File metadata

  • Download URL: chaturbate_poller-0.13.2.tar.gz
  • Upload date:
  • Size: 132.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for chaturbate_poller-0.13.2.tar.gz
Algorithm Hash digest
SHA256 b6a9825fe6bf2215090f0770e0e06a8a828d95ff529aab2c47e4286d74366a56
MD5 0c5992a6bc1d8e88043f47f2b0a5beea
BLAKE2b-256 5cd79b1781193e167c3195c7f2e289f497580837f6886e5a450d586d7a896caa

See more details on using hashes here.

File details

Details for the file chaturbate_poller-0.13.2-py3-none-any.whl.

File metadata

File hashes

Hashes for chaturbate_poller-0.13.2-py3-none-any.whl
Algorithm Hash digest
SHA256 679410f481e7c0c9090ee63155539b9b0951f17e53e2bb960bdf686d8b90219f
MD5 9b6d8d1b635b97a46cc09fbdae4c711d
BLAKE2b-256 c1ffa2c2dbe86dbd958987b7aa3fe37c759c4cca7499079aaeb87ce907e02c3d

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page