Skip to main content

Tiny Hi-Rez API wrapper

Project description

Charybdis

Tiny Hi-Rez API Python wrapper that I wrote to use in my Smite related projects (and to play around with async).

Hi-Rez API documentation: https://webcdn.hirezstudios.com/hirez-studios/legal/smite-api-developer-guide.pdf

See the Hi-Rez API documentation for available methods and their parameters. The structure of the returned values is not described though, so some work is required to figure out what information can actually be obtained from the API.

Other Python wrappers:

Installation

pip install charybdis

Usage

Sync

import os

import charybdis

api = charybdis.Api(
    # These are also the default values.
    base_url=charybdis.Api.SMITE_PC_URL,
    dev_id=os.getenv("SMITE_DEV_ID"),
    auth_key=os.getenv("SMITE_AUTH_KEY"),
)

# Returns deserialized JSON.
scylla_skins = api.call_method(
    "getgodskins",  # Method name.
    "1988",  # God ID - Scylla.
    "1",  # Language ID - English.
)

for scylla_skin in scylla_skins:
    print(scylla_skin["skin_name"])

# Output:
# Standard Scylla
# Bewitching Bunny
# Child's Play
# COG Scylla
# and many more...

Async

import asyncio

import charybdis


async def main() -> None:
    async with charybdis.Api() as api:
        patch_info_task = asyncio.create_task(api.acall_method("getpatchinfo"))
        gods_task = asyncio.create_task(api.acall_method("getgods", "1"))

        patch_info = await patch_info_task
        gods = await gods_task

    newest_god = ""
    for god in gods:
        if god["latestGod"] == "y":
            newest_god = god["Name"]
            break

    print(
        f"The current patch is {patch_info['version_string']}"
        + f" and the newest god is {newest_god}."
    )


asyncio.run(main())

# Output:
# The current patch is 9.12 and the newest god is Maui.

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

charybdis-2.0.0.tar.gz (5.1 kB view hashes)

Uploaded Source

Built Distribution

charybdis-2.0.0-py3-none-any.whl (5.2 kB view hashes)

Uploaded Python 3

Supported by

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