Python API wrapper and PP/Star Rating calculation for osu!droid relax
Project description
Installation
pip install odrx-py git+https://github.com/unclem2/rosu-pp-py.git
API Wrapper
Quick Start
from odrx_py import AsyncODRXAPIClient
# Initialize client
client = AsyncODRXAPIClient()
# Get user by ID
user = await client.get_user_fromid(12345)
# Get beatmap
beatmap = await client.get_beatmap_fromid(1234567)
# Get leaderboard
leaderboard = await client.get_leaderboard(type="pp")
# Get top scores for a user
top_scores = await client.get_top_scores(12345)
Methods
User Methods
get_user_fromid(user_id)- Fetch user by IDget_user_fromusername(username)- Fetch user by username
Beatmap Methods
get_beatmap_fromid(map_id)- Fetch beatmap by IDget_beatmap_frommd5(md5)- Fetch beatmap by MD5 hashget_beatmap_leaderboard_fromid(map_id)- Get leaderboard for beatmap by IDget_beatmap_leaderboard_frommd5(md5)- Get leaderboard for beatmap by MD5
Score Methods
get_top_scores(user_id)- Get top 100 scores for userget_recent_score(user_id, offset)- Get recent scores with optional offsetget_scores_uid_beatmap_fromid(user_id, map_id)- Get user scores on beatmap by IDget_scores_uid_beatmap_frommd5(user_id, md5)- Get user scores on beatmap by MD5get_scores_uname_beatmap_fromid(username, map_id)- Get user scores by username on beatmap IDget_scores_uname_beatmap_frommd5(username, md5)- Get user scores by username on beatmap MD5
Leaderboard & Whitelist
get_leaderboard(type, country)- Get global leaderboard (type: "pp" or "score")get_whitelist()- Get whitelisted beatmapswhitelist_add_fromid(map_id)- Add beatmap to whitelist by ID (requires key)whitelist_add_frommd5(md5)- Add beatmap to whitelist by MD5 (requires key)
Authentication
For whitelist operations, provide your whitelist key:
client = AsyncODRXAPIClient(whitelist_key="your_key_here")
Performance Calculator and Rating Calculator
Quick Start
from odrx_py.performance import PPCalculator
from odrx_py.rating import SRCalculator
from pathlib import Path
# Initialize Path of the beatmap
beatmap = Path(__file__).parent / "resources" / "beatmap.osu"
# Initialize calculators
pp_calculator = PPCalculator(beatmap, mods=[{"acronym": "RX"}])
rating_calculator = SRCalculator(beatmap, mods=[{"acronym": "RX"}])
# Get the pp/star number/calculate
pp_calculator.calculate_performance()
rating_calculator.calculate_rating()
Performance Calculator Docs
-
PPCalculator(beatmap, mods, n300, n100, n50, misses, combo)- Initializes the Calculator class giving it the required data. -
calculate_performance()- Calculates the performance points.
Rating Calculator Docs
-
SRCalculator(beatmap, mods)- Initializes the Calculator class giving it the required data. -
calculate_rating()- Calculates the rating.
Mod Format
Normal mods
mods = [{
"acronym": "(insert mod name)"
}]
Speed modifier
mods = [{
"acronym": "CS",
"settings": {
"rateMultiplier": 1.0
}
}]
StrEnum of all Mods (src/enums/mods.py)
from enum import StrEnum
class Mods(StrEnum):
Relax = "RX"
DifficultyAdjust = "DA"
NightCore = "NC"
CustomSpeed = "CS"
DoubleTime = "DT"
Hidden = "HD"
FlashLight = "FL"
ShitMod = "RE" # REZ
WindUp = "WU"
Precise = "PR"
HardRock = "HR"
HalfTime = "HT"
AutoPilot = "AP"
WindDown = "WD"
ApproachDifferent = "AD"
Auto = "AT"
Easy = "EZ"
FreezeFrame = "FR"
Mirror = "MR"
Muted = "MU"
NoFail = "NF"
Random = "RD"
ScoreV2 = "V2"
SmallCircle = "SC"
SuddenDeath = "SD"
Perfect = "PF"
Traceable = "TC"
Synesthesia = "SY"
NoMod = "NM"
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file odrx_py-2.1.1.tar.gz.
File metadata
- Download URL: odrx_py-2.1.1.tar.gz
- Upload date:
- Size: 9.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
de6dc310b1c8cbb4358ce8b5f6f90b2574f8d40a05430b05b442918eba74ccd9
|
|
| MD5 |
01083de60b50da19a9b91119079ce326
|
|
| BLAKE2b-256 |
db1fee41a5395de9ea55b379880a53c28cc7c3b063490b95dbae593e12494a0d
|
File details
Details for the file odrx_py-2.1.1-py3-none-any.whl.
File metadata
- Download URL: odrx_py-2.1.1-py3-none-any.whl
- Upload date:
- Size: 13.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0b87e91646c47f26213945612b06c2a08e61d6f0efe627fa34d33316d37d23b1
|
|
| MD5 |
d14f174ff4433bd677a365705fb350d1
|
|
| BLAKE2b-256 |
26c67c330c896320f5d0198639f5c2cee9cf0684fa614e92f8f0e2e120e56c4d
|