Skip to content

Repository files navigation

LPDB_python

CIPyPI - VersionCode style: blackGitHub License

LPDB_python provides Python interfaces for the Liquipedia Database API (LPDB API).

What You Need

  • Python 3.12 or later
  • API key for LPDB
  • (Optional) aiohttp

Installation

pip install lpdb_python

Basic Uses

LPDB Session

Python wrapper for LPDB session is defined in session.py. The wrapper provides the following differences from making your own requests:

  • Type hints

  • Validation of data type names being requested
    If an invalid data type is supplied, then the session will raise ValueError before attempting to make a request.

  • Error / warning handling
    If an error is returned by LPDB, then they will be converted to and raised as a Python exception.

  • Pre-configured request header, including formatting of your API key in the request header

    importlpdb_pythonaslpdb# These are equivalentsession=lpdb.LpdbSession("your_lpdb_api_key")
    session=lpdb.LpdbSession("Apikey your_lpdb_api_key")

Async Session

Asynchronous implementation of LPDB session can be found in async_session/session.py. This implementation depends on aiohttp, which can be installed with this library with the following command:

pip install lpdb_python[async]

LPDB Data Types

Data types in LPDB can be found in https://liquipedia.net/commons/Help:LiquipediaDB.

The raw data returned from LPDB may not be in the corresponding Python types. To help easily access the data, defs.py file provides wrappers for each available data types that offers converted data as object properties.

A property provided by the wrapper may be None if the raw data passed to the constructor of the wrapper did not contain the data, or if it contained an empty string. Thus, the user should be checking for None where appropriate.

Example

importlpdb_pythonaslpdbsession=lpdb.LpdbSession("your_lpdb_api_key")
matches= [
lpdb.Match(lpdb_raw_match)
forlpdb_raw_matchinsession.make_request(
"match",
"leagueoflegends",
conditions="[[parent::World_Championship/2025]]",
streamurls="true",
)
]

Documentation

Documentation for this package can be found in GitHub Pages.

License

This library is licensed under the MIT License, unless otherwise stated in the header of a file.
It should be noted, however, that the data you will be fetching from LPDB API is not licensed under the MIT License. See Liquipedia API Terms of Use here.

Disclaimer

"Liquipedia" is a registered trademark of Team Liquid. Liquipedia does not endorse or sponsor this project.

About

(Unofficial) Python interfaces for the Liquipedia Database API (LPDB API)

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Used by

Contributors

Languages