lol-api-client
v0.3.2
Published
A Node client for interfacing with the League of Legends API
Downloads
4
Maintainers
Readme
lol-api-client
This is a (work in progess) Node module for interfacing with Riot's developer API
View this project on Github or npm.
Installation
Simply run npm install lol-api-client --save
to install the client as a dependency for your project.
Usage
Require the client
const Client = require('lol-api-client')
Instantiate the client. The constructor expects an apiKey
, a region
, and a platformId
. A Riot API key can be acquired here. Riot's list of valid regions provides the supported list of abbreviated region names. If you're not sure what region you should be using, the global
region will work for most endpoints - though it's up to Riot whether or not that's fully supported. The platformId
argument is one used in Riot's newer routes such as the Champion Mastery routes. Platforms for each region are indirectly documented at the bottom of this page on Riot's developer portal.
const client = new Client('your-api-key', 'na', 'NA1')
All request methods return a Promise
. If you typically work with callbacks, or are otherwise new to promises, check out MDN's docs to get a basic understanding of using promises for async code.
client.champions.getAll()
.then(championData => {
const champions = championData.champions
console.log(champions)
})
.catch(error => {
console.error(error)
})
API
Champions
getAll
Riot endpoint: /champion
Get all existing champions
getById (id)
Riot endpoint: /champion/{id}
Get a single champion by its champion id
getAllStaticData
Riot endpoint: /static-data/{region}/{version}/champion
Get all static champion data. Lore, title, images, etc.
getStaticDataById (id)
Riot endpoint: /static-data/{region}/{version}/champion/{id}
Get static data for a single champion by champion id
Matches
getById (id)
Riot endpoint: matches/{matchId}
Get a single match object by id
getMatchListBySummonerId (id)
Riot endpoint: /matchlist/by-summoner/{summonerId}
Get a list of recent matches for the provided summoner id.
Summoners
getByName (name) or ([names])
Riot endpoint: summoners/by-name/{summonerNames}
Get a list of summoner objects from a provided array of names or a single summoner object from a provided summoner name.
getById (id) or ([ids])
Riot endpoint summoners/{summonerIds}
Get a list of summoner objects from a provided array of ids or a single summoner object from a provided summoner id.
getMasteryPagesById (id) or ([ids])
Riot endpoint summoners/{summonerIds}/masteries
Get a set of mastery pages objects for the provided or summoner or multiple sets of mastery pages for a provided array of summoner ids.
getRunePagesById (id) or ([ids])
Riot endpoint summoners/{summonerIds}/runes
Get a set of rune pages objects for the provided or summoner or multiple sets of rune pages for a provided array of summoner ids.
Champion Mastery
getByPlayerAndChampion (playerId, championId)
Riot endpoint: /championmastery/location/{platformId}/player/{playerId}/champion/{championId}
Get a Champion Mastery object for a given player on a specific champion.
getAllByPlayer (playerId)
Riot endpoint: /championmastery/location/{platformId}/player/{playerId}/champions
Get all mastery scores for the provided player
getScore (playerId)
Riot endpoint: /championmastery/location/{platformId}/player/{playerId}/score
Get a player's total champion mastery score
getTopChampions (playerId)
Riot endpoint: /championmastery/location/{platformId}/player/{playerId}/topchampions
Get a player's top three highest champion mastery scores.
Contributing
If you'd like to contribute to this project, you can file an issue. When you've completed work and are looking for review, file a pull request from your fork of this repository. This project uses Javascript Standard Style, and standard
is listed as a dev dependency. There are linter plugins for Atom, Sublime Text and more that can be found on standard's Github page. npm test
will lint all code and Travis will fail if standard
throws any code style errors. This ensures that there are no pointless discussions about code style, and we can actually discuss implementation, logic, etc during code review.