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 is nil, 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

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

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

Link to this function get_beatmap!(id, opts \\ []) View Source
get_beatmap!(integer(), keyword()) :: map() | nil

Same as get_beatmap/2 but throws exceptions.

Link to this function get_beatmap(id, opts \\ []) View Source
get_beatmap(integer(), keyword()) ::
  {:ok, map() | nil} | {:error, OsuAPI.Error.t()}

Gets a beatmap by ID (beatmap ID, not beatmapset ID).

Link to this function get_beatmaps!(opts \\ []) View Source
get_beatmaps!(keyword()) :: [map()]

Same as get_beatmaps/2 but throws exceptions.

Link to this function get_beatmaps(opts \\ []) View Source
get_beatmaps(keyword()) :: {:ok, [map()]} | {:error, OsuAPI.Error.t()}

Gets beatmaps.

Link to this function get_beatmapset!(id, opts \\ []) View Source
get_beatmapset!(integer(), keyword()) :: [map()]

Same as get_beatmapset/2 but throws exceptions.

Link to this function get_beatmapset(id, opts \\ []) View Source
get_beatmapset(integer(), keyword()) ::
  {:ok, [map()]} | {:error, OsuAPI.Error.t()}

Gets a beatmapset by ID (beatmapset ID, not beatmap ID).

Link to this function get_match!(id, opts \\ []) View Source
get_match!(integer(), keyword()) :: map() | nil

Same as get_match/2 but throws exceptions.

Link to this function get_match(id, opts \\ []) View Source
get_match(integer(), keyword()) ::
  {:ok, map() | nil} | {:error, OsuAPI.Error.t()}

Gets a multiplayer match by ID.

Link to this function get_replay!(map_id, user, mode, opts \\ []) View Source
get_replay!(integer(), user(), integer(), keyword()) :: map() | nil

Same as get_replay/4 but throws exceptions.

Link to this function get_replay(map_id, user, mode, opts \\ []) View Source
get_replay(integer(), user(), integer(), keyword()) ::
  {:ok, map() | nil} | {:error, OsuAPI.Error.t()}

Gets replay data for a score.

Link to this function get_scores!(map_id, opts \\ []) View Source
get_scores!(integer(), keyword()) :: [map()]

Same as get_scores/2 but throws exceptions.

Link to this function get_scores(map_id, opts \\ []) View Source
get_scores(integer(), keyword()) :: {:ok, [map()]} | {:error, OsuAPI.Error.t()}

Gets a beatmap’s top scores.

Link to this function get_user!(user, opts \\ []) View Source
get_user!(user(), keyword()) :: map() | nil

Same as get_user/2 but throws exceptions.

Link to this function get_user(user, opts \\ []) View Source
get_user(user(), keyword()) :: {:ok, map() | nil} | {:error, OsuAPI.Error.t()}

Gets a user by username or user ID.

Link to this function get_user_best!(user, opts \\ []) View Source
get_user_best!(user(), keyword()) :: [map()]

Same as get_user_best/2 but throws exceptions.

Link to this function get_user_best(user, opts \\ []) View Source
get_user_best(user(), keyword()) :: {:ok, [map()]} | {:error, OsuAPI.Error.t()}

Gets a user’s top scores.

Link to this function get_user_recent!(user, opts \\ []) View Source
get_user_recent!(user(), keyword()) :: [map()]

Same as get_user_recent/2 but throws exceptions.

Link to this function get_user_recent(user, opts \\ []) View Source
get_user_recent(user(), keyword()) ::
  {:ok, [map()]} | {:error, OsuAPI.Error.t()}

Gets a user’s recent scores.

Link to this function mode(arg1) View Source
mode(integer()) :: atom()
mode(atom()) :: integer()

Translates the game mode enum to an atom and vice versa.