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

lolapi

v0.3.1

Published

Wrapper of the official League of Legends public API

Downloads

22

Readme

lolapi

Wrapper of the official League of Legends public API with integrated cache support.

Build Status

Installation

Install this package by running npm install lolapi.

Quick Start

var lolapi = require('lolapi')('my-api-key', 'euw');

var summonerName = 'wickd';
lolapi.Summoner.getByName(summonerName, function (error, summoner) {
  if (error) throw error;
  /* summoner object
  { wickd:
    {
      id: 71500,
      name: 'Wickd',
      profileIconId: 613,
      summonerLevel: 30,
      revisionDate: 1408199475000
    }
  } */
  var summonerId = summoner[summonerName].id;
  lolapi.Summoner.getRunes(summonerId, function (error, runes) {
    if (error) throw error;
    // do something with runes
  })
});

API

API callbacks follow default Node.JS pattern returning error object as the first argument and result as the second one.

Every API call has an optional argument options with following available properties:

  • region may be added in order to define the region; if it's not set, region from the constructor will be used; if that is not defined either, region will default to Europe West
  • cacheRequest a flag indicating if specific request should be cached(note that you must have redis server running in order for this to work)

Most of the API calls have additional available properties covered below.

Constructor(apiKey[, region, options])

Constructor of the main singleton.

Additional options properties:

  • useRedis - a flag indicating if Redis cache database should be used(false by default). Please note, that in order to use cache, you must have redis server running on your computer
  • port - port Redis server is running on(if unspecified, default 6379 will be used)
  • hostname - hostname Redis server is running on(if unspecified, default 127.0.0.1 will be used)
  • cacheTTL - sets a timeout on cached data in seconds(an hour by default)

Simple initialization:

var lolapi = require('lolapi')('my-api-key');
// ready to go!

A more advanced example:

var options = {
  useRedis: true,
  hostname: '127.0.0.1',
  port: 6379,
  cacheTTL: 7200
};
var lolapi = require('lolapi')('my-api-key', 'euw', options);
// all requests are now being cached with a timeout of 2 hours
var summonerName = 'wickd';
lolapi.Summoner.getByName(summonerName, function () {
  // calls remote API server, will take 500ms~

  lolapi.Summoner.getByName(summonerName, function () {
    // takes results from cache, will now take 1-5 ms
  });
});

setRateLimit(limitPer10s, limitPer10min)

Sets a request limit. When either limit is reached, subsequent requests will be queued and ran when possible.

Champion.get(championId, [options, ]callback)

Retrieves a champion by its ID.

Champion.getAll([options, ]callback)

Retrieves all champions.

Additional options properties:

  • freeToPlay - if true, will only return champions that are free to play

Example:

lolapi.Champion.getAll({ freeToPlay: true }, function (error, champion) {
  // do something with free to play champions
});

CurrentGame.getBySummonerId(summonerId, [options, ]callback)

Get data about game currently in progress.

FeaturedGames.get([options, ]callback)

Get featured games.

Game.getBySummonerId(summonerId, [options, ]callback)

Get recent games by summoner ID.

League.getBySummonerId(summonerIds, [options, ]callback)

Get leagues by summoner ID or array of summoner IDs.

League.getEntriesBySummonerId(summonerIds, [options, ]callback)

Get league entries by summoner ID or array of summoner IDs.

League.getByTeamId(teamIds, [options, ]callback)

Get leagues by team ID or array of team IDs.

League.getEntriesByTeamId(teamIds, [options, ]callback)

Get league entries by team ID or array of team IDs.

League.getChallenger(type, [options, ]callback)

Get challenger tier leagues.

Property type may contain one of the following values:

  • RANKED_SOLO_5X5
  • RANKED_TEAM_3X3
  • RANKED_TEAM_5X5

Match.get(matchId, [options, ]callback)

Get match by match ID.

Additional options properties:

  • includeTimeline - if true, will include timeline of the match in the results

MatchList.getBySummonerId(summonerIds, [options, ]callback)

Get match history by summoner ID or array of summoner IDs.

Additional options properties:

  • championIds - array(or comma-separated list) of champion IDs you want to see in resulting matches
  • rankedQueues - array(or comma-separated list) of ranked queues you want to see the results of
  • seasons - array(or comma-separated list) of seasons to use for fetching games
  • beginTime - begin time to use for fetching games specified as epoch milliseconds
  • endTime - end time to use for fetching games specified as epoch milliseconds
  • beginIndex - begin index to use for fetching games
  • endIndex - end index to use for fetching games

Example:

var options = {
  championIds: 412,
  rankedQueues: ['RANKED_SOLO_5X5', 'RANKED_TEAM_5X5'],
  beginIndex: 0,
  endIndex: 10
}; // these options will return 10 ranked 5v5 games containing champion Thresh
lolapi.MatchList.getBySummonerId(71500, options, function (error, matches) {
  // got the matches!
});

Static.getChampions([options, ]callback)

Get list of champions.

Additional options properties:

  • locale - locale code for returned data (e.g., en_US, es_ES)
  • version - data dragon version for returned data
  • dataById - if true, the returned data map will use the champions' IDs as the keys
  • champData - tags to return additional data. Available tags: all, allytips, altimages, blurb, enemytips, image, info, lore, partype, passive, recommended, skins, spells, stats, tags

Static.getChampion(championId, [options, ]callback)

Get champion by ID.

Additional options properties:

  • locale - locale code for returned data (e.g., en_US, es_ES)
  • version - data dragon version for returned data
  • champData - tags to return additional data. Available tags: all, allytips, altimages, blurb, enemytips, image, info, lore, partype, passive, recommended, skins, spells, stats, tags

Static.getItems([options, ]callback)

Get list of items.

Additional options properties:

  • locale - locale code for returned data (e.g., en_US, es_ES)
  • version - data dragon version for returned data
  • itemListData - tags to return additional data. Available tags: all, colloq, consumeOnFull, consumed, depth, from, gold, groups, hideFromAll, image, inStore, into, maps, requiredChampion, sanitizedDescription, specialRecipe, stacks, stats, tags, tree

Static.getItem(itemId, [options, ]callback)

Get item by ID.

Additional options properties:

  • locale - locale code for returned data (e.g., en_US, es_ES)
  • version - data dragon version for returned data
  • itemData - tags to return additional data. Available tags: all, colloq, consumeOnFull, consumed, depth, from, gold, hideFromAll, image, inStore, into, maps, requiredChampion, sanitizedDescription, specialRecipe, stacks, stats, tags

Static.getMasteries([options, ]callback)

Get list of masteries.

Additional options properties:

  • locale - locale code for returned data (e.g., en_US, es_ES)
  • version - data dragon version for returned data
  • masteryListData - tags to return additional data. Available tags: all, image, prereq, ranks, sanitizedDescription, tree

Static.getMastery(masteryId, [options, ]callback)

Get mastery by ID.

Additional options properties:

  • locale - locale code for returned data (e.g., en_US, es_ES)
  • version - data dragon version for returned data
  • masteryListData - tags to return additional data. Available tags: all, image, prereq, ranks, sanitizedDescription

Static.getRunes([options, ]callback)

Get list of runes.

Additional options properties:

  • locale - locale code for returned data (e.g., en_US, es_ES)
  • version - data dragon version for returned data
  • runeListData - tags to return additional data. Available tags: all, basic, colloq, consumeOnFull, consumed, depth, from, gold, hideFromAll, image, inStore, into, maps, requiredChampion, sanitizedDescription, specialRecipe, stacks, stats, tags

Static.getRune(runeId, [options, ]callback)

Get rune by ID.

Additional options properties:

  • locale - locale code for returned data (e.g., en_US, es_ES)
  • version - data dragon version for returned data
  • runeData - tags to return additional data. Available tags: all, colloq, consumeOnFull, consumed, depth, from, gold, hideFromAll, image, inStore, into, maps, requiredChampion, sanitizedDescription, specialRecipe, stacks, stats, tags

Static.getSummonerSpells([options, ]callback)

Get list of summoner spells.

Additional options properties:

  • locale - locale code for returned data (e.g., en_US, es_ES)
  • version - data dragon version for returned data
  • dataById - if true, the returned data map will use the spells' IDs as the keys
  • spellData - tags to return additional data. Available tags: all, cooldown, cooldownBurn, cost, costBurn, costType, effect, effectBurn, image, key, leveltip, maxrank, modes, range, rangeBurn, resource, sanitizedDescription, sanitizedTooltip, tooltip, vars

Static.getSummonerSpell(summonerSpellId, [options, ]callback)

Get summoner spell by ID.

Additional options properties:

  • locale - locale code for returned data (e.g., en_US, es_ES)
  • version - data dragon version for returned data
  • spellData - tags to return additional data. Available tags: all, cooldown, cooldownBurn, cost, costBurn, costType, effect, effectBurn, image, key, leveltip, maxrank, modes, range, rangeBurn, resource, sanitizedDescription, sanitizedTooltip, tooltip, vars

Static.getRealm([options, ]callback)

Get realm data.

Static.getVersions([options, ]callback)

Get versions data.

Stats.getRanked([options, ]callback)

Get ranked stats by summoner ID.

Additional options properties:

  • season - name of the season you want to retrieve stats of(eg. SEASON3 or SEASON4)

Stats.getSummary([options, ]callback)

Get player stats summaries by summoner ID.

Additional options properties:

  • season - name of the season you want to retrieve stats of(eg. SEASON3 or SEASON4)

Status.get(region, [options, ]callback)

Get specific shard status by region.

Status.getAll([options, ]callback)

Get shard list.

Summoner.get(summonerIds, [options, ]callback)

Get summoner by ID or list of summoner IDs.

Summoner.getByName(summonerNames, [options, ]callback)

Get summoner by name or list of summoner names.

Summoner.getName(summonerIds, [options, ]callback)

Get summoner name by ID or list of summoner IDs.

Summoner.getRunes(summonerIds, [options, ]callback)

Get summoner runes by ID or list of summoner IDs.

Summoner.getMasteries(summonerIds, [options, ]callback)

Get summoner masteries by ID or list of summoner IDs.

Team.get(teamId, [options, ]callback)

Get team by ID.

Team.getBySummonerId(summonerId, [options, ]callback)

Get team by summoner ID.