2
votes

In their docs for getting top tracks on an artist they mention this:

The 10 maximum tracks are the ones displayed by the Spotify app. If you want to fetch more artist’s top tracks, an alternative way is to use Echo Nest song/search to accomplish this. It will accept a Spotify artist id for input and give you Spotify id’s in the output.

I'm pretty sure the Echo Nest Api no longer exists, so I am wondering if there is still a way to get songs of an artist other than just 10 of them?

Alternatively I was thinking of using Last.fm's Api to do it if Spotify no longer supports that functionality, if anyone has any other suggestions of how one could work around this that would be great! Thanks in advance.

2

2 Answers

3
votes

I think you won't be able to achieve it in single API call in Spotify. However there's an alternative:

Request all albums of an artist (have a look here):

https://api.spotify.com/v1/artists/{id}/albums

And then request the tracks of each album (have a look here):

https://api.spotify.com/v1/albums/{id}/tracks

To avoid one request for each album, you can get multiple albums at once and when an album is requested, the tracks of such album will be returned in a paging object. You can pass the desired albums identifiers separated by , in the id query parameter to the following endpoint (have a look here):

https://api.spotify.com/v1/albums
2
votes

A solution that was more sufficient for me here was:

https://api.spotify.com/v1/search?type=track&q=artist:ArtistName

this returns the top songs by this artist, with pagination so definitely more than 10 results.

The only caveat is that this includes songs that the artist might be featured on, but I think this is useful really as if it's a popular song your user might be looking for it.