10

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.

user954348
  • 105
  • 1
  • 7
  • Have you [read the documentation](http://developers.soundcloud.com/docs/api/reference#users)? – MikeSmithDev Feb 07 '13 at 15:50
  • IMHO looks like the search functionality just doesn't work as expected as the "filter" (q) some how trumps your search of tracks by user. Same results using javascript SDK too when pulling by user_id. – MikeSmithDev Feb 07 '13 at 18:13
  • I agree, it doesn't seem to work I'm hoping on of the Sound Cloud team will see this. – user954348 Feb 08 '13 at 08:47
  • This was a problem on SoundCloud side. It was the same for browsing tracks by genre etc. Now it's fixed, and q param is not required anymore. If the problem occurs again, they have a workaround to set q=* and it will work as expected. – cucko Feb 15 '13 at 12:08
  • I know you've probably solved this by now, but please read and accept my answer for any future visitors! It's a common mistake. – Sam Ballantyne Apr 26 '14 at 19:52

3 Answers3

1

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.

Gui
  • 9,555
  • 10
  • 42
  • 54
  • Unfortunately this will not work. It returns tracks that aren't his, as other people have tagged tracks with 'royaloperahouse'. It also won't return all of his tracks. – MikeSmithDev Feb 07 '13 at 18:21
0

Try this (you'll have to check my syntax):

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

or

SC.get('users/YOUR_ID/tracks/', {q:'royaloperahouse', tags: 'insights' },  function(result) { 
    console.log(result[0].tag_list);
});
bill m
  • 111
  • 2
  • 13
0

First, understand the difference between the user "id" and the user "permalink". They're both unique user identifiers, but they're separate things with different purposes. You can use the former, but not the latter, to access tracks. So instead of

http://.../users/royaloperahouse/...

you should be using

http://.../users/12127832/...

substituting 12127832 for the appropriate ID if you're looking for a different artist. Also, you should probably specify JSON as the return type. To conclude, your server call should look like this:

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

Also: don't post your client ID on Stack Overflow!!!

Sam Ballantyne
  • 487
  • 6
  • 18