Skip to main content

A Riot API wrapper specifically for League of Legends.

Project description

pyke

PyPI - Version Documentation PyPI - Downloads Coverage License: MIT

pyke is a thin async first Riot API wrapper specifically designed for League of Legends.

Key Features

  • Pythonic API - Clean, intuitive interface that mirrors Riot's API structure exactly
  • Production Logging - Standard Python logging integration with configurable levels

Installation

Install the latest version directly from PyPI:

pip install pyke-lol

Note: You need Python 3.9+ to use pyke.


Quickstart

from pyke import Continent, Pyke, exceptions

# Initialize the API
api = Pyke("RGAPI-...")

# Every pyke method follows the same convention as the Riot API
# For example account/v1/accounts/by-riot-id/{gameName}/{tagLine} becomes:
account = 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 = api.account.region_by_puuid(Continent.EUROPE, account["puuid"])
except exceptions.DataNotFound as e:
    print(e)  # Output: Data not found (Error Code: 404)
    quit()

Configuration

pyke offers timeout configuration:

from pyke import Pyke

api = Pyke(
    api_key="RGAPI-...",
    timeout=60,                    # Request timeout in seconds (default: 60)
)

Logging

pyke uses Python's standard logging module for comprehensive diagnostics:

import logging
from pyke import Pyke

# Configure logging before creating Pyke instance
logging.basicConfig(
    level=logging.INFO,
    format="%(asctime)s [%(levelname)s] %(name)s: %(message)s",
    datefmt="%H:%M:%S",
)

api = Pyke("RGAPI-...")

Log Levels

  • DEBUG: Detailed diagnostic information
  • INFO: Request URLs with rate limit tracking: (45/100) - https://na1.api.riotgames.com/...
  • WARNING: Retries, rate limiting, malformed API responses
  • ERROR: Critical failures

Common Configurations

# Production (quiet) - only warnings and errors
logging.basicConfig(level=logging.WARNING)

# Development (verbose) - see all requests
logging.basicConfig(level=logging.INFO)

# Debugging - maximum verbosity
logging.basicConfig(level=logging.DEBUG)

# Completely silent
logging.getLogger('pyke').setLevel(logging.CRITICAL)

# Log to file
logging.basicConfig(
    level=logging.INFO,
    filename="api_requests.log",
    format="%(asctime)s [%(levelname)s] %(name)s: %(message)s"
)

Advanced Features

Custom Exception Handling

pyke provides typed exceptions for all HTTP status codes:

from pyke import exceptions

try:
    summoner = 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 after 5 retries (Error Code: 429)
except exceptions.InternalServerError as e:
    print(f"Server error: {e}")  # Internal server error (Error Code: 500)

Available exceptions: BadRequest (400), Unauthorized (401), Forbidden (403), DataNotFound (404), MethodNotAllowed (405), UnsupportedMediaType (415), RateLimitExceeded (429), InternalServerError (500), BadGateway (502), ServiceUnavailable (503), GatewayTimeout (504)

Continental vs Regional Routing

pyke automatically handles Riot's routing requirements:

from pyke import Continent, Region

# Continental routing (Account-V1, Match-V5)
account = api.account.by_riot_id(Continent.EUROPE, "saves", "000")

# Regional routing (Summoner-V4, League-V4, etc.)
summoner = api.summoner.by_puuid(Region.EUW, account.puuid)

Continental Routing:

  • AMERICAS: NA, BR, LAN, LAS
  • ASIA: KR, JP
  • EUROPE: EUNE, EUW, ME1, TR, RU
  • SEA: OCE, SG2, TW2, VN2

Complete Feature List

  • Production Logging - Standard Python logging with configurable levels
  • Custom Exceptions - 11 typed exception classes for precise error handling
  • Continental Routing - Automatic routing for Account/Match endpoints
  • Configurable Timeouts - Adjust request timeouts for slow endpoints
  • Mirror API Design - Intuitive mapping to Riot's API structure
  • Pythonic Interface - Clean, idiomatic Python code
  • 94% Test Coverage - Comprehensive integration test suite
  • Python 3.9-3.14 - Tested across 6 Python versions

Documentation & Resources


Contributing & Support

Found a bug or have a feature request? Open an issue on GitHub.

For any questions or help, please reach out on Discord: .irm


License

MIT License - see LICENSE.txt for details.

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

pyke_lol-3.0.0.tar.gz (15.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyke_lol-3.0.0-py3-none-any.whl (30.4 kB view details)

Uploaded Python 3

File details

Details for the file pyke_lol-3.0.0.tar.gz.

File metadata

  • Download URL: pyke_lol-3.0.0.tar.gz
  • Upload date:
  • Size: 15.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pyke_lol-3.0.0.tar.gz
Algorithm Hash digest
SHA256 971b30ae5f5c35464631ee7313735009e0acfa0e222c8fcc9324a77f29bde281
MD5 491e28b53e8c813913b820202a82ec18
BLAKE2b-256 a4791d6a3753c61d49563a668d307c573885598c7c3a7c1e6be041ee60ba6045

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyke_lol-3.0.0.tar.gz:

Publisher: python-publish.yml on diodemusic/pyke

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyke_lol-3.0.0-py3-none-any.whl.

File metadata

  • Download URL: pyke_lol-3.0.0-py3-none-any.whl
  • Upload date:
  • Size: 30.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pyke_lol-3.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 43956745dccd3a8eb754a23a2074ab431d58227fd21b038239dc1bfbcc2d8196
MD5 318d48e1a677f47200f83b5b20c50862
BLAKE2b-256 e17b1c6bccd713f70f52d8b24afd79896bbdc97eace77d006436439324b070ea

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyke_lol-3.0.0-py3-none-any.whl:

Publisher: python-publish.yml on diodemusic/pyke

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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