taycaldwell / riot-api-java

Riot Games API Java Library
http://taycaldwell.github.io/riot-api-java/
Apache License 2.0
190 stars 73 forks source link

How can we get the placements stats ? #53

Closed JonZarate closed 8 years ago

JonZarate commented 8 years ago

If you try to get the rancked information of a unrancked summoner, even if he has played some placement games it returns nothing.

Is this possible?

Thanks.

taycaldwell commented 8 years ago

getRankedStats should return information for a summoner in their placements.

Can you provide a code snippet?

Here is an example of a summoner currently in their placements, and the data returned:

{
   "modifyDate": 1456041435000,
   "champions": [
      {
         "id": 103,
         "stats": {
            "totalDeathsPerSession": 38,
            "totalSessionsPlayed": 4,
            "totalDamageTaken": 84403,
            "totalQuadraKills": 0,
            "totalTripleKills": 0,
            "totalMinionKills": 516,
            "maxChampionsKilled": 9,
            "totalDoubleKills": 2,
            "totalPhysicalDamageDealt": 52060,
            "totalChampionKills": 22,
            "totalAssists": 22,
            "mostChampionKillsPerSession": 9,
            "totalDamageDealt": 390010,
            "totalFirstBlood": 0,
            "totalSessionsLost": 3,
            "totalSessionsWon": 1,
            "totalMagicDamageDealt": 236988,
            "totalGoldEarned": 38554,
            "totalPentaKills": 0,
            "totalTurretsKilled": 2,
            "mostSpellsCast": 0,
            "maxNumDeaths": 11,
            "totalUnrealKills": 0
         }
      },
      {
         "id": 0,
         "stats": {
            "totalDamageTaken": 84403,
            "totalTripleKills": 0,
            "totalMinionKills": 516,
            "maxChampionsKilled": 9,
            "maxLargestCriticalStrike": 0,
            "totalChampionKills": 22,
            "totalPhysicalDamageDealt": 52060,
            "rankedPremadeGamesPlayed": 0,
            "totalSessionsLost": 3,
            "totalNeutralMinionsKilled": 8,
            "totalSessionsWon": 1,
            "totalMagicDamageDealt": 236988,
            "maxLargestKillingSpree": 2,
            "totalPentaKills": 0,
            "maxTimeSpentLiving": 624,
            "totalDeathsPerSession": 38,
            "totalQuadraKills": 0,
            "totalSessionsPlayed": 4,
            "totalDoubleKills": 2,
            "totalAssists": 22,
            "maxTimePlayed": 2160,
            "mostChampionKillsPerSession": 9,
            "totalDamageDealt": 390010,
            "botGamesPlayed": 0,
            "killingSpree": 6,
            "totalFirstBlood": 0,
            "rankedSoloGamesPlayed": 0,
            "totalHeal": 9927,
            "totalGoldEarned": 38554,
            "mostSpellsCast": 0,
            "totalTurretsKilled": 2,
            "maxNumDeaths": 11,
            "totalUnrealKills": 0,
            "normalGamesPlayed": 0
         }
      }
   ],
   "summonerId": 32236660
}
Linnun commented 8 years ago

I'd like to add that specifically the leagues endpoint will always return an empty dataset until you are actually placed in a league (for obvious reasons).

rithms already provided a way to get ranked stats, which will also work if a summoner is still to be placed.

What exact data would you like to receive?

JonZarate commented 8 years ago

Yes, I was getting a null league entry, I will try the function rithms suggested. Thank you.

JonZarate commented 8 years ago

I just realised. I can't see how many W/L the summoner has in RankedStats. Is it supposed to be there ? I can't find it.

Linnun commented 8 years ago

I have added an example script that should retrieve your desired data:

https://github.com/rithms/riot-api-java/blob/master/examples/RankedWinsAndLosses.java

Please let me know, if you need help with anything else.

taycaldwell commented 8 years ago

Wins and losses can be retreived from the totalSessionsWon and totalSessionsLost fields.

As you can see from my example above, RankedStats divides stats by champions. The 'id' field is the champion ID of the champion for those stats. A champion ID of 0 means overall stats.

So you can get W/L for each individual champion, and overall W/L.

taycaldwell commented 8 years ago

That example might not work for him, as it has version 4 features like the ApiConfig. I believe he's using the v3.9.0 jar form the releases page.

Here's the example using 3.9.0 syntax: https://gist.github.com/rithms/19e2a8235dbdd0caee3c

Linnun commented 8 years ago

It should work with 3.9.0, if you replace

ApiConfig config = new ApiConfig().setKey("YOUR-API-KEY-HERE");
RiotApi api = new RiotApi(config);

with

RiotApi api = new RiotApi("YOUR-API-KEY-HERE");

(and adjust the imports)

JonZarate commented 8 years ago

Yes I am using the one from the release page but I had no problems to initialize the API. The code is working too, thank you. I didn't figure out the first id was for overall data.