soundcloud / api

A public repo for our Developer Community to engage about bugs and feature requests on our Public API
143 stars 22 forks source link

Can I jump to a specific page when using linked_partitioning? #234

Closed alexweinstein closed 1 year ago

alexweinstein commented 1 year ago

Following the Soundcloud API documentation, when getting /tracks or /playlists we set the linked_partitioning parameter to true and check for next_href on the return. If next_href exists, follow that url for the next set of data.

This makes sense for an endless scroll.

But is it possible to send the user to a specific page of results? For example, a URL for Page 3 of a user's tracks when limit is set to 200? Or is this just not possible with linked_partitioning? Is there any other way to get this type of pagination with Soundcloud API?

alexweinstein commented 1 year ago

bump

mgoodfellow commented 1 year ago

Hey, I'm not SC, but no, they don't have offset based pagination anymore.

AFAIK, their API a long time ago used to have offset paging on some of the really old APIs but they all got deprecated in favour of cursor based pagination.

The issue will be with their large distributed data stores that don't lend themselves to offset based pagination (issues with distributed sharding, inconsistent results, and issues with getting a "total" count which you need for pages), so it simply isn't an option anymore unfortunately.

In your specific use case you describe above, you can work out the number of "pages" because the user object has a track_count and private_tracks_count. However, when it comes to loading page 3, as per your example, you will need to traverse the pages, and make 3 API calls in turn.

alexweinstein commented 1 year ago

@mgoodfellow Got it. Thanks so much for jumping in. I appreciate it.