A Python 3.8+ implementation of the challonge.com API.
Project description
chyllonge
A Python 3.8+ implementation of the challonge.com API.
Prerequisites
chyllonge
requires that the CHALLONGE_KEY
and CHALLONGE_USER
environment variables are set.
CHALLONGE_USER
is yourchallonge.com
username.CHALLONGE_KEY
is yourchallonge.com
API key. An API key can be generated here.
chyllonge
also allows a CHALLONGE_IANA_TZ_NAME
environment variable, which accepts an
IANA-compliant time zone name - for
example: Europe/Berlin
.
Installation
To install chyllonge
, execute pip install chyllonge
.
Usage
Detailed API documentation is available at https://api.challonge.com/v1.
from chyllonge.api import ChallongeAPI
from datetime import datetime, timedelta
api = ChallongeAPI()
# create a basic tournament
tournament = api.tournaments.create(name="My Chyllonge Tournament")
print(tournament["id"])
# create a tournament that starts in an hour
an_hour_from_now = (datetime.now() + timedelta(hours=1)).isoformat() + api.http.tz_utc_offset_string
tournament = api.tournaments.create(name="My Chyllonge Tournament", start_at=an_hour_from_now, check_in_duration=60)
print(tournament["id"])
# create a tournament, add Alice and Bob, process their check-ins, start the tournment, set their match underway,
# score their match (congratulations Alice!), finalize the tournament
an_hour_from_now = (datetime.now() + timedelta(hours=1)).isoformat() + api.http.tz_utc_offset_string
tournament = api.tournaments.create(name="Alice and Bob Play Bingo", start_at=an_hour_from_now, check_in_duration=60)
api.participants.add(tournament["id"], name="Alice")
api.participants.add(tournament["id"], name="Bob")
api.tournaments.process_checkins(tournament["id"])
api.tournaments.start(tournament["id"])
match = api.matches.get_all(tournament_id=tournament["id"])[0]
alice = api.participants.get_all(tournament["id"])[0]
api.matches.set_underway(tournament["id"], match["id"])
api.matches.update(tournament["id"], match["id"], match_scores_csv="3-1,2-2", match_winner_id=alice["id"])
api.tournaments.finalize(tournament["id"])
finished_tournment = api.tournaments.get(tournament["id"])
History
chyllonge
was inspired by pychallonge
- developed by Russ Amos - which (in turn) includes pychal
.
See CONTRIBUTORS.txt
for the original authors.
Testing
To run local tests, run python -m unittest tests/tests.py
.
Note that the unit tests will create tournaments in your account, called chyllonge-temp
. It will try to delete them
afterward, but automated cleanup is not always guaranteed.
Contributing
Please feel free to contribute, and to suggest updates to these contribution guidelines!
The current guidelines are:
- Functions should be documented in-line using
reStructuredText
format. - Support for older Python versions should be dropped as those minor updates approach end-of-life.
- There are no plans to support XML for the time being (although this is a nice-to-have).
Building
chyllonge
is built using flit
and build
.
Releases
New versions of chyllonge
are released to PyPI with the help of a GitHub Action workflow, which:
- Updates the
pyproject.toml
version - Creates a GitHub release
- Invokes
build
, which publishes to PyPI
Non-frequently Asked Questions
Q: How do you pronounce chyllonge
?
A: Like "chill-ahnge".
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
Built Distribution
File details
Details for the file chyllonge-1.1.1.tar.gz
.
File metadata
- Download URL: chyllonge-1.1.1.tar.gz
- Upload date:
- Size: 11.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c51a58bce813c92536253dd0dd566783b89a5c566276c700631cf06a99e13464 |
|
MD5 | 6f6059def817c36a2a3d97dcb8fea5ec |
|
BLAKE2b-256 | 1a3a65077553c72fa01062e26dd7dd0ee219311111bfce4651cbeac48be15e3e |
File details
Details for the file chyllonge-1.1.1-py3-none-any.whl
.
File metadata
- Download URL: chyllonge-1.1.1-py3-none-any.whl
- Upload date:
- Size: 10.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bc1d01bc084cbb2a66194f7d663fea54c03eaafe5865fab6924afb6327e95d77 |
|
MD5 | 94f08b7fc70b76f032abe94377d0d493 |
|
BLAKE2b-256 | 7eb8da246ad58658db3571a10a29ee33d7ae965fd736957ad02ae4bb80614241 |