getTopArtists method
Get the top artists listened to by a user. You can stipulate a time period. Sends the overall chart by default.
NOTE: the output list is already ordered by rank.
Implementation
Future<List<Artist>?> getTopArtists({
required String user,
Period? period,
int page = 1,
int limit = 50,
}) async {
final parameters = {
'user': user,
'period': period?.value,
'page': page,
'limit': limit,
};
final request = Request(
api: _api,
method: 'user.getTopArtists',
parameters: parameters,
);
final response = await request.send(mode: RequestMode.GET);
final topArtist = response['topartists']['artist'];
return parseLastFMList<Artist>(topArtist, (i) => Artist.fromJson(i));
}