Complete python wrapper for osu! api v2 and v1.
Project description
ossapi (documentation)
ossapi is the definitive python wrapper for the osu! api. ossapi has complete coverage of api v2 and api v1, and provides both sync (Ossapi
) and async (OssapiAsync
) versions for api v2.
If you need support or would like to contribute, feel free to ask in the #ossapi
channel of the circleguard discord.
Installation
To install:
pip install ossapi
# or, if you want to use OssapiAsync:
pip install ossapi[async]
To upgrade:
pip install -U ossapi
To get started, read the docs: https://circleguard.github.io/ossapi/.
Quickstart
The docs have an in depth quickstart, but here's a super short version for api v2:
from ossapi import Ossapi
# create a new client at https://osu.ppy.sh/home/account/edit#oauth
api = Ossapi(client_id, client_secret)
# see docs for full list of endpoints
print(api.user("tybug").username)
print(api.user(12092800, mode="osu").username)
print(api.beatmap(221777).id)
Async
ossapi provides an async variant, OssapiAsync
, which has an identical interface to Ossapi
:
import asyncio
from ossapi import OssapiAsync
api = OssapiAsync(client_id, client_secret)
async def main():
await api.user("tybug")
asyncio.run(main())
Read more about OssapiAsync on the docs.
Lazer
You can retrieve lazer-specific data (scores, leaderboards, etc) with ossapi:
from ossapi import Ossapi
api_lazer = Ossapi(client_id, client_secret, domain="lazer")
# best score on the lazer server (lazer + osu scores combined)
scores = api_lazer.user_scores(12092800, "best")
print(scores[0].pp)
Read more about domains on the docs.
Endpoints
All endpoints for api v2.
- Beatmap Packs
- Beatmaps
- Beatmapsets
- Changelog
- Chat
- Comments
- Events
- Forums
- Friends
- Home
- Matches
- Me
- News
- OAuth
- Rankings
- Rooms
- Scores
- Seasonal Backgrounds
- Spotlights
- Users
- Wiki
API v1 Usage
You can get your api v1 key at https://osu.ppy.sh/home/account/edit#legacy-api.
Basic usage:
from ossapi import OssapiV1
api = OssapiV1("key")
print(api.get_beatmaps(user=53378)[0].submit_date)
print(api.get_match(69063884).games[0].game_id)
print(api.get_scores(221777)[0].username)
print(len(api.get_replay(beatmap_id=221777, user=6974470)))
print(api.get_user(12092800).playcount)
print(api.get_user_best(12092800)[0].pp)
print(api.get_user_recent(12092800)[0].beatmap_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
Built Distribution
File details
Details for the file ossapi-3.4.0.tar.gz
.
File metadata
- Download URL: ossapi-3.4.0.tar.gz
- Upload date:
- Size: 94.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9204fa312372f7d8093272ab109d0e0bba0cb98048e3b700f3769f9ff7f3140d |
|
MD5 | af6a42ffa9ef71e66fbde266d434a18e |
|
BLAKE2b-256 | f0dab6a3047bccda49011654c4bbbfbf14b3609ea5800edea2814fa8a630d730 |
File details
Details for the file ossapi-3.4.0-py3-none-any.whl
.
File metadata
- Download URL: ossapi-3.4.0-py3-none-any.whl
- Upload date:
- Size: 90.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d696ef7d73be07ea45c74c405efc888b817a1b45f0a494d337f5e08a0363860c |
|
MD5 | 6047fb87151f225bdf1f73478e7373f3 |
|
BLAKE2b-256 | f06a93e2d7263860f4ff26df65fc8e83ce580a9663f603bad07a4760444940be |