Documentation
¶
Overview ¶
Package webapi is a small Spotify Web API client for search and saved albums. It logs in with the user's own developer app through the Authorization Code flow with PKCE, so it needs no client secret.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNotConfigured means no client ID is set. ErrNotConfigured = errors.New("no Spotify developer app client ID is set") // ErrNotLoggedIn means there is no valid Web API token. ErrNotLoggedIn = errors.New("not logged in to the Spotify Web API") )
Functions ¶
func ArtistNames ¶
ArtistNames joins artist names with commas.
Types ¶
type Album ¶
type Album struct {
URI string `json:"uri"`
Name string `json:"name"`
Artists []Artist `json:"artists"`
ReleaseDate string `json:"release_date"`
TotalTracks int `json:"total_tracks"`
Images []Image `json:"images"`
}
Album is a Spotify album.
type Artist ¶
type Artist struct {
URI string `json:"uri"`
Name string `json:"name"`
Images []Image `json:"images"`
}
Artist is a Spotify artist. Artists inside track and album objects have no images.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client calls the Spotify Web API.
func (*Client) BeginLogin ¶
BeginLogin starts the callback server and returns the URL the user must open in a browser.
func (*Client) Configured ¶
Configured reports whether a client ID is set.
func (*Client) SavedAlbums ¶
SavedAlbums returns the albums in the user's library, newest first.
type Login ¶
type Login struct {
URL string
// contains filtered or unexported fields
}
Login is a login in progress. Show URL to the user, then call Wait.
type Playlist ¶
type Playlist struct {
URI string `json:"uri"`
Name string `json:"name"`
Images []Image `json:"images"`
Owner struct {
DisplayName string `json:"display_name"`
} `json:"owner"`
// The February 2026 API renamed "tracks" to "items". Both are read.
Tracks *struct {
Total int `json:"total"`
} `json:"tracks"`
Items *struct {
Total int `json:"total"`
} `json:"items"`
}
Playlist is a Spotify playlist.
func (Playlist) TrackCount ¶
TrackCount returns the number of tracks, or -1 if unknown.
type RateLimitError ¶
RateLimitError means Spotify rejected the call because of its rate limit.
func (*RateLimitError) Error ¶
func (e *RateLimitError) Error() string
type SearchResult ¶
type SearchResult struct {
Tracks Page[Track] `json:"tracks"`
Albums Page[Album] `json:"albums"`
Artists Page[Artist] `json:"artists"`
Playlists Page[*Playlist] `json:"playlists"`
}
SearchResult holds the results of a search. Spotify sometimes puts null entries in the playlist results, so they are pointers.