Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to search specific user's tracks by tag with the Sound Cloud API?

I want to search for tracks by tag relating only to my user name i.e. the Royal Opera House.

For example:

http://api.soundcloud.com/users/royaloperahouse/tracks/?client_id=238947HSGDHSDG&tags=eric

tells me I need to use a q parameter. To humour it I search:

http://api.soundcloud.com/users/royaloperahouse/tracks/??client_id=238947HSGDHSDG&tags=eric&q=e

and simply get a list of sounds from the whole of Sound Cloud not the ones relating to just my user. Similarly if I try and search the tracks API (not by users) and limit the query with &user_id I get videos relating to all users not one specific to the Royal Opera House.

The ultimate aim is to find all tracks that the Royal Opera House has uploaded relating to a specific artist. At the moment the way we are solving it is by getting all of our uploaded tracks (37 at present) and iterating through those to match the tracks by the relevant tag. Obviously as our music list grows this will start to be a problem.

Thanks.

like image 951
user954348 Avatar asked Feb 07 '13 13:02

user954348


People also ask

How do you search tags on SoundCloud?

On the search results screen, if you only want to search for music, click Tracks. You can also click one of the options under “Filter by Tag” to show only results that have been designated with specific keywords (“tags”).

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 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". Then in the next step you can exchange the code for an access token.


1 Answers

I haven't used this API before, but after a few tests i think i've found your problem.

You shouldn't use users as the first url segment because you aren't searching for users, you are searching for tracks filtered by username and tags.

Instead use tracks as the first url segment, and use the q parameter to filter the username. Then you can use use the tags parameter as well.

Test this url: http://api.soundcloud.com/tracks?q=username&tags=tag

SC.get('/tracks/', {q:'royaloperahouse', tags: 'insights' },  function(result) { 
    console.log(result[0].tag_list);
});

To be honest i still do not understand the q parameter. In API documentation you find references about it in tracks, users, etc and in search page they talk about it too but i haven't found any documentation about what the q parameter is filtering in each query type. In tracks is the username (and possible user id)

If you are consuming this API, you should ask soundcloud team in their google group more the meaning of this parameter.

like image 104
Gui Avatar answered Nov 02 '22 10:11

Gui