Star ✨ on GitHub

Rest

Handles direct HTTP interactions with the Lavalink REST API (v4). Used internally by the Node and Player classes but can be accessed for advanced operations.

The Rest class is a wrapper around the Lavalink v4 REST API. It handles authentication, request headers, and response parsing. Every Node instance has its own Rest property.

Methods

loadTracks(identifier)

loadTracks(identifier)#

Resolves a track, playlist, or search query against the Lavalink node.

identifierstring required

The search query or URL (e.g. ytsearch:faded, https://...).

Example
const res = await node.rest.loadTracks("ytsearch:alan walker");

updatePlayer(guildId, data, noReplace)

Updates the state of a player on the Lavalink server (play track, pause, seek, volume, filters).

guildIdstring required

The Guild ID.

dataobject required

The update payload (track, position, paused, volume, filters, etc.).

noReplaceboolean

If true, the operation will be ignored if a track is already playing.

Example
await node.rest.updatePlayer(guildId, {
    paused: true,
    volume: 50
});

destroyPlayer(guildId)

destroyPlayer(guildId)#

Destroys the player on the remote Lavalink server.

guildIdstring required

The Guild ID.

Example
await node.rest.destroyPlayer(guildId);

getPlayers()

getPlayers()#

Retrieves a list of all active players on this specific Lavalink session.

Example
const players = await node.rest.getPlayers();

getPlayer(guildId)

getPlayer(guildId)#

Retrieves the specific state of a player for a guild.

guildIdstring required

The Guild ID.

Example
const playerState = await node.rest.getPlayer(guildId);

decodeTrack(encodedTrack)

decodeTrack(encodedTrack)#

Decodes a single base64 track string using the Lavalink API.

encodedTrackstring required

The base64 encoded string.

Example
const track = await node.rest.decodeTrack("QAA...");

decodeTracks(encodedTracks)

decodeTracks(encodedTracks)#

Decodes an array of base64 track strings in a single request.

encodedTracksstring[] required

Array of base64 encoded strings.

Example
const tracks = await node.rest.decodeTracks(["QAA...", "QAB..."]);

getInfo()

getInfo()#

Retrieves general information about the Lavalink server (version, build time, git commit, etc.).

Example
const info = await node.rest.getInfo();

getStats()

getStats()#

Retrieves current system statistics (CPU, memory, players, uptime).

Example
const stats = await node.rest.getStats();

getVersion()

getVersion()#

Retrieves the plain version string of the Lavalink server.

Example
const version = await node.rest.getVersion();

updateSession(resuming, timeout)

Updates the session configuration for resuming.

resumingboolean required

Whether resuming is enabled.

timeoutnumber required

The number of seconds the session should stay alive after disconnect.

Example
await node.rest.updateSession(true, 60); // 60 seconds

getRoutePlannerStatus()

getRoutePlannerStatus()#

Retrieves the status of the IP route planner (if enabled on the server).

Example
const status = await node.rest.getRoutePlannerStatus();

freeFailedAddress(address)

Unmarks a failed IP address in the route planner, allowing it to be used again.

addressstring required

The IP address to free.

Example
await node.rest.freeFailedAddress("1.2.3.4");

freeAllFailedAddresses()

Unmarks all failed IP addresses in the route planner.

Example
await node.rest.freeAllFailedAddresses();