Is there an way to access the new charts https://soundcloud.com/charts/top (top 50) with the soundcloud api? Or is there an other way?
Maybe with an crawl with php or something?
To found parameters that you can use with HTTP API Request, you can do this:
Now for example if you want know parameters for retrive "TOP 50 - Dance & EDM":
Some example:
TOP | Dance & EDM
https ://api-v2.soundcloud.com/charts?kind=top&genre=soundcloud%3Ageneres%3Adanceedm&client_id=...
TOP | Deep House
https ://api-v2.soundcloud.com/charts?kind=top&genre=soundcloud%3Agenres%3Adeephouse&client_id=...
New & Hot
Country https ://api-v2.soundcloud.com/charts?kind=trending&genre=soundcloud%3Agenres%3Acountry&client_id=...
All Parameters:
kind:
genre:
Example in php to get a json response of TOP50 - Country:
URL: https ://api-v2.soundcloud.com/charts?kind=top&genre=soundcloud%3Agenres%3Acountry&client_id=XXXXXXXXXXX&limit=10&linked_partitioning=1
URL Parameters:
Kind: Top
Genre: soundcloud:genres:country
client_id: XXXXXXXXXXX
limit: 10
linked_partitioning: 1
limit: how many songs you want to receive in response.
linked_partitioning: page number, according to the limit.
e.g. linked_partitioning with Limit = 10:
e.g. linked_partitioning with Limit = 20:
Now that you have URL, if you want retrive JSON response with PHP
you have to write for example:
<?php
$url = "https://api-v2.soundcloud.com/charts?kind=top&genre=soundcloud%3Agenres%3Acountry&client_id=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&limit=10&linked_partitioning=1";
// Get JSON Response
$json = file_get_contents($url);
// Decode response to array
$objectJSON = json_decode($json, true);
Example Json Response:
{
"genre":"soundcloud:genres:country",
"kind":"top",
"last_updated":"2016-03-24T09:50:02Z",
"collection":[
{
"track":{
"commentable":true,
"comment_count":211,
"downloadable":true,
"download_count":80,
"duration":251060,
.
.
.
"kind":"track",
.
.
.
.
"license":"all-rights-reserved",
"streamable":true,
"title":"Award winning Falling Star",
"uri":"https://api.soundcloud.com/tracks/245170733",
.
.
.
"country_code":"US"
}
"score":1093171.0
},
{
...
},
OTHER TRACKS HERE...
],
"query_urn":"soundcloud:charts:bc9b903f2cee44e7bca955bc2fc4601d",
"next_href":"https://api-v2.soundcloud.com/charts?genre=soundcloud%3Agenres%3Acountry&query_urn=soundcloud%3Acharts%3Abc9b903f2cee44e7bca955bc2fc4601d&offset=20&kind=top&limit=20"
}
}
If you want read JSON content of response:
// Read Json taking for example Name, Title and SoundCloud URI of song.
foreach ($objectJSON["collection"] as $key => $value) {
echo 'user: ' . $value['track']['user']['full_name'] . "<br/>";
echo 'title: ' . $value['track']['title'] . "<br/>";
echo 'url: ' . $value['track']['uri'] . "<br/><br/>";
}
echo $response;
?>
Result of this PHP:
user: ...
title: ...
url: ...
user: ...
title: ...
url: ...
...
Example of this code
I hope I have helped you and sorry for my english.
EDIT:
I think that SoundCloud has changed the way to get the next page. Now you need to change the "offset" param.
Like this:
Page 1: ....&limit=20&offset=0
Page 2: ....&limit=20&offset=20
Page 3: ....&limit=20&offset=40
ANSWER FOR @VietHung QUESTION.
Q: Can you explore system playlists?
(Eg: soundcloud:system-playlists charts-top:all-music)
To find system playlist, I have used Charles Web Debugging Proxy.
The idea is to sniff network package sent by SoundClound App from iOS device (in my case).
After that you configure Charles to sniff SSL packages correctly, you can use you pc as proxy for your smartphone.
(You must install Charles cert on Windows and on iOS device to sniff SSL packages correctly, for more information search on google).
Now, open SoundCloud App and click on every playlists (TOP, NEWS) inside the app.
Below a screenshot (Quality powered by paint, sorry ahah):
Now inside Charles we can see something like this:
I set the focus only on the SoundCloud host for better reading of incoming packages.
Charles is smart and puts all similar requests into a subfolder, in our case we have to look at all the requests within 'system-playlist'.
Now from all requests you can retrieve all system playlists values.
I have not listed all playlist song because currently I do not have much time.
As soon as I can, I edit this post with the complete list of possible system playlists vales.
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