18

Is it possible to get the track list from a specific user via the soundcloud API WITHOUT requiring that specific user to authenticate?

I'm looking for something like the YouTube feeds you can get here: https://gdata.youtube.com/feeds/api/users/mrromandiaz/uploads?max-results=10 (I've pointed this at my account, but the username "mrromandiaz" can be replaced with any username to retrieve that user's videos...

Question is, does Soundcloud offer anything similar? I don't need to authenticate, or post, or upload, or control anything... just get user's track lists to show on their profiles, without resorting to the default player.

Roman
  • 258
  • 1
  • 2
  • 6

2 Answers2

28

Yep, the API endpoint is at /users/{user_id}/tracks. If you don't have the user id, but only their username (permalink), you can use the /resolve endpoint to get the user data, including their id.

Documentation here: user resource and here resolve.

nickf
  • 537,072
  • 198
  • 649
  • 721
  • yes i am trying to access it but it always says unauthorized, can you tell me how can i get the tracks without being authenticated ? – Vikas Gupta Jan 30 '13 at 11:33
  • @VikasGupta you need to include your client id with each request. this doesn't mean you need to log in, but you need your application's client id. – nickf Jan 30 '13 at 12:28
  • @nickf yes i am trying that i even tried http://api.soundcloud.com/resolve.json?url=https://soundcloud.com/matas/hobnotropic&client_id=CLIENT_ID and i also tried this https://api.soundcloud.com/tracks?client_id=CLIENT_ID but it says unauthorised every time.. Please help – Vikas Gupta Jan 30 '13 at 13:31
  • 1
    @VikasGupta try a valid client id. http://api.soundcloud.com/resolve.json?url=https://soundcloud.com/matas/hobnotropic&client_id=YOUR_CLIENT_ID – nickf Jan 30 '13 at 15:34
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/23675/discussion-between-vikas-gupta-and-nickf) – Vikas Gupta Jan 31 '13 at 04:57
4

To get the track list from a specific user via the soundcloud API without authenticating:

(javascript example)

SC.initialize({
      client_id: "YOUR_CLIENT_ID",
      redirect_uri: "http://example.com/callback.html",
  });

/**
Once that's done you are all set and ready to call the SoundCloud API. 
**/

/**
Call to the SoundCloud API. 
Retrieves list of tracks, and displays a list with links to the tracks showing 'tracktitle' and 'track duration'
**/

  var userId = 39090345; // user_id of Prutsonic

  SC.get("/tracks", {
      user_id: userId,
      limit: 100
  }, function (tracks) {



      for (var i = 0; i < tracks.length; i++) {
          console.log(tracks[i].title);
      }

  });

You can try my fiddle here: http://jsfiddle.net/tobiasbeuving/26pHX/5/

(PHP example:)

    try {
        $tracks = $client->get('tracks', array('user_id' => '39090345','limit' => 100));
    } catch (Services_Soundcloud_Invalid_Http_Response_Code_Exception $e) {
        print $e->getMessage();
    }

(I just answered a similar question Soundcloud stratus player won't dynamically add more than an individual track at a time but I don't know how to handle the 'duplicate question' situation.

Cheers, T

Community
  • 1
  • 1
Tobias Beuving
  • 630
  • 6
  • 18