This Golang package is a hassle free way of interfacing with the SoundCloud Api. As simple as passing in a client id and your set to got with most of the resources SoundCloud has to offer.
go get github.com/david-castaneda/go-soundcloud
import (
SoundCloud "github.com/david-castaneda/go-soundcloud/soundcloud"
)
func main() {
client := SoundCloud.Auth(<SOUNCLOUD_CLIENT_ID>)
}
The following is a list of all the endpoints currently available with this client.
Returns a SoundCloud User
func main() {
client := SoundCloud.Auth(<SOUNCLOUD_CLIENT_ID>)
usr, err := client.Users(<USERNAME>)
if err != nil {
log.Fatal(err)
}
fmt.Print(usr)
}
Returns a users SoundCloud playlists
func main() {
client := SoundCloud.Auth(<SOUNCLOUD_CLIENT_ID>)
playlists, err := client.Playlists(username)
if err != nil {
log.Fatal(err)
}
fmtPlaylists, err := json.Marshal(playlists)
if err != nil {
log.Fatal(err)
}
fmt.Print(string(usr))
}
Returns a list of users SoundCloud followers
func main() {
client := SoundCloud.Auth(<SOUNCLOUD_CLIENT_ID>)
followers, err := client.Followers(<USER_ID>)
if err != nil {
log.Fatal(err)
}
fmtFollowers, err := json.Marshal(followers)
if err != nil {
log.Fatal(err)
}
fmt.Print(string(fmtFollowers))
}
Returns a list of users SoundCloud followings
func main() {
client := SoundCloud.Auth(<SOUNCLOUD_CLIENT_ID>)
followings, err := client.Followings(<USER_ID>)
if err != nil {
log.Fatal(err)
}
fmtFollowings, err := json.Marshal(followings)
if err != nil {
log.Fatal(err)
}
fmt.Print(string(fmtFollowings))
}
Given a SoundCloud url, this resource returns any data the url may have generated
- An example of when to use this resource is when trying to find out a users id with only the username available. This endpoint will return the same response users would return, however can be used with any SoundCloud url.
func main() {
url := "https://soundcloud.com/<USERNAME>"
client := SoundCloud.Auth(<SOUNCLOUD_CLIENT_ID>)
rslv, err := client.Resolve(url)
if err != nil {
log.Fatal(err)
}
fmt.Print(string(*rslv))
}
This package is using Zero external dependencies.
If you would like to contribute, you can create a template and make a PR or fork the projects and make a PR. All contributions/suggestions are welcome.
- All the missing resources 😅