Code Monkey home page Code Monkey logo

node-challonge's Introduction

##Usage

###Get all tournaments on your account

var challonge = require('./node-challonge');

var client = challonge.createClient({
	apiKey: '***yourAPIKey***'
});


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

###Create a tournament

var challonge = require('./node-challonge');

// create a new instance of the client
var client = challonge.createClient({
	apiKey: '***yourAPIKey***',
});

// create a tournament
client.tournaments.create({
	tournament: {
		name: 'new_tournament_name',
		url: 'new_tournament_url',
		tournamentType: 'single elimination',
	},
	callback: function(err, data){
		if (err) { console.log(err); 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(err, 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:


The structure of this api wrapper is ripped off from https://github.com/nodejitsu/nodejitsu-api

node-challonge's People

Contributors

tidwell avatar ricardojoaoreis avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.