Client v2¶
Repository¶
This module contains a repository for API v2 token objects.
- class aiosu.v2.repository.oauthtoken.BaseTokenRepository¶
Base token repository. Allows for custom token storage.
- abstract async exists(session_id: int) bool ¶
Check if a token exists.
- abstract async add(session_id: int, token: OAuthToken) OAuthToken ¶
Add a token.
- abstract async get(session_id: int) OAuthToken ¶
Get a token.
- abstract async update(session_id: int, token: OAuthToken) OAuthToken ¶
Update a token.
- abstract async delete(session_id: int) None ¶
Delete a token.
- class aiosu.v2.repository.oauthtoken.SimpleTokenRepository¶
Simple in-memory token repository.
- async exists(session_id: int) bool ¶
Check if a token exists.
- async add(session_id: int, token: OAuthToken) OAuthToken ¶
Add a token.
- async get(session_id: int) OAuthToken ¶
Get a token.
- async update(session_id: int, token: OAuthToken) OAuthToken ¶
Update a token.
- async delete(session_id: int) None ¶
Delete a token.
Client Storage¶
This module handles multiple API v2 Client sessions.
- class aiosu.v2.clientstorage.ClientStorage(**kwargs: Any)¶
OAuth sessions manager.
- Parameters:
**kwargs – See below
- Keyword Arguments:
- token_repository (
aiosu.v2.repository.oauthtoken.BaseTokenRepository
) – Optional, defaults to instance of
aiosu.v2.repository.oauthtoken.SimpleTokenRepository
- token_repository (
client_secret (
str
)client_id (
int
)- base_url (
str
) – Optional, base API URL, defaults to “https://osu.ppy.sh”
- base_url (
- create_app_client (
bool
) – Optional, whether to automatically create guest clients, defaults to True
- create_app_client (
- client_secret: str¶
- client_id: int¶
- base_url: str¶
- on_client_add(func: F) F ¶
A decorator that is called whenever a client is added, to be used as:
@client_storage.on_client_add
async def func(event: ClientAddEvent)
- on_client_update(func: F) F ¶
A decorator that is called whenever any stored client is updated, to be used as:
@client_storage.on_client_update
async def func(event: ClientUpdateEvent)
- property app_client: Client¶
Client credentials app client.
- Raises:
ValueError – If no app client is provided and creation is disabled
- Returns:
Client credentials app client session
- Return type:
- client_exists(client_uid: int) bool ¶
Checks if a client exists.
- Parameters:
client_uid (int) – The owner user ID of the client
- Returns:
Whether the client with the given ID exists
- Return type:
bool
- async add_client(token: OAuthToken, **kwargs: Any) Client ¶
Adds a client to storage.
- Parameters:
token (aiosu.models.oauthtoken.OAuthToken) – The token object of the client
**kwargs – See below
- Keyword Arguments:
- id (
int
) – Optional, the ID of the client session
- id (
- Returns:
The client with the given ID or token
- Return type:
- async get_client(**kwargs: Any) Client ¶
Gets a client from storage.
- Parameters:
**kwargs – See below
- Keyword Arguments:
- id (
int
) – Optional, the owner user ID of the client
- id (
- token (
OAuthToken
) – Optional, the token object of the client
- token (
- Raises:
InvalidClientRequestedError – If no valid ID or token is provided
- Returns:
The client with the given ID or token
- Return type:
- async revoke_client(client_uid: int) None ¶
Revokes a client from storage.
- Parameters:
client_uid (int) – The owner user ID of the client
- Raises:
InvalidClientRequestedError – If no client exists with the given ID
- async aclose() None ¶
Closes all client sessions.
Client¶
This module handles API requests for API v2 (OAuth).
You can read more about it here: https://osu.ppy.sh/docs/index.html
- class aiosu.v2.client.Client(**kwargs: Any)¶
osu! API v2 Client
- Parameters:
**kwargs – See below
- Keyword Arguments:
- token_repository (
aiosu.v2.repository.oauthtoken.BaseTokenRepository
) – Optional, defaults to instance of
aiosu.v2.repository.oauthtoken.SimpleTokenRepository
- token_repository (
- session_id (
int
) – Optional, ID of the session to search in the repository, defaults to 0
- session_id (
- client_id (
int
) – Optional, required to refresh tokens
- client_id (
- client_secret (
str
) – Optional, required to refresh tokens
- client_secret (
- base_url (
str
) – Optional, base API URL, defaults to “https://osu.ppy.sh”
- base_url (
- token (
aiosu.models.oauthtoken.OAuthToken
) – Optional, defaults to client credentials if not provided
- token (
- limiter (
tuple[int, int]
) – Optional, rate limit, defaults to (600, 60) (600 requests per minute)
- limiter (
- session_id: int¶
- client_id: int¶
- client_secret: str¶
- base_url: str¶
- on_client_update(func: F) F ¶
A decorator that is called whenever a client is updated, to be used as:
@client.on_client_update
async def func(event: ClientUpdateEvent)
- async get_current_token() OAuthToken ¶
Get the current token
- async get_featured_tracks(**kwargs: Any) ArtistTracksResponse ¶
Query tracks from featured artists.
- Parameters:
**kwargs – See below
- Keyword Arguments:
- album (
str
) – Optional, the album to filter by.
- album (
- artist (
str
) – Optional, the artist to filter by.
- artist (
- genre (
int
) – Optional, the genre ID to filter by.
- genre (
- length (
tuple[int, int]
) – Optional, the length range to filter by.
- length (
- bpm (
tuple[int, int]
) – Optional, The BPM range to filter by.
- bpm (
- query (
str
) – Optional, the search query to filter by.
- query (
- is_default_sort (
bool
) – Optional, whether to sort by the default sort.
- is_default_sort (
- sort (
str
) – Optional, the sort to use.
- sort (
- exclusive_only (
bool
) – Optional, whether to only get osu! exclusive tracks.
- exclusive_only (
- Raises:
APIException – Contains status code and error message
- Returns:
Featured artist tracks response object
- Return type:
- async get_seasonal_backgrounds() SeasonalBackgroundSet ¶
Gets the current seasonal background set.
- Raises:
APIException – Contains status code and error message
- Returns:
Seasonal background set object
- Return type:
- async get_changelog_listing(**kwargs: Any) ChangelogListing ¶
Gets the changelog listing.
- Parameters:
**kwargs – See below
- Keyword Arguments:
- message_formats (
list[aiosu.models.changelog.ChangelogMessageFormat]
) – Optional, message formats to get, defaults to
["html", "markdown"]
- message_formats (
- from (
str
) – Optional, the start date to return.
- from (
- to (
str
) – Optional, the end date to return.
- to (
- max_id (
int
) – Optional, the maximum ID to return.
- max_id (
- stream (
str
) – Optional, the stream to return.
- stream (
- cursor_string (
str
) – Optional, the cursor string to use.
- cursor_string (
- Raises:
APIException – Contains status code and error message
- Returns:
Changelog listing object
- Return type:
- async get_changelog_build(stream: str, build: str) Build ¶
Gets a specific build from the changelog.
- Parameters:
stream – The stream to get the build from
build – The build to get
- Raises:
APIException – Contains status code and error message
- Returns:
Build object
- Return type:
- async lookup_changelog_build(changelog_query: str | int, **kwargs: Any) Build ¶
Looks up a build from the changelog.
- Parameters:
changelog_query (Union[str, int]) – The query to search for
**kwargs – See below
- Keyword Arguments:
- is_id (
bool
) – Optional, whether the query is an ID or not, defaults to
True
if the query is an int
- is_id (
- message_formats (
list[aiosu.models.changelog.ChangelogMessageFormat]
) – Optional, message formats to get, defaults to
["html", "markdown"]
- message_formats (
- Raises:
APIException – Contains status code and error message
- Returns:
Build object
- Return type:
- async get_news_listing(**kwargs: Any) NewsListing ¶
Gets the news listing.
- Parameters:
**kwargs – See below
- Keyword Arguments:
- limit (
int
) – Optional, the number of news posts to return. Min: 1, Max: 21, defaults to 12
- limit (
- year (
int
) – Optional, the year to filter by.
- year (
- cursor_string (
str
) – Optional, the cursor string to use for pagination.
- cursor_string (
- Raises:
APIException – Contains status code and error message
- Returns:
News listing object
- Return type:
- async get_news_post(news_query: str | int, **kwargs: Any) NewsPost ¶
Gets a news post.
- Parameters:
news_query (Union[str, int]) – The query to search for
**kwargs – See below
- Keyword Arguments:
- is_id (
bool
) – Optional, whether the query is an ID or not, defaults to
True
if the query is an int
- is_id (
- Raises:
APIException – Contains status code and error message
- Returns:
News post object
- Return type:
- async get_wiki_page(locale: str, path: str) WikiPage ¶
Gets a wiki page.
- Parameters:
locale (str) – The locale of the wiki page
path (str) – The path of the wiki page
- Raises:
APIException – Contains status code and error message
- Returns:
Wiki page object
- Return type:
- async get_comment(comment_id: int, **kwargs: Any) CommentBundle ¶
Gets a comment.
- Parameters:
comment_id (int) – The ID of the comment
**kwargs – See below
- Keyword Arguments:
- cursor_string (
str
) – Optional, cursor string to get the next page of comments
- cursor_string (
- Raises:
APIException – Contains status code and error message
- Returns:
Comment bundle object
- Return type:
- async get_comments(**kwargs: Any) CommentBundle ¶
Gets comments.
- Parameters:
**kwargs – See below
- Keyword Arguments:
- commentable_type (
aiosu.models.comment.CommentableType
) – Optional, commentable type to get comments from
- commentable_type (
- commentable_id (
int
) – Optional, commentable ID to get comments from
- commentable_id (
- parent_id (
int
) – Optional, parent ID to get comments from
- parent_id (
- sort (
aiosu.models.comment.CommentSortType
) – Optional, sort order of comments, defaults to
"new"
- sort (
- cursor_string (
str
) – Optional, cursor string to get the next page of comments
- cursor_string (
- Raises:
APIException – Contains status code and error message
- Returns:
Comment bundle object
- Return type:
- async search(query: str, **kwargs: Any) SearchResponse ¶
Searches for a user, beatmap, beatmapset, or wiki page.
- Parameters:
query (str) – The query to search for
**kwargs – See below
- Keyword Arguments:
- mode (
aiosu.models.search.SearchMode
) – Optional, gamemode to search for, defaults to
all
- mode (
- page (
int
) – Optional, page to get, ignored if mode is
all
- page (
- Raises:
APIException – Contains status code and error message
RefreshTokenExpiredError – If the client refresh token has expired
- Returns:
Search response object
- Return type:
- async get_me(**kwargs: Any) User ¶
Gets the user who owns the current token
- Parameters:
**kwargs – See below
- Keyword Arguments:
- mode (
aiosu.models.gamemode.Gamemode
) – Optional, gamemode to search for
- mode (
- Raises:
APIException – Contains status code and error message
RefreshTokenExpiredError – If the client refresh token has expired
- Returns:
Requested user
- Return type:
- async get_own_friends() list[User] ¶
Gets the token owner’s friend list
- Raises:
APIException – Contains status code and error message
RefreshTokenExpiredError – If the client refresh token has expired
- Returns:
List of friends
- Return type:
list[aiosu.models.user.User]
- async get_user(user_query: str | int, **kwargs: Any) User ¶
Gets a user by a query.
- Parameters:
user_query (Union[str, int]) – Username or ID to search by
**kwargs – See below
- Keyword Arguments:
- mode (
aiosu.models.gamemode.Gamemode
) – Optional, gamemode to search for
- mode (
- qtype (
aiosu.models.user.UserQueryType
) – Optional, “string” or “id”. Type of the user_query
- qtype (
- Raises:
APIException – Contains status code and error message
RefreshTokenExpiredError – If the client refresh token has expired
- Returns:
Requested user
- Return type:
- async get_users(user_ids: list[int]) list[User] ¶
Get multiple user data.
- Parameters:
user_ids (list[int]) – The IDs of the users
- Raises:
APIException – Contains status code and error message
RefreshTokenExpiredError – If the client refresh token has expired
- Returns:
List of user data objects
- Return type:
list[aiosu.models.user.User]
- async get_user_kudosu(user_id: int, **kwargs: Any) list[KudosuHistory] ¶
Get a user’s kudosu history.
- Parameters:
user_id (int) – User ID to search by
**kwargs – See below
- Keyword Arguments:
- limit (
int
) – Optional, number of scores to get
- limit (
- offset (
int
) – Optional, offset of the first score to get
- offset (
- Raises:
APIException – Contains status code and error message
RefreshTokenExpiredError – If the client refresh token has expired
- Returns:
List of kudosu history objects
- Return type:
- async get_user_recents(user_id: int, **kwargs: Any) list[Score | LazerScore] ¶
Get a user’s recent scores.
- Parameters:
user_id (int) – User ID to search by
**kwargs – See below
- Keyword Arguments:
- mode (
aiosu.models.gamemode.Gamemode
) – Optional, gamemode to search for
- mode (
- limit (
int
) – Optional, number of scores to get. Min: 1, Max: 100, defaults to 100
- limit (
- include_fails (
bool
) – Optional, whether to include failed scores, defaults to
False
- include_fails (
- offset (
int
) – Optional, page offset to start from, defaults to 0
- offset (
- new_format (
bool
) – Optional, whether to use the new format, defaults to
False
- new_format (
- Raises:
APIException – Contains status code and error message
RefreshTokenExpiredError – If the client refresh token has expired
- Returns:
List of requested scores
- Return type:
list[aiosu.models.score.Score] or list[aiosu.models.lazer.LazerScore]
- async get_user_bests(user_id: int, **kwargs: Any) list[Score | LazerScore] ¶
Get a user’s top scores.
- Parameters:
user_id (int) – User ID to search by
**kwargs – See below
- Keyword Arguments:
- mode (
aiosu.models.gamemode.Gamemode
) – Optional, gamemode to search for
- mode (
- limit (
int
) – Optional, number of scores to get. Min: 1, Max: 100, defaults to 100
- limit (
- offset (
int
) – Optional, page offset to start from, defaults to 0
- offset (
- new_format (
bool
) – Optional, whether to use the new format, defaults to
False
- new_format (
- Raises:
APIException – Contains status code and error message
RefreshTokenExpiredError – If the client refresh token has expired
- Returns:
List of requested scores
- Return type:
list[aiosu.models.score.Score] or list[aiosu.models.lazer.LazerScore]
- async get_user_firsts(user_id: int, **kwargs: Any) list[Score | LazerScore] ¶
Get a user’s first place scores.
- Parameters:
user_id (int) – User ID to search by
**kwargs – See below
- Keyword Arguments:
- mode (
aiosu.models.gamemode.Gamemode
) – Optional, gamemode to search for
- mode (
- limit (
int
) – Optional, number of scores to get. Min: 1, Max: 100, defaults to 100
- limit (
- offset (
int
) – Optional, page offset to start from, defaults to 0
- offset (
- new_format (
bool
) – Optional, whether to use the new format, defaults to
False
- new_format (
- Raises:
APIException – Contains status code and error message
RefreshTokenExpiredError – If the client refresh token has expired
- Returns:
List of requested scores
- Return type:
list[aiosu.models.score.Score] or list[aiosu.models.lazer.LazerScore]
- async get_user_pinned(user_id: int, **kwargs: Any) list[Score | LazerScore] ¶
Get a user’s pinned scores.
- Parameters:
user_id (int) – User ID to search by
**kwargs – See below
- Keyword Arguments:
- mode (
aiosu.models.gamemode.Gamemode
) – Optional, gamemode to search for
- mode (
- limit (
int
) – Optional, number of scores to get. Min: 1, Max: 100, defaults to 100
- limit (
- offset (
int
) – Optional, page offset to start from, defaults to 0
- offset (
- new_format (
bool
) – Optional, whether to use the new format, defaults to
False
- new_format (
- Raises:
APIException – Contains status code and error message
RefreshTokenExpiredError – If the client refresh token has expired
- Returns:
List of requested scores
- Return type:
list[aiosu.models.score.Score] or list[aiosu.models.lazer.LazerScore]
- async get_user_beatmap_scores(user_id: int, beatmap_id: int, **kwargs: Any) list[Score] ¶
Get a user’s scores on a specific beatmap.
- Parameters:
user_id (int) – User ID to search by
beatmap_id (int) – Beatmap ID to search by
**kwargs – See below
- Keyword Arguments:
- mode (
aiosu.models.gamemode.Gamemode
) – Optional, gamemode to search for
- mode (
- legacy_only (
bool
) – Optional, whether to only get legacy scores, defaults to
False
- legacy_only (
- Raises:
APIException – Contains status code and error message
RefreshTokenExpiredError – If the client refresh token has expired
- Returns:
List of requested scores
- Return type:
list[aiosu.models.score.Score]
- async get_user_beatmaps(user_id: int, type: UserBeatmapType, **kwargs: Any) list[Beatmapset] ¶
Get a user’s beatmaps.
- Parameters:
user_id (int) – ID of the user
type (aiosu.models.beatmap.UserBeatmapType) – Type of beatmaps to get
**kwargs – See below
- Keyword Arguments:
- limit (
int
) – Optional, number of beatmaps to get
- limit (
- offset (
int
) – Optional, offset of the first beatmap to get
- offset (
- Raises:
APIException – Contains status code and error message
RefreshTokenExpiredError – If the client refresh token has expired
- Returns:
List of requested beatmaps
- Return type:
- async get_user_most_played(user_id: int, **kwargs: Any) list[BeatmapUserPlaycount] ¶
Get a user’s most played beatmaps.
- Parameters:
user_id (int) – ID of the user
**kwargs – See below
- Keyword Arguments:
- limit (
int
) – Optional, number of beatmaps to get
- limit (
- offset (
int
) – Optional, offset of the first beatmap to get
- offset (
- Raises:
APIException – Contains status code and error message
RefreshTokenExpiredError – If the client refresh token has expired
- Returns:
List of user playcount objects
- Return type:
- async get_user_recent_activity(user_id: int, **kwargs: Any) list[Event] ¶
Get a user’s recent activity.
- Parameters:
user_id (int) – ID of the user
**kwargs – See below
- Keyword Arguments:
- limit (
int
) – Optional, number of events to get
- limit (
- offset (
int
) – Optional, offset of the first event to get
- offset (
- Raises:
APIException – Contains status code and error message
RefreshTokenExpiredError – If the client refresh token has expired
- Returns:
List of events
- Return type:
list[aiosu.models.event.Event]
- async get_events() EventResponse ¶
Get global events.
- Raises:
APIException – Contains status code and error message
RefreshTokenExpiredError – If the client refresh token has expired
- Returns:
Event response object
- Return type:
- async get_beatmap_scores(beatmap_id: int, **kwargs: Any) list[Score] ¶
Get scores submitted on a specific beatmap.
- Parameters:
beatmap_id (int) – Beatmap ID to search by
**kwargs – See below
- Keyword Arguments:
- mode (
aiosu.models.gamemode.Gamemode
) – Optional, gamemode to search for
- mode (
- mods (
aiosu.models.mods.Mods
) – Optional, mods to search for
- mods (
- type (
aiosu.models.common.BeatmapScoreboardType
) – Optional, beatmap score ranking type
- type (
- legacy_only (
bool
) – Optional, whether to only get legacy scores, defaults to
False
- legacy_only (
- Raises:
APIException – Contains status code and error message
RefreshTokenExpiredError – If the client refresh token has expired
- Returns:
List of requested scores
- Return type:
list[aiosu.models.score.Score]
- async get_beatmap(beatmap_id: int) Beatmap ¶
Get beatmap data.
- Parameters:
beatmap_id (int) – The ID of the beatmap
- Raises:
APIException – Contains status code and error message
RefreshTokenExpiredError – If the client refresh token has expired
- Returns:
Beatmap data object
- Return type:
- async get_beatmaps(beatmap_ids: list[int]) list[Beatmap] ¶
Get multiple beatmap data.
- Parameters:
beatmap_ids (list[int]) – The IDs of the beatmaps
- Raises:
APIException – Contains status code and error message
RefreshTokenExpiredError – If the client refresh token has expired
- Returns:
List of beatmap data objects
- Return type:
- async lookup_beatmap(**kwargs: Any) Beatmap ¶
Lookup beatmap data.
- Parameters:
**kwargs – See below
- Keyword Arguments:
- checksum (
str
) – Optional, the MD5 checksum of the beatmap
- checksum (
- filename (
str
) – Optional, the filename of the beatmap
- filename (
- id (
int
) – Optional, the ID of the beatmap
- id (
- Raises:
ValueError – If no arguments are specified
APIException – Contains status code and error message
RefreshTokenExpiredError – If the client refresh token has expired
- Returns:
Beatmap data object
- Return type:
- async get_beatmap_attributes(beatmap_id: int, **kwargs: Any) BeatmapDifficultyAttributes ¶
Gets difficulty attributes for a beatmap.
- Parameters:
beatmap_id (int) – The ID of the beatmap
**kwargs – See below
- Keyword Arguments:
- mode (
aiosu.models.gamemode.Gamemode
) – Optional, gamemode to search for
- mode (
- mods (
aiosu.models.mods.Mods
) – Optional, mods to apply to the result
- mods (
- Raises:
APIException – Contains status code and error message
RefreshTokenExpiredError – If the client refresh token has expired
- Returns:
Difficulty attributes for a beatmap
- Return type:
- async get_beatmapset(beatmapset_id: int) Beatmapset ¶
Get beatmapset data.
- Parameters:
beatmapset_id (int) – The ID of the beatmapset
- Raises:
APIException – Contains status code and error message
RefreshTokenExpiredError – If the client refresh token has expired
- Returns:
Beatmapset data object
- Return type:
- async lookup_beatmapset(beatmap_id: int) Beatmapset ¶
Lookup beatmap data.
- Parameters:
beatmap_id (int) – The ID of a beatmap in the set
- Raises:
APIException – Contains status code and error message
RefreshTokenExpiredError – If the client refresh token has expired
- Returns:
Beatmapset data object
- Return type:
- async search_beatmapsets(**kwargs: Any) BeatmapsetSearchResponse ¶
Search beatmapset by filter.
- Parameters:
search_filter (str) – The search filter.
**kwargs – See below
- Keyword Arguments:
- query (
str
) – Optional, search query
- query (
- mode (
aiosu.models.gamemode.Gamemode
) – Optional, gamemode to search for
- mode (
- category (
aiosu.models.beatmap.BeatmapsetCategory
) – Optional, beatmapset category
- category (
- show_explicit (
bool
) – Optional, whether to show explicit content, defaults to
False
- show_explicit (
- genre (
aiosu.models.beatmap.BeatmapsetGenre
) – Optional, beatmapset genre
- genre (
- language (
aiosu.models.beatmap.BeatmapsetLanguage
) – Optional, beatmapset language
- language (
- bundled (
aiosu.models.beatmap.BeatmapsetBundleFilterType
) – Optional, filter by bundled status. Currently not implemented
- bundled (
- sort (
aiosu.models.beatmap.BeatmapsetSortType
) – Optional, sort order
- sort (
- only_video (
bool
) – Optional, whether to only show beatmapsets with video, defaults to
False
- only_video (
- only_storyboard (
bool
) – Optional, whether to only show beatmapsets with storyboard, defaults to
False
- only_storyboard (
- recommended_difficulty (
bool
) – Optional, whether to only show beatmapsets with recommended difficulty, defaults to
False
- recommended_difficulty (
- only_followed (
bool
) – Optional, whether to only show beatmapsets from followed mappers, defaults to
False
- only_followed (
- only_spotlights (
bool
) – Optional, whether to only show beatmapsets were featured in spotlights, defaults to
False
- only_spotlights (
- only_featured_artists (
bool
) – Optional, whether to only show beatmapsets were featured artists, defaults to
False
- only_featured_artists (
- include_converts (
bool
) – Optional, whether to include converted beatmapsets, defaults to
False
- include_converts (
- cursor_string (
str
) – Optional, cursor string to get the next page of results
- cursor_string (
- Raises:
APIException – Contains status code and error message
RefreshTokenExpiredError – If the client refresh token has expired
- Returns:
Beatmapset search response
- Return type:
- async get_beatmap_packs(**kwargs: Any) BeatmapPacksResponse ¶
Get beatmap packs.
- Parameters:
**kwargs – See below
- Keyword Arguments:
- type (
aiosu.models.beatmap.BeatmapPackType
) – Optional, beatmap pack type
- type (
- cursor_string (
str
) – Optional, cursor string to get the next page of results
- cursor_string (
- Raises:
APIException – Contains status code and error message
RefreshTokenExpiredError – If the client refresh token has expired
- Returns:
Beatmap packs response
- Return type:
- async get_beatmap_pack(pack_tag: str, **kwargs: Any) BeatmapPack ¶
Get beatmap pack.
- Parameters:
pack_tag (str) – The tag of the beatmap pack
**kwargs – See below
- Keyword Arguments:
- legacy_only (
bool
) – Optional, whether or not to consider lazer scores for completion data, defaults to
False
- legacy_only (
- Raises:
APIException – Contains status code and error message
RefreshTokenExpiredError – If the client refresh token has expired
- Returns:
Beatmap pack object
- Return type:
- async get_beatmapset_events(**kwargs: Any) list[BeatmapsetEvent] ¶
Get beatmapset events.
- Parameters:
**kwargs – See below
- Keyword Arguments:
- limit (
int
) – Optional, number of results per page
- limit (
- page (
int
) – Optional, page number
- page (
- user_id (
int
) – Optional, user ID
- user_id (
- beatmapset_id (
int
) – Optional, beatmapset ID
- beatmapset_id (
- min_date (
datetime.datetime
) – Optional, minimum date
- min_date (
- max_date (
datetime.datetime
) – Optional, maximum date
- max_date (
- types (
list[aiosu.models.beatmap.BeatmapsetEventType]
) – Optional, event types
- types (
- Raises:
APIException – Contains status code and error message
RefreshTokenExpiredError – If the client refresh token has expired
- Returns:
List of beatmapset events
- Return type:
list[aiosu.models.event.Event]
- async get_beatmapset_discussions(**kwargs: Any) BeatmapsetDiscussionResponse ¶
Get beatmapset discussions.
- Parameters:
**kwargs – See below
- Keyword Arguments:
- beatmap_id (
int
) – Optional, beatmap ID
- beatmap_id (
- beatmapset_id (
int
) – Optional, beatmapset ID
- beatmapset_id (
- beatmapset_status (
aiosu.models.beatmap.BeatmapsetRequestStatus
) – Optional, beatmapset status
- beatmapset_status (
- limit (
int
) – Optional, number of results per page
- limit (
- page (
int
) – Optional, page number
- page (
- message_types (
list[aiosu.models.beatmap.BeatmapsetDisscussionType]
) – Optional, message types
- message_types (
- only_unresolved (
bool
) – Optional, only unresolved discussions
- only_unresolved (
- sort (
aiosu.models.common.SortType
) – Optional, sort order, defaults to
id_desc
- sort (
- user_id (
int
) – Optional, user ID
- user_id (
- with_deleted (
bool
) – Optional, include deleted discussions
- with_deleted (
- cursor_string (
str
) – Optional, cursor string
- cursor_string (
- Raises:
APIException – Contains status code and error message
RefreshTokenExpiredError – If the client refresh token has expired
- Returns:
Beatmapset discussion response
- Return type:
- async get_beatmapset_discussion_posts(**kwargs: Any) BeatmapsetDiscussionPostResponse ¶
Get beatmapset discussion posts.
- Parameters:
**kwargs – See below
- Keyword Arguments:
- beatmapset_discussion_id (
int
) – Optional, beatmapset discussion ID
- beatmapset_discussion_id (
- limit (
int
) – Optional, number of results per page
- limit (
- page (
int
) – Optional, page number
- page (
- sort (
aiosu.models.common.SortType
) – Optional, sort order, defaults to
id_desc
- sort (
- types (
list[str]
) – Optional, post types
- types (
- user_id (
int
) – Optional, user ID
- user_id (
- with_deleted (
bool
) – Optional, include deleted discussions
- with_deleted (
- cursor_string (
str
) – Optional, cursor string
- cursor_string (
- Raises:
APIException – Contains status code and error message
RefreshTokenExpiredError – If the client refresh token has expired
- Returns:
Beatmapset discussion post response
- Return type:
- async get_beatmapset_discussion_votes(**kwargs: Any) BeatmapsetDiscussionVoteResponse ¶
Get beatmapset discussion votes.
- Parameters:
**kwargs – See below
- Keyword Arguments:
- beatmapset_discussion_id (
int
) – Optional, beatmapset discussion ID
- beatmapset_discussion_id (
- limit (
int
) – Optional, number of results per page
- limit (
- page (
int
) – Optional, page number
- page (
- receiver_id (
int
) – Optional, receiver ID
- receiver_id (
- score (
aiosu.models.beatmap.BeatmapsetDiscussionVoteScoreType
) – Optional, “1” for upvote, “-1” for downvote
- score (
- sort (
aiosu.models.common.SortType
) – Optional, sort order, defaults to
id_desc
- sort (
- user_id (
int
) – Optional, user ID
- user_id (
- with_deleted (
bool
) – Optional, include deleted discussions
- with_deleted (
- cursor_string (
str
) – Optional, cursor string
- cursor_string (
- Raises:
APIException – Contains status code and error message
RefreshTokenExpiredError – If the client refresh token has expired
- Returns:
Beatmapset discussion vote response
- Return type:
- async get_score(score_id: int, mode: Gamemode, **kwargs: Any) Score | LazerScore ¶
Gets data about a score.
- Parameters:
score_id (int) – The ID of the score
mode (aiosu.models.gamemode.Gamemode) – The gamemode to search for
**kwargs – See below
- Keyword Arguments:
- new_format (
bool
) – Optional, whether to use the new score format, defaults to
False
- new_format (
- Raises:
APIException – Contains status code and error message
RefreshTokenExpiredError – If the client refresh token has expired
- Returns:
Score data object
- Return type:
- async get_score_replay(score_id: int, mode: Gamemode) BytesIO ¶
Gets the replay file for a score.
- Parameters:
score_id (int) – The ID of the score
mode (aiosu.models.gamemode.Gamemode) – The gamemode to search for
- Raises:
APIException – Contains status code and error message
RefreshTokenExpiredError – If the client refresh token has expired
- Returns:
Replay file
- Return type:
io.BytesIO
- async get_rankings(mode: Gamemode, type: RankingType, **kwargs: Any) Rankings ¶
Get rankings.
- Parameters:
mode (aiosu.models.gamemode.Gamemode) – The gamemode to search for
type (aiosu.models.rankings.RankingType) – The ranking type to search for
**kwargs – See below
- Keyword Arguments:
- country (
str
) – Optional, country code
- country (
- filter (
aiosu.models.rankings.RankingFilter
) – Optional, ranking filter
- filter (
- spotlight (
int
) – Optional, spotlight ID
- spotlight (
- variant (
aiosu.models.rankings.RankingVariant
) – Optional, ranking variant
- variant (
- cursor_string (
str
) – Optional, cursor string
- cursor_string (
- Raises:
APIException – Contains status code and error message
RefreshTokenExpiredError – If the client refresh token has expired
- Returns:
Rankings
- Return type:
- async get_rankings_kudosu(**kwargs: Any) Rankings ¶
Get kudosu rankings.
- Parameters:
**kwargs – See below
- Keyword Arguments:
- page_id (
int
) – Optional, page ID
- page_id (
- Raises:
APIException – Contains status code and error message
RefreshTokenExpiredError – If the client refresh token has expired
- Returns:
Rankings
- Return type:
- async get_spotlights() list[Spotlight] ¶
Gets the current spotlights.
- Raises:
APIException – Contains status code and error message
RefreshTokenExpiredError – If the client refresh token has expired
- Returns:
List of spotlights
- Return type:
- async get_forum_topic(topic_id: int, **kwargs: Any) ForumTopicResponse ¶
Gets a forum topic.
- Parameters:
topic_id (int) – The ID of the topic
**kwargs – See below
- Keyword Arguments:
- limit (
int
) – Optional, the number of posts to return. Min: 1, Max: 50, defaults to 20
- limit (
- sort (
aiosu.models.common.SortType
) – Optional, the sort type to use. Defaults to
id_asc
- sort (
- start (
int
) – Optional, the start post ID to use for pagination.
- start (
- end (
int
) – Optional, the end post ID to use for pagination.
- end (
- cursor_string (
str
) – Optional, the cursor string to use for pagination.
- cursor_string (
- Raises:
APIException – Contains status code and error message
RefreshTokenExpiredError – If the client refresh token has expired
- Returns:
Forum topic response object
- Return type:
- async create_forum_topic(forum_id: int, title: str, content: str, **kwargs: Any) ForumCreateTopicResponse ¶
Creates a forum topic.
- Parameters:
forum_id (int) – The ID of the forum to create the topic in
title (str) – The title of the topic
content (str) – The content of the topic
**kwargs – See below
- Keyword Arguments:
- with_poll (
bool
) – Optional, whether to create a poll with the topic. Defaults to
False
- with_poll (
- poll_title (
str
) – Optional, the title of the poll
- poll_title (
- poll_options (
list[str]
) – Optional, the options for the poll
- poll_options (
- poll_length_days (
int
) – Optional, the length of the poll in days. Defaults to 0
- poll_length_days (
- poll_vote_change (
bool
) – Optional, whether to allow users to change their vote. Defaults to
False
- poll_vote_change (
- poll_hide_results (
bool
) – Optional, whether to hide the results of the poll. Defaults to
False
- poll_hide_results (
- poll_max_votes (
int
) – Optional, the maximum number of votes a user can make. Defaults to 1
- poll_max_votes (
- Raises:
APIException – Contains status code and error message
RefreshTokenExpiredError – If the client refresh token has expired
- Returns:
Forum create topic response object
- Return type:
- async reply_forum_topic(topic_id: int, content: str) ForumPost ¶
Replies to a forum topic.
- Parameters:
topic_id (int) – The ID of the topic
content (str) – The content of the post
- Raises:
APIException – Contains status code and error message
RefreshTokenExpiredError – If the client refresh token has expired
- Returns:
Forum post object
- Return type:
- async edit_forum_topic_title(topic_id: int, new_title: str) ForumTopic ¶
Edits a forum topic’s title.
- Parameters:
topic_id (int) – The ID of the topic
new_title (str) – The new title of the topic
- Raises:
APIException – Contains status code and error message
RefreshTokenExpiredError – If the client refresh token has expired
- Returns:
Forum topic object
- Return type:
- async edit_forum_post(post_id: int, new_content: str) ForumPost ¶
Edits a forum post.
- Parameters:
post_id (int) – The ID of the post
new_content (str) – The new content of the post
- Raises:
APIException – Contains status code and error message
RefreshTokenExpiredError – If the client refresh token has expired
- Returns:
Forum post object
- Return type:
- async get_chat_ack(**kwargs: Any) list[ChatUserSilence] ¶
Gets chat acknowledgement.
- Parameters:
**kwargs – See below
- Keyword Arguments:
- since (
int
) – Optional, the last message ID received
- since (
- silence_id_since (
int
) – Optional, the last silence ID received
- silence_id_since (
- Raises:
APIException – Contains status code and error message
RefreshTokenExpiredError – If the client refresh token has expired
- Returns:
List of chat user silence objects
- Return type:
- async get_chat_updates(since: int, **kwargs: Any) ChatUpdateResponse ¶
Gets chat updates.
- Parameters:
since (int) – The last message ID received
**kwargs – See below
- Keyword Arguments:
- limit (
int
) – Optional, the maximum number of messages to return. Min: 1, Max: 50. Defaults to 50
- limit (
- channel_id (
int
) – Optional, the channel ID to get messages from
- channel_id (
- silence_id_since (
int
) – Optional, the last silence ID received
- silence_id_since (
- includes (
list[aiosu.models.chat.ChatIncludeType]
) – Optional, the additional information to include. Defaults to all.
- includes (
- Raises:
ValueError – If limit is not between 1 and 50
APIException – Contains status code and error message
RefreshTokenExpiredError – If the client refresh token has expired
- Returns:
Chat update response object
- Return type:
- async get_channel(channel_id: int) ChatChannelResponse ¶
Gets channel.
- Parameters:
channel_id (int) – The channel ID to get
- Raises:
APIException – Contains status code and error message
RefreshTokenExpiredError – If the client refresh token has expired
- Returns:
Chat channel object
- Return type:
- async get_channels() list[ChatChannel] ¶
Gets a list of joinable public channels.
- Raises:
APIException – Contains status code and error message
RefreshTokenExpiredError – If the client refresh token has expired
- Returns:
List of chat channel objects
- Return type:
- async get_channel_messages(channel_id: int, **kwargs: Any) list[ChatMessage] ¶
Gets channel messages.
- Parameters:
channel_id (int) – The channel ID to get messages from
**kwargs – See below
- Keyword Arguments:
- limit (
int
) – Optional, the maximum number of messages to return. Min: 1, Max: 50. Defaults to 50
- limit (
- since (
int
) – Optional, the ID of the oldest message to return
- since (
- until (
int
) – Optional, the ID of the newest message to return
- until (
- Raises:
ValueError – If limit is not between 1 and 50
APIException – Contains status code and error message
RefreshTokenExpiredError – If the client refresh token has expired
- Returns:
List of chat message objects
- Return type:
- async create_chat_channel(type: ChatChannelType, **kwargs: Any) ChatChannel ¶
Creates a chat channel.
- Parameters:
type (aiosu.models.chat.ChatChannelType) – The type of the channel.
**kwargs – See below
- Keyword Arguments:
- message (
str
) – Required if type is
ANNOUNCE
, the message to send in the PM
- message (
- target_id (
int
) – Only used if if type is
PM
, the ID of the user to send a PM to
- target_id (
- target_ids (
list[int]
) – Only used if type is
ANNOUNCE
, the IDs of the users to send a PM to
- target_ids (
- channel_name (
str
) – Only used if type is
ANNOUNCE
, the name of the channel
- channel_name (
- channel_description (
str
) – Only used if type is
ANNOUNCE
, the description of the channel
- channel_description (
- Raises:
ValueError – If missing required parameters
APIException – Contains status code and error message
RefreshTokenExpiredError – If the client refresh token has expired
- Returns:
Chat channel object
- Return type:
- async join_channel(channel_id: int, user_id: int) ChatChannel ¶
Joins a channel.
- Parameters:
channel_id (int) – The channel ID to join
user_id (int) – The user ID to join as
- Raises:
APIException – Contains status code and error message
RefreshTokenExpiredError – If the client refresh token has expired
- Returns:
Chat channel object
- Return type:
- async leave_channel(channel_id: int, user_id: int) None ¶
Leaves a channel.
- Parameters:
channel_id (int) – The channel ID to leave
user_id (int) – The user ID to leave as
- Raises:
APIException – Contains status code and error message
RefreshTokenExpiredError – If the client refresh token has expired
- async mark_read(channel_id: int, message_id: int) None ¶
Marks a channel as read.
- Parameters:
channel_id (int) – The channel ID to mark as read
message_id (int) – The message ID to mark as read up to
- Raises:
APIException – Contains status code and error message
RefreshTokenExpiredError – If the client refresh token has expired
- async send_message(channel_id: int, message: str, is_action: bool) ChatMessage ¶
Sends a message to a channel.
- Parameters:
channel_id (int) – The ID of the channel
message (str) – The message to send
is_action (bool) – Whether the message is an action
- Raises:
APIException – Contains status code and error message
RefreshTokenExpiredError – If the client refresh token has expired
- Returns:
Chat message object
- Return type:
- async send_private_message(user_id: int, message: str, is_action: bool, **kwargs: Any) ChatMessageCreateResponse ¶
Sends a message to a user.
- Parameters:
user_id (int) – The ID of the user
message (str) – The message to send
is_action (bool) – Whether the message is an action
**kwargs – See below
- Keyword Arguments:
- uuid (
str
) – Optional, client-side message identifier to be sent back in response and websocket json
- uuid (
- Raises:
APIException – Contains status code and error message
RefreshTokenExpiredError – If the client refresh token has expired
- Returns:
Chat message create response object
- Return type:
- async get_multiplayer_matches(**kwargs: Any) MultiplayerMatchesResponse ¶
Gets the multiplayer matches.
- Parameters:
**kwargs – See below
- Keyword Arguments:
- sort (
aiosu.models.common.SortType
) – Optional, the sort type
- sort (
- limit (
int
) – Optional, number of scores to get. Min: 1, Max: 50, defaults to 50
- limit (
- cursor_string (
str
) – Optional, the cursor string to get the next page of results
- cursor_string (
- Raises:
ValueError – If limit is not between 1 and 50
APIException – Contains status code and error message
RefreshTokenExpiredError – If the client refresh token has expired
- Returns:
Multiplayer matches response object
- Return type:
- async get_multiplayer_match(match_id: int, **kwargs: Any) MultiplayerMatchResponse ¶
Gets a multiplayer match.
- Parameters:
match_id (int) – The ID of the match
**kwargs – See below
- Keyword Arguments:
- limit (
int
) – Optional, number of scores to get. Min: 1, Max: 100, defaults to 100
- limit (
- before (
int
) – Optional, the ID of the score to get the scores before
- before (
- after (
int
) – Optional, the ID of the score to get the scores after
- after (
- Raises:
ValueError – If limit is not between 1 and 100
APIException – Contains status code and error message
RefreshTokenExpiredError – If the client refresh token has expired
- Returns:
Multiplayer match response object
- Return type:
- async get_multiplayer_rooms(**kwargs: Any) list[MultiplayerRoom] ¶
Gets the multiplayer rooms.
- Parameters:
**kwargs – See below
- Keyword Arguments:
- mode (
aiosu.models.multiplayer.MultiplayerRoomMode
) – Optional, the multiplayer room mode
- mode (
- limit (
int
) – Optional, number of scores to get. Min: 1, Max: 50, defaults to 50
- limit (
- sort (
aiosu.models.common.SortType
) – Optional, the sort type
- sort (
- category (
aiosu.models.multiplayer.MultiplayerRoomCategory
) – Optional, the multiplayer room category
- category (
- type (
aiosu.models.multiplayer.MultiplayerRoomGroupType
) – Optional, the multiplayer room group type
- type (
- Raises:
ValueError – If limit is not between 1 and 50
APIException – Contains status code and error message
RefreshTokenExpiredError – If the client refresh token has expired
- Returns:
List of multiplayer rooms
- Return type:
- async get_multiplayer_room(room_id: int) MultiplayerRoom ¶
Gets a multiplayer room.
- Parameters:
room_id (int) – The ID of the room
- Raises:
APIException – Contains status code and error message
RefreshTokenExpiredError – If the client refresh token has expired
- Returns:
Multiplayer room object
- Return type:
- async get_multiplayer_leaderboard(room_id: int, **kwargs: Any) MultiplayerLeaderboardResponse ¶
Gets the multiplayer leaderboard for a room.
- Parameters:
room_id (int) – The ID of the room
**kwargs – See below
- Keyword Arguments:
- limit (
int
) – Optional, number of scores to get. Min: 1, Max: 50, defaults to 50
- limit (
- Raises:
ValueError – If limit is not between 1 and 50
APIException – Contains status code and error message
RefreshTokenExpiredError – If the client refresh token has expired
- Returns:
Multiplayer leaderboard response object
- Return type:
- async get_multiplayer_scores(room_id: int, playlist_id: int, **kwargs: Any) MultiplayerScoresResponse ¶
Gets the multiplayer scores for a room.
- Parameters:
room_id (int) – The ID of the room
playlist_id (int) – The ID of the playlist
**kwargs – See below
- Keyword Arguments:
- limit (
int
) – Optional, the number of scores to return
- limit (
- sort (
aiosu.models.multiplayer.MultiplayerScoreSortType
) – Optional, the sort order of the scores
- sort (
- cursor_string (
str
) – Optional, the cursor string to use for pagination
- cursor_string (
- Raises:
ValueError – If limit is not between 1 and 100
APIException – Contains status code and error message
RefreshTokenExpiredError – If the client refresh token has expired
- Returns:
Multiplayer scores response object
- Return type:
- async revoke_token() None ¶
Revokes the current token and closes the session.
- Raises:
APIException – Contains status code and error message
RefreshTokenExpiredError – If the client refresh token has expired
- async aclose() None ¶
Closes the client session.