A Lightweight Spotify API Wrapper For Golang
import "github.com/tobiola/spotify"
https://developer.spotify.com/documentation/web-api/
clientId := "[Client ID Here]"
clientSecret := "[Client Secret Here]"
redirectUri := "[URL that should handle the callback]"
func HandleLogin(w http.ResponseWriter, r *http.Request) {
scope := "streaming user-read-private user-read-email user-modify-playback-state"
redirectLink, _ := spotify.GetRedirectLink(redirectUri, clientId, scope)
http.Redirect(w, r, redirectLink, http.StatusSeeOther)
}
func HandleCallback(w http.ResponseWriter, r *http.Request) {
client, _ := spotify.GetClientFromCallback(r.URL, redirectUri, clientId, clientSecret)
}
// Play
client.Play()
// or
client.PlayTrack(track)
// or
client.PlayTracks(tracks)
// Pause
client.Pause()
options := spotify.SearchOptions{Query: "hotline bling", Type: "track"}
result, _ := client.Search(options)
client.Play(result.Tracks.Items[0])
- Authentication
- Albums
- Browse
- Follow
- Library
- Personalization
- Player
- Playlists
- Search
- Tracks
- Users Profile