Sunday, July 23, 2017

Soundcloud API returning incorrect values for Likes and Following

Leave a Comment

The Soundcloud API is returning incorrect counts for favourites (likes) and following.

Does anyone know how to fix or if it's just something on soundclouds side?

Example: User 29084746 is Jorja Smith, she has 29 likes. https://soundcloud.com/jorjasmith

https://api.soundcloud.com/users/29084746/favorites?client_id=XXX&page_size=200&linked_partitioning=1

returns 17 likes.

Edit: Just to clarify, this is happening with every user I test, not just this example.

2 Answers

Answers 1

Using this question (asked in 2016) as a reference, I found that:

There is a setting for Premium account that can prevent the track from showing as a like in third-party software.

So, some tracks are most likely hidden from third parties, and thus from the API.

this is happening with every user I test

Well, maybe now they are allowing every user to hide their posts from API access, as pointed out by sauntimo's answer.

Answers 2

I found an API key (took maybe 37 seconds on google...) and got the likes for that user from the API and stuck them in a table in this fiddle. I went down the list until I found one on the site that wasn't returned by the API. The first one was this track "Sharpness". Also, good heavens did I feel tragically uncool reading some of this music stuff I don't understand.

Anyway, I found the artist id for the missing "sharpness" track by doing a user search like this. Note that track_count in the returned object is 79. I then got the artists tracks like this (as per the API docs) and was intrigued to see that [ ] was returned. I did spot that this user was on a free plan according to the response, so it doesn't look like it's something to do with the artist having a premium account. Also whilst Jora has a premium account it seems unlikely that this would only hide certain likes.

I then repeated this process for another missing track, "U-GO-I-GO", found the artist here with track_count : 32 and then got their tracks which again came back as an empty array, [ ].

In conclusion it seems like there must be a setting for users to prevent API access to tracks which they upload. Then, when another user likes one of these users' tracks, these tracks are not returned by queries on the second users likes, hence the discrepancy in number of likes on the site vs returned by the API for your original user Jora Smith.

Further to this, in the help center there is an article on Disabling App Playback which states

If you would like to restrict playback of your track, you can choose to disable app playback through your track's Permissions tab. This means that your track will only be playable on SoundCloud and through SoundCloud embeds, instead of websites or apps that use our API.

Soundcloud Screenshot

I suspect that means that where the uploading user has disabled "app playback", these tracks are completely unavailable to the api. Note that it definitely seems to be the uploading user's permissions settings which are causing your discrepancy, not the user who's likes you're retrieving.

If You Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment