I am new to soundcloud. I have done my research but the soundcloud documentation is lacking severely.
I am trying to understand the API. If anyone can help answer the following questions it would be helpful.
Can I access my tracks through the JavaScript API and retrieve JUST the titles of the tracks?
Where do I get my "User ID" from?
I have created an app. Is the Redirect URI mandatory?
I have tried to use the following https://api.soundcloud.com/tracks?client_id=MY_CLIENT_ID. I get some other members information. And yes I replaced MY_CLIENT_ID with the client_id from my new app.
I have tried to use https://api.soundcloud.com/oauth2/token?client_id=xxx&client_secret=xxx&grant_type=password&username=xxx&password=xxx (with my app client_id, client_secret, username & password and I get a 404...not sure why.
Any response to put me in the right direction would be great. Thanks!
Can I access my tracks through the JavaScript API and retrieve JUST the titles of the tracks?
No, there's no way of retrieving only the titles, you'll get the whole sound representation in JSON or XML depending on the format
parameter sent in request.
Where do I get my "User ID" from?
You could use /resolve
endpoint to retrieve an ID from the permalink of the user, yours or any other or, if you authorised the user, you could hit /me
endpoint to get the representation of the authorised user.
I have created an app. Is the Redirect URI mandatory?
Yes
I have tried to use the following https://api.soundcloud.com/tracks?client_id=MY_CLIENT_ID. I get some other members information. And yes I replaced MY_CLIENT_ID with the client_id from my new app.
client_id
is an id for your application, which is the “client” of SoundCloud API (which is the “server” in this case), your user is something else. If you are talking about “authorised” user when referring to “my client id”, then you could query /me/tracks
for the tracks that belong to that user.
I have tried to use https://api.soundcloud.com/oauth2/token?client_id=xxx&client_secret=xxx&grant_type=password&username=xxx&password=xxx (with my app client_id, client_secret, username & password and I get a 404...not sure why.
Please follow the documentation for oauth2
endpoint – the request should be POST and not GET and you need to submit code
parameter, value for which you'd get from the code that would run on your Redirect URI – after user successfully signs in that URL will be requested with code
as GET parameter, so you can use it.
Addition to @gryzzly answer. You can access API without token, but you will get it only to your account.
As you can see here, there is an option for username/password authorization, and here you can see example, how to do it using SDK.
When you do your POST request, do all your parameters in the body of the post request:
wget --post-data="client_id=ID&client_secret=SECRET&grant_type=password&username=USERNAME&password=PASSWORD" https://api.soundcloud.com/oauth2/token
Here is the PHP request example:
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.soundcloud.com/oauth2/token");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, "client_id=ID&client_secret=SECRET&grant_type=password&username=USERNAME&password=PASSWORD");
$result = curl_exec($ch);
curl_close($ch);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With