Create URLs

The buildUrl constant has multiple methods that allow you to create different URLs in the ppy.sh domain. Each method returns a URL string as an output.

Example

import { buildUrl } from 'osu-web.js';

const userProfileUrl = buildUrl.user(14544646); // Output: https://osu.ppy.sh/u/14544646
const forumPostUrl = buildUrl.forumTopic(1789556); // Output: https://osu.ppy.sh/community/forums/topics/1789556

Methods

beatmapsetCover

Parameters

ParameterTypeOptionalDescription
beatmapsetIdnumberA beatmapset’s ID

Returns

`https://assets.ppy.sh/beatmaps/${beatmapsetId}/covers/cover.jpg`;

beatmapsetThumbnail

Parameters

ParameterTypeOptionalDescription
beatmapsetIdnumberA beatmapset’s ID

Returns

`https://b.ppy.sh/thumb/${beatmapsetId}.jpg`;

beatmap

Parameters

ParameterTypeOptionalDescription
beatmapIdnumberA beatmap’s ID

Returns

`https://osu.ppy.sh/b/${beatmapId}`;

beatmapset

Parameters

ParameterTypeOptionalDescription
beatmapsetIdnumberA beatmapset’s ID

Returns

`https://osu.ppy.sh/s/${beatmapsetId}`;

userAvatar

Parameters

ParameterTypeOptionalDescription
userIdnumberA user’s ID

Returns

`https://s.ppy.sh/a/${beatmapsetId}`;

user

Parameters

ParameterTypeOptionalDescription
userIdnumberA user’s ID

Returns

`https://osu.ppy.sh/u/${userId}`;

score

Parameters

ParameterTypeOptionalDescription
gamemodeGameModeThe score’s game mode
scoreIdnumberA score’s ID

Returns

`https://osu.ppy.sh/scores/${gamemode}/${scoreId}`;

forum

Parameters

ParameterTypeOptionalDescription
forumIdnumberA forum’s ID

Returns

`https://osu.ppy.sh/community/forums/${forumId}`;

forumTopic

Parameters

ParameterTypeOptionalDescription
topicIdnumberA forum topic’s (forum post) ID

Returns

`https://osu.ppy.sh/community/forums/topics/${forumId}`;

room

Parameters

ParameterTypeOptionalDescription
roomIdnumberA multplayer room’s ID

Returns

`https://osu.ppy.sh/multiplayer/rooms/${roomId}`;

match

Parameters

ParameterTypeOptionalDescription
matchIdnumberA match’s ID

Returns

`https://osu.ppy.sh/mp/${matchId}`;

authRequest

Parameters

ParameterTypeOptionalDescription
clientIdnumberOAuth client ID
redirectUristringOAuth redirect URI
scopesScope[]An array of OAuth scopes. Defaults to ['identify']
statestringData that will be returned when a temporary code is issued

Returns

`https://osu.ppy.sh/oauth/authorize?client_id=${clientId}&redirect_uri=${redirectUri}&response_type=code&scope=${scopes}&state=${state}`;

Create custom URL

Don’t see a method that creates a URL you’re looking for? Use the custom method to create a URL using the ppy.sh domain as a base.

Parameters

ParameterTypeOptionalDescription
pathstringPath to set after https://{subdomain}.ppy.sh/
subdomainstringSpecify a subdomain to point to. Defaults to osu

Returns

`https://${subdomain}.ppy.sh/${path}`;

Notice that something is missing? Found a typo? Think something's incomplete? Or think that something can be explained better? Feel free to open a pull request or submit an issue on the library's Github repository .