osuAPI
Contents
Constructor
const osuAPI = require('osuapi-js');
const api = new osuAPI(APIKey, { beatmaps: { fetchCreatorInfo: false } });
APIkey
- Your osu! API key. You can get one from here.options
- Object that contains default options for the API.baseURI
- Base API URI. (default is https://osu.ppy.sh/api/)beatmaps
- Options for fetching beatmaps.fetchCreatorInfo
- If set to true, beatmap and beatmap set objects'creator
properties will contain User object, if false it'll return string with creator's username. Default is true.
Methods
.getUser(user, mode, eventDays, type)
Fetches user info
Param | Type | Optional | Default | Description |
---|---|---|---|---|
user | string | number | ✘ | none | User's username or ID from which to fetch. |
mode | osuMode | ✔ | 'standard' | Mode which gather information from. |
eventDays | number | ✔ | 1 | Max number of days between now and last event date. |
type | osuType | ✔ | Auto detection | Specify if user is a user ID or a username. Optional, default behaviour is automatic recognition (may be problematic for usernames made up of digits only). |
Returns: Promise<User>
Example:
osuAPI.getUser('nrabulinski')
.then(user => {
console.log(user);
});
.getBeatmaps(ID, mapset, mode, fetchCreatorInfo)
Fethes info about beatmap(s) or Beatmap set
Param | Type | Optional | Default | Description |
---|---|---|---|---|
ID | number | ✘ | none | Beatmap(set)'s ID. |
mapset | boolean | ✔ | false | Is the ID an ID of a beatmap set? |
mode | osuMode | ✔ | none | Return beatmaps from specific mode. Maps of all modes are returned by default. |
fetchCreatorInfo | boolean | ✔ | true | specified in osuAPI options | Should <result>.creator be a string or User object? |
Returns: Promise<Beatmap|Beatmapset>
Example:
osuAPI.getBeatmaps(460569, true)
.then(beatmapset => {
console.log(beatmapset.difficulties);
});