Skip to content
Node.js League/LoL/League Of Legends API wrapper, Focus is to be easy to use
JavaScript
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
LeagueAPI
.gitignore
README.md
package-lock.json
package.json

README.md

LeagueAPIWrapper (Node.JS)

Simple Wrapper for all League Of Legends API methods

https://www.npmjs.com/package/leagueapiwrapper

Example get accountInfo object to be used in other methods:

let LeagueAPI = require('leagueapiwrapper');
LeagueAPI = new LeagueAPI(leagueAPIKey, Region.NA);

LeagueAPI.getSummonerByName('LeagueOfSausage')
    .then(function(accountInfo) {
        // do something with accountInfo
	console.log(accountInfo);
    })
    .catch(console.log);

Get featured games, populated with DDRagon data

LeagueAPI.initialize()
    .then(function(){ return LeagueAPI.getFeaturedGames() })
    .then(function(data) {
        console.log(data);
    })
    .catch(console.log);

Methods

initialize

// Objects will now contain full objects, instead of id's. 
// E.G from 'mapId: 12' to 'mapObject: { id: 12 name: howlingAbyss ... }'
LeagueAPI.initialize()
    .then() {
    	// LeagueAPI returned objects will now have details from DDRagon API.
    })
    .catch(console.log);

setFullyLoadClasses(boolean)

// Setting initialize() sets to true.
// Must call initialize if setting this to true
LeagueAPI.setFullyLoadClasses(false);

changeRegion(Region)

// Changed Region for API calls
LeagueAPI.changeRegion(Region.NA);

getThirdPartyCode(AccountObject)

// Returns thirdPartyCode. Note: will 'Forbidden' if no thirdPartyCode is available for the accountInfo/accountId
// Note: I don't have an accountId example that works here
LeagueAPI.getThirdPartyCode(accountId)
	.then(function(data) {
		console.log(data);
	})
	.catch(console.log);

getStatus()

// Returns the status of the LeagueAPI endpoints 
LeagueAPI.getStatus()
	.then(console.log)
	.catch(console.log);

getFeaturedGames()

// Returns the current featured games on League
LeagueAPI.getFeaturedGames()
	.then(console.log)
	.catch(console.log);

getMatch(matchId)

// matchId taken from a getMatchList call
// Gets the Match object for the ID passed
LeagueAPI.getMatch(2970107953)
	.then(console.log)
	.catch(console.log);

getMatchByTournament(matchId, tournamentCode)

// Gets the Match object for the ID passed with tournamentCode. Note: I don't have an example tournament code
LeagueAPI.getMatchByTournament(2970107953, tournamentCode)
	.then(console.log)
	.catch(console.log);

getMatchIdsByTournament(tournamentCode)

// Gets the Match ids for the tournamentCode. Note: I don't have an example tournament code
LeagueAPI.getMatchIdsByTournament(tournamentCode)
	.then(console.log)
	.catch(console.log);

getPositionalRankQueues()

LeagueAPI.getPositionalRankQueues()
	.then(console.log)
	.catch(console.log);

getSummonerByName(summonerName)

// Returns an accountObject which can be used in other methods, or view account information on
LeagueAPI.getSummonerByName('LeagueOfDrMundo')
	.then(function(accountObject) {
		console.log(accountObject);
	})
	.catch(console.log);

getActiveGames(accountObject)

LeagueAPI.getSummonerByName('LeagueOfDrMundo')
	.then(function(accountObject) {
		// Gets active games. Will return 404 if not currently in an active game
		return LeagueAPI.getActiveGames(accountObject);
	})
	.then(function(activeGames) { 
		console.log(activeGames);
	})
	.catch(console.log);

getMatchList(accountObject)

LeagueAPI.getSummonerByName('LeagueOfDrMundo')
	.then(function(accountObject) {
		// Gets match list for the account
		return LeagueAPI.getMatchList(accountObject);
	})
	.then(function(activeGames) { 
		console.log(activeGames);
	})
	.catch(console.log);

getMatchTimeline(matchId)

// Returns a timeline of the match
LeagueAPI.getMatchTimeline(3026936146)
	.then(console.log)
	.catch(console.log);

getChampionMasteryTotal(accountObject)

LeagueAPI.getSummonerByName('LeagueOfSausage')
	.then(function(accountObj) {
		// Returns the total champion master (sum of all champion mastery for all champions)
		return LeagueAPI.getChampionMasteryTotal(accountObj);
	})
	.then(function(championMasteryTotal)
	{
		console.log(championMasteryTotal);
	})
	.catch(console.log);

getChampionMastery(accountObject)

LeagueAPI.getSummonerByName('LeagueOfDrMundo')
	.then(function(accountObj) {
		// Returns a list of every single champion played by the account, along with mastery details
		return LeagueAPI.getChampionMastery(accountObj);
	})
	.then(function(championMasteryList)
	{
		console.log(championMasteryList);
	})
	.catch(console.log);

getChampionMasteryByChampion(accountObject, championObj)

const drMundoChampId = 36;
const leagueOfDrMundoSummonerId = 'IE2WdICfZnhEWYPIBfHio7jxCeo1IFynclJAPquqENRrpeYK';

// Returns the championMastery details for the given account/accountId and champion/championId
LeagueAPI.getChampionMasteryByChampion(leagueOfDrMundoSummonerId, drMundoChampId)
	.then(console.log)
	.catch(console.log);

getFreeChampionRotation()

// Returns details for the current champion rotation. Initialize first for details on each champion
LeagueAPI.getFreeChampionRotation()
	.then(console.log)
	.catch(console.log);

Disclaimer

MundoScript is not endorsed by Riot Games and does not reflect the views or opinions of Riot Games or anyone officially involved in producing or managing League of Legends. League of Legends and Riot Games are trademarks or registered trademarks of Riot Games, Inc. League of Legends © Riot Games, Inc.

Feel free to make suggestions on features/etc.

You can’t perform that action at this time.