Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
from riotRequests import *
# Riot API documentation was used.
# https://developer.riotgames.com/api-methods/ and https://developer.riotgames.com/static-data.html
def summonerRank(region, summonerName):
"""Returns summoners current rank in solo/duo and flex queue by taking region and summoner name as input"""
summonerNameTitled = summonerName.title()
summonerData = requestSummonerData(region, summonerName, APIKey)
summonerID = str(summonerData['id'])
rankedData = requestRankedData(region, summonerID, APIKey)
# The if statement below is used to prevent confusion between solo/duo and flex queue.
# In this case JSON data changes it position by refreshing it.
if rankedData[0]['queueType'] == "RANKED_FLEX_SR":
flex = 0
solo = 1
else:
flex = 1
solo = 0
soloLeague = rankedData[solo]['leagueName']
soloRank = rankedData[solo]['tier'] + " " + rankedData[solo]['rank']
soloLeaguePoints = rankedData[solo]['leaguePoints']
soloWins = rankedData[solo]['wins']
soloLosses = rankedData[solo]['losses']
flexLeague = rankedData[flex]['leagueName']
flexRank = rankedData[flex]['tier'] + " " + rankedData[flex]['rank']
flexLeaguePoints = rankedData[flex]['leaguePoints']
flexWins = rankedData[flex]['wins']
flexLosses = rankedData[flex]['losses']
return ("¬¬ Solo/Duo Queue\n" +
str(summonerNameTitled) + " is currently playing in " + str(
soloLeague) + " league and his/her solo rank is " + str(soloRank) +
" with " + str(soloLeaguePoints) + " league points (LP)\n" +
str(summonerNameTitled) + " won " + str(soloWins) + " and lost " + str(soloLosses) + " games\n" +
"\n¬¬ Flex Queue \n" +
str(summonerNameTitled) + " is currently playing in " + str(
flexLeague) + " league and his/her flex rank is " + str(flexRank) +
" with " + str(flexLeaguePoints) + " league points (LP)\n" +
str(summonerNameTitled) + " won " + str(flexWins) + " and lost " + str(flexLosses) + " games")