#
Search Album
You can search for albums by providing the album title as the search query.
#
Usage
- Import the Function
import YoutubeMusic from "youtubemusic.js";
- Invoke the Function
YoutubeMusic.searchAlbums("For Your Entertainment")
.then((response) => {
// Handle the response data here
console.log(response);
})
.catch((error) => {
// Handle errors here
console.error(error);
});
#
Response Format
The response object returned by the API contains detailed information about the albums matching the search query. Each album object typically includes the following properties:
id
: Unique identifier for the album.title
: Title of the album.artist
: Name of the artist associated with the album.releasedYear
: Release date of the album.imageURL
: The cover url of the album.artistId
: The associated artist id.gradientColor
: The cover url gradient colors.
#
Example Response
[
{
id: "MPREb_jeA2tKVCWcC",
title: "For Your Entertainment",
artist: "Adam Lambert",
type: "Album",
imageURL:
"https://lh3.googleusercontent.com/CiMiAagSsAkxt-lj39ej1KKq05GbzAxW3LNxm-eWR9SgLku-XLJYHbE7hq4tkRIlNo6MGlJ__G3JzjoW=w544-h544-l90-rj",
artistId: "UCE0e75AsD74BLP07SfM6OzQ",
releasedYear: "2009",
gradientColor: ["3422552064", "3422552064"],
},
];
#
Important Notes
- Make sure to provide an accurate and complete album title for precise search results.
- Handle the response data and errors appropriately in your application.