Documentation
¶
Overview ¶
*
A client library for the Spotify Web Service API, written in the Go programming language (golang). Use of this library requires a Spotify Developer Account. Start here to set one up: https://developer.spotify.com/my-applications/ See the README.md for more information.
*
Index ¶
- type AccessToken
- type AddTrackToPlaylistRequest
- type AddTrackToPlaylistResponse
- type Album
- type Artist
- type ClientId
- type ClientSecret
- type CreatePlaylistRequest
- type Params
- type Playlist
- type PlaylistOwner
- type PlaylistResponse
- type PlaylistTrack
- type RedirectUri
- type ResponseUserAgent
- type TokenResponse
- type Track
- type TracklistResponse
- type UserInfoResponse
- type Username
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AccessToken ¶
type AccessToken string
Type overrides to ensure various string-like values don't get mixed up.
type AddTrackToPlaylistRequest ¶
type AddTrackToPlaylistRequest struct {
Uris []string `json:"uris"`
}
type AddTrackToPlaylistResponse ¶
type AddTrackToPlaylistResponse struct {
SnapshotId string `json:"snapshot_id"`
}
func AddTracksToPlaylist ¶
func AddTracksToPlaylist(accessToken AccessToken, username Username, playlist Playlist, tracks []Track) (AddTrackToPlaylistResponse, error)
Method will add tracks to an existing playlist
type ClientSecret ¶
type ClientSecret string
type CreatePlaylistRequest ¶
type Playlist ¶
type Playlist struct {
Href string `json:"href"`
Id string `json:"id"`
Name string `json:"name"`
Owner PlaylistOwner `json:"owner"`
}
func CreatePlaylist ¶
func CreatePlaylist(accessToken AccessToken, username Username, playlistName string, playlistPublic bool) (Playlist, error)
Given an AccessToken, UserName (retrieved using the GetAccessToken and GetUserInfo functions), and new playlist name, this method will create a new playlist.
func GetPlaylistInfo ¶
func GetPlaylistInfo(accessToken AccessToken, username Username, playlistId string) (Playlist, error)
Given an AccessToken, UserName (retrieved using the GetAccessToken and GetUserInfo functions), and Playlist ID, this function will return a simplified Playlist object
func GetUserPlaylists ¶
func GetUserPlaylists(accessToken AccessToken, username Username) ([]Playlist, error)
Given an AccessToken and a UserName (retrieved using the GetAccessToken and GetUserInfo functions), this function will extract all of the user's playlists as a slice of Playlist objects.
type PlaylistOwner ¶
type PlaylistResponse ¶
type PlaylistTrack ¶
type PlaylistTrack struct {
Track Track `json:"track"`
}
type RedirectUri ¶
type RedirectUri string
type ResponseUserAgent ¶
type ResponseUserAgent struct {
Useragent string `json:"user-agent"`
}
type TokenResponse ¶
type TokenResponse struct {
AccessToken AccessToken `json:"access_token"`
TokenType string `json:"token_type"`
ExpiresIn int64 `json:"expires_in"`
RefreshToken string `json:"refresh_token"`
}
func GetAccessToken ¶
func GetAccessToken(accessCode string, clientId ClientId, clientSecret ClientSecret, redirectUri RedirectUri) (*TokenResponse, error)
Given an access code returned by the spotify web server, along with the Client ID and Client Secret for your spotify app (see: https://developer.spotify.com/my-applications/) this method will retrieve an access token, returned as type TokenResponse
type Track ¶
type Track struct {
Id string `json:"id"`
Href string `json:"href"`
Name string `json:"name"`
Album Album `json:"album"`
Artists []Artist `json:"artists"`
}
func GetTracksForPlaylist ¶
func GetTracksForPlaylist(accessToken AccessToken, owner Username, playlistId string) ([]Track, error)
For a given user and playlist, this method will return track listings for each entry in the selected playlist as a slice of Track objects.
type TracklistResponse ¶
type UserInfoResponse ¶
type UserInfoResponse struct {
Id Username `json:"id"`
URI string `json:"uri"`
DisplayName string `json:"display_name"`
Email string `json:"email"`
}
func GetUserInfo ¶
func GetUserInfo(accessToken AccessToken) (*UserInfoResponse, error)
Given an AccessToken returned by the GetAccessToken method, this function will retrieve information about the authenticated user. This information is used to retrieve their playlists later.