Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting specific user's track list with soundcloud API

Tags:

api

soundcloud

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.

like image 683
Roman Avatar asked Apr 15 '12 05:04

Roman


People also ask

What can you do with SoundCloud API?

Our API gives you the ability to upload, manage and share tracks. Your app can take an audio file and upload it to a user's SoundCloud account. You can also manage metadata (including tags) or add the track to playlists.

How do I get oauth tokens on SoundCloud?

You don't generate it on yourself, you get it from the SoundCloud API. You have first to authorize with your client_id, client_secret and a redirect_url then in the redirect_url (which the soundcloud server will call it should be some script on your server) you can get the token from the GET parameter "code".

Can I use SoundCloud API?

To access the SoundCloud® API, you will first need to register your app at https://soundcloud.com/you/apps using your SoundCloud® account. When you've done that, we'll issue you with a client ID and client secret. Your client ID is required for all calls to the SoundCloud® API.


2 Answers

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

like image 23
Tobias Beuving Avatar answered Nov 16 '22 01:11

Tobias Beuving


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.

like image 66
nickf Avatar answered Nov 16 '22 02:11

nickf