#
Search Track
Look for a just with a query.
#
Usage
Import the Function
import { searchTracks } from "youtubemusic.js";
Invoke the Function
const query: string = "Your search query here"; const searchResults = await searchTracks(query); console.log(searchResults);
#
Function Parameters
#
Return Value
The function returns an array of objects, each containing information about a matching track. The structure of each object conforms to the SearchTracks
interface defined in the interfaces/index.ts
file.
#
Example
import { searchTracks } from "youtubemusic.js";
async function searchAndPrintResults(query: string): Promise<void> {
const searchResults = await searchTracks(query);
console.log(searchResults);
}
const query: string = "Epic Music";
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.