To create a data science project, there is one crucial component any aspiring data scientist must have: data!
One source of abundant data comes from the massively popular online game, League of Legends, which luckily enough supports an API that makes it extremely easy to access user and game data.
Here is the website for the Riot Games API (Riot Games is the company that created and manages LoL): https://developer.riotgames.com/
To use LoL data, you must have a League of Legends account. It’s free to sign up and free to play!
When you first log in, the site assigns you an API key. Since this is my first time using an API, I had no idea what this meant. I learned (through many questions) that this key is what allows you to send requests to the API for data. There is a limit to the number of requests that can be made at any given time (500 requests every 10 minutes, 10 requests every 10 seconds) per key. For development, this amount should be fine. But if you make your application public and you have multiple users on your site (making multiple requests), then you may need more keys, possibly even a production key. Every ping to the site counts as a request. For example, if you ask the site to send you kallyope’s profile information (that’s me!), that’s one request. Say you see I’m in a game, and you want that game’s information–that’s another request. You can see the other players that are in that game, and you want to know who they are. That’s another nine requests. So as you can see, the requests can add up very quickly!
Okay, so now you have an API key and you want to start pulling data off the site. How do you do that?
You have to access the API Reference through the API Documentation (in the top menu). Or you can just click on this link here: https://developer.riotgames.com/api/methods#!/960
(SIDENOTE: WOW! So as I was writing up this post, I started poking around more parts of the site. And my mind is blowing up with all the cool information you can access, for example about champions. To read more about the awesomeness that is currently making me see stars, check my blog for a future post.)
I started with the Summoner tabs, which is user data. I clicked the first “Get” set, which allows you to look up users based on their username.
At the bottom of each section is an Execute Request button. For some of the fields you don’t have to specify the information you are looking for (e.g., champion info). For others, you have to provide some information to guide the API to what you are seeking. For the summoner name, I typed in my username, kallyope.
When I click Execute Request, I gain access to this link: https://na.api.pvp.net/api/lol/na/v1.4/summoner/by-name/kallyope?api_key=<key> You should replace <key> with your own API key. The link sends me to a plain text page with the information on it that I requested, in this case, information about the user kallyope.
The data is stored as JSON data. They look a lot like dicts in Python, don’t they? There is the key “kallyope” followed by the values “id”, “name”, etc. Then within those values, there are key-value pairs. The key “id” is paired with the value of kallyope’s id, “39017501”.
One thing that is awesome about this link is I can just replace my username in the URL with any username that I know, and it will give me that user’s information. For example, when I look up my friend, zunger, here is his information.
And that is how you can access League of Legends API in a nutshell!
You may be asking yourself, okay, that’s nice, I can see this information on a webpage, but what can I DO with it!? I ask myself that same question. One easy option is to throw this information into Python and create a table that organizes the information. See this post for my first attempt to wrangle online data in Python!