npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

challonge-js

v1.1.1

Published

Wrapper for the challonge api.

Downloads

3

Readme

##Usage

###Get all tournaments on your account

const challonge = require('./node-challonge');
const client = challonge.createClient({
  apiKey: '<yourApiKey>'
});

client.tournaments.index({
  callback: function (error, data) {
    if (error) { console.log(error); return; }
    console.log(data);
  }
});

###Create a tournament

const challonge = require('./node-challonge');
const client = challonge.createClient({
  apiKey: '<yourApiKey>'
});

client.tournaments.create({
  tournament: {
    name: 'new_tournament_name',
    url: 'new_tournament_url',
    tournamentType: 'single elimination'
  },
  callback: function (error, data) {
    if (error) { console.log(error); return; }
    console.log(data);
  }
});

##API Client

createClient takes one argument for configuration and returns an instance of the api client. The configuration object can contain the following options:

  • apiKey string (required) - Your challonge API Key

  • subdomain string (optional) - Setting the subdomain automatically passes tournament[subdomain] and prefixes the subdomain to tournament urls. If you don't want to pass a subdomain to the constructor, and want to use an organization (or multiple organizations), you must use client.setSubdomain('subdomain') before making api calls.

  • format string (optional) - The format of the response data. Defaults to 'json'. If set to 'json', will return javascript objects. 'xml' will return the raw text string.

  • massageProperties boolean (optional) - If the response object should be massaged into camelCase properties when using json format. Defaults to true.

The wrapper is organized into resource.method to match the API

For API calls that require nested params (eg: http://api.challonge.com/v1/documents/tournaments/create) properties should be specified as a nested object:

{
	tournament: {
		name: 'new_tournament_name',
		url: 'new_tournament_url',
		tournamentType: 'single elimination'
	},
	callback: function (error, data) {}
}

All properties can be specified camelCase instead of using under_scores Both of the following are valid:

tournament: { tournamentType: 'single elimination' }
tournament: { tournament_type: 'single elimination' }

##TODO

  1. validate required params
  2. docs
  3. tests

##Bugs in the API / docs

Some minor gatchas:

  • server 500s if trying to finalize() a tournament that has not yet been start()ed

  • http://api.challonge.com/v1/documents/participants/create shows participant_id as a required field when the server does not respect passing it, and is not required.

  • http://api.challonge.com/v1/documents/participants/randomize shows participant_id as a required field when the server does not respect passing it, and is not required.


The structure of this api wrapper is ripped off from https://github.com/nodejitsu/nodejitsu-api
This repository was forked from https://github.com/Tidwell/node-challonge