Module: Osu::API

Defined in:
lib/osu/api.rb,
lib/osu/api/hash.rb,
lib/osu/api/mods.rb,
lib/osu/api/constants.rb,
lib/osu/api/get_request.rb

Overview

Interface to Osu's REST API

Defined Under Namespace

Modules: GetRequest, Mods, UserScore Classes: Beatmap, BeatmapScore, User, UserBestScore, UserRecentScore

Constant Summary collapse

BASE_URL =

Base URL

'https://osu.ppy.sh'.freeze
API_URL =

API URL to Osu

"#{BASE_URL}/api".freeze
MODE =

Osu! game modes

[
  :standard,
  :taiko,
  :ctb,
  :mania
]
APPROVAL =

Approval enum

{
  4 => :loved,
  3 => :qualified,
  2 => :approved,
  1 => :ranked,
  0 => :pending,
 -1 => :wip,
 -2 => :graveyard
}

Class Method Summary collapse

Class Method Details

.auth(auth) ⇒ Hash

Returns auth hash part.

Returns:

  • (Hash)

    auth hash part


38
39
40
# File 'lib/osu/api/hash.rb', line 38

def auth(auth)
  { k: auth }
end

.beatmap(id) ⇒ Hash

Returns beatmap hash part.

Returns:

  • (Hash)

    beatmap hash part


23
24
25
# File 'lib/osu/api/hash.rb', line 23

def beatmap(id)
  { b: id }
end

.beatmap_set(id) ⇒ Hash

Returns beatmapset hash part.

Returns:

  • (Hash)

    beatmapset hash part


28
29
30
# File 'lib/osu/api/hash.rb', line 28

def beatmap_set(id)
  { s: id }
end

.event_days(number) ⇒ Hash

Returns event days hash part.

Returns:

  • (Hash)

    event days hash part


18
19
20
# File 'lib/osu/api/hash.rb', line 18

def event_days(number)
  { event_days: number }
end

.limit(number) ⇒ Hash

Returns limit hash part.

Returns:

  • (Hash)

    limit hash part


43
44
45
# File 'lib/osu/api/hash.rb', line 43

def limit(number)
  { limit: number }
end

.mode(mode) ⇒ Hash

Returns mode hash part.

Returns:

  • (Hash)

    mode hash part


33
34
35
# File 'lib/osu/api/hash.rb', line 33

def mode(mode)
  { m: MODE.index(mode) }
end

.mods(bits) ⇒ Hash

Returns mods hash part.

Returns:

  • (Hash)

    mods hash part


48
49
50
# File 'lib/osu/api/hash.rb', line 48

def mods(bits)
  { mods: bits }
end

.user(data) ⇒ Hash

Returns user hash part.

Returns:

  • (Hash)

    user hash part


9
10
11
12
13
14
15
# File 'lib/osu/api/hash.rb', line 9

def user(data)
  if data.is_a? Integer
    { u: data, type: 'id' }
  elsif data.is_a? String
    { u: data, type: 'string' }
  end
end