README

#YoutubeMusic

This guide explains how to use the YoutubeMusic class provided by the YoutubeMusic.js library to interact with the YouTube Music API.

#Importing the Class

// Importing the class - TypeScript ESNext import { YoutubeMusic } from "youtubemusic.js";

#Creating an Instance

Create an instance of the YoutubeMusic class to use its methods:

const instance = new YoutubeMusic();

#Usage

#Searching for a Song

You can search for a song using the search method. It takes two parameters: the search query and the type of search (e.g., playlists, tracks). Here's an example of how to search for the song "True Faith":

import { Search } from "youtubemusic.js"; instance.search("True Faith", Search.Tracks).then((searchResponse) => { console.log(searchResponse); });

In this example, Search.Playlists specifies that you want to search in playlists. You can change it to Search.Tracks or other search types based on your requirement.

Query ParameterDescriptionDefaultRequired
querySearch QueryTrackTrue

#Getting Information about a Song

To retrieve information about a specific song, use the get method. Provide the video ID of the song and specify the type of information you want (e.g., track details). Here's an example:

import { Get } from "youtubemusic.js"; instance.get("qCNbdYd9K30", Get.Track).then((trackResponse) => { console.log(trackResponse); });

In this example, "qCNbdYd9K30" is the video ID of the song. Change Get.Track to other options like Get.Playlist if you want information about a playlist.

Query ParameterDescriptionDefaultRequired
idThe id of the trackTrackTrue
Methods

search
https://github.com/TrishCX/YoutubeMusic.js/blob/main/src/classes/YoutubeMusic.ts
get
https://github.com/TrishCX/YoutubeMusic.js/blob/main/src/classes/YoutubeMusic.ts