Question

How can I get all the comments from a particular track on soundcloud? My script only returns 200, while the soundcloud page for the particular track states that there are currently 400+ comments.

Is there a limit in the API?

Thanks!

Was it helpful?

Solution

Limit per call is 200. Implement pagination.

https://developers.soundcloud.com/docs#pagination

Here is an example to get 400 comments using JS, JQuery + SC SDK.

 SC.get('/tracks/' + track.id + '/comments',{ limit: page_size }, function(comments) {
    for (var i = 0; i < comments.length; i++) {
        $('#result').append(comments[i].created_at + ': ' + comments[i].body + '<br/>');
    }
  });
  SC.get('/tracks/' + track.id + '/comments',{ limit: page_size, offset: page_size}, function(comments) {
    for (var i = 0; i < comments.length; i++) {
      $('#result').append(comments[i].created_at + ': ' + comments[i].body + '<br/>');
    }
  }); 

http://jsfiddle.net/iambnz/9uXKt/

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top