Skip to content

tobiola/go-spotify

Repository files navigation

spotify

GoDoc Build Status Go Report Card

A Lightweight Spotify API Wrapper For Golang

Usage

import "github.com/tobiola/spotify"

Getting started

Official Spotfy API

https://developer.spotify.com/documentation/web-api/

Authentication

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

Player

// Play 
client.Play()
// or
client.PlayTrack(track)
// or
client.PlayTracks(tracks)

// Pause
client.Pause()

Search

options := spotify.SearchOptions{Query: "hotline bling", Type: "track"}
result, _ := client.Search(options)

client.Play(result.Tracks.Items[0])

Progress

  • Authentication
  • Albums
  • Browse
  • Follow
  • Library
  • Personalization
  • Player
  • Playlists
  • Search
  • Tracks
  • Users Profile