challonge-get
Node.js endpoint for every Challonge API v1 GET method. See https://api.challonge.com/v1 for methods and parameters.
Currently, only authenticated (HTTPS) API requests are implemented. From Challonge API:
All interactions with the API require a Challonge account with a verified email address and API key. You can generate one from your developer settings page.
Usage
Install packages. From within the project directory:
npm install
To use in a script, create a new API instance:
const challonge = ;api = <api_key>
Then you can access different endpoints of the API with
api.<tournaments|participants|matches|matchAttachments>.<index()|show()>
async { /** Retrieve a set of tournaments created with your account. */ const tournaments = await apitournamentsindex'all'; /** * Retrieve a tournament with the * given Tournament ID (e.g. 10230) * or URL (e.g. 'single_elim' for challonge.com/single_elim) */ const tournament = await apitournaments; /** Retrieve all the participants for tournament 10230 */ const participants = await apiparticipantsindex'10230'; /** Retrieve a participant with ID 183240 */ const participant = await apiparticipants; /** Retrieve all the matches for a tournament with ID 10230 */ const matches = await apimatchesindex'10230'; /** Retrieve a match with ID 273421*/ const match = await apimatches;
! Match Attachments are not available at this time - further testing is required !
Each method has an .index()
and an .show()
method. .index()
returns an Array of JSON objects matching the search criteria (determined by the type of object it's called on). .show()
returns an individual JSON object by it's search criteria, typically a unique ID.
Note that these functions are async
!
See code comments or the JSDoc for more details on function parameters.
Errors
challonge-get does not handle node-fetch
errors, it passes them up to the calling function.
Tests
Install dev depenancies:
npm install --dev
Create a .credentials.json in the ./tests
folder:
Run tests:
npm test
Note that there is no error handling at the moment, and Challonge (seems?) to have a rate limit (but it's not known). Calls may fail when done in rapid succession.
Contributing
challonge-get is open for contributions. Please use the issue tracker to report any problems or make a pull request and I'll get to it as soon as I can. Thanks!