Spaces:
Sleeping
Download docs/API.md from morgk/soundcloak: direct link, hf CLI and curl.
- Browser
- Download file 6.92 kB
-
https://huggingface.co/spaces/morgk/soundcloak/resolve/main/docs/API.md
- Command line
-
hf download hf://spaces/morgk/soundcloak/docs/API.md
-
curl -L -o API.md https://huggingface.co/spaces/morgk/soundcloak/resolve/main/docs/API.md
API endpoints
/_/info
/_/infoGet details about instance's configuration. Some instances may hide this information, but it's enabled by default. Example response:
{
"DefaultPreferences": {
"Player": "restream",
"ProxyStreams": true,
"FullyPreloadTrack": false,
"ProxyImages": true,
"ParseDescriptions": true,
"AutoplayNextTrack": false,
"AutoplayNextRelatedTrack": false,
"DefaultAutoplayMode": "normal",
"HLSAudio": "aac",
"RestreamAudio": "mpeg",
"DownloadAudio": "mpeg",
"ShowAudio": false,
"SearchSuggestions": false,
"DynamicLoadComments": false,
"KeepPlayerFocus": false,
"Waveform": false
},
"Commit": "910261d",
"Repo": "https://git.maid.zone/stuff/soundcloak",
"ProxyImages": true,
"ProxyStreams": true,
"Restream": true,
"GetWebProfiles": true,
"EnableAPI": true
}
/_/searchSuggestions
/_/searchSuggestionsGet search suggestions. Query parameters:
q: query to look upformat: set to opensearch if you want it in opensearch JSON format
Example response for /_/searchSuggestions?q=music:
[
"music sounds better with you",
"music is the answer",
"musica para dormir",
"music for soul 6",
"musica cristiana",
"musica de amor nunca mais",
"music for soul 4 -pn ft tdat",
"musica",
"music on"
]
/_/rss/:user
/_/rss/:userGenerates an RSS feed for user tracks. Put a username instead of :user. Query parameters:
proxy_images: if images should be proxied through instance. Instance must haveProxyImagesenabled. By default, uses value from preferences
/_/proxy/images
/_/proxy/imagesProxy an image through this instance. Instance must have ProxyImages enabled. Query parameters:
url: image URL. Only accepting images from*.sndcdn.com
/_/api/hls/:author/:track
/_/api/hls/:author/:trackGet an HLS playlist for streaming the track. Query parameters:
audio: force the audio. Can beaac_hq,aac,mpegoraac_lq. By default, uses value from preferencesredirect: if should redirect to playlist on soundcloud's CDN. By defaultfalseredirect_parts: if should redirect to the track parts on soundcloud's CDN. IfProxyStreamsis disabled on server, will betrueby default, otherwisefalse
/_/api/progressive/:author/:track
/_/api/progressive/:author/:trackGet an MP3 file of the track. Query parameters:
redirect: if should redirect to the MP3 on soundcloud's CDN. IfProxyStreamsis disabled on server, will betrueby default, otherwisefalse
/_/api/restream/:author/:track
/_/api/restream/:author/:trackGet an MP3 or Fragmented M4A file of the track, with metadata injected if needed. Instance must have Restream enabled for this to work. Query parameters:
audio: force the audio. Can beaac_hq,aac,mpegoraac_lq. By default, uses value from preferencesmetadata: if should inject metadata. By defaultfalse. Metadata values are taken from track on soundcloudtitle: override title in metadatagenre: override genre in metadataauthor: override author in metadata
/_/api/v2/...
/_/api/v2/...Proxy for soundcloud's api-v2.soundcloud.com. Instance must have EnableAPI enabled. Automatically adds latest client_id value to your requests, so you don't need to. Only GET requests are allowed, your supplied headers and body get ignored. List of allowed endpoints:
/resolve?url=...(for getting info from url likehttps://soundcloud.com/:user/:track)/charts/selections/mixed-selections/users/.../tracks/.../search/.../playlists/.../featured_tracks/...
So, for example, request like https://api-v2.soundcloud.com/users/420953284?client_id=tkIWLs4MIowq7bCXP80TOwx6DnDa7UPc will be turned into <instance>/_/api/v2/users/420953284. For more information about what endpoints there are, you can look at soundcloud's official frontend using devtools or read soundcloak/other tools source code. Here is a big list of endpoints, extracted from the official frontend code. Also keep in mind that there is no caching on this proxy, please cache things on your own
Notes about API
Keep in mind that this is unofficial, using reversed not-public API, probably not compliant with any terms of service that soundcloud have. Soundcloud likes to break things like this once in a while, but I try to keep it working. If you wanna use this for your application, it would be great to host your own soundcloak server, or to spread traffic across the public ones (maybe you could also support the people running them)
Audio streaming
Soundcloud offers two audio presets. There is multiple methods available for streaming audio, each with it's own behavior:
- HLS (
/_/api/hls/:author/:track)
HLS breaks down an audio into multiple smaller files. This let's you load audio parts on demand, instead of start to finish. You can stream both MP3 and AAC audio with this, but you usually need some program/library to handle the streaming. For web, there is hls.js. If you use ?redirect=true option, keep in mind that this playlist link and parts inside it will automatically expire after track duration + 105s. Otherwise, soundcloak automatically handles renewing the audio playlist.
- Progressive (
/_/api/progressive/:author/:track)
This only lets you stream tracks as mp3 128kb/s file. If you use ?redirect=true option, keep in mind that this file link will automatically expire after track duration + 105s. Otherwise, soundcloak automatically handles renewing the audio file
- Restream (
/_/api/restream/:author/:track)
This combines both HLS (automatically converting to regular audio file) and Progressive methods, and also adds metadata injection on the fly.
Other applications using the API
- @sndcldbot - simple inline telegram bot, search for tracks, paste track/playlist/user link to download
- cloudscape - minimal ad-free soundcloud client/frontend
Old API
Currently, it's still all working, but I plan to remove it sometime later, so please migrate everything to the new methods. Also /_/restream/... has been redirected to /_/api/restream/...