Skip to content

ArtistStructure

Defined in: src/structures/artist.ts:21

new ArtistStructure(client: FMClient): ArtistStructure;

Defined in: src/structures/artist.ts:24

FMClient

ArtistStructure

getSimilar(options: GetArtistBase): Promise<SimilarArtistResponse>;

Defined in: src/structures/artist.ts:47

Get all the artists similar to this artist.

GetArtistBase

The options. See ArtistGetSimilarOptions.

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 }
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(options: GetArtistBase): Promise<ArtistTopAlbumsResponse>;

Defined in: src/structures/artist.ts:191

Get the top albums for an artist on Last.fm, ordered by popularity.

GetArtistBase

The options. See ArtistGetTopAlbumsOptions.

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 }
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(options: GetArtistBase): Promise<ArtistTopTracksResponse>;

Defined in: src/structures/artist.ts:116

Get the top tracks by an artist on Last.fm, ordered by popularity.

GetArtistBase

The options. See ArtistGetTopTracksOptions.

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 }
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(options: ArtistSearchOptions): Promise<ArtistSearchResponse>;

Defined in: src/structures/artist.ts:264

Search for an artist by name. Returns artist matches sorted by relevance.

ArtistSearchOptions

The options. See ArtistSearchOptions.

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 }
const res = await fm.artist.search({
artist: "Michael Jackson",
limit: 5,
});
if (res.success) {
console.log(`Found ${res.artists.length} matching artists`);
}