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

riot-games-api-nodejs

v1.0.7

Published

Access Riot Games API with ease.

Downloads

38

Readme

riot-games-api-nodejs

This module is no longer maintained. Pull requests will still be accepted.

NPM

Access all information that Riot provides using thier API. This is an extremly simple node module that allows you to gather information from Riot.

Please refer to the Riot Games Official API. Also, please note that when an update occures to a specific API that you are using, it will most likely break. If this happens, please report it on the github repo.

Quick Example

riot.champion.id(
    '21',
    {},
    function(err, data) {
        if (err instanceof Error) {
            console.log("Error 1: " + err);
            return 0;
        }
        else {
            var rankedEnabled = data.rankedPlayEnabled;
            if (rankedEnabled == true){
                console.log('Champion 21 (Miss Fortune) can be played in ranked');
            } else {
                console.log('Champion 21 (Miss Fortune) can not be played in ranked');
            }
        }
    }
)

Installation

From npm registry

The npm release is always the recent stable version.

npm install riot-games-api-nodejs
var riot = require('riot-games-api-nodejs')

From Github

The code on Github is the most recent version, but may be untested.

git clone https://github.com/hardtacos/riot-games-api-nodejs
cd riot-games-api-nodejs
npm install

var riot = require('/path/to/riot-games-api-nodejs')

Usage

// load the module
var riot = require('riot-games-api-nodejs')

// search by summoner id, their league information
riot.leaugue.bySummoner( "123456", {}, console.log)

Configuration

  • httpProtocol (string)

Which HTTP protocol to use: http (default) or https

  • timeout (integer)

Destroy the request after this number of milliseconds. Default: 30000 (30 sec).

  • developerKey (string)

Example:

var riot = require('riot-games-api-nodejs')
riot.developerKey = '1234578-1234-1234-123456789000'
riot.static.champions( {}, cb );

Callbacks

Each method takes a callback function as last parameter. When everything seems alright err is null, otherwise err will be instanceof Error for tracing.

function( err, data ) {
	if( err instanceof Error ) {
		console.log( err )
	} else {
		console.log( data )
	}
}

Properties:

err.message   : the error message
err.stack     : stack trace
err.origin    : what it relates to (api, method, request)
err.details   : api response or other information when available, or `null`

Messages:

Error: invalid response       api       API response can't be parsed
Error: not json               api       Expected JSON, received something else
Error: not found              method    Requested data was not found
Error: not allowed            method    No permission to requested data
Error: invalid id             method    Requested video ID is invalid
Error: connection closed      api       Connection dropped early
Error: connection error       request   Can't connect to API
Error: request timeout        request   The request took too long to connect or process
Error: error                  api       API returned an error, see err.details
Error: developer key missing  api       developerKey is not set, see Configuration.

===========================================================================================

champion-v1.2

Retrieve Champion Information
riot.champion.all(
     {
        'freeToPlay': 'true'
    },
    console.log
);

riot.champion.id(
    "21", {},
    console.log
)

===========================================================================================

game-v1.3

Retrieve recent games by summoner ID
riot.game.bySummoner(
    
    "5908", {},
    console.log
)

===========================================================================================

league-v2.5

Retrieve league information for both individuals and teams

riot.league.bySummoner(
    "5908", {},
    console.log
);

riot.league.bySummonerEntry(
    "5908, xxxxx", {},
    console.log
);

riot.league.byTeam(
    "TEAM-c80824c9-c568-42de-bdbb-271543b209e1", {},
    console.log
);

riot.league.byTeamEntry(
    "TEAM-c80824c9-c568-42de-bdbb-271543b209e1, xxxxx", {},
    console.log
);

riot.league.challenger(
    {
    	type : 'RANKED_SOLO_5X5'
    },
    console.log
);

===========================================================================================

staticData-v1.2

Retrieve static information about League of Legends (i.e. champions, runes, masteries, items, etc...)

riot.staticData.champions(
    {},
    console.log
);

riot.staticData.championsId(
    "21",
    {},
    console.log
);

riot.staticData.item(
    {
        itemData : 'name, description'
    },
    console.log
);

riot.staticData.itemId(
    '3454',
    {
        itemData : 'stats'
    },
    console.log
);

===========================================================================================

lolStatus-v1.0

Retrieve server statuses

riot.lolStatus(console.log).shards();
riot.lolStatus(console.log).region(settings.region);

===========================================================================================

match-v2.2

riot.match.match(
    "5908",
    {},
    console.log
)

Retrieve match by match ID.

===========================================================================================

matchhistory-v2.2

riot.matchHistory.matchHistory(
    "5908",
    {},
    console.log
)

Retrieve match history by match ID.

===========================================================================================

stats-v1.3

riot.stats.ranked(
    "5908",
    {
        season : 'SEASON4'
    },
    console.log
);

riot.stats.summary(
    "5908",
    {
        season : 'SEASON4'
    },
    console.log
)

Retrieve stats by summoner ID.

===========================================================================================

summoner-v1.4

riot.summoner.byName(
    'Dyrus', //or 'Dyrus,I DIED TO WOLVES,InsertSmurfHere'
    {},
    console.log
);

riot.summoner.summonerIds(
    '5908' //or '5908,52322873,44979373'
    {},
    console.log
);

riot.summoner.masteries(
    '5908' //or '5908,52322873,44979373'
    {},
    console.log
);

riot.summoner.name(
    '5908' //or '5908,52322873,44979373'
    {},
    console.log
);

riot.summoner.runes(
    '5908' //or '5908,52322873,44979373'
    {},
    console.log
);

Retrieve summoner information by summoner name or summonerID.

===========================================================================================

teams-v2.4

riot.team.bySummonerId(
    '5908',
    {},
    console.log
);

riot.team.teamId(
    'TEAM-c80824c9-c568-42de-bdbb-271543b209e1', //or multiple teams, separated by commas
    {},
    console.log
);

Retrieve teams information by either summonerId or teamID

===========================================================================================

talk

Directly talk to the API. This function takes care of connecting and calling the callback only when valid JSON is returned.

Param        Type       Description
----------   --------   ----------------------------------------------------
path         string     full method path without leading slash
fields       object     GET parameters
callback     function   callback function to receive results