Skip to main content

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

Project description

PyPI version

ossapi

ossapi (so called to avoid pypi naming conflicts with the existing osuapi) is a python wrapper for the osu! api. Ossapi includes support for api v2.

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"}`

api v2

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

This support is in beta, so if you would like to use ossapi for api v2, you will need to run the following to download the latest beta release:

pip install --pre --upgrade ossapi

Usage

You will need to 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.

from ossapi import *

# 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.ranking("osu", RankingType.PERFORMANCE, country="US").ranking[0].user.username)
print(api.user_scores(12092800, "best")[0].accuracy)
print(api.beatmap(beatmap_id=221777).last_updated)
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).comments[0].message)
print(api.download_score(mode="osu", score_id=2797309065))
print(api.search_beatmaps({"title": "the big black"}).beatmapsets[0].title)
print(api.search_beatmaps(cursor=api.search_beatmaps().cursor).beatmapsets[0].title)
print(api.beatmapsets_events(types=[BeatmapsetEventType.ISSUE_REOPEN]).events[0].type)
print(api.user(12092800).playstyle)

Work on api v2's endpoints is ongoing. Some endpoints are not currently implemented. You can track our progress towards implementing all documented api v2 endpoints here: https://github.com/circleguard/ossapi/issues/14.

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.0b4.tar.gz (26.4 kB view details)

Uploaded Source

Built Distribution

ossapi-2.0.0b4-py3-none-any.whl (28.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: ossapi-2.0.0b4.tar.gz
  • Upload date:
  • Size: 26.4 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.0b4.tar.gz
Algorithm Hash digest
SHA256 3548f4f820f2327b7bcbda425567f15b054cf89ce118f35e1fa4c4f264216afd
MD5 bb3afc62eb00e863cce7b3dde1801bf8
BLAKE2b-256 d173146bb5a483a140afa03da628359f777965a4d2e2d01e6084a1a3e6f50064

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ossapi-2.0.0b4-py3-none-any.whl
  • Upload date:
  • Size: 28.4 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.0b4-py3-none-any.whl
Algorithm Hash digest
SHA256 2a2ca55b583a0fb9c644b1934a7b698dd8c8b7dbc1c082f45448bd8db8103b0d
MD5 5fbd14fb5a3a3c5477d25c7e9e3e9d37
BLAKE2b-256 efc55cf889821e2295653a4f6be4e2722b98cd83b270ade86d7246dec6451daf

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