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)#
→Promise<IRESTLoadTracks>Resolves a track, playlist, or search query against the Lavalink node.
The search query or URL (e.g. ytsearch:faded, https://...).
const res = await node.rest.loadTracks("ytsearch:alan walker");
updatePlayer(guildId, data, noReplace)
updatePlayer(guildId, data, noReplace)#
→Promise<any>Updates the state of a player on the Lavalink server (play track, pause, seek, volume, filters).
The Guild ID.
The update payload (track, position, paused, volume, filters, etc.).
If true, the operation will be ignored if a track is already playing.
await node.rest.updatePlayer(guildId, {
paused: true,
volume: 50
});
destroyPlayer(guildId)
destroyPlayer(guildId)#
→Promise<void>Destroys the player on the remote Lavalink server.
The Guild ID.
await node.rest.destroyPlayer(guildId);
getPlayers()
getPlayers()#
→Promise<IRESTGetPlayers[]>Retrieves a list of all active players on this specific Lavalink session.
const players = await node.rest.getPlayers();
getPlayer(guildId)
getPlayer(guildId)#
→Promise<any>Retrieves the specific state of a player for a guild.
The Guild ID.
const playerState = await node.rest.getPlayer(guildId);
decodeTrack(encodedTrack)
decodeTrack(encodedTrack)#
→Promise<ITrack>Decodes a single base64 track string using the Lavalink API.
The base64 encoded string.
const track = await node.rest.decodeTrack("QAA...");
decodeTracks(encodedTracks)
decodeTracks(encodedTracks)#
→Promise<ITrack[]>Decodes an array of base64 track strings in a single request.
Array of base64 encoded strings.
const tracks = await node.rest.decodeTracks(["QAA...", "QAB..."]);
getInfo()
Retrieves general information about the Lavalink server (version, build time, git commit, etc.).
const info = await node.rest.getInfo();
getStats()
getStats()#
→Promise<INodeStats>Retrieves current system statistics (CPU, memory, players, uptime).
const stats = await node.rest.getStats();
getVersion()
getVersion()#
→Promise<string>Retrieves the plain version string of the Lavalink server.
const version = await node.rest.getVersion();
updateSession(resuming, timeout)
updateSession(resuming, timeout)#
→Promise<any>Updates the session configuration for resuming.
Whether resuming is enabled.
The number of seconds the session should stay alive after disconnect.
await node.rest.updateSession(true, 60); // 60 seconds
getRoutePlannerStatus()
getRoutePlannerStatus()#
→Promise<IRoutePlannerStatus>Retrieves the status of the IP route planner (if enabled on the server).
const status = await node.rest.getRoutePlannerStatus();
freeFailedAddress(address)
freeFailedAddress(address)#
→Promise<void>Unmarks a failed IP address in the route planner, allowing it to be used again.
The IP address to free.
await node.rest.freeFailedAddress("1.2.3.4");
freeAllFailedAddresses()
freeAllFailedAddresses()#
→Promise<void>Unmarks all failed IP addresses in the route planner.
await node.rest.freeAllFailedAddresses();