# Track Details

Get information about a track.

# Usage

  1. Import the Function

    import { getTrack } from "youtubemusic.js";
  2. Invoke the Function

    const id: string = "Track id";
    const searchResults = await getTrack(query);
    console.log(searchResults);

# Function Parameters

Query Parameter Description Default Required
id The track id for getting the information. undefined True

# Return Value

The function returns a objects, containing detailed information about the track. The structure of each object conforms to the ITrack interface defined in the interfaces/index.ts file.

# Example

import { getTrack } from "path/to/searchTracks";

async function searchAndPrintResults(query: string): Promise<void> {
  const searchResults = await searchTracks(query);
  console.log(searchResults);
}

const id: string = "g6_2Rygz38Y";
searchAndPrintResults(query);

# Notes 📝

  • Make sure to handle errors appropriately, especially network-related errors that might occur during the API request.
  • Do not call the functions when working in a for loop it might rate limit.

Feel free to incorporate and modify this function according to your project requirements.