How To Use Riot API With Python. In this tutorial, I will use Riot API... | by Barney H. | Towards Data Science

I recommend reading their document to know the latest change of their API before you start to do anything.
The Riot Games API is a REST API the provided developers data to use for building our own applications or websites. Currently, all League of Legends APIs is version 4(Updated 03/19/2020). Since this version, they no longer include a minor version in the API path.
Below is some of the data that you can get from Riot Games API:
Service status.
Summoner details: name, level, profile icon, account ids.
Match History and Match details and timelines by Summoner name.
Someone’s current game info, if someone is in the game.
Other information, check out the API documentation
You will always need a key to access the Riot Games API. We will talk about how to get an API key.
First, Use your Riot account to login Riot Developer Portal. It’s the account every time you use to play league of legends.
In your Dashboard, there’s a DEVELOPMENT API KEY. Remember, the key will expire 24 hours. Do not share your API key with anyone. If you’re getting a `403` response from the Riot API, you probably just need to refresh your key.
Also, you can register a personal Riot product, then you will not need to refresh your key every 24 hours. Typically, the personal application will take two weeks to review.
Keep in mind how many requests you make, since there’s a cap for a development API key and personal product key:
20 requests every 1 second
100 requests every 2 minutes
If you register a production API key, which is much harder to register. The cap is:
3,000 requests every 10 seconds
180,000 requests every 10 minutes
After you do all the requirements above, now you should get a development API key. Let’s try to take a look at the Doublelift Riot account. Use your API key to test on the Riot API by access:
https://na1.api.riotgames.com/lol/summoner/v4/summoners/by-name/Doublelift?api_key=RGAPI-YOUR-API-KEY
The result should be like this:
Remember, Riot API is regionalized, you need to pick your region. Also, for account details, only Summoner’s name is easy to get and not encrypted. Other account id information is encrypted.
Also, Summoner and account IDs are only unique per region, and PUUIDs is unique globally.
If you search for riot api or league of legends api on Google, there are a lot of libraries that you can use. Here is a list of Riot API Libraries. A lot of them are not well maintained, as you know Riot has upgraded their API version to V4 and deprecated all old versions.
Here I use a Python library called Riot-Watcher. To start you can easily run
pip3 install riotwatcher
To see account information like that we just try from URL:
We can also get rank information using one line:
For example, we want to fetch the last game information.
Then compare to the op.gg data. We got some accurate data but hard to read. We need access to Champion and other static data.
Now we only get the id of each champion. We need to know the name of each one for a better understanding.
From Data Dragon, you can get all static information data for League of Legend.
After running the code, we got something like this.
Also, spell, runes, and items information will be available from Data Dragon. Now you almost get all needed data to build an application like op.gg.
If you print the latest game detail. You may notice that position information is a little different from what we got from op.gg.
‘role’: ‘DUO_CARRY’,‘lane’: ‘BOTTOM’
You can build a map to identify each champion’s position.
(MID_LANE, SOLO): MIDDLE
(TOP_LANE, SOLO): TOP
(JUNGLE, NONE): JUNGLE
(BOT_LANE, DUO_CARRY): BOTTOM
(BOT_LANE, DUO_SUPPORT): UTILITY
Now you have learned what the Riot Games API is, and you have successfully use python to retrieve your first bits of data from the API. And these are almost all the data to build op.gg.
Riot API also provides access to live client data and replay data. I plan to talk about how to build a basic live client script to give you information about your current game. If you have any questions, please ask them below.
You can get all of the info about champions, items, and more from DataDragon.
The Riot developer discord channel.