4

I am trying to use the javascript SDK for Soundcloud to return a list of tracks that are streamable.

My question is: How do I filter search results for only streamable songs using the javascript SDK?

Here is an example that will return songs that are not streamable:

SC.get('/tracks', {q: 'mat zo', filter: 'streamable'}).then(function (tracks) { 
    console.log(tracks); 
});

Here is what the request comes out to be:

api.soundcloud.com/tracks?q=mat+zo&filter=streamable&format=json&client_id=[XXX]

I noticed that the first track in this response has streamable=false.
snippet of the response:

...
streamable: false
tag_list: "Remix Mat Zo Burn Ellie Goulding"
title: "Burn (Mat Zo Remix)"
track_type: ""
...

Looking at the Soundcloud SDK documentation I don't see a way to do this as the 'filter' query parameter only accepts '(all, public, private)'.

https://developers.soundcloud.com/docs/api/reference#tracks (I am looking at the Filters)

same unanswered question: stackoverflow.com/questions/23791711/filtering-tracks-by-streamable-in-soundcloud

Thanks in advance, this is my first question. I can provide more of my code upon request.

2
  • Are you asking for a way to accomplish it by altering the request to the Soundcloud SDK, or by dealing with the returned data from the request? Dec 16, 2015 at 5:16
  • I am asking how to alter the request made to the server to only give me a response of streamable=true songs. Thanks for clarifying. Dec 16, 2015 at 5:17

2 Answers 2

1

There is no (documented) filter for the streamable property on the API. You can however easily filter out the unstreamable tracks yourself:

SC.get('/tracks', {q: 'mat zo'}).then(function (tracks) { 
    for(var i = 0; i < tracks.length; i++) {
        if(!(tracks[i].streamable)) {           
        tracks.splice(i,1);
      } 
    }
    console.log(tracks); 
});
1
  • Thanks Hartger. I was hoping that there was a way to make the server do it but I can do it this way. Dec 16, 2015 at 21:42
-1

It's hard to tell without having a token to test. However, the documentation around "Search" appears to imply that sounds can be filtered by property directly:

Some resource types, such as sounds, can be filtered by fields like license, duration or tag_list.

  // find all sounds of buskers licensed under 'creative commons share alike'
SC.get('/tracks', {
  q: 'buskers', license: 'cc-by-sa'
}).then(function(tracks) {
  console.log(tracks);
});

In your case, you should replace license with streamable and 'cc-by-sa' with 'true'.

2
  • I tried that and got the same json response back as my first example. :( ` SC.get('/tracks', {q: 'mat zo', streamable: true}).then(function (tracks) { console.log(tracks); }); stream_url: "api.soundcloud.com/tracks/104236584/stream" streamable: false tag_list: "Remix Mat Zo Burn Ellie Goulding" title: "Burn (Mat Zo Remix)" track_type: ""` Dec 16, 2015 at 5:40
  • Here is a client id to play with: 429600260189ef2f5faf0ae09ea502f7 Dec 16, 2015 at 5:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.