/go-soundcloud

Golang library to interface with SoundCloud API

Primary LanguageGo

go-souncloud

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.

Directory

Getting started

  • Installing

go get github.com/david-castaneda/go-soundcloud
  • Importing

import (
	SoundCloud "github.com/david-castaneda/go-soundcloud/soundcloud"
)
  • Authenticating

func main() {
	client := SoundCloud.Auth(<SOUNCLOUD_CLIENT_ID>)
}

Resources

The following is a list of all the endpoints currently available with this client.

  • Users

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)
}
  • Playlist

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))
}
  • Followers

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))
}
  • Followings

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))
}
  • Resolve

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))
}

Technologies

This package is using Zero external dependencies.

Contributing

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.

In the works 👨🏻‍💻

  • All the missing resources 😅