1.0.4 • Published 6 years ago

teemo-shroom v1.0.4

Weekly downloads
3
License
ISC
Repository
bitbucket
Last release
6 years ago

Teemo Shroom

Teemo Shroom - An up to date NodeJS Framework for Riot's API (minus tournament endpoints)

Including in a project

const teemo = require('teemo-shroom');

How to set your Riot API Key

You can set an environment variable of export RIOT_API_KEY=yourkey and the framework will use this as your key, so you don't have to hard code it if you don't want to. Just pass that on to the people who use your code. You can also set it with the following:

teemo.setApiKey('yourkey');

Functions to note for use in your development

FunctionDescriptionArgumentsreturn
setApiKeyAllows you to set your Riot API KEYkey - your api keyN/A
getApiKeyFor debugging purposes it returns the Riot API Key that is setN/Astring your Riot API Key that is set
getModulesReturns an object of modules lets you know whats enabled and disabled added for developers to be able to debugN/Aobject with objects that contain the following information: boolean active - is module active, string name - The name of the module, object module - functions to use when getting the needed endPointData. IE: {inactive: { active: false, name: 'Inactive Test', module: null }
getRegionsReturns an object of regions and data associated with the regionsN/Aobject with objects that contain the following information: string endpoint - the hostname for the endpoint, string - name a user friendly name for the object. IE: { endpoint: 'na1.api.riotgames.com', name: 'North America' }
getRegionReturns a specific region listed in getRegions based on the keynamestring region - the region you wish to get endpoint information for. IE: naan object containing connection information for a given region. IE: { endpoint: 'na1.api.riotgames.com', name: 'North America' }
sendRequestSends the request to Riot's APIstring regionName - the region you wish to query against. IE: na, object endPoint - the result given from calling ritopls.modules.{name}.{function}. See belowobject - result of your query if it failed it would be something like this { result: false, message: 'reason for failure' }. If the result succeeded then the result object would not be false and would be the result given by Riot's API
modules.champion.moduleReturns a list of champions or a single champion based on if you passed in a championId or notinteger championId - the id of the champion you wish to lookupreturn will be an object that you would pass in as endPoint for sendRequest (the second param)
modules.league.module.getQueuesReturns the queue types you can query onN/Areturn will be an object of objects, and are useful when calling modules.league.byQueue, as it expects you to pass the key to one of them in. Example Item: { solo: { name: 'Ranked Solo/Duo', value: 'RANKED_SOLO_5x5' } }
modules.league.module.getRanksReturns the rank types you can query on, useful also for displaying the name to the user wishing to make the queryN/Areturn will be an object of objects, and are useful when calling modules.league.byQueue, as it expects you to pass the key to one of them in. Example Item: { challenger: { name: 'Challenger Teir', value: 'challengerleagues' }
modules.league.module.byQueuelook up the league for a given queuestring rank - the rank you wish to look up master, challenger, string queue_type the queue type you want to look up solo, flex, twistedobject - the result of your lookup byQueue for challenger/master and the type of queue IE solo, needed for sendRequest
modules.league.module.byLeagueLook up a leagueleagueId - the league you wish to lookupobject - the endPoint information needed for sendRequest
modules.league.module.bySummonerIdLook up a summonersummonerId - the id of the summoner you wish to lookupobject - the endPoint information needed for sendRequest
modules.mastery.module.bySummonerIdlookup a summoners champion masteries or a single champion masterystring summonerId - the summonerId for the summoner you want to look up champion mastery on, string championId - the championId for the champion mastery you want too look at for the summonerobject - the endPoint information needed for sendRequest
modules.mastery.module.getTotalScoreBySummonerIdlook up the total mastery score for a given summonerstring summonerId - the summonerId for the summoner you want to look up points total forobject - the endPoint information needed for sendRequest
modules.match.module.byAccountIdlook up matches for a given accountIdstring matchid - the accountId you wish to look up matches forobject - the endPoint information needed for sendRequest
modules.match.module.byMatchIdlook up a specific matchstring matchId - the matchId for the match you wish to look up, boolean withTimeline - do you wish to also have a timeline of the matchobject - the endPoint information needed for sendRequest
modules.match.module.byTournamentIdlook up matches or single match for a given tournament codestring tournamentId - the tournament you wish to look up matches for, string matchId - the match you wish to look atobject - the endPoint information needed for sendRequest
modules.spectator.module.bySummonerIdLook up current game information for a given summonerIdstring summonerId - the summonerId for the summoner you wish to look up current game information forobject - the endPoint information needed for sendRequest
modules.spectator.module.featuredGamesLook up featured games currently going onN/Aobject - the endPoint information needed for sendRequest
modules.status.moduleget the league of legends status for the given regionN/Aobject - endPoint information needed for sendRequest
modules.summoner.module.byAccountIdlook up summoner information by accountIdstring accountId - the accountId for the summoner you wish to look upobject - endPoint information needed for sendRequest
modules.summoner.module.bySummonerNamelook up summoner information by their namestring summonerName - the summoner name for the summoner you wish to look upobject - endPoint information needed for sendRequest
modules.summoner.module.bySummonerIdlook up summoner information by there summonerIdstring summonerId - the summonerId for the summoner you wish to look upobject -endPoint information needed for sendRequest

Ok thats all well and dandy, but whats the code look like to query something

` const teemo = require('teemo-shroom');

/**

  • Look up a summoner by summoner name
  • @param string region - the region the summoner is apart of ie 'na'
  • @param string name - the summoner name ie 'darthvaderxd'
  • @return object - contains the result of the lookup */ const lookupSummonerByName = async (region, name) => { const endPoint = ritopls.modules.summoner.module.bySummonerName(name);

    if (endPoint.result === false) {
        return endPoint;
    }
    
    const result = await ritopls.sendRequest(region, endPoint);
    return result;

    }; `

For more examples see the examples folder

Checkout this YouTube video for getting started if you find yourself stuck https://youtu.be/I9C8umvrD8k

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago