Get Top Artists
To display the user’s top artists, you can use the getTopArtists method. This method returns an array of the user’s top artists.
async function getTopArtists(userId, amount, offset){ try { const tracks = await vibify.getTopArtists(userId, amount, offset); console.log('Last Listened Tracks:', tracks); } catch (error) { console.error('Error:', error); }}
getTopArtists('user-id', 1, 0);Or with cURL:
curl -H "x-api-key: (your api key)" "http://localhost:3000/top-artists/user-id?amount=1"Returns
{ "items":[ { "external_urls":{ "spotify":"https://open.spotify.com/artist/30FDJPN3RtwJZ20g5YGCRX" }, "followers":{ "href":null, "total":188607 }, "genres":[ "future funk" ], "href":"https://api.spotify.com/v1/artists/30FDJPN3RtwJZ20g5YGCRX", "id":"30FDJPN3RtwJZ20g5YGCRX", "images":[ { "url":"https://i.scdn.co/image/ab6761610000e5ebe385819b611d2524bf08182a", "height":640, "width":640 }, { "url":"https://i.scdn.co/image/ab67616100005174e385819b611d2524bf08182a", "height":320, "width":320 }, { "url":"https://i.scdn.co/image/ab6761610000f178e385819b611d2524bf08182a", "height":160, "width":160 } ], "name":"Yung Bae", "popularity":50, "type":"artist", "uri":"spotify:artist:30FDJPN3RtwJZ20g5YGCRX" }, { "external_urls":{ "spotify":"https://open.spotify.com/artist/0Repe2EiNjaFAFIukrroUM" }, "followers":{ "href":null, "total":514388 }, "genres":[ "brighton indie" ], "href":"https://api.spotify.com/v1/artists/0Repe2EiNjaFAFIukrroUM", "id":"0Repe2EiNjaFAFIukrroUM", "images":[ { "url":"https://i.scdn.co/image/ab6761610000e5ebd8099257b7798dd6e30f3511", "height":640, "width":640 }, { "url":"https://i.scdn.co/image/ab67616100005174d8099257b7798dd6e30f3511", "height":320, "width":320 }, { "url":"https://i.scdn.co/image/ab6761610000f178d8099257b7798dd6e30f3511", "height":160, "width":160 } ], "name":"Ren", "popularity":63, "type":"artist", "uri":"spotify:artist:0Repe2EiNjaFAFIukrroUM" } ]}