osu! API v0.1.2 OsuAPI View Source
A wrapper around the osu! API.
Usage
iex> OsuAPI.get_user("cookiezi", event_days: 5)
{:ok, %{user_id: 124493, username: "Cookiezi"}, ...}
The get_*
function names mirror the API itself as do the parameter names,
which can be passed as a trailing keyword list.
The returned data is mostly identical to the osu! API documentation, except for the following:
- The return value of functions which return at most one result
(
get_user/2
for example) is a map instead of a list containing one map. If no result is found, then the value isnil
, instead of an empty list. - Numbers, booleans, dates, and lists are parsed to their native types, and enum values are converted to their symbolic values as atoms.
- Enums named
*_id
have the suffix removed, since the atoms aren’t IDs.
Configuration
To access the osu! API, you need to provide an API key.
You can pass the k
parameter around if you want,
but otherwise you can configure its value in config.exs
:
config :osu_api, api_key: "<your key here>"
You can also set the OSU_API_KEY
environment variable.
Link to this section Summary
Functions
Same as get_beatmap/2
but throws exceptions
Gets a beatmap by ID (beatmap ID, not beatmapset ID)
Same as get_beatmaps/2
but throws exceptions
Gets beatmaps
Same as get_beatmapset/2
but throws exceptions
Gets a beatmapset by ID (beatmapset ID, not beatmap ID)
Same as get_match/2
but throws exceptions
Gets a multiplayer match by ID
Same as get_replay/4
but throws exceptions
Gets replay data for a score
Same as get_scores/2
but throws exceptions
Gets a beatmap’s top scores
Same as get_user/2
but throws exceptions
Gets a user by username or user ID
Same as get_user_best/2
but throws exceptions
Gets a user’s top scores
Same as get_user_recent/2
but throws exceptions
Gets a user’s recent scores
Translates the game mode enum to an atom and vice versa
Link to this section Types
Link to this section Functions
Same as get_beatmap/2
but throws exceptions.
get_beatmap(integer(), keyword()) :: {:ok, map() | nil} | {:error, OsuAPI.Error.t()}
Gets a beatmap by ID (beatmap ID, not beatmapset ID).
Same as get_beatmaps/2
but throws exceptions.
get_beatmaps(keyword()) :: {:ok, [map()]} | {:error, OsuAPI.Error.t()}
Gets beatmaps.
Same as get_beatmapset/2
but throws exceptions.
get_beatmapset(integer(), keyword()) :: {:ok, [map()]} | {:error, OsuAPI.Error.t()}
Gets a beatmapset by ID (beatmapset ID, not beatmap ID).
Same as get_match/2
but throws exceptions.
get_match(integer(), keyword()) :: {:ok, map() | nil} | {:error, OsuAPI.Error.t()}
Gets a multiplayer match by ID.
Same as get_replay/4
but throws exceptions.
Gets replay data for a score.
Same as get_scores/2
but throws exceptions.
get_scores(integer(), keyword()) :: {:ok, [map()]} | {:error, OsuAPI.Error.t()}
Gets a beatmap’s top scores.
Same as get_user/2
but throws exceptions.
get_user(user(), keyword()) :: {:ok, map() | nil} | {:error, OsuAPI.Error.t()}
Gets a user by username or user ID.
Same as get_user_best/2
but throws exceptions.
get_user_best(user(), keyword()) :: {:ok, [map()]} | {:error, OsuAPI.Error.t()}
Gets a user’s top scores.
Same as get_user_recent/2
but throws exceptions.
get_user_recent(user(), keyword()) :: {:ok, [map()]} | {:error, OsuAPI.Error.t()}
Gets a user’s recent scores.
Translates the game mode enum to an atom and vice versa.