Expandable Models

A common pattern in the osu! api is to have a “compact” variant of a model with less attributes, for performance reasons. For instance, UserCompact and User. It is also common to want to “expand” a compact model into its full representation to access these additional attributes. To do so, use the expand method:

compact_user = api.search(query="tybug").users.data[0]
# `statistics` is only available on `User` not `UserCompact`,
# so expansion is necessary
full_user = compact_user.expand()
print(full_user.statistics.ranked_score)

Note

Expanding a model requires an api call, so it is not free. Use only when necessary.

Here is the full list of expandable models: