pygrid: Python client for the GRID esports API
pygrid simplifies the usage of the GRID esports API by managing all of the hard parts for you. A collection of data pipeline functions that support processing of game data are also provided with this library.
Features & Todo
- Rate limited access to GRID GraphQL endpoints.
- Simple client class to access commonly used queries.
- Automatic pagination for queries that require multiple API calls.
- Minimal external dependencies. The client and ETL functions only require httpx, pendulum, pydantic, orjson and tqdm.
- Release on PyPi for easier installation.
- Release my scripts that parse returned data files ideally in a database agnositic format. As I don't expect this library to become that popular, my main focus will be on compatability with my own ATG database format.
- Complete unit testing coverage of all parsing functions.
- Better documentation and figure out how to pass filtering options through the pagination function.
Installation
pip install grid-lol-client
Usage
import os
from pygrid.client import GridClient
client = GridClient(os.environ["GRID_API_KEY"])
With the client setup with your GRID API key, you can now begin to request data from the centra data API.
all_teams = client.get_all_teams()
3%|███▊ | 100/3629 [00:01<00:53, 65.66it/s]
Functions which call REST APIs will return an httpx.response object. Example usage:
available_files = client.get_available_files("2796434")
next(file for file in available_files.json()["files"] if file["id"] == "events-grid")
{'id': 'events-grid',
'description': 'Grid Series Events (.jsonl)',
'status': 'ready',
'fileName': 'events_2796434_grid.jsonl.zip',
'fullURL': 'https://api.grid.gg/file-download/events/grid/series/2796434'}
Query for series with filters
from pygrid import OrderDirection, SeriesType
import pendulum
available_series = client.get_all_series(
order=OrderDirection.DESC,
title_ids = [3], # Only LoL series (Val series by default also selected)
gte = pendulum.now().add(weeks=-2).to_iso8601_string(), # Earliest series time
game_types = [SeriesType.SCRIM], # COMPETITIVE is Champion's Queue
# tournaments = ["825437", "825439", "825438", "825440", "825441"],
)
Development
Generating API clients with Ariadne Codegen
Ariadne Codegen lets us translate raw GraphQL queries into a Python library as well as bringing GraphQL's type safety to Python with Pydantic
You'll need to set your GRID API key to be able to access the central data GraphQL API
export GRID_API_KEY=YOUR_KEY_HERE
ariadne-codegen client --config central-data.toml
ariadne-codegen client --config series-state.toml
Publishing and packaging
Poetry is used to manage packages and publishing to PyPi.
poetry add package_name -D # Development packages
poetry publish
License
Metadata
Release files for grid-lol-client 0.2.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| grid_lol_client-0.2.7.tar.gz | 27.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| grid_lol_client-0.2.7-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 69.1 kB
Release files / grid_lol_client-0.2.7.tar.gz
| Download URL | grid_lol_client-0.2.7.tar.gz |
|---|---|
| Size | 27.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8e2526ba2a59bbf7dabc4bbac7cbbcabc683844fe45b728665bed8bee8b31f53
|
|
BLAKE2b-256 checksum How to use checksums |
f4b3870af8f9312ea834defafa5bf68fde3df3cb86bd53c8a1c5e888392ee132
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.1.3 CPython/3.12.3 Linux/6.11.0-29-generic
|
Release files / grid_lol_client-0.2.7-py3-none-any.whl
| Download URL | grid_lol_client-0.2.7-py3-none-any.whl |
|---|---|
| Size | 41.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
12ae6e3c53e5ad334c57730058c7bf48bca905290ece0f0e3dc71d4a4bd58108
|
|
BLAKE2b-256 checksum How to use checksums |
630bb65e63dffd6f544983af36e57f757056a7d66e0813db3f94e9ffe0f73fb2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.1.3 CPython/3.12.3 Linux/6.11.0-29-generic
|