MingweiSamuel / TeemoJS

A Fast & Lightweight Riot API Wrapper For Javascript
GNU Lesser General Public License v3.0
45 stars 5 forks source link

TeemoJS

TeemoJS is a fast and lightweight Riot API wrapper written in Node.js. Contained in about 300 lines, it has a minimalist design to make it flexible and easy to maintain. There is a specific set of things TeemoJS aims to do, and it aims to do them well:

It is up to the developer to do the rest.

TeemoJS supports the new TFT APIs.

Installation

npm install --save teemojs

Usage

const TeemoJS = require('teemojs');
let api = TeemoJS('RGAPI-KEY-HERE');

api.get('na1', 'summoner.getBySummonerName', 'LUG nutsk')
  .then(data => console.log(data.name + "'s summoner id is " + data.id + '.'));

// Get C9 Sneaky's games on Ezreal and Kalista for a particular season.
api.get('na1', 'match.getMatchlist', 78247, { champion: [81, 429], season: 8 })
  .then(...);

All requests are done via .get(...).

*Note: this is optional if config.prefix isn't interpolated in custom or Champion.GG configurations.

Configuration

The TeemoJS constructor can take an second argument which is a configuration object. defaultConfig.json is used by default. The supplied config object will override any corresponding values in the defaultConfig. The configuration specifies the number of retries and maximum concurrent requests, as well as the Riot API endpoint URLs.

Constructors with config

let api = TeemoJS('RGAPI-KEY-HERE', config);
let api = TeemoJS(configWithKey);

config Object

Only modify the following properties if you know what you're doing. This is mainly documentation for future reference.

Setting defaultConfig & Other premade configurations

defaultConfig is stored in the TeemoJS.defaultConfig property and can be changed if needed.

There are three more premade configurations provided:

Champion.GG Example:

let api = TeemoJS('cgg0api0key', TeemoJS.championGGConfig);
api.get('champion.getChampion', 143)
  .then(data => console.log("Zyra's winrate as " + data[0].role + ' is ' + data[0].winRate + '.'));