Skip to main content

Lightweight Python wrapper for the Challonge API

Project description

pychallonge

Lightweight Python wrapper for the Challonge API. The pychallonge module was created by Russ Amos and maintained by George Lemanis

Python version support

  • 3.10 or later

Installation

The pychallonge package is available on PyPI and you can install it through your favorite package manager:

pip install pychallonge

Usage

from challonge import Client

# Create a client with your Challonge API credentials.
client = Client(user="your_challonge_username", api_key="your_api_key")

# Retrieve a tournament by its id (or its url).
tournament = client.tournaments.show(3272)

# Tournaments, matches, and participants are returned as typed dataclasses.
print(tournament.id)          # 3272
print(tournament.name)        # My Awesome Tournament
print(tournament.started_at)  # None

# Retrieve the participants for a given tournament.
participants = client.participants.index(tournament.id)
print(len(participants))  # 13

# Mutations (POST/PUT) return the updated resource directly.
tournament = client.tournaments.start(tournament.id)
print(tournament.started_at)  # 2011-07-31 16:16:02-04:00

# Close the client when done, or use it as a context manager.
client.close()

Context manager

with Client(user="your_challonge_username", api_key="your_api_key") as client:
    tournament = client.tournaments.show(3272)

Async

from challonge import AsyncClient

async with AsyncClient(user="your_challonge_username", api_key="your_api_key") as client:
    tournament = await client.tournaments.show(3272)
    participants = await client.participants.index(tournament.id)

Timezone

By default datetime fields are normalised to your machine's local timezone. Pass a timezone string to override:

client = Client(user="your_challonge_username", api_key="your_api_key", timezone="UTC")

See challonge.com for full API documentation.

API Issues

The Challonge API has some issues with the attachments endpoints. When uploading an attachment with a file (asset), the API returns a 500 internal server error. This issue has been reported to Challonge.

The check-in undo endpoint has unexpected behaviour: the checked_in field in the API response remains True even after a successful undo. The participant is correctly marked as not checked in on the website.

Running the tests

Tests make real API calls and require a Challonge account. Set CHALLONGE_USER and CHALLONGE_KEY in your environment before running.

$ git clone https://github.com/ZEDGR/pychallonge
$ cd pychallonge
$ CHALLONGE_USER=my_user CHALLONGE_KEY=my_api_key uv run pytest tests.py -v

Note that several tournaments are created and destroyed over the course of the tests. If any test fails mid-run, orphaned tournaments can be cleaned up as follows:

from challonge import Client

with Client(user="my_user", api_key="my_api_key") as client:
    for t in client.tournaments.index():
        if t.name.startswith("pychal"):
            client.tournaments.destroy(t.id)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pychallonge-3.0.0.tar.gz (30.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pychallonge-3.0.0-py3-none-any.whl (8.7 kB view details)

Uploaded Python 3

File details

Details for the file pychallonge-3.0.0.tar.gz.

File metadata

  • Download URL: pychallonge-3.0.0.tar.gz
  • Upload date:
  • Size: 30.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pychallonge-3.0.0.tar.gz
Algorithm Hash digest
SHA256 8be51714c7209c33dd7b15d87612c1a00090aba04de8c09cfe348536ce007ab4
MD5 1f8d90e8c698ff0cb609e9d8c79cdfba
BLAKE2b-256 db7e6dd376dfe2cdc1e5bd277c875d0a4b5b3a068eda465667c49ba9ab26a0bd

See more details on using hashes here.

Provenance

The following attestation bundles were made for pychallonge-3.0.0.tar.gz:

Publisher: publish.yml on ZEDGR/pychallonge

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pychallonge-3.0.0-py3-none-any.whl.

File metadata

  • Download URL: pychallonge-3.0.0-py3-none-any.whl
  • Upload date:
  • Size: 8.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pychallonge-3.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2af46e7fe38d1a5bf8210ac685766650b053cc18ab98fcddf231407107ce410a
MD5 c4599478defb7d73a46c9770614ccbf1
BLAKE2b-256 b9bb62336cdc389beb9ce58e44b0f1ce0932e9886fad94a4316e85efa1e78d75

See more details on using hashes here.

Provenance

The following attestation bundles were made for pychallonge-3.0.0-py3-none-any.whl:

Publisher: publish.yml on ZEDGR/pychallonge

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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