Skip to main content

A python wrapper for the osu! api. Includes api v2 support.

Project description

PyPI version

ossapi (documentation)

ossapi is a python wrapper for the osu! api which has complete coverage of both api v2 and api v1. ossapi also 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
client_id = None
client_secret = None
callback_url = None # choose a port on localhost, eg http://localhost:727/

# client credentials authentication...
api = Ossapi(client_id, client_secret)

# ...or authorization grant authentication
api = Ossapi(client_id, client_secret, callback_url)

# go wild with endpoint calls! See docs for all endpoints
print(api.user("tybug2"))

Async

ossapi provides an async variant, OssapiAsync, which has an identical interface to Ossapi:

import asyncio
from ossapi import Ossapi

client_id = None
client_secret = None
api = Ossapi(client_id, client_secret)

async def main():
    await api.user("tybug2")

loop = asyncio.get_event_loop()
loop.run_until_complete(main())

Read more about OssapiAsync on the docs.

Endpoints

All endpoints for api v2.

API v1 Usage

You can get your api v1 key at https://osu.ppy.sh/p/api/. Note that due to a redirection bug, you may need to log in and wait 30 seconds before being able to access the api page through the above link.

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ossapi-3.1.0.tar.gz (86.8 kB view details)

Uploaded Source

Built Distribution

ossapi-3.1.0-py3-none-any.whl (89.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: ossapi-3.1.0.tar.gz
  • Upload date:
  • Size: 86.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.10

File hashes

Hashes for ossapi-3.1.0.tar.gz
Algorithm Hash digest
SHA256 d6aa8e0ada0bd88255b319b6096a47d029893173311e4b19940a28ee7702703d
MD5 1906c84f7cd87925378bdb522d2b4560
BLAKE2b-256 d669e105f64aea20a795c72cfaf89f5a99cb14a6439a814d5f2fe32156d3cc45

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ossapi-3.1.0-py3-none-any.whl
  • Upload date:
  • Size: 89.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.10

File hashes

Hashes for ossapi-3.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 264ec42d5cc3697f28a38630e00b19445c4867145442b0f5a574106791e048c8
MD5 8b0e9d0c54bab29b25fb62b7826b1c48
BLAKE2b-256 e509b71f9e07f8cb2c627d9f6fb3b85e57ccebb6fb692ea9a03414ca379ce464

See more details on using hashes here.

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