Skip to main content

The definitive python wrapper for the osu! api

Project description

ossapi (documentation) PyPI version

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://liam-devoe.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.

Other domains

You can use ossapi to interact with the api of other deployments of the osu website, such as https://dev.ppy.sh.

from ossapi import Ossapi

api = Ossapi(client_id, client_secret, domain="dev")
# get the dev server pp leaderboards
ranking = api.ranking("osu", "performance").ranking
# pearline06, as of 2023
print(ranking[0].user.username)

Read more about domains on the docs.

Endpoints

All endpoints for api v2.

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

ossapi-5.3.5.tar.gz (99.7 kB view details)

Uploaded Source

Built Distribution

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

ossapi-5.3.5-py3-none-any.whl (96.3 kB view details)

Uploaded Python 3

File details

Details for the file ossapi-5.3.5.tar.gz.

File metadata

  • Download URL: ossapi-5.3.5.tar.gz
  • Upload date:
  • Size: 99.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.11

File hashes

Hashes for ossapi-5.3.5.tar.gz
Algorithm Hash digest
SHA256 530e0d1157f40925038b07d49c4816ff5eb5d22104232bd25920a1755e0aa84a
MD5 732b000f01274835fda2b2c6bb79fae8
BLAKE2b-256 5ba947c42d50a1d575af739016e779d770c00159a52c3a8f18dc954d616a0c8d

See more details on using hashes here.

File details

Details for the file ossapi-5.3.5-py3-none-any.whl.

File metadata

  • Download URL: ossapi-5.3.5-py3-none-any.whl
  • Upload date:
  • Size: 96.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.11

File hashes

Hashes for ossapi-5.3.5-py3-none-any.whl
Algorithm Hash digest
SHA256 3412079b7a9c0d19b574576862b06fb8570cc5dedcc170a38e7bb4f71b8f890a
MD5 66918bf8c4ec24caabf0d92528d02b9d
BLAKE2b-256 2a1142d5bc1b47a57750ba95cde5a200213b20c435db3f4857e035b44501ef02

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