A Python 3 implementation of the speedrun.com REST API
Project description
srcomapi (SpeedrunComAPI)
A Python 3 implementation of the speedrun.com REST API. pip3 install srcomapi
Does not support Python 2. Sorry.
Usage
Start
>>> import srcomapi, srcomapi.datatypes as dt
>>> api = srcomapi.SpeedrunCom(); api.debug = 1
Searching for a game
# It's recommended to cache the game ID and use it for future requests.
# Data is cached for the current session by classname/id so future
# requests for the same game are instantaneous.
>>> api.search(srcomapi.datatypes.Game, {"name": "super mario sunshine"})
[<Game "Super Mario Sunshine">]
>>> game = _[0]
Getting the current world record for a game category
>>> game.categories
[<Category "Any%">, ...]
>>> _[0].records[0].runs
[{'run': <Run <Game "Super Mario Sunshine">/<Category "Any%">/9mr570dy 4498>, 'place': 1}, ...]
>>> _[0]["run"].times
{'primary_t': 4498, ...}
# primary_t is the time in seconds
Getting a dict containing all runs from a game
sms_runs = {}
for category in game.categories:
if not category.name in sms_runs:
sms_runs[category.name] = {}
if category.type == 'per-level':
for level in game.levels:
sms_runs[category.name][level.name] = dt.Leaderboard(api, data=api.get("leaderboards/{}/level/{}/{}?embed=variables".format(game.id, level.id, category.id)))
else:
sms_runs[category.name] = dt.Leaderboard(api, data=api.get("leaderboards/{}/category/{}?embed=variables".format(game.id, category.id)))
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
srcomapi-0.3.3.tar.gz
(6.2 kB
view details)
Built Distribution
File details
Details for the file srcomapi-0.3.3.tar.gz
.
File metadata
- Download URL: srcomapi-0.3.3.tar.gz
- Upload date:
- Size: 6.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.9.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d5abb9c87bc16a931078f4531e59e5b9831f1a1174dcac5e2f0340d7e46e4c39 |
|
MD5 | 5db17f9303b4224972d67bb1b7502eff |
|
BLAKE2b-256 | 2740987514cfcc1d91ef673c8715f5c2c6f38307501f4284692d636956b75dc1 |
File details
Details for the file srcomapi-0.3.3-py3-none-any.whl
.
File metadata
- Download URL: srcomapi-0.3.3-py3-none-any.whl
- Upload date:
- Size: 6.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.9.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2024f1337b8aebcd60e23b722ecfc35041572ea50bae7272d9d4b891d6cee9d9 |
|
MD5 | 45e8d807730e836444bdb28c4e739b56 |
|
BLAKE2b-256 | 34bc0a4fc1c9ba9d0a63283aa2a599b6fd1bf3c85004bc059451239c35c6b67d |