Skip to content

getTrackPreview

LakhindarPal edited this page May 12, 2024 · 1 revision

Method: getTrackPreview()

getTrackPreview(trackId, countryCode?): Promise<string>

Retrieves the preview URL of a track from the Tidal API based on the provided track ID and country code.

Parameters

  • trackId: number

The ID of the track.

  • countryCode?: string= "US"

The country code to use for retrieving the track information. Defaults to "US".

Returns

Promise<string>

A promise that resolves to the track preview URL.

Usage

const { getTrackPreview } = require("tidal-music-api");

// example track ID
const id = 188267445;

try {
  const preview = await getTrackPreview(id);
  console.log(preview);
} catch (error) {
  console.error("Error:", error);
}
Clone this wiki locally