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

Python version support

  • 3.10+

Installation

For the stable version

pip install pychallonge

For latest development

pip install -e git+https://github.com/ZEDGR/pychallonge#egg=pychallonge

Usage

import challonge

# Tell pychallonge about your [Challonge API credentials](http://api.challonge.com/v1).
challonge.set_credentials("your_challonge_username", "your_api_key")

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

# Tournaments, matches, and participants are all represented as normal Python dicts.
print(tournament["id"]) # 3272
print(tournament["name"]) # My Awesome Tournament
print(tournament["started_at"]) # None

# Retrieve the participants for a given tournament.
participants = challonge.participants.index(tournament["id"])
print(len(participants)) # 13

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

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.

Datetime fields from the API carry inconsistent timezone offsets. Pychallonge normalises these to your machine's local timezone. You can also set a specific timezone with the set_timezone function.

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 python -m unittest tests.py

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:

import challonge
challonge.set_credentials("my_user", "my_api_key")
for t in challonge.tournaments.index():
    if t["name"].startswith("pychal"):
        challonge.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-2.0.0.tar.gz (30.4 kB view details)

Uploaded Source

Built Distribution

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

pychallonge-2.0.0-py3-none-any.whl (10.4 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for pychallonge-2.0.0.tar.gz
Algorithm Hash digest
SHA256 f6b6daa4a5b34af22ef163708bc7bccd082f833b76bb416e128058a23dc29ecd
MD5 376fec6cfae4ce80f938c7b4df8d1471
BLAKE2b-256 60ce3ea31877b15c1151db6013a3d165befda70800fa80f228fd6a032c1bf64a

See more details on using hashes here.

Provenance

The following attestation bundles were made for pychallonge-2.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-2.0.0-py3-none-any.whl.

File metadata

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

File hashes

Hashes for pychallonge-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3f5350bfc5f6d7c2905ddb9c2c09e3fed38df68c7e85c2d06c9dad4c34c9eed9
MD5 f21f50ee77fd5af5df190e862eb3e04c
BLAKE2b-256 5a374d180fb7565ad1a6095556f04ab8ccada918fd273fbecf63569209f19899

See more details on using hashes here.

Provenance

The following attestation bundles were made for pychallonge-2.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