API Reference¶
Enums¶
- class UserAccountHistory[source]¶
-
- type: UserAccountHistoryType¶
- class UserGroup[source]¶
-
- description: GroupDescription | None¶
- class Covers[source]¶
-
- card_2x: <ossapi.utils.Field object at 0x1029cc080>¶
- cover_2x: <ossapi.utils.Field object at 0x1029b7ec0>¶
- list_2x: <ossapi.utils.Field object at 0x1029cc0b0>¶
- slimcover_2x: <ossapi.utils.Field object at 0x1029cc0e0>¶
- class Nominations[source]¶
-
- required_meta: NominationsRequired¶
- class UserProfileCustomization[source]¶
-
- beatmapset_download: BeatmapsetDownload | None¶
- user_list_filter: UserListFilters | None¶
- user_list_sort: UserListSorts | None¶
- user_list_view: UserListViews | None¶
Models¶
- class Mod(value)[source]¶
An ingame osu! mod.
Common combinations are available as
HDDT
,HDHR
, andHDDTHR
.- Parameters:
value (int or str or list) – A representation of the desired mod. This can either be its integer representation such as
64
forDT
and72
(64
+8
) forHDDT
, or a string such as"DT"
forDT
and"HDDT"
(orDTHD
) forHDDT
, or a list of strings such as["HD", "DT"]
forHDDT
.
If used, the string must be composed of two-letter acronyms for mods, in any order.
Notes
The nightcore mod is never set by itself. When we see plays set with
NC
, we are really seeing aDT + NC
play.NC
by itself is512
, but what we expect to see is576
(512 + 64
;DT
is64
). As suchMod.NC
is defined to be the more intuitive version—DT + NC
. We provide the true, technical version of theNC
mod (512
) asMod._NC
.This same treatment and reasoning applies to
Mod.PF
, which we define asPF + SD
. The technical version of PF is available asMod._PF
.A full list of mods and their specification can be found at https://osu.ppy.sh/help/wiki/Game_Modifiers, or a more technical list at https://github.com/ppy/osu-api/wiki#mods.
Warning
The fact that this class subclasses ModCombination is slightly misleading. This is only done so that this class can be instantiated directly, backed by an internal ModCombination, instead of exposing ModCombination to users.
- class UserCompact[source]¶
- account_history: list[UserAccountHistory] | None¶
- active_tournament_banner: ProfileBanner | None¶
- active_tournament_banners: list[ProfileBanner] | None¶
- blocks: UserRelation | None¶
- friends: list[UserRelation] | None¶
- monthly_playcounts: list[UserMonthlyPlaycount] | None¶
- rankHistory: RankHistory | None¶
- rank_history: RankHistory | None¶
- replays_watched_counts: list[UserReplaysWatchedCount] | None¶
- statistics: UserStatistics | None¶
- statistics_rulesets: UserStatisticsRulesets | None¶
- user_achievements: list[UserAchievement] | None¶
- user_preferences: UserProfileCustomization | None¶
- class User[source]¶
- account_history: list[UserAccountHistory] | None¶
- active_tournament_banner: ProfileBanner | None¶
- active_tournament_banners: list[ProfileBanner] | None¶
- blocks: UserRelation | None¶
- daily_challenge_user_stats: DailyChallengeUserStats¶
- friends: list[UserRelation] | None¶
- monthly_playcounts: list[UserMonthlyPlaycount] | None¶
- playstyle: PlayStyles | None¶
- profile_order: list[ProfilePage]¶
- rankHistory: RankHistory | None¶
- rank_highest: RankHighest | None¶
- rank_history: RankHistory | None¶
- replays_watched_counts: list[UserReplaysWatchedCount] | None¶
- statistics: UserStatistics | None¶
- statistics_rulesets: UserStatisticsRulesets | None¶
- user_achievements: list[UserAchievement] | None¶
- user_preferences: UserProfileCustomization | None¶
- class BeatmapCompact[source]¶
-
- status: RankStatus¶
- class Beatmap[source]¶
-
- owner: <ossapi.utils.Field object at 0x102aa5cd0>¶
- ranked: RankStatus¶
- status: RankStatus¶
- user: function¶
- class BeatmapsetCompact[source]¶
-
- current_nominations: list[Nomination] | None¶
- status: RankStatus¶
- class Beatmapset[source]¶
-
- availability: Availability¶
- current_nominations: list[Nomination] | None¶
- nominations_summary: Nominations¶
- ranked: RankStatus¶
- status: RankStatus¶
- user: function¶
- class _LegacyScore[source]¶
-
- beatmapset: BeatmapsetCompact | None¶
- match: ScoreMatchInfo | None¶
- statistics: Statistics¶
- class Score[source]¶
-
- beatmapset: BeatmapsetCompact | None¶
- match: ScoreMatchInfo | None¶
- mods: list[NonLegacyMod]¶
- statistics: Statistics¶
- class CommentableMeta[source]¶
- current_user_attributes: CommentableMetaCurrentUserAttributes | None¶
- class CommentBundle[source]¶
- commentable_meta: list[CommentableMeta]¶
- users: list[UserCompact]¶
- class ForumPost[source]¶
- body: ForumPostBody¶
- class ForumTopic[source]¶
-
- poll: ForumPollModel | None¶
- type: ForumTopicType¶
- class ForumPollModel[source]¶
-
- options: list[ForumPollOption]¶
- title: ForumPollTitle¶
- class ForumTopicAndPosts[source]¶
-
- search: ForumTopicSearch¶
- topic: ForumTopic¶
- class ForumTopicSearch[source]¶
-
- sort: ForumTopicSort | None¶
- class Search[source]¶
- users: <ossapi.utils.Field object at 0x10186e540>¶
- wiki_pages: <ossapi.utils.Field object at 0x102aa6000>¶
- class Users[source]¶
- users: list[UserCompact]¶
- class BeatmapPacks[source]¶
- beatmap_packs: list[BeatmapPack]¶
- class Rankings[source]¶
- beatmapsets: list[Beatmapset] | None¶
- ranking: list[UserStatistics] | list[CountryStatistics] | None¶
- class BeatmapsetDiscussion[source]¶
-
- message_type: MessageType¶
- posts: list[BeatmapsetDiscussionPost] | None¶
- starting_post: BeatmapsetDiscussionPost | None¶
- class KudosuHistory[source]¶
- action: KudosuAction¶
- giver: KudosuGiver | None¶
- post: KudosuPost¶
- class BeatmapPlaycount[source]¶
-
- beatmapset: BeatmapsetCompact | None¶
- class AchievementEvent[source]¶
- achievement: EventAchivement¶
- class BeatmapPlaycountEvent[source]¶
- beatmap: EventBeatmap¶
- class BeatmapsetApproveEvent[source]¶
- approval: BeatmapsetApproval¶
- beatmapset: EventBeatmapset¶
- class BeatmapsetDeleteEvent[source]¶
- beatmapset: EventBeatmapset¶
- class BeatmapsetReviveEvent[source]¶
- beatmapset: EventBeatmapset¶
- class BeatmapsetUpdateEvent[source]¶
- beatmapset: EventBeatmapset¶
- class BeatmapsetUploadEvent[source]¶
- beatmapset: EventBeatmapset¶
- class RankEvent[source]¶
- beatmap: EventBeatmap¶
- class RankLostEvent[source]¶
- beatmap: EventBeatmap¶
- class Build[source]¶
- changelog_entries: list[ChangelogEntry] | None¶
- update_stream: UpdateStream | None¶
- class ChangelogEntry[source]¶
-
- github_user: GithubUser¶
- class ChangelogListing[source]¶
-
- search: ChangelogSearch¶
- streams: list[UpdateStream]¶
- class MultiplayerScores[source]¶
-
- scores: list[MultiplayerScore]¶
- user_score: MultiplayerScore | None¶
- class MultiplayerScore[source]¶
-
- scores_around: MultiplayerScoresAround | None¶
- statistics: Statistics¶
- class MultiplayerScoresAround[source]¶
- higher: list[MultiplayerScore]¶
- lower: list[MultiplayerScore]¶
- class NewsListing[source]¶
-
- news_sidebar: NewsSidebar¶
- search: NewsSearch¶
- class DifficultyAttributes[source]¶
- attributes: BeatmapDifficultyAttributes¶
- class BeatmapPack[source]¶
-
- beatmapsets: list[Beatmapset] | None¶
- user_completion_data: BeatmapPackUserCompletionData | None¶
- class BeatmapsetSearchResult[source]¶
- beatmapsets: list[Beatmapset]¶
- class BeatmapsetDiscussions[source]¶
-
- beatmapsets: list[Beatmapset]¶
- discussions: list[BeatmapsetDiscussion]¶
- included_discussions: list[BeatmapsetDiscussion]¶
- reviews_config: ReviewsConfig¶
- users: list[UserCompact]¶
- class BeatmapsetDiscussionPosts[source]¶
- beatmapsets: list[BeatmapsetCompact]¶
- discussions: list[BeatmapsetDiscussion]¶
- posts: list[BeatmapsetDiscussionPost]¶
- users: list[UserCompact]¶
- class BeatmapsetDiscussionVotes[source]¶
-
- discussions: list[BeatmapsetDiscussion]¶
- users: list[UserCompact]¶
- votes: list[BeatmapsetDiscussionVote]¶
- class BeatmapsetEventCommentKudosuChange[source]¶
-
- new_vote: KudosuVote¶
- votes: list[KudosuVote]¶
- class BeatmapsetEventCommentKudosuRecalculate[source]¶
-
- new_vote: KudosuVote | None¶
- class BeatmapsetEvent[source]¶
- beatmapset: BeatmapsetCompact | None¶
- discussion: BeatmapsetDiscussion | None¶
- type: BeatmapsetEventType¶
- class ChatChannel[source]¶
-
- recent_messages: list[ChatMessage] | None¶
- type: ChannelType¶
- class ChatMessage[source]¶
-
- sender: UserCompact¶
- class CreatePMResponse[source]¶
- channel: ChatChannel¶
- message: ChatMessage¶
- presence: list[ChatChannel] | None¶
- class ModdingHistoryEventsBundle[source]¶
- events: list[BeatmapsetEvent]¶
- reviewsConfig: BeatmapsetDiscussionReview¶
- users: list[UserCompact]¶
- class UserRelation[source]¶
-
- relation_type: UserRelationType¶
- target: UserCompact | None¶
- class UserStatistics[source]¶
-
- grade_counts: UserGradeCounts¶
- user: UserCompact | None¶
- variants: list[StatisticsVariant] | None¶
- class UserStatisticsRulesets[source]¶
- fruits: UserStatistics | None¶
- mania: UserStatistics | None¶
- osu: UserStatistics | None¶
- taiko: UserStatistics | None¶
- class RoomPlaylistItem[source]¶
- allowed_mods: list[RoomPlaylistItemMod]¶
- beatmap: BeatmapCompact¶
- required_mods: list[RoomPlaylistItemMod]¶
- class _Room1[source]¶
-
- category: RoomCategory¶
- host: UserCompact¶
- playlist: list[RoomPlaylistItem]¶
- recent_participants: list[UserCompact]¶
- class Room[source]¶
-
- category: RoomCategory¶
- current_playlist_item: RoomPlaylistItem | None¶
- difficulty_range: RoomDifficultyRange¶
- host: UserCompact¶
- playlist: list[RoomPlaylistItem]¶
- playlist_item_stats: RoomPlaylistItemStats¶
- recent_participants: list[UserCompact]¶
- class RoomLeaderboardScore[source]¶
-
- user: UserCompact¶
- class RoomLeaderboardUserScore[source]¶
-
- user: UserCompact¶
- class RoomLeaderboard[source]¶
- leaderboard: list[RoomLeaderboardScore]¶
- user_score: RoomLeaderboardUserScore¶
- class MatchGame[source]¶
- beatmap: BeatmapCompact | None¶
- scoring_type: ScoringType¶
- class MatchEvent[source]¶
- detail: MatchEventDetail¶
- class MatchResponse[source]¶
-
- events: list[MatchEvent]¶
- users: list[UserCompact]¶
Ossapi¶
- class Ossapi(client_id, client_secret, redirect_uri=None, scopes=[Scope.PUBLIC], *, grant=None, strict=False, token_directory=None, token_key=None, access_token=None, refresh_token=None, domain=Domain.OSU, api_version=20241024)[source]¶
A wrapper around osu! api v2. The main entry point for ossapi.
- Parameters:
client_id (int) – The id of the client to authenticate with.
client_secret (str) – The secret of the client to authenticate with.
redirect_uri (str) – The redirect uri for the client. Must be passed if using the authorization code grant. This must exactly match the redirect uri on the client’s settings page. Additionally, in order for ossapi to receive authentication from this redirect uri, it must be a port on localhost, e.g. “http://localhost:3914/”. You can change your client’s redirect uri from its settings page.
scopes (List[str]) – What scopes to request when authenticating.
grant (Grant or str) – Which oauth grant (aka flow) to use when authenticating with the api. The osu api offers the client credentials (pass “client” for this parameter) and authorization code (pass “authorization” for this parameter) grants.
The authorization code grant requires user interaction to authenticate the first time, but grants full access to the api. In contrast, the client credentials grant does not require user interaction to authenticate, but only grants guest user access to the api. This means you will not be able to do things like download replays on the client credentials grant.
If not passed, the grant will be automatically inferred as follows: ifredirect_uri
is passed, use the authorization code grant. Ifredirect_uri
is not passed, use the client credentials grant.strict (bool) – Whether to run in “strict” mode. In strict mode, ossapi will raise an exception if the api returns an attribute in a response which we didn’t expect to be there. This is useful for developers which want to catch new attributes as they get added. More checks may be added in the future for things which developers may want to be aware of, but normal users do not want to have an exception raised for.
If you are not a developer, you are very unlikely to want to use this parameter.token_directory (str) – If passed, the given directory will be used to store and retrieve token files instead of locally wherever ossapi is installed. Useful if you want more control over token files.
token_key (str) – If passed, the given key will be used to name the token file instead of an automatically generated one. Note that if you pass this, you are taking responsibility for making sure it is unique / unused, and also for remembering the key you passed if you wish to eg remove the token in the future, which requires the key.
access_token (str) – Access token from the osu! api. Allows instantiating
Ossapi
after manually authenticating with the osu! api.refresh_token (str) – Refresh token from the osu! api. Allows instantiating
Ossapi
after manually authenticating with the osu! api. Optional if usingGrant.CLIENT_CREDENTIALS
.domain (Domain or str) – The domain to retrieve information from. This defaults to
Domain.OSU
, which corresponds to osu.ppy.sh, the main website.
To retrieve information from dev.ppy.sh, specifyDomain.DEV
.
See Domains for more about domains.
OssapiAsync¶
- class OssapiAsync(client_id, client_secret, redirect_uri=None, scopes=[Scope.PUBLIC], *, grant=None, strict=False, token_directory=None, token_key=None, access_token=None, refresh_token=None, domain=Domain.OSU, api_version=20241024)[source]¶
Async equivalent of
Ossapi
. Main (async) entry point into osu! api v2.- Parameters:
client_id (int) – The id of the client to authenticate with.
client_secret (str) – The secret of the client to authenticate with.
redirect_uri (str) – The redirect uri for the client. Must be passed if using the authorization code grant. This must exactly match the redirect uri on the client’s settings page. Additionally, in order for ossapi to receive authentication from this redirect uri, it must be a port on localhost, e.g. “http://localhost:3914/”. You can change your client’s redirect uri from its settings page.
scopes (List[str]) – What scopes to request when authenticating.
grant (Grant or str) – Which oauth grant (aka flow) to use when authenticating with the api. The osu api offers the client credentials (pass “client” for this parameter) and authorization code (pass “authorization” for this parameter) grants.
The authorization code grant requires user interaction to authenticate the first time, but grants full access to the api. In contrast, the client credentials grant does not require user interaction to authenticate, but only grants guest user access to the api. This means you will not be able to do things like download replays on the client credentials grant.
If not passed, the grant will be automatically inferred as follows: ifredirect_uri
is passed, use the authorization code grant. Ifredirect_uri
is not passed, use the client credentials grant.strict (bool) – Whether to run in “strict” mode. In strict mode, ossapi will raise an exception if the api returns an attribute in a response which we didn’t expect to be there. This is useful for developers which want to catch new attributes as they get added. More checks may be added in the future for things which developers may want to be aware of, but normal users do not want to have an exception raised for.
If you are not a developer, you are very unlikely to want to use this parameter.token_directory (str) – If passed, the given directory will be used to store and retrieve token files instead of locally wherever ossapi is installed. Useful if you want more control over token files.
token_key (str) – If passed, the given key will be used to name the token file instead of an automatically generated one. Note that if you pass this, you are taking responsibility for making sure it is unique / unused, and also for remembering the key you passed if you wish to eg remove the token in the future, which requires the key.
access_token (str) – Access token from the osu! api. Allows instantiating
Ossapi
after manually authenticating with the osu! api.refresh_token (str) – Refresh token from the osu! api. Allows instantiating
Ossapi
after manually authenticating with the osu! api. Optional if usingGrant.CLIENT_CREDENTIALS
.domain (Domain or str) – The domain to retrieve information from. This defaults to
Domain.OSU
, which corresponds to osu.ppy.sh, the main website.
To retrieve information from dev.ppy.sh, specifyDomain.DEV
.
See Domains for more about domains.
Scope¶
- class Scope(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶
The OAuth scopes used by the api.
- CHAT_WRITE = 'chat.write'¶
- CHAT_WRITE_MANAGE = 'chat.write_manage'¶
- CHAT_READ = 'chat.read'¶
- DELEGATE = 'delegate'¶
- FORUM_WRITE = 'forum.write'¶
- FRIENDS_READ = 'friends.read'¶
- IDENTIFY = 'identify'¶
- PUBLIC = 'public'¶
Domain¶
- class Domain(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶
Different possible api domains. These correspond to different deployments of the osu server, such as osu.ppy.sh or dev.ppy.sh.
The default domain, and the one the vast majority of users want, is
Domain.OSU
, and corresponds to the main website.- OSU = 'osu'¶
- DEV = 'dev'¶
Grant¶
Replay¶
- class Replay(replay, api)[source]¶
A replay played by a player.
Notes
This is a thin wrapper around an
osrparse.replay.Replay
instance. It converts some attributes to more appropriate types and addsuser()
andbeatmap()
to retrieve api-related objects.- property beatmap: Beatmap¶
The beatmap this replay was played on.
Warning
Accessing this property for the first time will result in a web request to retrieve the beatmap from the api. We cache the return value, so further accesses are free.