[PYTHON] I want to get League of Legends data ①

I want to get League of Legends data

This is the first post to commemorate.

Introduction

In this article, I wanted to get the data of "League of Legends" (hereinafter LOL), which is the game I'm addicted to, and numerically express the winning percentage and the champions I'm good at. (Well, sites like OPGG and YOURGG already exist, but my own For studying)

environment

As of January 29, 2020 OS:windows10 Anaconda:4.8.1 python:3.7.6

Advance preparation

Since the API is officially provided when collecting LOL data, we will use it this time. To do this, type the command below to install *** riotwather ***.

python -m pip install riotwatcher

You have to get the API KEY, so log in from here and remember the DEVELOPMENT API KEY. (This API KEY needs to be updated and rewritten if it becomes unusable due to the expiration date of 1 day.)

Get the data

(https://qiita.com/hyo_07/items/f106efbde82aeb47c8a0) I referred to this article.

sample_1.py


from riotwatcher import RiotWatcher

API_KEY="{The API KEY you just got}"
wather = RiotWatcher(API_KEY)
region = "jp1" #Server selection: Japanese mackerel is jp1
name = "Macha-kun" #Enter the summoner name
summoner = watcher.summoner.by_name(region,name) #Acquisition of player data
print(summoner)

When this is executed, the contents of the dictionary type summoner can be output. Actually, the contents are ["id": str, "accountId": str, "puuid": str, "fileIconId": int, "revisionDate": int, "summonerLevel": int].

sample_1.py


recentmatchlists = watcher.match.matchlist_by_account(region,summoner["accountId"]) #Get a list of data for the last 20 games
matches = recentmatchlists["matches"]
match_data = watcher.match.by_id(region,matches[0]["gameId"]) #Extract only one match
print(match_data)

Add these to the previous code and output the data for one game. image.png As you can see from this, there is a huge amount of data even in one game. (I couldn't take a screenshot because it didn't fit on the screen)

Examine the contents of the data

Let's take a look at the contents of ** match_data ** one by one.

The data I want this time is the number of wins and losses, the number of kills, the number of deaths, the number of assists, the kill involvement rate, the champion used, the champion who played, the lane, CS, the gold earned, the damage done to the champion, the time of the game. To go. The game mode is narrowed down to rank.

Let's find the item just mentioned from the previous output. (It's hard to find with a lot of letters: D) By the way, match_data is a dict type.

Object name Mold Data description
gameId int Game identification number
platformId str Server location
gameCreation int Timestamp when the loading screen is displayed
gameDuration int Game time
queueId int 420=Rank, 430=Normal, 450=ARAM
mapId int
seasonId int 13=Season10
gameVersion str Game version
gameMode str ARAM or CLASSIC
gameType str
teams list Details below
participants list Details below
participantIdentities list Details below

It looks like the above when roughly divided. However, at this stage, the information I want is clear only for ** gameDuration ** and ** gameMode **. ** temas **, ** partitions ** and ** partial Identities ** are of * list type *, so it seems necessary to take a closer look.

So, let's take a look at the contents of ** teams ** one by one.


match_data["teams"][0] #Team 1
match_data["teams"][1] #Team 2
Object name Mold Data description
teamId int 100=Blue team,200=Red team
win str "Win" or "Fail"
firstBlood bool True if you take the first blood
firstTower bool True if you take the first tower
firstInhibitor boo True if you take the first inhibitor
firstBaron bool True if you take the first baron
firstDragon bool True if you take the first dragon
firstRiftHerald bool True if you take the first lift herald
towerKills int Number of broken towers
inhibitorKills int Number of broken inhibitors
baronKills int Number of times Baron was defeated
dragonKills int Number of times the dragon was defeated
vilemawKills int Is it like a twisted tree line limited character? Number of times defeated
riftHeraldKills int Number of times you defeated Lift Herald
dominionVictoryScore int
bans list Details below

** bans ** is a * list type *, so let's dig deeper.

match_data["teams"][0]["bans"] #Team 1 BAN
match_data["teams"][1]["bans"] #Team 2 BAN
Object name Mold Data description
championId int Champion number
pickTurn int Pick order

Now let's look at ** partials **.

match_data["participants"][0] #Take data for one person
Object name Mold Data description
participantsId int 1~10 player identification numbers
teamId int 100=Blue team, 200=Red team
championId int Champion identification number
spell1Id int Summoner spell 1
spell2Id int Summoner spell 2
stats dict Details below
timeline dict Details below

There are ** stats ** and ** timeline ** of * dict type *, so let's check the details by following the example.

match_data["participants"][0]["stats"] #Output stats for one person
Object name Mold Data description
participantId int 1~10 player identification numbers
win bool True if you win
item0 int Item identification number
item1 int Item identification number
item2 int Item identification number
item3 int Item identification number
item4 int Item identification number
item5 int Item identification number
item6 int Item identification number
kills int Number of kills
deaths int Number of deaths
assists int Number of assists
largestKillingSpree int Maximum Killing Spree
largestMultiKill int Maximum multi-kill
killingSprees int Number of killing spree
longestTimeSpentLiving int
doubleKills int Number of double kills
tripleKills int Number of triple kills
quadraKills int Number of quadrakills
pentaKills int Number of pentakills
unrealKills int
totalDamageDealt int Total of all damage
magicDamageDealt int Total magic damage
physicalDamageDealt int Total physical damage
trueDamageDealt int Total confirmed damage
largestCriticalStrike int
magicDamageDealtToChampions int Total magic damage to the champion
physicalDamageDealtToChampions int Total physical damage to the champion
trueDamageDealtToChampions int Total confirmed damage to the champion
totalHeal int Total amount of recovery
totalUnitsHealed int
damageSelfMitigated int
damageDealtToObjectives int Damage to objects
damageDealtToTurrets int Damage to the tower
visionScore int Visibility score
timeCCingOthers int Number of behavioral disturbances
totalDamageTaken int Total damage received
magicalDamageTaken int Total magic damage received
physicalDamageTaken int Total physical damage received
trueDamageTaken int Total confirmed damage received
goldEarned int Earn gold
goldSpent int
turretKills int Number of towers destroyed
inhibitorKills int Number of broke inhibitors
totalMinionsKilled int Number of defeated units
neutralMinionsKilled int Number of defeated minions
neutralMinionsKilledEnemyJungle int Number of defeated opponent's jungle creep
totalTimeCrowdControlDealt int
champLevel int Champion level
visionWardsBoughtInGame int
sightWardsBoughtInGame int
wardsPlaced int Number of words placed
wardsKilled int Number of broken words
firstBloodKill bool True if you take the first blood
firstBloodAssist bool True if you get the assistance of First Blood
firstTowerKill bool True if you take the first tower
firstTowerAssist bool True if you get the assistance of the first tower
combatPlayerScore int
objectivePlayerScore int
totalPlayerScore int
totalScoreRank int
playerScore0 int
playerScore1 int
playerScore2 int
playerScore3 int
playerScore4 int
playerScore5 int
playerScore6 int
playerScore7 int
playerScore8 int
playerScore9 int
perk0 int
perk0Var1 int
perk0Var2 int
perk0Var3 int
perk1 int
perk1Var1 int
perk1Var2 int
perk1Var3 int
perk2 int
perk2Var1 int
perk2Var2 int
perk2Var3 int
perk3 int
perk3Var1 int
perk3Var2 int
perk3Var3 int
perk4 int
perk4Var1 int
perk4Var2 int
perk4Var3 int
perk5 int
perk5Var1 int
perk5Var2 int
perk5Var3 int
perkPrimaryStyle int
perkSubStyle int
statPerk0 int
statPerk1 int
statPerk2 int

The amount is amazing, and I have no idea what the data represents from the middle.

Let's take a second look and look at the ** timeline ** in the same way.

match_data["participants"][0]["timeline"] #Output timeline for one person
Object name Mold Data description
participantsId int 1~10 player identification numbers
creepsPerMinDeltas dict 1 minute CS
xpPerMinDeltas dict 1 minute of experience points
goldPerMinDeltas dict 1 minute earned gold
csDiffPerMinDeltas dict
xpDiffPerMinDeltas dict
damageTakenPerMinDeltas dict Damage received in 1 minute
damageTakenDiffPerMinDeltas dict
role str SOLO,DUO_SUPPORT,DUO_CARRY,NONE
lane str TOP,JUNGLE,MIDDLE,One of BOTTOM

Where it is * dict type *, data such as * "0-10" * and * "10-20" * at 10-minute intervals are stored in * float type *.

Finally, let's examine ** partial Identities **.

match_data["participantIdentities"][0] #Output partial Identities for one person
Object name Mold Data description
participantId int 1~10 player identification numbers
player dict Details below

Check the contents of ** player **.

match_data["participantIdentities"][0]["player"] #Player information for one player
Object name Mold Data description
platformId str The location of the server where you first created your account
accountId str Account ID
summonerName str Summoner name
summonerId str Summoner ID
currentPlatformId str Current server location
currentAccountId str Current account ID
matchHistoryUri str Battle record URI
profileIcon int Icon identification number

Finally

It takes a lot of patience to check this amount of data one by one. The place where the data description is blank is where it is not necessary this time. I want to fill it someday: D

Next, I would like to go to the work of analyzing using this extracted data.

Recommended Posts

I want to get League of Legends data ③
I want to get League of Legends data ②
I want to get League of Legends data ①
I want to create a web application that uses League of Legends data ①
Keras I want to get the output of any layer !!
I want to get custom data attributes of html as elements using Python Selenium
I want to get the name of the function / method being executed
[Note] I want to completely preprocess the data of the Titanic issue-Age version-
Anyway, I want to check JSON data easily
I want to knock 100 data sciences with Colaboratory
I tried to get CloudWatch data with Python
I want to customize the appearance of zabbix
I want to get the path of the directory where the running file is stored.
I want to visualize the transfer status of the 2020 J League, what should I do?
I want to get / execute variables / functions / classes of external files from Python
Library for "I want to do that" of data science on Jupyter Notebook
I want to detect images of cats from Instagram
I want to grep the execution result of strace
I want to install a package of Php Redis
[Python] I tried to get Json of squid ring 2
I want to say that there is data preprocessing ~
I want to increase the security of ssh connections
I want to solve Sudoku (Sudoku)
I want to use a python data source in Re: Dash to get query results
I want to be able to analyze data with Python (Part 3)
I tried to get the location information of Odakyu Bus
I want to specify another version of Python with pyvenv
I want to be able to analyze data with Python (Part 1)
[Python] I want to get a common set between numpy
I want to start a lot of processes from python
I want to use only the normalization process of SudachiPy
NikuGan ~ I want to see a lot of delicious meat! !!
I want to be able to analyze data with Python (Part 4)
I want to color black-and-white photos of memories with GAN
I want to be able to analyze data with Python (Part 2)
I want to judge the authenticity of the elements of numpy array
I want to know the features of Python and pip
How to get an overview of your data in Pandas
I tried to get data from AS / 400 quickly using pypyodbc
I sent the data of Raspberry Pi to GCP (free)
I want to understand systemd roughly
I want to scrape images to learn
I want to do ○○ with Pandas
I want to copy yolo annotations
I want to debug with Python
I want to manually assign the training parameters of the [Pytorch] model
I tried to get a database of horse racing using Pandas
I tried to get the index of the list using the enumerate function
I want to read the html version of "OpenCV-Python Tutorials" OpenCV 3.1 version
I want to use both key and value of Python iterator
I tried to get a list of AMI Names using Boto3
I want to acquire and list Japanese stock data without scraping
I want to check the position of my face with OpenCV!
Python techniques for those who want to get rid of beginners
I want to know the population of each country in the world.
[Python] I tried to get various information using YouTube Data API!
I want to convert vertically held data (long type) to horizontally held data (wide type)
I tried to get data from AS / 400 quickly using pypyodbc Preparation 1
I want to pin Spyder to the taskbar
I want to get angry with my mom when my memory is tight
I want to detect objects with OpenCV