Comments (1)
import java.util.List;
import constant.*;
import dto.Summoner.*;
import com.google.gson.*;
import main.java.riotapi.*;
import dto.League.*;
public class LeagueApp {
public static void main(String[] args) throws RiotApiException {
RiotApi api = new RiotApi("API-KEY-HERE");
Summoner summoner = api.getSummonerByName(Region.NA, "RiotSchmick");
// Get list of leagues the player is in
List<League> leagues = api.getLeagueEntryBySummoner(summoner.getId());
// Iterate through leagues to find Solo-Q, and print out the league name and tier
for(League league : leagues) {
if(league.getQueue().equals(QueueType.RANKED_SOLO_5x5.name())) {
System.out.println("League Name: " + league.getName());
System.out.println("Tier: " + league.getTier());
// Get the league entry for the given player of this que
// and print out the division, lp, and wins and losses
LeagueEntry entry = league.getEntries().get(0);
System.out.println("Division: " + entry.getDivision());
System.out.println("LP: " + entry.getLeaguePoints());
System.out.println("Wins: " + entry.getWins());
System.out.println("Losses: " + entry.getLosses());
}
}
}
}
As you can probably see, the API separates this info into two different objects, League, and LeagueEntry. That's because a League can have multiple divisions, consisting of multiple summoners, thus multiple league entries.
You use getLeagueEntryBySummoner() instead of getLeagueBySummoner() if you only want to get league entry info for the summoner you want. getLeagueBySummoner() returns league entry info for ALL summoners in the same league as the summoner.
Hope this helps.
Output:
League Name: Sona's Templars
Tier: SILVER
Division: I
LP: 22
Wins: 6
Losses: 9
from riot-api-java.
Related Issues (20)
- How to separate TeamStats for each team?
- Gradle build not updated to V4?
- getLeagueById throws RiotApiException HOT 1
- GetGameDuration in Android Studio HOT 3
- get Summoner ID in champ select HOT 1
- Asking about the api HOT 3
- Endpoints for V4 not updated HOT 2
- Support for ACS
- getDataChampion returning 403 HOT 2
- Summoner is in game
- How do I import this in a Scala IntelliJ Project
- get runes pages by summoner
- NumberFormatException when trying to call getMatch() HOT 1
- 403: Forbidden HOT 2
- TeamFightTactics
- Add Tournament Stub
- 403 Forbidden HOT 2
- getDataChampion returns 403 Forbidden
- Cant get the name of a champion
- TFT API Data
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from riot-api-java.