Skip to main content

The Riot API in Python, made easy.

Project description

Blitzcrank

Riot API made easy

Intoduction

Welcome to Blitzcrank, a module to help with interaction with the Riot API. Although there are many modules like it, most simply act as wrappers to the Riot API without providing much useful functionality. The aim of this project is to make access to the Riot API as painless as possible, while still allowing the richness of data it provides.

While Blitzcrank is easy to use, if you're new to Python or programming in general, take a look at this guide first and familiarise yourself with Python in general before attempting to use this module. A more well rounded foundation will make it easier for you to grow. This four hour seminar is suitable for complete programmming beginners.

Features

  • Built in (custom) rate limiting
  • Extra tooling for quick extraction of match data (see Built in indexing below)
  • Coverage of all base API endpoints the Riot API provides
  • Champion/Item APIs to allow built in querying of champion and item IDs, names and statistics

Installation

  • Install blitzcrank using pip

    pip install blitzcrank

  • Import from the same directory level using

    from blitzcrank import Blitzcrank

Getting started

Here's a sample of using Blitzcrank to get base player information;

from blitzcrank import Blitzcrank

b = Blitzcrank('RGAPI-XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX', 'euw1')
b.summoner.by_name('Montagne')

>> {'id': '5-u_LoLzSaKwdrnG9vK35E8Ju27IXVu6XMM2Y38pxIfhjwM', 
    'accountId': 'igL1_xtGwMyfW89c9EFvok3_yvOGrBOjeosOxL2WtzCg2X4', 
    'puuid': 'k3uFuLaNZplggr93emIb9W3JP0Gf_1D-3vUKt4Bd8m78I1RXiKvvDslyJ53fdbO7zJsN405siJDQPA', 
    'name': 'Montagne', 
    'profileIconId': 691, 
    'revisionDate': 1581790964000, 
    'summonerLevel': 118}

For most methods, a summoner name or account ID is needed;

from blitzcrank import Blitzcrank

b = Blitzcrank('RGAPI-XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX', 'euw1')
s = b.summoner.by_name('Montagne')
b.league.rank_by_summoner_id(s['id'])

>> [{'leagueId': '717ffd55-1b41-4197-bf31-afeafa6346bc', 
    'queueType': 'RANKED_SOLO_5x5', 
    'tier': 'SILVER', 
    'rank': 'I', 
    'summonerId': '5-u_LoLzSaKwdrnG9vK35E8Ju27IXVu6XMM2Y38pxIfhjwM', 
    'summonerName': 'Montagne', 
    'leaguePoints': 39, 
    'wins': 88, 
    'losses': 82, 
    'veteran': True, 
    'inactive': False, 
    'freshBlood': False, 
    'hotStreak': False}]

Built in indexing

When analysing data, a lot of time is taken making sure you've prefixed correctly according to the Riot Documentation. Blitzcrank lets you rocket grab statistics in simple one liners.

from blitzcrank import Blitzcrank
import json

b = Blitzcrank("RGAPI-XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX", "euw1")

summoner = "Thebausffs"
summoner_id = b.summoner.by_name(summoner).get('accountId')
match_id = b.match.matchlist_by_account(summoner_id, queues=[420])['matches'][0]['gameId']

game_data = b.match.by_id(match_id)
timeline_data = b.match.timeline_by_id(match_id)

stats_array = []

for participant in range(1,11):
    participant_stats = {
        "summoner": b.summoner.by_account(b.match.account_id_for_participant(participant, game_data))["name"],
        "champion": b.match.champion_for_participant(participant, game_data),
        "opposing_champion": b.match.lane_opponent_for_participant(participant, game_data, timeline_data),
        "csdiff@15": b.match.csdiff_at_15_for_participant(participant, game_data, timeline_data),
        "cs_per_min": b.match.cs_per_min_for_participant(participant, game_data),
        "golddiff@15": b.match.golddiff_at_15_for_participant(participant, game_data, timeline_data),
        "gold_per_min": b.match.gold_per_min_for_participant(participant, game_data),
        "control_wards_placed": b.match.control_wards_placed_for_participant(participant, timeline_data)
    }

    stats_array.append(participant_stats)

print(json.dumps(stats_array, sort_keys=True, indent=4))

You can find more examples of usage within the examples directory.

Note

A lot of the examples utilise pandas, a helpful library for dealing with tables of information. Once data is saved within pandas into a CSV format, it can be easily copy/pasted into google sheets, or various other locations where scouting reports may be held.

Rate limiting

Blitzcrank will by default use the developer API key rate limits. You can change these such as in this example below;

from blitzcrank import Blitzcrank

b = Blitzcrank("RGAPI-10ec71d4-32b7-464b-a75d-9ce28708f6c7", "euw1")
b.change_rate_limits(short_call_limit=500, short_call_period=10, =long_call_limit30000, long_call_period=600)

There is a more verbose rate limit example in the examples directory, as well as a test.

Feature request and collaboration

If you'd like to request a feature, please make an issue on this repository with the title starting "FR". e.g

"FR: Query Riot API for my future"

If you're a developer, and you spot anything that you think can be improved within blitzcrank, you are more than welcome to open up a pull request with your desired changes. Any changes which can be well justified, will be implemented.

To do's

  • Extended documentation of each method (in-line or otherwise)
  • Demo video including projects created with Blitzcrank

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

blitzcrank-0.0.2.tar.gz (13.0 kB view details)

Uploaded Source

File details

Details for the file blitzcrank-0.0.2.tar.gz.

File metadata

  • Download URL: blitzcrank-0.0.2.tar.gz
  • Upload date:
  • Size: 13.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.3.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.8.0

File hashes

Hashes for blitzcrank-0.0.2.tar.gz
Algorithm Hash digest
SHA256 4324ff72e1920de3aff4ffafc7d2126c6c4896d3f59a72faeadc9dc3ec6eba8e
MD5 fdfb8f7eb76110828f291b2307803b5f
BLAKE2b-256 0d180fbe18959a00bc51793b89b4e51dcc46ed45bc372e61cf4e663e1ad42478

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page