Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
   package com.robrua.orianna.api;
   
   import java.io.IOException;
   import java.net.URLEncoder;
   import java.util.Collection;
   import java.util.HashMap;
   import java.util.HashSet;
   import java.util.List;
  import java.util.Map;
  import java.util.Set;
  
  import  com.robrua.easyjava.net.rest.SimpleRESTClient;
Queries the LoL REST API for information, returning the JSON strings it receives from the API.

Author(s):
Rob Rua (FatalElement - NA) (robrua@alumni.cmu.edu)
  
  public class JSONRiotAPI {
      private static final Map<StringStringAPIVersions;
      private static final Pattern IOEXCEPTION_PATTERN = Pattern.compile("Server returned HTTP response code: (.*?) for URL:? (.*)");
      private static final Set<QueueTyperankedQueues;
  
      static {
           = new HashMap<StringString>();
          .put("champion""v1.2");
          .put("game""v1.3");
          .put("league""v2.5");
          .put("static-data""v1.2");
          .put("match""v2.2");
          .put("matchhistory""v2.2");
          .put("stats""v1.3");
          .put("summoner""v1.4");
          .put("team""v2.4");
  
           = new HashSet<QueueType>();
      }
  
      private static String getCollectionString(final Collection<?> items) {
          final StringBuilder string = new StringBuilder();
          for(final Object item : items) {
              string.append("," + item.toString());
          }
  
          return string.substring(1);
      }
  
      private static String getNameCollectionString(final Collection<Stringnames) {
          final StringBuilder string = new StringBuilder();
          for(final String name : names) {
              string.append("," + name.toLowerCase().replaceAll("\\s"""));
          }
  
          return string.substring(1);
      }
  
      private static APIException handleIOException(final IOException e) {
          final Matcher matcher = .matcher(e.getMessage());
          if(matcher.find()) {
              final String URL = matcher.group(2);
              final int responseCode = Integer.parseInt(matcher.group(1));
              switch(responseCode) {
                  case 400:
                      return new APIException(..URLe);
                  case 401:
                      return new APIException(..URLe);
                  case 404:
                      return new APIException(..URLe);
                  case 429:
                      return new APIException(..URLe);
                  case 500:
                      return new APIException(..URLe);
                  case 503:
                      return new APIException(..URLe);
                  default:
                      return new APIException(..URLe);
              }
          }
          return new APIException(..e);
      }
  
      private final String APIKey;
     private final SimpleRESTClient dynamicData;
     private final RateLimiter rateLimiter;
     private final SimpleRESTClient staticData;

    

Parameters:
mirror the data server to query
forRegion the region for which to query data
APIKey your LoL API key
 
     public JSONRiotAPI(final Region mirrorfinal Region forRegionfinal String APIKey) {
         this(mirrorforRegionAPIKeynull);
     }

    

Parameters:
mirror the data server to query
forRegion the region for which to query data
APIKey your LoL API key
rateLimiter queries will be throttled automatically to meet this rate limit
 
     public JSONRiotAPI(final Region mirrorfinal Region forRegionfinal String APIKeyfinal RateLimiter rateLimiter) {
         this. = APIKey;
         this. = rateLimiter;
 
         final String regionName = forRegion.toString().toLowerCase();
          = new SimpleRESTClient("https://global.api.pvp.net/api/lol/static-data/" + regionName + "/");
          = new SimpleRESTClient("https://" + mirror.toString().toLowerCase() + ".api.pvp.net/api/lol/" + regionName + "/");
     }

    

Parameters:
forRegion the region for which to query data
APIKey your LoL API key
 
     public JSONRiotAPI(final Region forRegionfinal String APIKey) {
         this(forRegionforRegionAPIKeynull);
     }

    

Parameters:
forRegion the region for which to query data
APIKey your LoL API key
rateLimiter queries will be throttled automatically to meet this rate limit
 
     public JSONRiotAPI(final Region forRegionfinal String APIKeyfinal RateLimiter rateLimiter) {
         this(forRegionforRegionAPIKeyrateLimiter);
     }
 
     private Map<StringStringbaseParams() {
         final HashMap<StringStringparams = new HashMap<StringString>();
         params.put("api_key");
         return params;
     }

    

Returns:
the API's JSON formatted response
See also:
LoL API Specification
 
     public String getChallengerLeague() {
     }

    

Parameters:
type the queue for which to get the Challenger league
Returns:
the API's JSON formatted response
See also:
LoL API Specification
 
     public String getChallengerLeague(final LeagueType type) {
         final Map<StringStringparams = baseParams();
         params.put("type"type.toString());
 
         return waitForRateLimiter(.get("league") + "/league/challenger"params);
     }

    

Parameters:
ID the ID to get information for
Returns:
the API's JSON formatted response
See also:
LoL API Specification
 
     public String getChampion(final int ID) {
         return getChampion(IDnullnullnull);
     }

    

Parameters:
ID the ID to get information for
champData the additional information to get about the champion
Returns:
the API's JSON formatted response
See also:
LoL API Specification
 
     public String getChampion(final int IDfinal Set<ChampionDatachampData) {
         return getChampion(IDchampDatanullnull);
     }

    

Parameters:
ID the ID to get information for
champData the additional information to get about the champion
locale the locale to specify
version the data version number
Returns:
the API's JSON formatted response
See also:
LoL API Specification
 
     public String getChampion(final int IDfinal Set<ChampionDatachampDatafinal String localefinal String version) {
         final Map<StringStringparams = baseParams();
         if(champData != null) {
             params.put("champData"getCollectionString(champData));
         }
         if(locale != null) {
             params.put("locale"locale);
         }
         if(version != null) {
             params.put("version"version);
         }
 
         try {
             return .get(.get("static-data") + "/champion/" + IDparams);
         }
         catch(final IOException e) {
             throw handleIOException(e);
         }
     }

    

Returns:
the API's JSON formatted response
See also:
LoL API Specification
 
     public String getChampions() {
         return getChampions(nullnullnulltrue);
     }

    

Parameters:
champData the additional information to get about all champions
Returns:
the API's JSON formatted response
See also:
LoL API Specification
 
     public String getChampions(final Set<ChampionDatachampData) {
         return getChampions(champDatanullnulltrue);
     }

    

Parameters:
champData the additional information to get about all champions
byChampionName whether the results should be organized by name or not (if not, will be by ID)
Returns:
the API's JSON formatted response
See also:
LoL API Specification
 
     public String getChampions(final Set<ChampionDatachampDatafinal boolean byChampionName) {
         return getChampions(champDatanullnullbyChampionName);
     }

    

Parameters:
champData the additional information to get about all champions
locale the locale to specify
version the data version number
byChampionName whether the results should be organized by name or not (if not, will be by ID)
Returns:
the API's JSON formatted response
See also:
LoL API Specification
 
     public String getChampions(final Set<ChampionDatachampDatafinal String localefinal String versionfinal boolean byChampionName) {
         final Map<StringStringparams = baseParams();
         if(champData != null) {
             params.put("champData"getCollectionString(champData));
         }
         if(locale != null) {
             params.put("locale"locale);
         }
         if(version != null) {
             params.put("version"version);
         }
         params.put("dataById", Boolean.toString(!byChampionName));
 
         try {
             return .get(.get("static-data") + "/champion"params);
         }
         catch(final IOException e) {
             throw handleIOException(e);
         }
     }

    

Parameters:
ID the ID to get information for
Returns:
the API's JSON formatted response
See also:
LoL API Specification
 
     public String getChampionStatus(final int ID) {
         return waitForRateLimiter(.get("champion") + "/champion/" + IDbaseParams());
     }

    

Returns:
the API's JSON formatted response
See also:
LoL API Specification
 
     public String getChampionStatuses() {
         return getChampionStatuses(false);
     }

    

Parameters:
onlyFreeToPlay whether to only show statuses for free to play champions
Returns:
the API's JSON formatted response
See also:
LoL API Specification
 
     public String getChampionStatuses(final boolean onlyFreeToPlay) {
         final Map<StringStringparams = baseParams();
         params.put("freeToPlay", Boolean.toString(onlyFreeToPlay));
 
         return waitForRateLimiter(.get("champion") + "/champion"params);
     }

    

Parameters:
ID the ID to get information for
Returns:
the API's JSON formatted response
See also:
LoL API Specification
 
     public String getItem(final int ID) {
         return getItem(IDnullnullnull);
     }

    

Parameters:
ID the ID to get information for
itemData the additional information to get about the item
Returns:
the API's JSON formatted response
See also:
LoL API Specification
 
     public String getItem(final int IDfinal Set<ItemDataitemData) {
         return getItem(IDitemDatanullnull);
     }

    

Parameters:
ID the ID to get information for
itemData the additional information to get about the item
locale the locale to specify
version the data version number
Returns:
the API's JSON formatted response
See also:
LoL API Specification
 
     public String getItem(final int IDfinal Set<ItemDataitemDatafinal String localefinal String version) {
         final Map<StringStringparams = baseParams();
         if(itemData != null) {
             params.put("itemData"getCollectionString(itemData));
         }
         if(locale != null) {
             params.put("locale"locale);
         }
         if(version != null) {
             params.put("version"version);
         }
 
         try {
             return .get(.get("static-data") + "/item/" + IDparams);
         }
         catch(final IOException e) {
             throw handleIOException(e);
         }
     }

    

Returns:
the API's JSON formatted response
See also:
LoL API Specification
 
     public String getItems() {
         return getItems(nullnullnull);
     }

    

Parameters:
itemListData the additional information to get about all items
Returns:
the API's JSON formatted response
See also:
LoL API Specification
 
     public String getItems(final Set<ItemDataitemListData) {
         return getItems(itemListDatanullnull);
     }

    

Parameters:
itemListData the additional information to get about all items
locale the locale to specify
version the data version number
Returns:
the API's JSON formatted response
See also:
LoL API Specification
 
     public String getItems(final Set<ItemDataitemListDatafinal String localefinal String version) {
         final Map<StringStringparams = baseParams();
         if(itemListData != null) {
             params.put("itemListData"getCollectionString(itemListData));
         }
         if(locale != null) {
             params.put("locale"locale);
         }
         if(version != null) {
             params.put("version"version);
         }
 
         try {
             return .get(.get("static-data") + "/item"params);
         }
         catch(final IOException e) {
             throw handleIOException(e);
         }
     }

    

Returns:
the API's JSON formatted response
See also:
LoL API Specification
 
     public String getMasteries() {
         return getMasteries(nullnullnull);
     }

    

Parameters:
masteryListData the additional information to get about all masteries
Returns:
the API's JSON formatted response
See also:
LoL API Specification
 
     public String getMasteries(final Set<MasteryDatamasteryListData) {
         return getMasteries(masteryListDatanullnull);
     }

    

Parameters:
masteryListData the additional information to get about all masteries
locale the locale to specify
version the data version number
Returns:
the API's JSON formatted response
See also:
LoL API Specification
 
     public String getMasteries(final Set<MasteryDatamasteryListDatafinal String localefinal String version) {
         final Map<StringStringparams = baseParams();
         if(masteryListData != null) {
             params.put("masteryListData"getCollectionString(masteryListData));
         }
         if(locale != null) {
             params.put("locale"locale);
         }
         if(version != null) {
             params.put("version"version);
         }
 
         try {
             return .get(.get("static-data") + "/mastery"params);
         }
         catch(final IOException e) {
             throw handleIOException(e);
         }
     }

    

Parameters:
ID the ID to get information for
Returns:
the API's JSON formatted response
See also:
LoL API Specification
 
     public String getMastery(final int ID) {
         return getMastery(IDnullnullnull);
     }

    

Parameters:
ID the ID to get information for
masteryData the additional information to get about the mastery
Returns:
the API's JSON formatted response
See also:
LoL API Specification
 
     public String getMastery(final int IDfinal Set<MasteryDatamasteryData) {
         return getMastery(IDmasteryDatanullnull);
     }

    

Parameters:
ID the ID to get information for
masteryData the additional information to get about the mastery
locale the locale to specify
version the data version number
Returns:
the API's JSON formatted response
See also:
LoL API Specification
 
     public String getMastery(final int IDfinal Set<MasteryDatamasteryDatafinal String localefinal String version) {
         final Map<StringStringparams = baseParams();
         if(masteryData != null) {
             params.put("masteryData"getCollectionString(masteryData));
         }
         if(locale != null) {
             params.put("locale"locale);
         }
         if(version != null) {
             params.put("version"version);
         }
 
         try {
             return .get(.get("static-data") + "/mastery/" + IDparams);
         }
         catch(final IOException e) {
             throw handleIOException(e);
         }
     }

    

Parameters:
ID the ID to get information for
Returns:
the API's JSON formatted response
See also:
LoL API Specification
 
     public String getMatch(final long ID) {
         return getMatch(IDtrue);
     }

    

Parameters:
ID the ID to get information for
includeTimeline whether to include the timeline
Returns:
the API's JSON formatted response
See also:
LoL API Specification
 
     public String getMatch(final long IDfinal boolean includeTimeline) {
         final Map<StringStringparams = baseParams();
         params.put("includeTimeline", Boolean.toString(includeTimeline));
 
         return waitForRateLimiter(.get("match") + "/match/" + IDparams);
     }

    

Returns:
the API's JSON formatted response
See also:
LoL API Specification
 
     public String getRealm() {
         try {
             return .get(.get("static-data") + "/realm"baseParams());
         }
         catch(final IOException e) {
             throw handleIOException(e);
         }
     }

    

Parameters:
ID the ID to get information for
Returns:
the API's JSON formatted response
See also:
LoL API Specification
 
     public String getRune(final int ID) {
         return getRune(IDnullnullnull);
     }

    

Parameters:
ID the ID to get information for
runeData the additional information to get about the rune
Returns:
the API's JSON formatted response
See also:
LoL API Specification
 
     public String getRune(final int IDfinal Set<RuneDataruneData) {
         return getRune(IDruneDatanullnull);
     }

    

Parameters:
ID the ID to get information for
runeData the additional information to get about the rune
locale the locale to specify
version the data version number
Returns:
the API's JSON formatted response
See also:
LoL API Specification
 
     public String getRune(final int IDfinal Set<RuneDataruneDatafinal String localefinal String version) {
         final Map<StringStringparams = baseParams();
         if(runeData != null) {
             params.put("runeData"getCollectionString(runeData));
         }
         if(locale != null) {
             params.put("locale"locale);
         }
         if(version != null) {
             params.put("version"version);
         }
 
         try {
             return .get(.get("static-data") + "/rune/" + IDparams);
         }
         catch(final IOException e) {
             throw handleIOException(e);
         }
     }

    

Returns:
the API's JSON formatted response
See also:
LoL API Specification
 
     public String getRunes() {
         return getRunes(nullnullnull);
     }

    

Parameters:
runeListData the additional information to get about all runes
Returns:
the API's JSON formatted response
See also:
LoL API Specification
 
     public String getRunes(final Set<RuneDataruneListData) {
         return getRunes(runeListDatanullnull);
     }

    

Parameters:
runeListData the additional information to get about all runes
locale the locale to specify
version the data version number
Returns:
the API's JSON formatted response
See also:
LoL API Specification
 
     public String getRunes(final Set<RuneDataruneListDatafinal String localefinal String version) {
         final Map<StringStringparams = baseParams();
         if(runeListData != null) {
             params.put("runeListData"getCollectionString(runeListData));
         }
         if(locale != null) {
             params.put("locale"locale);
         }
         if(version != null) {
             params.put("version"version);
         }
 
         try {
             return .get(.get("static-data") + "/rune"params);
         }
         catch(final IOException e) {
             throw handleIOException(e);
         }
     }

    

Parameters:
summonerName the summoner to get information for
Returns:
the API's JSON formatted response
See also:
LoL API Specification
 
     public String getSummoner(String summonerName) {
         try {
             summonerName = URLEncoder.encode(summonerName"UTF-8").replace("+""%20");
         }
         catch(final UnsupportedEncodingException e) {}
 
         return waitForRateLimiter(.get("summoner") + "/summoner/by-name/" + summonerNamebaseParams());
     }

    

Parameters:
summonerID the summoner to get information for
Returns:
the API's JSON formatted response
See also:
LoL API Specification
 
     public String getSummonerByID(final long summonerID) {
         return waitForRateLimiter(.get("summoner") + "/summoner/" + summonerIDbaseParams());
     }

    

Parameters:
summonerID the summoner to get information for
Returns:
the API's JSON formatted response
See also:
LoL API Specification
 
     public String getSummonerGamesByID(final long summonerID) {
         return waitForRateLimiter(.get("game") + "/game/by-summoner/" + summonerID + "/recent"baseParams());
     }

    

Parameters:
summonerID the summoner to get information for
Returns:
the API's JSON formatted response
See also:
LoL API Specification
 
     public String getSummonerLeagueEntriesByID(final long summonerID) {
         return waitForRateLimiter(.get("league") + "/league/by-summoner/" + summonerID + "/entry"baseParams());
     }

    

Parameters:
summonerID the summoner to get information for
Returns:
the API's JSON formatted response
See also:
LoL API Specification
 
     public String getSummonerLeaguesByID(final long summonerID) {
         return waitForRateLimiter(.get("league") + "/league/by-summoner/" + summonerIDbaseParams());
     }

    

Parameters:
summonerID the summoner to get information for
Returns:
the API's JSON formatted response
See also:
LoL API Specification
 
     public String getSummonerMasteriesByID(final long summonerID) {
         return waitForRateLimiter(.get("summoner") + "/summoner/" + summonerID + "/masteries"baseParams());
     }

    

Parameters:
summonerID the ID to get information for
Returns:
the API's JSON formatted response
See also:
LoL API Specification
 
     public String getSummonerMatchHistory(final long summonerID) {
         return getSummonerMatchHistory(summonerIDnullnullnullnull);
     }

    

Parameters:
summonerID the ID to get information for
beginIndex the begin index to use for fetching games. No more than 15 games will be fetched.
endIndex the end index to use for fetching games. No more than 15 games will be fetched.
Returns:
the API's JSON formatted response
See also:
LoL API Specification
 
     public String getSummonerMatchHistory(final long summonerIDfinal Integer beginIndexfinal Integer endIndex) {
         return getSummonerMatchHistory(summonerIDnullnullbeginIndexendIndex);
     }

    

Parameters:
summonerID the ID to get information for
championIDs which champions to limit this search to
rankedQueues which queues to limit this search to. Any queues other than RANKED_SOLO_5x5, RANKED_TEAM_5x5, and RANKED_TEAM_3x3 will be ignored.
Returns:
the API's JSON formatted response
See also:
LoL API Specification
 
     public String getSummonerMatchHistory(final long summonerIDfinal List<IntegerchampionIDsfinal List<QueueTyperankedQueues) {
         return getSummonerMatchHistory(summonerIDchampionIDsrankedQueuesnullnull);
     }

    

Parameters:
summonerID the ID to get information for
championIDs which champions to limit this search to
rankedQueues which queues to limit this search to. Any queues other than RANKED_SOLO_5x5, RANKED_TEAM_5x5, and RANKED_TEAM_3x3 will be ignored.
beginIndex the begin index to use for fetching games. No more than 15 games will be fetched.
endIndex the end index to use for fetching games. No more than 15 games will be fetched.
Returns:
the API's JSON formatted response
See also:
LoL API Specification
 
     public String getSummonerMatchHistory(final long summonerIDfinal List<IntegerchampionIDsfinal List<QueueTyperankedQueuesfinal Integer beginIndex,
             final Integer endIndex) {
         final Map<StringStringparams = baseParams();
         if(championIDs != null) {
             params.put("championIds"getCollectionString(championIDs));
         }
         if(rankedQueues != null) {
             rankedQueues.retainAll(.);
             if(!rankedQueues.isEmpty()) {
                 params.put("rankedQueues"getCollectionString(rankedQueues));
             }
         }
         if(beginIndex != null) {
             params.put("beginIndex"beginIndex.toString());
         }
         if(endIndex != null) {
             params.put("endIndex"endIndex.toString());
         }
 
         return waitForRateLimiter(.get("matchhistory") + "/matchhistory/" + summonerIDparams);
     }

    

Parameters:
summonerID the summoner to get information for
Returns:
the API's JSON formatted response
See also:
LoL API Specification
 
     public String getSummonerName(final long summonerID) {
         return waitForRateLimiter(.get("summoner") + "/summoner/" + summonerID + "/name"baseParams());
     }

    

Parameters:
summonerIDs the summoners to get information for
Returns:
the API's JSON formatted response
See also:
LoL API Specification
 
     public String getSummonerNames(final List<LongsummonerIDs) {
         return waitForRateLimiter(.get("summoner") + "/summoner/" + getCollectionString(summonerIDs) + "/name"baseParams());
     }

    

Parameters:
summonerID the summoner to get information for
Returns:
the API's JSON formatted response
See also:
LoL API Specification
 
     public String getSummonerRankedStatsByID(final long summonerID) {
         return getSummonerRankedStatsByID(summonerIDnull);
     }

    

Parameters:
summonerID the summoner to get information for
season the season to get stats for
Returns:
the API's JSON formatted response
See also:
LoL API Specification
 
     public String getSummonerRankedStatsByID(final long summonerIDfinal Season season) {
         final Map<StringStringparams = baseParams();
         if(season != null) {
             params.put("season"season.toString());
         }
 
         return waitForRateLimiter(.get("stats") + "/stats/by-summoner/" + summonerID + "/ranked"params);
     }

    

Parameters:
summonerID the summoner to get information for
Returns:
the API's JSON formatted response
See also:
LoL API Specification
 
     public String getSummonerRunesByID(final long summonerID) {
         return waitForRateLimiter(.get("summoner") + "/summoner/" + summonerID + "/runes"baseParams());
     }

    

Parameters:
summonerNames the summoners to get information for
Returns:
the API's JSON formatted response
See also:
LoL API Specification
 
     public String getSummoners(final List<StringsummonerNames) {
         return waitForRateLimiter(.get("summoner") + "/summoner/by-name/" + getNameCollectionString(summonerNames), baseParams());
     }

    

Parameters:
summonerIDs the summoners to get information for
Returns:
the API's JSON formatted response
See also:
LoL API Specification
 
     public String getSummonersByID(final List<LongsummonerIDs) {
         return waitForRateLimiter(.get("summoner") + "/summoner/" + getCollectionString(summonerIDs), baseParams());
     }

    

Parameters:
summonerIDs the summoners to get information for
Returns:
the API's JSON formatted response
See also:
LoL API Specification
 
     public String getSummonersLeagueEntriesByID(final List<LongsummonerIDs) {
         return waitForRateLimiter(.get("league") + "/league/by-summoner/" + getCollectionString(summonerIDs) + "/entry"baseParams());
     }

    

Parameters:
summonerIDs the summoners to get information for
Returns:
the API's JSON formatted response
See also:
LoL API Specification
 
     public String getSummonersLeaguesByID(final List<LongsummonerIDs) {
         return waitForRateLimiter(.get("league") + "/league/by-summoner/" + getCollectionString(summonerIDs), baseParams());
     }

    

Parameters:
summonerIDs the summoners to get information for
Returns:
the API's JSON formatted response
See also:
LoL API Specification
 
     public String getSummonersMasteriesByID(final List<LongsummonerIDs) {
         return waitForRateLimiter(.get("summoner") + "/summoner/" + getCollectionString(summonerIDs) + "/masteries"baseParams());
     }

    

Parameters:
ID the ID to get information for
Returns:
the API's JSON formatted response
See also:
LoL API Specification
 
     public String getSummonerSpell(final int ID) {
         return getSummonerSpell(IDnullnullnull);
     }

    

Parameters:
ID the ID to get information for
spellData the additional information to get about the summoner spell
Returns:
the API's JSON formatted response
See also:
LoL API Specification
    public String getSummonerSpell(final int IDfinal Set<SummonerSpellDataspellData) {
        return getSummonerSpell(IDspellDatanullnull);
    }

    

Parameters:
ID the ID to get information for
spellData the additional information to get about the summoner spell
locale the locale to specify
version the data version number
Returns:
the API's JSON formatted response
See also:
LoL API Specification
    public String getSummonerSpell(final int IDfinal Set<SummonerSpellDataspellDatafinal String localefinal String version) {
        final Map<StringStringparams = baseParams();
        if(spellData != null) {
            params.put("spellData"getCollectionString(spellData));
        }
        if(locale != null) {
            params.put("locale"locale);
        }
        if(version != null) {
            params.put("version"version);
        }
        try {
            return .get(.get("static-data") + "/summoner-spell/" + IDparams);
        }
        catch(final IOException e) {
            throw handleIOException(e);
        }
    }

    

Returns:
the API's JSON formatted response
See also:
LoL API Specification
    public String getSummonerSpells() {
        return getSummonerSpells(nullnullnulltrue);
    }

    

Parameters:
spellData the additional information to get about all summoner spells
Returns:
the API's JSON formatted response
See also:
LoL API Specification
    public String getSummonerSpells(final Set<SummonerSpellDataspellData) {
        return getSummonerSpells(spellDatanullnulltrue);
    }

    

Parameters:
spellData the additional information to get about all summoner spells
bySpellName whether the results should be organized by name or not (if not, will be by ID)
Returns:
the API's JSON formatted response
See also:
LoL API Specification
    public String getSummonerSpells(final Set<SummonerSpellDataspellDatafinal boolean bySpellName) {
        return getSummonerSpells(spellDatanullnullbySpellName);
    }

    

Parameters:
spellData the additional information to get about all summoner spells
locale the locale to specify
version the data version number
bySpellName whether the results should be organized by name or not (if not, will be by ID)
Returns:
the API's JSON formatted response
See also:
LoL API Specification
    public String getSummonerSpells(final Set<SummonerSpellDataspellDatafinal String localefinal String versionfinal boolean bySpellName) {
        final Map<StringStringparams = baseParams();
        if(spellData != null) {
            params.put("spellData"getCollectionString(spellData));
        }
        if(locale != null) {
            params.put("locale"locale);
        }
        if(version != null) {
            params.put("version"version);
        }
        params.put("dataById", Boolean.toString(!bySpellName));
        try {
            return .get(.get("static-data") + "/summoner-spell"params);
        }
        catch(final IOException e) {
            throw handleIOException(e);
        }
    }

    

Parameters:
summonerIDs the summoners to get information for
Returns:
the API's JSON formatted response
See also:
LoL API Specification
    public String getSummonersRunesByID(final List<LongsummonerIDs) {
        return waitForRateLimiter(.get("summoner") + "/summoner/" + getCollectionString(summonerIDs) + "/runes"baseParams());
    }

    

Parameters:
summonerID the summoner to get information for
Returns:
the API's JSON formatted response
See also:
LoL API Specification
    public String getSummonerStatsByID(final long summonerID) {
        return getSummonerStatsByID(summonerIDnull);
    }

    

Parameters:
summonerID the summoner to get information for
season the season to get stats for
Returns:
the API's JSON formatted response
See also:
LoL API Specification
    public String getSummonerStatsByID(final long summonerIDfinal Season season) {
        final Map<StringStringparams = baseParams();
        if(season != null) {
            params.put("season"season.toString());
        }
        return waitForRateLimiter(.get("stats") + "/stats/by-summoner/" + summonerID + "/summary"params);
    }

    

Parameters:
summonerIDs the summoners to get information for
Returns:
the API's JSON formatted response
See also:
LoL API Specification
    public String getSummonersTeamsByID(final List<LongsummonerIDs) {
        return waitForRateLimiter(.get("team") + "/team/by-summoner/" + getCollectionString(summonerIDs), baseParams());
    }

    

Parameters:
summonerID the summoner to get information for
Returns:
the API's JSON formatted response
See also:
LoL API Specification
    public String getSummonerTeamsByID(final long summonerID) {
        return waitForRateLimiter(.get("team") + "/team/by-summoner/" + summonerIDbaseParams());
    }

    

Parameters:
teamID the team to get information for
Returns:
the API's JSON formatted response
See also:
LoL API Specification
    public String getTeam(final String teamID) {
        return waitForRateLimiter(.get("team") + "/team/" + teamIDbaseParams());
    }

    

Parameters:
teamID the team to get information for
Returns:
the API's JSON formatted response
See also:
LoL API Specification
    public String getTeamLeagueEntriesByID(final String teamID) {
        return waitForRateLimiter(.get("league") + "/league/by-team/" + teamID + "/entry"baseParams());
    }

    

Parameters:
teamID the team to get information for
Returns:
the API's JSON formatted response
See also:
LoL API Specification
    public String getTeamLeaguesByID(final String teamID) {
        return waitForRateLimiter(.get("league") + "/league/by-team/" + teamIDbaseParams());
    }

    

Parameters:
teamIDs the teams to get information for
Returns:
the API's JSON formatted response
See also:
LoL API Specification
    public String getTeams(final List<StringteamIDs) {
        return waitForRateLimiter(.get("team") + "/team/" + getCollectionString(teamIDs), baseParams());
    }

    

Parameters:
teamIDs the teams to get information for
Returns:
the API's JSON formatted response
See also:
LoL API Specification
    public String getTeamsLeagueEntriesByID(final List<StringteamIDs) {
        return waitForRateLimiter(.get("league") + "/league/by-team/" + getCollectionString(teamIDs) + "/entry"baseParams());
    }

    

Parameters:
teamIDs the teams to get information for
Returns:
the API's JSON formatted response
See also:
LoL API Specification
    public String getTeamsLeaguesByID(final List<StringteamIDs) {
        return waitForRateLimiter(.get("league") + "/league/by-team/" + getCollectionString(teamIDs), baseParams());
    }

    

Returns:
the API's JSON formatted response
See also:
LoL API Specification
    public String getVersions() {
        try {
            return .get(.get("static-data") + "/versions"baseParams());
        }
        catch(final IOException e) {
            throw handleIOException(e);
        }
    }
    private String waitForRateLimiter(final String URIfinal Map<StringStringparams) {
        final Supplier<Stringcall = () -> {
            try {
                return .get(URIparams);
            }
            catch(final IOException e) {
                throw handleIOException(e);
            }
        };
        if( != null) {
            try {
                return .waitForCall(call);
            }
            catch(final InterruptedException e) {
                throw new APIException(..e);
            }
        }
        return call.get();
    }
New to GrepCode? Check out our FAQ X