Soundcloud API does not explicitly support json pagination

The specific example I worked with:

http://api.soundcloud.com/users/dubstep/tracks.json?client_id=YOUR_CLIENT_ID

You will get the first 50 tracks, but the next-href object will not look like what you see in the xml version .

However, you can use offset and restriction, and it works as expected, but then I will need to โ€œblindlyโ€ scan the tracks until there are no more tracks, unlike the XML version, which gives you the โ€œnext pageโ€ Results. I would not even notice that it was paginated, but by accident, when I looked for the json object and noticed that there were exactly 50 tracks (which is even suspicious).

Is there a plan to support next-href tag in json? Am I missing something? is it a mistake he is missing?

+4
source share
3 answers

There is an undocumented parameter that you can use linked_partitioning=1 , which will add next_href to the answer.

http://api.soundcloud.com/users/dubstep/tracks.json?client_id=YOUR_CLIENT_ID&linked_partitioning=1

+13
source

sI saw this code should help (this is in Ruby):

 # start paging through results, 100 at a time tracks = client.get('/tracks', :order => 'created_at', :limit => page_size, :linked_partitioning => 1) tracks.each { |t| puts t.title } 

However, the first result set will show, and I will see "next_href" at the end of the answer, but what should you do to show the next result set?

0
source

for ex:

 // build our API URL $clientid = "Your API Client ID"; // Your API Client ID $userid = "/ IDuser"; // ID of the user you are fetching the information for // Grab the contents of the URL //more php get $number="1483"; $offset=1300; $limit=200; $soundcloud_url = "http://api.soundcloud.com/users/{$userid}/tracks.json?client_id={$clientid}&offset={$offset}&limit={$limit}"; $tracks_json = file_get_contents($soundcloud_url); $tracks = json_decode($tracks_json); foreach ($tracks as $track) { echo "<pre>"; echo $track->title . ":"; echo $track->permalink_url . ""; echo "</pre>"; } 
0
source

All Articles