Search code examples
restapispotifylast.fmechonest

How To Get All Songs of An Artist on Spoitfy?


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.


Solution

  • 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