Announcements

Help Wizard

Step 1

NEXT STEP

FAQs

Please see below the most popular frequently asked questions.

Loading article...

Loading faqs...

VIEW ALL

Ongoing Issues

Please see below the current ongoing issues which are under investigation.

Loading issue...

Loading ongoing issues...

VIEW ALL

Web API: Pagination for „Get Artist’s Albums” broken

Web API: Pagination for „Get Artist’s Albums” broken

When calling “Get Artist’s Albums” using a "include_groups" filter, the "next" URL in the response is showing a next page, even though there are no more items to return with respect to the chosen "include_groups". Also the "total" parameter of the response does not fit to what’s expected. An example would be

 

https://api.spotify.com/v1/artists/2ye2Wgw4gimLv2eAKyk1NB/albums?include_groups=compilation&market=D...

 

This request returns just one item, a single compilation album. Nevertheless the "next" URL in the result is showing up as "https://api.spotify.com/v1/artists/2ye2Wgw4gimLv2eAKyk1NB/albums?offset=20&limit=20&market=DE&locale...". Requesting the next page ("limit" = 20, "offset" = 20) returns an empty "items" list, but again a "next" URL ("offset" = 40), and so on...

 

Also the "total" number returned does not match the API reference: "The total number of items available to return." which is not true in that case since the number of available compilations in this example is exactly "1" but the actual "total" number returned is "62".

 

How should the front end client now know when to ask for a next page returning some valid items and not just an empty list? "total" number is useless as well as relying on the "next" URL. And BTW, why the request parameter "album_type" was just renamed to "include_groups", using the same arguments as before? This adds just additional overhead to an existing implementation without any obvious improvements.

 

You can easily reproduce this issue using Spotify's web API developer site.

 

Spotify, pls. fix that.

Reply
2 Replies

It's been broken for 8 years . The unannounced renaming of the album type parameter also baffles me. Why they would implement breaking changes instead of just leaving it be, if they don't plan on fixing/adding stuff.

I have always used this approach to display a "next page" button in my application for years:

 

if (limit + offset) < total:

    # do stuff to display "next"

 

This was working in a proper manner, I always got a reasonable "total" value that fits to my "get_albums()" request. I have never seen that my application has displayed a "next page" if there were no more items which is the case now since I have fixed the "include_groups" issue. So this means that also the "total" calculation is broken now or has changed at least.

Suggested posts