Giulioni Lorenzo Giulioni Lorenzo - 5 months ago 36
Node.js Question

SoundCloud API: same call, different response between curl and NodeJS

I have a problem calling the SoundCloud API: for the same API call from the same server I get different results between doing a CURL request and NodeJs. The following two calls have been made within 2 seconds one from the other.

Call from our server "SiaMusic":


{"id":3789802,"kind":"user","permalink":"siamusic","username":"SiaMusic","last_modified":"2016/03/27 21:00:51 +0000","uri":"","permalink_url":"","avatar_url":"","country":null,"first_name":"","last_name":"","full_name":"","description":"","city":"","discogs_name":null,"myspace_name":null,"website":"","website_title":"","track_count":204,"playlist_count":23,"online":false,"plan":"Pro Plus","public_favorites_count":1,"subscriptions":[{"product":{"id":"creator-pro-unlimited","name":"Pro Unlimited"}}],"followers_count":137277,"followings_count":0}

Call from NodeJs using "request" module:

var options = {
method: 'GET',
url: '',
qs: {client_id: 'MY_CLIENT_ID' },
json: true
request(options, function(err, response, body) {
//handle error, if body

Response: body:
{ id: 3789802, kind: 'user', permalink: 'siamusic', username: 'SiaMusic', last_modified: '2016/03/27 21:00:51 +0000', uri: '', permalink_url: '', avatar_url: '', country: null, first_name: '', last_name: '', full_name: '', description: '', city: '', discogs_name: null, myspace_name: null, website: '', website_title: '', track_count: 204, playlist_count: 23, online: false, plan: 'Pro Plus', public_favorites_count: 1, subscriptions: [ [Object] ], followers_count: 136692, followings_count: 0 }}

As you can see from the JSON the "followers_count" differs a lot and also happens (for NodeJs calls) that I get the same results across 5 to 30 days. Are the API served by a CDN?


As said in the comments of my original question the problem is solved by adding a timestamp field in the QueryString of the API call. That way the request will always be different and you'll always obtain the most updated value.

Thanks to @JacopoBrovida for the tips!