Skip to main content

A thin python wrapper around the osu! api, delegating error handling and rate limiting (among other things) to the user.

Project description

PyPI version

ossapi

ossapi (so called to avoid pypi naming conflicts with the existing osuapi) is a minimal python wrapper for the osu! api. This wrapper was created for, and is used in, circleguard. Passed params are checked to make sure the api will accept them, and that all required params are present. No attempt is made to check http status codes or retry requests that fail.

Usage

To install:

pip install ossapi

To use:

from ossapi import Ossapi

api = Ossapi("API_KEY")
json = api.get_replay({"m": "0", "b": "1776628", "u": "3256299"})
# either strings or ints will work. Returns something like
# `{"content":"XQAAIA....3fISw=","encoding":"base64"}`

osu api v2

We also provide support for api v2. (Note: requires python 3.8+)

You can create an oauth client on your settings page (https://osu.ppy.sh/home/account/edit), then use the client's id, secret, and redirect_uri to authenticate.

# authenticates with client credentials grant (grants guest user access,
# some endpoints are unavailable to you, such as `download_score`)
api = OssapiV2(client_id, client_secret)
# if you also pass `redirect_uri`, we authenticate with authorization
# code grant, which grants full permissions. Note that `redirect_uri` must
# match the redirect uri specified in the oauth client you created, and
# must also be to a port on localhost (eg `"http://localhost:3918/"`).
# You will be redirected to an authorization page for the client in your
# browser the first time you instantiate `OssapiV2`. The token received
# is used instead for every subsequent instantiation instead of authorizing
# again.
api = OssapiV2(client_id, client_secret, redirect_uri)

# example usages of endpoints
print(api.beatmap(beatmap_id=221777).status)
print(api.beatmap_user_score(beatmap_id=221777, user_id=2757689).score.mods)
print(api.search(query="peppy").user.data[0].profile_colour)
print(api.comment(comment_id=1).cursor.created_at)
print(api.download_score(mode="osu", score_id=2797309065))
print(api.search_beatmaps("the big black").beatmapsets[0].title)

Work on api v2's endpoints is ongoing and unstable. Consider support for it to be in beta.

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-2.0.0b1.tar.gz (22.8 kB view details)

Uploaded Source

Built Distribution

ossapi-2.0.0b1-py3-none-any.whl (24.7 kB view details)

Uploaded Python 3

File details

Details for the file ossapi-2.0.0b1.tar.gz.

File metadata

  • Download URL: ossapi-2.0.0b1.tar.gz
  • Upload date:
  • Size: 22.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.0

File hashes

Hashes for ossapi-2.0.0b1.tar.gz
Algorithm Hash digest
SHA256 1811c7e55e930ab6d93935d1e519941a57b5c94010c2e21df5679e1132e798df
MD5 37653eeb5a9245fcf75ffd17f5219e99
BLAKE2b-256 03bbac368232a6c8fd6dad4ae18e42b9dd6bf68beb46343f4797c81c63376a5c

See more details on using hashes here.

File details

Details for the file ossapi-2.0.0b1-py3-none-any.whl.

File metadata

  • Download URL: ossapi-2.0.0b1-py3-none-any.whl
  • Upload date:
  • Size: 24.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.0

File hashes

Hashes for ossapi-2.0.0b1-py3-none-any.whl
Algorithm Hash digest
SHA256 03582a06ba4807c02ecf3da3fb4bbe84bfd3a9dc3f7cb2c53c0731b2cb487ec9
MD5 537e36b235e68097506ceb0eae2e3325
BLAKE2b-256 9ce6c585775273a060369799d4f75fe39706599ad9459e2316ab54c79ac02468

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