Christoffer Reijer
Christoffer Reijer

Reputation: 1995

Order by playbacks when fetching tracks from SoundCloud

I am fetching a list of tracks from soundcloud's API using the following query to retrieve the 5 most popular tracks:

https://api.soundcloud.com/tracks?client_id=XXX&order=hotness&limit=5

But recently SoundCloud removed the hotness order. In the blog post they say tracks can instead be sorted by playback_count. But can this be done in the query or do they suggest I pull down the whole SoundCloud library and order them in the client? The following doesn't seem to work:

https://api.soundcloud.com/tracks?client_id=XXX&order=playback_count&limit=5

So how would one retrieve the top tracks on SoundCloud?

Upvotes: 6

Views: 4328

Answers (3)

Justin
Justin

Reputation: 166

Just wanted to provide an update. It seems soundcloud has moved to v2 of the explore API call.

Use this to get a list of categories:
https://api.soundcloud.com/explore/v2

And this to get tracks from a category:
https://api-v2.soundcloud.com/explore/metal?limit=10&offset=0

So far it seems to without a key, although I have no idea how long that will last.

EDIT: So the 2nd url doesn't seem to allow cross-origin, but so far this does work, though it only returns the trackID not the full information

https://api.soundcloud.com/explore/v2/metal?limit=50&consumer_key=XXX

Upvotes: 4

Christoffer Reijer
Christoffer Reijer

Reputation: 1995

The solution was to use the undocumented calls for the explorer feature that SoundCloud itself uses (I used the dev tools in Chrome to check the AJAX calls).

https://api.soundcloud.com/explore/sounds/category?limit=L&client_id=XXX

This appears to use some sort of sorting on the popularity of the songs. The songs can then be filtered on only music by checking the "grouping" attribute. I then have to resolve the list of IDs to actual songs which can be done with the (documented, official) API call:

https://api.soundcloud.com/tracks?ids=1,2,3&client_id=XXX

This seems to work perfectly and I also get the added benefit of an even distribution among genres. But of course, this can stop working at any moment since the API calls are undocumented and perhaps not meant for public use.

Upvotes: 4

cucko
cucko

Reputation: 1436

check here, soundcloud removed order by hotness.

Has order by hotness been removed from Soundclouds API

so, for now, only order by date is possible.

Upvotes: 0

Related Questions