Skip to main content

A python wrapper for the speedrun.com API

Project description

srcom.py

This project is a work in progress.

An asynchronous Python wrapper for the speedrun.com REST API. Currently it focuses on the most important parts of the API, i.e., games, runs, users. It follows an object-oriented design, with methods integrating different parts of the API together and allowing simple retrieval of information.

Simple Example

import asyncio

import srcom


async def main():
    client = srcom.Client()

    # Exact match by abbreviation
    game = await client.get_game(abbreviation="khfm")

    # Make sure to close the HTTP session!
    await client.close()

    # You can also use a context manager to automatically close the client
    async with srcom.Client() as client:
        # Fuzzy search game by name
        game = await client.get_game(name="Kingdom Hearts II")
        # You can get any resource directly from its ID as well
        game = await srcom.Game.from_id(game.id, client)

        # Gets the 3 fastest runs for the default category
        for run in await game.leaderboard(3):
            await print_run(run)

        print()

        # Returns at most 20 runs (default limit in API)
        for run in await game.runs():
            await print_run(run)

        print()

        # Gets the WR for the default category for the game
        record = await game.record()
        await print_run(record)


async def print_run(run):
    # Retrieve the runner
    player = await run.player()
    print("{}    {}    {}    {}".format(
        run.time,
        player.name,
        player.country or 'NONE',  # player.country can be None
        (await run.category()).name,
        run.link,  # direct link to run on speedrun.com
    ))


asyncio.get_event_loop().run_until_complete(main())

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

srcom.py-0.0.2.tar.gz (8.3 kB view details)

Uploaded Source

Built Distribution

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

srcom.py-0.0.2-py3-none-any.whl (8.4 kB view details)

Uploaded Python 3

File details

Details for the file srcom.py-0.0.2.tar.gz.

File metadata

  • Download URL: srcom.py-0.0.2.tar.gz
  • Upload date:
  • Size: 8.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.6

File hashes

Hashes for srcom.py-0.0.2.tar.gz
Algorithm Hash digest
SHA256 4e0d291aafbfddf44a4b571743b269b95bfd29d0b0fc2bc5059696669f2bf22c
MD5 8b19e54d6586029e6b1c54a611774113
BLAKE2b-256 4188a6d8c1681fc6adc7316b2e5b4dba729e2ca2239e202cc83d05d18846f2b4

See more details on using hashes here.

File details

Details for the file srcom.py-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: srcom.py-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 8.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.6

File hashes

Hashes for srcom.py-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 ff50d057aa925d6b8044389bc7f412a3d2dcec0daff9478766ff9016435d9d12
MD5 389497cd438426aade98dc9a228fb79b
BLAKE2b-256 06abeb8638b89df1f2a00a0181ae6e2f25450eb89503b4d7eaedc5c66cac8d78

See more details on using hashes here.

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