Skip to main content

ATG - All The Games

Latest Version Python Versions License

Opinionated but flexible library of database models and scripts and APIs to store solo queue / competitive games, player, team and game data tailored for LoL Esports.

Features

  • Functions to access Riot & GRID APIs with smart region handling
  • SQLAlchemy database models compatible with both solo queue & esports games
  • Database models to store riot game event JSONL files
  • Ability to store complete Match-V5 JSON objects
  • Scripts to insert/manage solo queue accounts & store new solo queue games

1.X Release Notes

As of version 1.X, PostgreSQL is the required database backend due to the use of JSONB columns which are declared using the sqlalchemy.dialects.postgresql.JSONB datatype.

I have decided to bump the major version since this library is mature enough for my production needs however expect extensive schema changes as I look to fully mature my database models.

Although naming initially reflects the match-v5 API's choices and the terminology used by GRID esports, I've had to make some changes.

Here is are the major differences / exceptions that should be noted.

Key used Meaning Examples
Series A collection of related games A series has many games
source_data Raw/unprocessed/additional data Specifically in ParticipantStats we store the unprocessed match_v5 columns here
X_id table_id; Foreign key name champion_id, game_id
team_id Blue / red sides 100 - Blue, 200 - Red
participant_id The "#" of the participant From 1 - 10 representing blue top -> red bottom most of the time.

Todo

  • Remove the usage of ratelimit in favor of something that actually does stable rate limiting
  • Properly handle API error codes
  • Add the ability to store draft / other available esports game information
  • Open source GRID API code and GRID insertion scripts
  • Handle database sessions and API keys better using dependency injection or something other than passing session objects around. I kind of like the current functional nature of the API
  • Normalize database objects. Specifically the series/tournament-game relationship
  • Reduce the number of nullable columns where possible. This is especially a problem on the game table
  • Introduce enums where appropriate
  • Transition to HTTPX > requests
  • Remove or update the player_team_association table. I currently don't use it but it's definitely useful and should be revisited in the future.

Setup & Example Usage

It is recommended to use a virtual environment when directly running this library's scripts.

Setup dependencies

uv sync

Edit the .env file with your Riot API key and database connection string. The psycopg3 database driver is installed if this code is installed as a library and is recommended.

uv run main.py

Local database

A docker-compose.yml is provided to run the PostgreSQL backend locally, reading its credentials from the same .env.

docker compose up -d

Note: alembic upgrade head cannot build a database from scratch, as the migration history begins against an already populated database. get_session_factory creates the schema on first connection; follow it with alembic stamp head to track migrations.

Example usage

Linking a pro player by name to a solo queue account

import os
from sqlalchemy import select

from ATG.database import get_session_factory
from ATG.api import get_account_by_riot_id
from ATG.models import Player, Account

RIOT_API = os.environ["RIOT_API"]
Session = get_session_factory(os.environ["PROD_DB"])

def link_pro(pro_name, soloq):
    with Session() as session:
        try:
            player = session.execute(select(Player).where(Player.name == pro_name)).scalar_one()
        except:
            print(f"Unable to find associated player for {pro_name}")
            return
        name, tagline = soloq.split("#")
        details = get_account_by_riot_id(name, tagline, RIOT_API).json()
        new_acc = Account(puuid=details['puuid'], name=details['gameName'], tagline=details['tagLine'], region='NA1', player_id=player.id)
        session.add(new_acc)
        try:
            session.commit()
            print(f"Linked {pro_name} with {name}#{tagline}")
        except:
            session.rollback()
            print(f"Account {name}#{tagline} already linked")

link_pro("Tactical", "Tactical0#NA1")

Schema changes - Alembic commands

In the case of schema changes, Alembic allows us to automatically generate a script to apply the changes to the database. When a commit will cause a schema change, an alembic script should be attached to the commit.

alembic revision --autogenerate -m "changes"
alembic upgrade head

uv

Commands to publish updates on PyPi

uv build
uv publish

ATG is not endorsed by Riot Games and does not reflect the views or opinions of Riot Games or anyone officially involved in producing or managing Riot Games properties. Riot Games and all associated properties are trademarks or registered trademarks of Riot Games, Inc

Metadata

Release files for ATG-lib 1.5.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ATG-lib 1.5.7
File Size Uploaded Provenance Actions
atg_lib-1.5.7.tar.gz 36.3 kB Without provenance Details for atg_lib-1.5.7.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for ATG-lib 1.5.7
File Interpreter ABI Platform Actions
atg_lib-1.5.7-py3-none-any.whl Python 3 none any Details for atg_lib-1.5.7-py3-none-any.whl

Total release size: 81.3 kB

Release files / atg_lib-1.5.7.tar.gz

Download URL atg_lib-1.5.7.tar.gz
Size 36.3 kB
Tags Source
SHA-256 checksum
How to use checksums
bee6344da6d0e17c57241c27db5af79a6845ee2876cf9d407cbce14e5c28f49c
BLAKE2b-256 checksum
How to use checksums
3422119eb3b48145ab0fa2b80c08a13dcba3663663bc7f9edc1e339e07a3e967
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.5 {"installer":{"name":"uv","version":"0.13.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / atg_lib-1.5.7-py3-none-any.whl

Download URL atg_lib-1.5.7-py3-none-any.whl
Size 45.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2faf85e70214faa81731e4a6fd17b4e7a60e84971bf36896e2c2cb13bac248d3
BLAKE2b-256 checksum
How to use checksums
988b56513bfa14356866667edb38d803cfde9b7bd862fa82830ca1daf8e00ea0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.5 {"installer":{"name":"uv","version":"0.13.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for ATG-lib 1.5.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page