1.0.2 • Published 2 years ago

@rascm/osu v1.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

npm.io

The module is promise based, and uses osu!API v2. To use API you need to register your app here, just scroll down to set up oAuth applications. You will need the client id and secret code. Only the most frequently used, stable API endpoints are available! If something is wrong, you can report it on GitHub.

Usage

Current stable release (1.x) requires at least Node.js 15.0.0.

Install with npm

$ npm i @rascm/osu

Load module, and request token in ESM:

import osu from '@rasm/osu';
const auth = new osu.Authentication("Your client id here", "Your secret key here");
const token = await auth.client(); // Return {"access_token" : "your access token here", "token_type" : "Bearer", "expires_in" : 86400} or {"error" : "reason here", "response" : "returned object from API"}

Load module, and request token in Common JS:

const osu = require('@rascm/osu');
const auth = new osu.Authentication("Your client id here", "Your secret key here");
const token = auth.client();
token.then(access_token => {
	// access_token = {"access_token" : "your access token here", "token_type" : "Bearer", "expires_in" : 86400}  or {"error" : "reason here", "response" : "returned object from API"}
});
token.catch(error => {
    // error = Reject reason
});

Available Endpoints

Beatmapsets:

Beatmap and beatmapset listing, filtering, search, beatmapset events, and information fetching about beatmaps.

Scores:

Retrieve player results, view map rankings, retrieve matches, information about scores.

Users:

Detailed profiles of players, kudosu informations, player history...

Detailed information of functions

class Authentication

Generate access tokens, make authorization url.

Parametertyperequired
$client_idintegeryes
$client_secretstringyes

Functions:


client($params): return Promise

Client authentication provides an access token for developers that does not involve a user.

Parametertyperequired
$paramsobjectno

Default value:

object keytyperequireddefault value
client_idintegerno$client_id from class
client_secretstringno$client_secret from class
grant_typestringnoclient_credentials
scopestringnopublic

authorization($params): return Promise

Generate token for user.

Parametertyperequired
$paramsobjectyes

Default value:

object keytyperequireddefault value
client_idintegerno$client_id from class
client_secretstringno$client_secret from class
grant_typestringnoauthorization_code
redirect_uristringyes
codestringyes

url($searchParams): return String

Generate a url address for the user, where they can request a temporary code to generate a token for themselves.

Parametertyperequired
$paramsobjectyes

Default value:

object keytyperequireddefault value
client_idintegerno$client_id from class
response_typestringnocode
scopestringnoidentify public
redirect_uristringyes
codestringyes

class Beatmapsets extends ParseToken

Information about beatmaps, beatmapsets.

Parametertyperequired
$access_tokenobjectyes

Default value:

object keytyperequireddefault value
token_typestringyes
access_tokenstringyes
expires_inintegeryes

Functions:


events($searchParams): return Promise

Get recent beatmapset events.

Parametertyperequired
$searchParamsobjectno

Default value:

object keytyperequireddefault value
userstringno
typesarrayno'qualify', 'rank', 'nominate', 'disqualify', 'nomination_reset', 'remove_from_loved', 'approve'
min_datestringno
max_datestringno
  • user: user whose events you want to view.
  • types: List only the specified events. Each event must be entered in an array. Accepted values: nominate, qualify, rank, love, nomination_reset, nomination_reset_received, disqualify, remove_from_loved, kudosu_gain, kudosu_lost, genre_edit, language_edit, nsfw_toggle, issue_resolve, issue_reopen, beatmap_owner_change, kudosu_allow, kudosu_deny, approve, kudosu_recalculate, discussion_delete, discussion_restore, discussion_post_delete, discussion_post_restore
  • min_date: Start date, which cannot be greater than or equal to end date. Only accepted YYYY-MM-dd format.
  • max_date: End date, which cannot be less than or equal to start date. Only accepted YYYY-MM-dd format.

getBeatmap($beatmap_id): return Promise

Get information about beatmap with id.

Parametertyperequired
$beatmap_idintegeryes

getBeatmapset($beatmapset_id): return Promise

Get information about beatmapset with id.

Parametertyperequired
$beatmapset_idintegeryes

lookupBeatmap($searchParams): return Promise

Get beatmap information with id, filename, or checksum.

Parametertyperequired
$searchParamsobjectyes

filters:

At least one filter must be used

  • checksum
  • filename
  • id

search($searchParams): return Promise

Search and filter beatmap by criteria.

Parametertyperequired
$searchParamsobjectyes

filters:

At least one filter must be used

object keytypedefault value
visualstring
featuredArtistboolean
genrestring
languagestring
modestring
querystring
typestringany
  • visual: Should it include a video, a storyboard or both? Accepted values: storyboard, video, both.
  • featuredArtist: Search only the featured artists
  • genre: Search only beatmaps in this genre. Accepted values: videogame, anime, rock, pop, other, novelty, hiphop, electronic, metal, classical, folk, jazz or unspecified.
  • language: Search only beatmaps in this language. Accepted values: english, chinese, french, german, italian, japanese, korean, spanish, swedish, russian, polish, instrumental, unspecified or other.
  • mode: Search in specified game mode. Accepted values: standard, taiko, fruits or mania
  • query: You can enter the search terms.
  • type: What kind of maps should it search for? Accepted values: ranked, loved, qualified, pending, graveyard or any

class Scores extends ParseToken

Information about beatmap scores and matches

Parametertyperequired
$access_tokenobjectyes

Default value:

object keytyperequireddefault value
token_typestringyes
access_tokenstringyes
expires_inintegeryes

Functions:


getBeatmapScore($beatmap_id, $user_id, $searchParams): return Promise

Get beatmap score from a user.

Parametertyperequired
$beatmap_idintegeryes
$user_idintegeryes
$searchParamsobjectno

$searchParams object:

  • mode: Get score from specified game mode. Accepted values: fruits, mania, osu or taiko.

getInfo($score_id, $user_id, $mode): return Promise

Get information about score by id and mode.

Parametertyperequired
$score_idintegeryes
$modestringyes
  • $mode: The mode associated with the score. Accepted values: standard, taiko, fruits, mania

getMatch($match_id): return Promise

Get information about match.

Parametertyperequired
$match_idintegeryes
  • $match_id: Unique identifier of the match

getMatches($searchParams): return Promise

List matches.

Parametertyperequired
$searchParamsobjectno

$searchParams object:

  • limit: Number of matches per page Default: 20
  • offset: Result offset for pagination. Default: 0

getUserScores($user_id, $type, $searchParams): return Promise

List matches.

Parametertyperequired
$user_idintegeryes
$typestringno
$searchParamsobjectno

$type: Types of results achieved. Accepted values: best, firsts or recent. Default: best

$searchParams object:

  • limit: Number of scores per page Default: 20
  • offset: Result offset for pagination. Default: 0

class Users extends ParseToken

Information about users.

Parametertyperequired
$access_tokenobjectyes

Default value:

object keytyperequireddefault value
token_typestringyes
access_tokenstringyes
expires_inintegeryes

Functions:


getBeatmaps($user_id, $type, $searchParams): return Promise

Get user beatmaps.

Parametertyperequired
$user_idintegeryes
$typestringno
$searchParamsobjectno

$type: Beatmap types. Accepted values: favourite, most_played, pending, ranked, graveyard or loved

$searchParams object:

  • limit: Number of beatmapsets per page Default: 20
  • offset: Result offset for pagination. Default: 0

getKudosu($user_id, $searchParams): return Promise

Get user kudosu informations.

Parametertyperequired
$user_idintegeryes
$searchParamsobjectno

$searchParams object:

  • limit: Number of beatmapsets per page Default: 20
  • offset: Result offset for pagination. Default: 0

getMe($mode): return Promise Requires user authentication!

Get current authenticated user information.

Parametertyperequired
$modestringno

$mode: User default mode will be used if not specified. Accepted values: standard, taiko, fruits or mania


getUser($user_id, $mode, $by): return Promise

Get specified user profile.

Parametertyperequired
$user_idinteger or string (depends on $by value)yes
$modestringno
$bystringno

$mode: User default mode will be used if not specified. Accepted values: standard, taiko, fruits or mania

$by: If you want to search by username, change it to 'name'. Default value: id


recentActivity($user_id, $searchParams): return Promise

Get user recent activities.

Parametertyperequired
$user_idintegeryes
$searchParamsobjectno

$searchParams object:

  • limit: Number of beatmapsets per page Default: 20
  • offset: Result offset for pagination. Default: 0

1.0.2

2 years ago

1.0.1

3 years ago

0.0.3

3 years ago

0.0.4

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago