pyke is a thin async Riot API wrapper for League of Legends.
Install the latest version directly from PyPI:
pip install pyke-lolYou need Python 3.10+
import asyncio
from pyke import Continent, Pyke, exceptions
async def main() -> None:
# Initialize the API
async with Pyke("RGAPI-...", timeout=60, print_url=True) as api:
# Every pyke method follows the same convention as the Riot API
# For example account/v1/accounts/by-riot-id/{gameName}/{tagLine} becomes:
account = await api.account.by_riot_id(Continent.EUROPE, "saves", "000")
print(f"Riot ID: {account['gameName']}#{account['tagLine']}")
print(f"PUUID: {account['puuid']}")
# pyke throws typed exceptions matching Riot API error codes
try:
region = await api.account.region_by_puuid(
Continent.EUROPE, account["puuid"]
)
except exceptions.DataNotFound as e:
print(e) # Output: Data not found (Error Code: 404)
quit()
print(f"Region: {region['region']}")Typed exceptions for all HTTP status codes:
from pyke import exceptions
try:
summoner = await api.summoner.by_puuid(Region.EUW, "NonExistentPuuid")
except exceptions.DataNotFound as e:
print(f"Not found: {e}") # Data not found (Error Code: 404)
except exceptions.RateLimitExceeded as e:
print(f"Rate limited: {e}") # Rate limit exceeded (Error Code: 429)
except exceptions.InternalServerError as e:
print(f"Server error: {e}") # Internal server error (Error Code: 500)For any questions or help, please reach out on Discord: .irm