#
Track Details
Get information about a track.
#
Usage
Import the Function
import { getTrack } from "youtubemusic.js";
Invoke the Function
const id: string = "Track id"; const searchResults = await getTrack(query); console.log(searchResults);
#
Function Parameters
#
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.