ArtistStructure
Defined in: src/structures/artist.ts:21
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new ArtistStructure(client: FMClient): ArtistStructure;Defined in: src/structures/artist.ts:24
Parameters
Section titled “Parameters”client
Section titled “client”Returns
Section titled “Returns”ArtistStructure
Methods
Section titled “Methods”getSimilar()
Section titled “getSimilar()”getSimilar(options: GetArtistBase): Promise<SimilarArtistResponse>;Defined in: src/structures/artist.ts:47
Get all the artists similar to this artist.
Parameters
Section titled “Parameters”options
Section titled “options”The options. See ArtistGetSimilarOptions.
Returns
Section titled “Returns”Promise<SimilarArtistResponse>
A promise that resolves to the API response object.
- Success:
{ success: true, similarArtists: Array, artistName: string } - Failure:
{ success: false, errorCode: ErrorCodes.MISSING_REQUIREMENTS | ErrorCodes.NO_SIMILAR_ARTISTS | number | string, errorMsg: string }
Example
Section titled “Example”const res = await fm.artist.getSimilar({ artist: "Michael Jackson", limit: 5,});
if (res.success) { console.log(`Similar to Michael Jackson: ${res.similarArtists.map((a) => a.name).join(", ")}`);}getTopAlbums()
Section titled “getTopAlbums()”getTopAlbums(options: GetArtistBase): Promise<ArtistTopAlbumsResponse>;Defined in: src/structures/artist.ts:191
Get the top albums for an artist on Last.fm, ordered by popularity.
Parameters
Section titled “Parameters”options
Section titled “options”The options. See ArtistGetTopAlbumsOptions.
Returns
Section titled “Returns”Promise<ArtistTopAlbumsResponse>
A promise that resolves to the API response object.
- Success:
{ success: true, topAlbums: Array, artistName: string } - Failure:
{ success: false, errorCode: ErrorCodes.MISSING_REQUIREMENTS | ErrorCodes.ARTIST_NO_TOP_ALBUMS | number | string, errorMsg: string }
Example
Section titled “Example”const res = await fm.artist.getTopAlbums({ artist: "The Weeknd", limit: 5,});
if (res.success) { console.log(`Top The Weeknd album: ${res.topAlbums[0].name}`);}getTopTracks()
Section titled “getTopTracks()”getTopTracks(options: GetArtistBase): Promise<ArtistTopTracksResponse>;Defined in: src/structures/artist.ts:116
Get the top tracks by an artist on Last.fm, ordered by popularity.
Parameters
Section titled “Parameters”options
Section titled “options”The options. See ArtistGetTopTracksOptions.
Returns
Section titled “Returns”Promise<ArtistTopTracksResponse>
A promise that resolves to the API response object.
- Success:
{ success: true, topTracks: Array, artistName: string } - Failure:
{ success: false, errorCode: ErrorCodes.MISSING_REQUIREMENTS | ErrorCodes.ARTIST_NO_TOP_TRACKS | number | string, errorMsg: string }
Example
Section titled “Example”const res = await fm.artist.getTopTracks({ artist: "Daft Punk", limit: 5,});
if (res.success) { console.log(`Top Daft Punk track: ${res.topTracks[0].name}`);}search()
Section titled “search()”search(options: ArtistSearchOptions): Promise<ArtistSearchResponse>;Defined in: src/structures/artist.ts:264
Search for an artist by name. Returns artist matches sorted by relevance.
Parameters
Section titled “Parameters”options
Section titled “options”The options. See ArtistSearchOptions.
Returns
Section titled “Returns”Promise<ArtistSearchResponse>
A promise that resolves to the API response object.
- Success:
{ success: true, artists: Array, totalResultsOnLastFm: number | null } - Failure:
{ success: false, errorCode: ErrorCodes.MISSING_REQUIREMENTS | ErrorCodes.NO_ARTIST_MATCHES | number | string, errorMsg: string }
Example
Section titled “Example”const res = await fm.artist.search({ artist: "Michael Jackson", limit: 5,});
if (res.success) { console.log(`Found ${res.artists.length} matching artists`);}