spotify

package module
v1.1.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 29, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

README

Spotify

GoDoc

This is a Go wrapper for working with Spotify's Web API.

It aims to support every task listed in the Web API Endpoint Reference, located here.

By using this library you agree to Spotify's Developer Terms of Use.

Installation

To install the library, simply

go get github.com/aprosvetova/spotify

Authentication

Spotify uses OAuth2 for authentication and authorization.
As of May 29, 2017 all Web API endpoints require an access token.

You can authenticate using a client credentials flow, but this does not provide any authorization to access a user's private data. For most use cases, you'll want to use the authorization code flow. This package includes an Authenticator type to handle the details for you.

Start by registering your application at the following page:

https://developer.spotify.com/my-applications/.

You'll get a client ID and secret key for your application. An easy way to provide this data to your application is to set the SPOTIFY_ID and SPOTIFY_SECRET environment variables. If you choose not to use environment variables, you can provide this data manually.

// the redirect URL must be an exact match of a URL you've registered for your application
// scopes determine which permissions the user is prompted to authorize
auth := spotify.NewAuthenticator(redirectURL, spotify.ScopeUserReadPrivate)

// if you didn't store your ID and secret key in the specified environment variables,
// you can set them manually here
auth.SetAuthInfo(clientID, secretKey)

// get the user to this URL - how you do that is up to you
// you should specify a unique state string to identify the session
url := auth.AuthURL(state)

// the user will eventually be redirected back to your redirect URL
// typically you'll have a handler set up like the following:
func redirectHandler(w http.ResponseWriter, r *http.Request) {
      // use the same state string here that you used to generate the URL
      token, err := auth.Token(state, r)
      if err != nil {
            http.Error(w, "Couldn't get token", http.StatusNotFound)
            return
      }
      // create a client using the specified token
      client := auth.NewClient(token)

      // the client can now be used to make authenticated requests
}

You may find the following resources useful:

  1. Spotify's Web API Authorization Guide: https://developer.spotify.com/web-api/authorization-guide/

  2. Go's OAuth2 package: https://godoc.org/golang.org/x/oauth2/google

Helpful Hints

Optional Parameters

Many of the functions in this package come in two forms - a simple version that omits optional parameters and uses reasonable defaults, and a more sophisticated version that accepts additional parameters. The latter is suffixed with Opt to indicate that it accepts some optional parameters.

Automatic Retries

The API will throttle your requests if you are sending them too rapidly. The client can be configured to wait and re-attempt the request. To enable this, set the AutoRetry field on the Client struct to true.

For more information, see Spotify rate-limits.

API Examples

Examples of the API can be found in the examples directory.

You may find tools such as Spotify's Web API Console or Rapid API valuable for experimenting with the API.

Documentation

Overview

Package spotify provides utilties for interfacing with Spotify's Web API.

Index

Constants

View Source
const (
	// AuthURL is the URL to Spotify Accounts Service's OAuth2 endpoint.
	AuthURL = "https://accounts.spotify.com/authorize"
	// TokenURL is the URL to the Spotify Accounts Service's OAuth2
	// token endpoint.
	TokenURL = "https://accounts.spotify.com/api/token"
)
View Source
const (
	// ScopeImageUpload seeks permission to upload images to Spotify on your behalf.
	ScopeImageUpload = "ugc-image-upload"
	// ScopePlaylistReadPrivate seeks permission to read
	// a user's private playlists.
	ScopePlaylistReadPrivate = "playlist-read-private"
	// ScopePlaylistModifyPublic seeks write access
	// to a user's public playlists.
	ScopePlaylistModifyPublic = "playlist-modify-public"
	// ScopePlaylistModifyPrivate seeks write access to
	// a user's private playlists.
	ScopePlaylistModifyPrivate = "playlist-modify-private"
	// ScopePlaylistReadCollaborative seeks permission to
	// access a user's collaborative playlists.
	ScopePlaylistReadCollaborative = "playlist-read-collaborative"
	// ScopeUserFollowModify seeks write/delete access to
	// the list of artists and other users that a user follows.
	ScopeUserFollowModify = "user-follow-modify"
	// ScopeUserFollowRead seeks read access to the list of
	// artists and other users that a user follows.
	ScopeUserFollowRead = "user-follow-read"
	// ScopeUserLibraryModify seeks write/delete access to a
	// user's "Your Music" library.
	ScopeUserLibraryModify = "user-library-modify"
	// ScopeUserLibraryRead seeks read access to a user's "Your Music" library.
	ScopeUserLibraryRead = "user-library-read"
	// ScopeUserReadPrivate seeks read access to a user's
	// subsription details (type of user account).
	ScopeUserReadPrivate = "user-read-private"
	// ScopeUserReadEmail seeks read access to a user's email address.
	ScopeUserReadEmail = "user-read-email"
	// ScopeUserReadCurrentlyPlaying seeks read access to a user's currently playing track
	ScopeUserReadCurrentlyPlaying = "user-read-currently-playing"
	// ScopeUserReadPlaybackState seeks read access to the user's current playback state
	ScopeUserReadPlaybackState = "user-read-playback-state"
	// ScopeUserModifyPlaybackState seeks write access to the user's current playback state
	ScopeUserModifyPlaybackState = "user-modify-playback-state"
	// ScopeUserReadRecentlyPlayed allows access to a user's recently-played songs
	ScopeUserReadRecentlyPlayed = "user-read-recently-played"
	// ScopeUserTopRead seeks read access to a user's top tracks and artists
	ScopeUserTopRead = "user-top-read"
	// ScopeStreaming seeks permission to play music and control playback on your other devices.
	ScopeStreaming = "streaming"
)

Scopes let you specify exactly which types of data your application wants to access. The set of scopes you pass in your authentication request determines what access the permissions the user is asked to grant.

View Source
const (
	CountryArgentina          = "AR"
	CountryAustralia          = "AU"
	CountryAustria            = "AT"
	CountryBelarus            = "BY"
	CountryBelgium            = "BE"
	CountryBrazil             = "BR"
	CountryCanada             = "CA"
	CountryChile              = "CL"
	CountryChina              = "CN"
	CountryGermany            = "DE"
	CountryHongKong           = "HK"
	CountryIreland            = "IE"
	CountryIndia              = "IN"
	CountryItaly              = "IT"
	CountryJapan              = "JP"
	CountrySpain              = "ES"
	CountryFinland            = "FI"
	CountryFrance             = "FR"
	CountryMexico             = "MX"
	CountryNewZealand         = "NZ"
	CountryRussia             = "RU"
	CountrySwitzerland        = "CH"
	CountryUnitedArabEmirates = "AE"
	CountryUnitedKingdom      = "GB"
	CountryUSA                = "US"
)

ISO 3166-1 alpha 2 country codes.

see: https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2

View Source
const (
	SearchTypeAlbum    SearchType = 1 << iota
	SearchTypeArtist              = 1 << iota
	SearchTypePlaylist            = 1 << iota
	SearchTypeTrack               = 1 << iota
)

Search type values that can be passed to the Search function. These are flags that can be bitwise OR'd together to search for multiple types of content simultaneously.

View Source
const (
	// DateLayout can be used with time.Parse to create time.Time values
	// from Spotify date strings.  For example, PrivateUser.Birthdate
	// uses this format.
	DateLayout = "2006-01-02"
	// TimestampLayout can be used with time.Parse to create time.Time
	// values from SpotifyTimestamp strings.  It is an ISO 8601 UTC timestamp
	// with a zero offset.  For example, PlaylistTrack's AddedAt field uses
	// this format.
	TimestampLayout = "2006-01-02T15:04:05Z"
)
View Source
const (
	// MarketFromToken can be used in place of the Options.Country parameter
	// if the Client has a valid access token.  In this case, the
	// results will be limited to content that is playable in the
	// country associated with the user's account.  The user must have
	// granted access to the user-read-private scope when the access
	// token was issued.
	MarketFromToken = "from_token"
)
View Source
const MaxNumberOfSeeds = 5

MaxNumberOfSeeds allowed by Spotify for a recommendation request

View Source
const Version = "1.0.0"

Version is the version of this library.

Variables

View Source
var ErrNoMorePages = errors.New("spotify: no more pages")

ErrNoMorePages is the error returned when you attempt to get the next (or previous) set of data but you've reached the end of the data set.

Functions

This section is empty.

Types

type AlbumType

type AlbumType int

AlbumType represents the type of an album. It can be used to filter results when searching for albums.

const (
	AlbumTypeAlbum AlbumType = 1 << iota
	AlbumTypeSingle
	AlbumTypeAppearsOn
	AlbumTypeCompilation
)

AlbumType values that can be used to filter which types of albums are searched for. These are flags that can be bitwise OR'd together to search for multiple types of albums simultaneously.

type AnalysisMeta

type AnalysisMeta struct {
	AnalyzerVersion string  `json:"analyzer_version"`
	Platform        string  `json:"platform"`
	DetailedStatus  string  `json:"detailed_status"`
	StatusCode      int     `json:"status"`
	Timestamp       int64   `json:"timestamp"`
	AnalysisTime    float64 `json:"analysis_time"`
	InputProcess    string  `json:"input_process"`
}

AnalysisMeta describes details about Spotify's audio analysis of the track

type AnalysisTrack

type AnalysisTrack struct {
	NumSamples              int64   `json:"num_samples"`
	Duration                float64 `json:"duration"`
	SampleMD5               string  `json:"sample_md5"`
	OffsetSeconds           int     `json:"offset_seconds"`
	WindowSeconds           int     `json:"window_seconds"`
	AnalysisSampleRate      int64   `json:"analysis_sample_rate"`
	AnalysisChannels        int     `json:"analysis_channels"`
	EndOfFadeIn             float64 `json:"end_of_fade_in"`
	StartOfFadeOut          float64 `json:"start_of_fade_out"`
	Loudness                float64 `json:"loudness"`
	Tempo                   float64 `json:"tempo"`
	TempoConfidence         float64 `json:"tempo_confidence"`
	TimeSignature           int     `json:"time_signature"`
	TimeSignatureConfidence float64 `json:"time_signature_confidence"`
	Key                     Key     `json:"key"`
	KeyConfidence           float64 `json:"key_confidence"`
	Mode                    Mode    `json:"mode"`
	ModeConfidence          float64 `json:"mode_confidence"`
	CodeString              string  `json:"codestring"`
	CodeVersion             float64 `json:"code_version"`
	EchoprintString         string  `json:"echoprintstring"`
	EchoprintVersion        float64 `json:"echoprint_version"`
	SynchString             string  `json:"synchstring"`
	SynchVersion            float64 `json:"synch_version"`
	RhythmString            string  `json:"rhythmstring"`
	RhythmVersion           float64 `json:"rhythm_version"`
}

AnalysisTrack contains audio analysis data about the track as a whole

type AudioAnalysis

type AudioAnalysis struct {
	Bars     []Marker      `json:"bars"`
	Beats    []Marker      `json:"beats"`
	Meta     AnalysisMeta  `json:"meta"`
	Sections []Section     `json:"sections"`
	Segments []Segment     `json:"segments"`
	Tatums   []Marker      `json:"tatums"`
	Track    AnalysisTrack `json:"track"`
}

AudioAnalysis contains a detailed audio analysis for a single track identified by its unique Spotify ID. See: https://developer.spotify.com/web-api/get-audio-analysis/

type AudioFeatures

type AudioFeatures struct {
	// Acousticness is a confidence measure from 0.0 to 1.0 of whether
	// the track is acoustic.  A value of 1.0 represents high confidence
	// that the track is acoustic.
	Acousticness float32 `json:"acousticness"`
	// An HTTP URL to access the full audio analysis of the track.
	// The URL is cryptographically signed and configured to expire
	// after roughly 10 minutes.  Do not store these URLs for later use.
	AnalysisURL string `json:"analysis_url"`
	// Danceability describes how suitable a track is for dancing based
	// on a combination of musical elements including tempo, rhythm stability,
	// beat strength, and overall regularity.  A value of 0.0 is least danceable
	// and 1.0 is most danceable.
	Danceability float32 `json:"danceability"`
	// The length of the track in milliseconds.
	Duration int `json:"duration_ms"`
	// Energy is a measure from 0.0 to 1.0 and represents a perceptual mesaure
	// of intensity and activity.  Typically, energetic tracks feel fast, loud,
	// and noisy.
	Energy float32 `json:"energy"`
	// The Spotify ID for the track.
	ID ID `json:"id"`
	// Predicts whether a track contains no vocals.  "Ooh" and "aah" sounds are
	// treated as instrumental in this context.  Rap or spoken words are clearly
	// "vocal".  The closer the Instrumentalness value is to 1.0, the greater
	// likelihood the track contains no vocal content.  Values above 0.5 are
	// intended to represent instrumental tracks, but confidence is higher as the
	// value approaches 1.0.
	Instrumentalness float32 `json:"instrumentalness"`
	// The key the track is in.  Integers map to pitches using standard Pitch Class notation
	// (https://en.wikipedia.org/wiki/Pitch_class).
	Key int `json:"key"`
	// Detects the presence of an audience in the recording.  Higher liveness
	// values represent an increased probability that the track was performed live.
	// A value above 0.8 provides strong likelihook that the track is live.
	Liveness float32 `json:"liveness"`
	// The overall loudness of a track in decibels (dB).  Loudness values are
	// averaged across the entire track and are useful for comparing the relative
	// loudness of tracks.  Typical values range between -60 and 0 dB.
	Loudness float32 `json:"loudness"`
	// Mode indicates the modality (major or minor) of a track.
	Mode int `json:"mode"`
	// Detects the presence of spoken words in a track.  The more exclusively
	// speech-like the recording, the closer to 1.0 the speechiness will be.
	// Values above 0.66 describe tracks that are probably made entirely of
	// spoken words.  Values between 0.33 and 0.66 describe tracks that may
	// contain both music and speech, including such cases as rap music.
	// Values below 0.33 most likely represent music and other non-speech-like tracks.
	Speechiness float32 `json:"speechiness"`
	// The overall estimated tempo of the track in beats per minute (BPM).
	Tempo float32 `json:"tempo"`
	// An estimated overall time signature of a track.  The time signature (meter)
	// is a notational convention to specify how many beats are in each bar (or measure).
	TimeSignature int `json:"time_signature"`
	// A link to the Web API endpoint providing full details of the track.
	TrackURL string `json:"track_href"`
	// The Spotify URI for the track.
	URI URI `json:"uri"`
	// A measure from 0.0 to 1.0 describing the musical positiveness conveyed
	// by a track.  Tracks with high valence sound more positive (e.g. happy,
	// cheerful, euphoric), while tracks with low valence sound more negative
	// (e.g. sad, depressed, angry).
	Valence float32 `json:"valence"`
}

AudioFeatures contains various high-level acoustic attributes for a particular track.

type Authenticator

type Authenticator struct {
	// contains filtered or unexported fields
}

Authenticator provides convenience functions for implementing the OAuth2 flow. You should always use `NewAuthenticator` to make them.

Example:

a := spotify.NewAuthenticator(redirectURL, spotify.ScopeUserLibaryRead, spotify.ScopeUserFollowRead)
// direct user to Spotify to log in
http.Redirect(w, r, a.AuthURL("state-string"), http.StatusFound)

// then, in redirect handler:
token, err := a.Token(state, r)
client := a.NewClient(token)

func NewAuthenticator

func NewAuthenticator(redirectURL string, scopes ...string) Authenticator

NewAuthenticator creates an authenticator which is used to implement the OAuth2 authorization flow. The redirectURL must exactly match one of the URLs specified in your Spotify developer account.

By default, NewAuthenticator pulls your client ID and secret key from the SPOTIFY_ID and SPOTIFY_SECRET environment variables. If you'd like to provide them from some other source, you can call `SetAuthInfo(id, key)` on the returned authenticator.

func (Authenticator) AuthURL

func (a Authenticator) AuthURL(state string) string

AuthURL returns a URL to the the Spotify Accounts Service's OAuth2 endpoint.

State is a token to protect the user from CSRF attacks. You should pass the same state to `Token`, where it will be validated. For more info, refer to http://tools.ietf.org/html/rfc6749#section-10.12.

func (Authenticator) AuthURLWithDialog

func (a Authenticator) AuthURLWithDialog(state string) string

AuthURLWithDialog returns the same URL as AuthURL, but sets show_dialog to true

func (Authenticator) AuthURLWithOpts

func (a Authenticator) AuthURLWithOpts(state string, opts ...oauth2.AuthCodeOption) string

AuthURLWithOpts returns the bause AuthURL along with any extra URL Auth params

func (Authenticator) Exchange

func (a Authenticator) Exchange(code string, opts ...oauth2.AuthCodeOption) (*oauth2.Token, error)

Exchange is like Token, except it allows you to manually specify the access code instead of pulling it out of an HTTP request.

func (Authenticator) NewClient

func (a Authenticator) NewClient(token *oauth2.Token) Client

NewClient creates a Client that will use the specified access token for its API requests.

func (*Authenticator) SetAuthInfo

func (a *Authenticator) SetAuthInfo(clientID, secretKey string)

SetAuthInfo overwrites the client ID and secret key used by the authenticator. You can use this if you don't want to store this information in environment variables.

func (Authenticator) Token

func (a Authenticator) Token(state string, r *http.Request) (*oauth2.Token, error)

Token pulls an authorization code from an HTTP request and attempts to exchange it for an access token. The standard use case is to call Token from the handler that handles requests to your application's redirect URL.

func (Authenticator) TokenWithOpts

func (a Authenticator) TokenWithOpts(state string, r *http.Request, opts ...oauth2.AuthCodeOption) (*oauth2.Token, error)

TokenWithOpts performs the same function as the Authenticator Token function but takes in optional URL Auth params

type Category

type Category struct {
	// A link to the Web API endpoint returning full details of the category
	Endpoint string `json:"href"`
	// The category icon, in various sizes
	Icons []Image `json:"icons"`
	// The Spotify category ID.  This isn't a base-62 Spotify ID, its just
	// a short string that describes and identifies the category (ie "party").
	ID string `json:"id"`
	// The name of the category
	Name string `json:"name"`
}

Category is used by Spotify to tag items in. For example, on the Spotify player's "Browse" tab.

type CategoryPage

type CategoryPage struct {
	Categories []Category `json:"items"`
	// contains filtered or unexported fields
}

CategoryPage contains Category objects returned by the Web API.

type Client

type Client struct {
	AutoRetry      bool
	AcceptLanguage string
	// contains filtered or unexported fields
}

Client is a client for working with the Spotify Web API. It is created by `NewClient` and `Authenticator.NewClient`.

func NewClient

func NewClient(client *http.Client) Client

NewClient returns a client for working with the Spotify Web API. The provided HTTP client must include the user's access token in each request; if you do not have such a client, use the `Authenticator.NewClient` method instead.

func (*Client) AddTracksToLibrary

func (c *Client) AddTracksToLibrary(ids ...ID) error

AddTracksToLibrary saves one or more tracks to the current user's "Your Music" library. This call requires the ScopeUserLibraryModify scope. A track can only be saved once; duplicate IDs are ignored.

func (*Client) AddTracksToPlaylist

func (c *Client) AddTracksToPlaylist(playlistID ID, trackIDs ...ID) (snapshotID string, err error)

AddTracksToPlaylist adds one or more tracks to a user's playlist. This call requires ScopePlaylistModifyPublic or ScopePlaylistModifyPrivate. A maximum of 100 tracks can be added per call. It returns a snapshot ID that can be used to identify this version (the new version) of the playlist in future requests.

func (*Client) ChangePlaylistAccess

func (c *Client) ChangePlaylistAccess(playlistID ID, public bool) error

ChangePlaylistAccess modifies the public/private status of a playlist. This call requires that the user has authorized the ScopePlaylistModifyPublic or ScopePlaylistModifyPrivate scopes (depending on whether the playlist is currently public or private). The current user must own the playlist in order to modify it.

func (*Client) ChangePlaylistDescription

func (c *Client) ChangePlaylistDescription(playlistID ID, newDescription string) error

ChangePlaylistDescription modifies the description of a playlist. This call requires that the user has authorized the ScopePlaylistModifyPublic or ScopePlaylistModifyPrivate scopes (depending on whether the playlist is currently public or private). The current user must own the playlist in order to modify it.

func (*Client) ChangePlaylistName

func (c *Client) ChangePlaylistName(playlistID ID, newName string) error

ChangePlaylistName changes the name of a playlist. This call requires that the user has authorized the ScopePlaylistModifyPublic or ScopePlaylistModifyPrivate scopes (depending on whether the playlist is public or private). The current user must own the playlist in order to modify it.

func (*Client) ChangePlaylistNameAccessAndDescription

func (c *Client) ChangePlaylistNameAccessAndDescription(playlistID ID, newName, newDescription string, public bool) error

ChangePlaylistNameAccessAndDescription combines ChangePlaylistName, ChangePlaylistAccess, and ChangePlaylistDescription into a single Web API call. It requires that the user has authorized the ScopePlaylistModifyPublic or ScopePlaylistModifyPrivate scopes (depending on whether the playlist is currently public or private). The current user must own the playlist in order to modify it.

func (*Client) ChangePlaylistNameAndAccess

func (c *Client) ChangePlaylistNameAndAccess(playlistID ID, newName string, public bool) error

ChangePlaylistNameAndAccess combines ChangePlaylistName and ChangePlaylistAccess into a single Web API call. It requires that the user has authorized the ScopePlaylistModifyPublic or ScopePlaylistModifyPrivate scopes (depending on whether the playlist is currently public or private). The current user must own the playlist in order to modify it.

func (*Client) CreatePlaylistForUser

func (c *Client) CreatePlaylistForUser(userID, playlistName, description string, public bool) (*FullPlaylist, error)

CreatePlaylistForUser creates a playlist for a Spotify user. The playlist will be empty until you add tracks to it. The playlistName does not need to be unique - a user can have several playlists with the same name.

Creating a public playlist for a user requires ScopePlaylistModifyPublic; creating a private playlist requires ScopePlaylistModifyPrivate.

On success, the newly created playlist is returned.

func (*Client) CurrentUser

func (c *Client) CurrentUser() (*PrivateUser, error)

CurrentUser gets detailed profile information about the current user.

Reading the user's email address requires that the application has the ScopeUserReadEmail scope. Reading the country, display name, profile images, and product subscription level requires that the application has the ScopeUserReadPrivate scope.

Warning: The email address in the response will be the address that was entered when the user created their spotify account. This email address is unverified - do not assume that Spotify has checked that the email address actually belongs to the user.

func (*Client) CurrentUserFollows

func (c *Client) CurrentUserFollows(t string, ids ...ID) ([]bool, error)

CurrentUserFollows checks to see if the current user is following one or more artists or other Spotify Users. This call requires ScopeUserFollowRead.

The t argument indicates the type of the IDs, and must be either "user" or "artist".

The result is returned as a slice of bool values in the same order in which the IDs were specified.

func (*Client) CurrentUsersAlbums

func (c *Client) CurrentUsersAlbums() (*SavedAlbumPage, error)

CurrentUsersAlbums gets a list of albums saved in the current Spotify user's "Your Music" library.

func (*Client) CurrentUsersAlbumsOpt

func (c *Client) CurrentUsersAlbumsOpt(opt *Options) (*SavedAlbumPage, error)

CurrentUsersAlbumsOpt is like CurrentUsersAlbums, but it accepts additional options for sorting and filtering the results.

func (*Client) CurrentUsersFollowedArtists

func (c *Client) CurrentUsersFollowedArtists() (*FullArtistCursorPage, error)

CurrentUsersFollowedArtists gets the current user's followed artists. This call requires that the user has granted the ScopeUserFollowRead scope.

func (*Client) CurrentUsersFollowedArtistsOpt

func (c *Client) CurrentUsersFollowedArtistsOpt(limit int, after string) (*FullArtistCursorPage, error)

CurrentUsersFollowedArtistsOpt is like CurrentUsersFollowedArtists, but it accept the optional arguments limit and after. Limit is the maximum number of items to return (1 <= limit <= 50), and after is the last artist ID retrieved from the previous request. If you don't wish to specify either of the parameters, use -1 for limit and the empty string for after.

func (*Client) CurrentUsersPlaylists

func (c *Client) CurrentUsersPlaylists() (*SimplePlaylistPage, error)

CurrentUsersPlaylists gets a list of the playlists owned or followed by the current spotify user.

Private playlists require the ScopePlaylistReadPrivate scope. Note that this scope alone will not return collaborative playlists, even though they are always private. In order to retrieve collaborative playlists the user must authorize the ScopePlaylistReadCollaborative scope.

func (*Client) CurrentUsersPlaylistsOpt

func (c *Client) CurrentUsersPlaylistsOpt(opt *Options) (*SimplePlaylistPage, error)

CurrentUsersPlaylistsOpt is like CurrentUsersPlaylists, but it accepts additional options for sorting and filtering the results.

func (*Client) CurrentUsersShows

func (c *Client) CurrentUsersShows() (*SavedShowPage, error)

CurrentUsersShows gets a list of shows saved in the current Spotify user's "Your Music" library.

func (*Client) CurrentUsersShowsOpt

func (c *Client) CurrentUsersShowsOpt(opt *Options) (*SavedShowPage, error)

CurrentUsersShowsOpt is like CurrentUsersShows, but it accepts additional options for sorting and filtering the results. API Doc: https://developer.spotify.com/documentation/web-api/reference-beta/#endpoint-get-users-saved-shows

func (*Client) CurrentUsersTopArtists

func (c *Client) CurrentUsersTopArtists() (*FullArtistPage, error)

CurrentUsersTopArtists is like CurrentUsersTopArtistsOpt but with sensible defaults. The default limit is 20 and the default timerange is medium_term.

func (*Client) CurrentUsersTopArtistsOpt

func (c *Client) CurrentUsersTopArtistsOpt(opt *Options) (*FullArtistPage, error)

CurrentUsersTopArtistsOpt gets a list of the top played artists in a given time range of the current Spotify user. It supports up to 50 artists in a single call. This call requires ScopeUserTopRead.

func (*Client) CurrentUsersTopTracks

func (c *Client) CurrentUsersTopTracks() (*FullTrackPage, error)

CurrentUsersTopTracks is like CurrentUsersTopTracksOpt but with sensible defaults. The default limit is 20 and the default timerange is medium_term.

func (*Client) CurrentUsersTopTracksOpt

func (c *Client) CurrentUsersTopTracksOpt(opt *Options) (*FullTrackPage, error)

CurrentUsersTopTracksOpt gets a list of the top played tracks in a given time range of the current Spotify user. It supports up to 50 tracks in a single call. This call requires ScopeUserTopRead.

func (*Client) CurrentUsersTracks

func (c *Client) CurrentUsersTracks() (*SavedTrackPage, error)

CurrentUsersTracks gets a list of songs saved in the current Spotify user's "Your Music" library.

func (*Client) CurrentUsersTracksOpt

func (c *Client) CurrentUsersTracksOpt(opt *Options) (*SavedTrackPage, error)

CurrentUsersTracksOpt is like CurrentUsersTracks, but it accepts additional options for track relinking, sorting and filtering the results. API Doc: https://developer.spotify.com/documentation/web-api/reference-beta/#endpoint-get-users-saved-tracks

func (*Client) FeaturedPlaylists

func (c *Client) FeaturedPlaylists() (message string, playlists *SimplePlaylistPage, e error)

FeaturedPlaylists gets a list of playlists featured by Spotify. It is equivalent to c.FeaturedPlaylistsOpt(nil).

func (*Client) FeaturedPlaylistsOpt

func (c *Client) FeaturedPlaylistsOpt(opt *PlaylistOptions) (message string, playlists *SimplePlaylistPage, e error)

FeaturedPlaylistsOpt gets a list of playlists featured by Spotify. It accepts a number of optional parameters via the opt argument.

func (*Client) FollowArtist

func (c *Client) FollowArtist(ids ...ID) error

FollowArtist adds the current user as a follower of one or more spotify artists, identified by their Spotify IDs.

Modifying the lists of artists or users the current user follows requires that the application has the ScopeUserFollowModify scope.

func (*Client) FollowPlaylist

func (c *Client) FollowPlaylist(owner ID, playlist ID, public bool) error

FollowPlaylist adds the current user as a follower of the specified playlist. Any playlist can be followed, regardless of its private/public status, as long as you know the owner and playlist ID.

If the public argument is true, then the playlist will be included in the user's public playlists. To be able to follow playlists privately, the user must have granted the ScopePlaylistModifyPrivate scope. The ScopePlaylistModifyPublic scope is required to follow playlists publicly.

func (*Client) FollowUser

func (c *Client) FollowUser(ids ...ID) error

FollowUser adds the current user as a follower of one or more spotify users, identified by their Spotify IDs.

Modifying the lists of artists or users the current user follows requires that the application has the ScopeUserFollowModify scope.

func (*Client) GetAlbum

func (c *Client) GetAlbum(id ID) (*FullAlbum, error)

GetAlbum gets Spotify catalog information for a single album, given its Spotify ID.

func (*Client) GetAlbumOpt

func (c *Client) GetAlbumOpt(id ID, opt *Options) (*FullAlbum, error)

GetAlbum is like GetAlbumOpt but it accepts an additional country option for track relinking

func (*Client) GetAlbumTracks

func (c *Client) GetAlbumTracks(id ID) (*SimpleTrackPage, error)

GetAlbumTracks gets the tracks for a particular album. If you only care about the tracks, this call is more efficient than GetAlbum.

func (*Client) GetAlbumTracksOpt

func (c *Client) GetAlbumTracksOpt(id ID, opt *Options) (*SimpleTrackPage, error)

GetAlbumTracksOpt behaves like GetAlbumTracks, with the exception that it allows you to specify options that limit the number of results returned and if track relinking should be used. The maximum number of results to return is specified by limit. The offset argument can be used to specify the index of the first track to return. It can be used along with limit to request the next set of results. Track relinking can be enabled by setting the Country option

func (*Client) GetAlbums

func (c *Client) GetAlbums(ids ...ID) ([]*FullAlbum, error)

GetAlbums gets Spotify Catalog information for multiple albums, given their Spotify IDs. It supports up to 20 IDs in a single call. Albums are returned in the order requested. If an album is not found, that position in the result slice will be nil.

func (*Client) GetAlbumsOpt

func (c *Client) GetAlbumsOpt(opt *Options, ids ...ID) ([]*FullAlbum, error)

GetAlbumsOpt is like GetAlbums but it accepts an additional country option for track relinking Doc API: https://developer.spotify.com/documentation/web-api/reference/albums/get-several-albums/

func (*Client) GetArtist

func (c *Client) GetArtist(id ID) (*FullArtist, error)

GetArtist gets Spotify catalog information for a single artist, given its Spotify ID.

func (*Client) GetArtistAlbums

func (c *Client) GetArtistAlbums(artistID ID) (*SimpleAlbumPage, error)

GetArtistAlbums gets Spotify catalog information about an artist's albums. It is equivalent to GetArtistAlbumsOpt(artistID, nil).

func (*Client) GetArtistAlbumsOpt

func (c *Client) GetArtistAlbumsOpt(artistID ID, options *Options, ts ...AlbumType) (*SimpleAlbumPage, error)

GetArtistAlbumsOpt is just like GetArtistAlbums, but it accepts optional parameters used to filter and sort the result.

The AlbumType argument can be used to find a particular types of album. If the market (Options.Country) is not specified, Spotify will likely return a lot of duplicates (one for each market in which the album is available)

func (*Client) GetArtists

func (c *Client) GetArtists(ids ...ID) ([]*FullArtist, error)

GetArtists gets spotify catalog information for several artists based on their Spotify IDs. It supports up to 50 artists in a single call. Artists are returned in the order requested. If an artist is not found, that position in the result will be nil. Duplicate IDs will result in duplicate artists in the result.

func (*Client) GetArtistsTopTracks

func (c *Client) GetArtistsTopTracks(artistID ID, country string) ([]FullTrack, error)

GetArtistsTopTracks gets Spotify catalog information about an artist's top tracks in a particular country. It returns a maximum of 10 tracks. The country is specified as an ISO 3166-1 alpha-2 country code.

func (*Client) GetAudioAnalysis

func (c *Client) GetAudioAnalysis(id ID) (*AudioAnalysis, error)

GetAudioAnalysis queries the Spotify web API for an audio analysis of a single track.

func (*Client) GetAudioFeatures

func (c *Client) GetAudioFeatures(ids ...ID) ([]*AudioFeatures, error)

GetAudioFeatures queries the Spotify Web API for various high-level acoustic attributes of audio tracks. Objects are returned in the order requested. If an object is not found, a nil value is returned in the appropriate position.

func (*Client) GetAvailableGenreSeeds

func (c *Client) GetAvailableGenreSeeds() ([]string, error)

GetAvailableGenreSeeds retrieves a list of available genres seed parameter values for recommendations.

func (*Client) GetCategories

func (c *Client) GetCategories() (*CategoryPage, error)

GetCategories gets a list of categories used to tag items in Spotify (on, for example, the Spotify player's "Browse" tab).

func (*Client) GetCategoriesOpt

func (c *Client) GetCategoriesOpt(opt *Options, locale string) (*CategoryPage, error)

GetCategoriesOpt is like GetCategories, but it accepts optional parameters.

The locale option can be used to get the results in a particular language. It consists of an ISO 639 language code and an ISO 3166-1 alpha-2 country code, separated by an underscore. Specify the empty string to have results returned in the Spotify default language (American English).

func (*Client) GetCategory

func (c *Client) GetCategory(id string) (Category, error)

GetCategory gets a single category used to tag items in Spotify (on, for example, the Spotify player's Browse tab).

func (*Client) GetCategoryOpt

func (c *Client) GetCategoryOpt(id, country, locale string) (Category, error)

GetCategoryOpt is like GetCategory, but it accepts optional arguments. The country parameter is an ISO 3166-1 alpha-2 country code. It can be used to ensure that the category exists for a particular country. The locale argument is an ISO 639 language code and an ISO 3166-1 alpha-2 country code, separated by an underscore. It can be used to get the category strings in a particular language (for example: "es_MX" means get categories in Mexico, returned in Spanish).

This call requires authorization.

func (*Client) GetCategoryPlaylists

func (c *Client) GetCategoryPlaylists(catID string) (*SimplePlaylistPage, error)

GetCategoryPlaylists gets a list of Spotify playlists tagged with a particular category.

func (*Client) GetCategoryPlaylistsOpt

func (c *Client) GetCategoryPlaylistsOpt(catID string, opt *Options) (*SimplePlaylistPage, error)

GetCategoryPlaylistsOpt is like GetCategoryPlaylists, but it accepts optional arguments.

func (*Client) GetPlaylist

func (c *Client) GetPlaylist(playlistID ID) (*FullPlaylist, error)

GetPlaylist gets a playlist

func (*Client) GetPlaylistOpt

func (c *Client) GetPlaylistOpt(playlistID ID, fields string) (*FullPlaylist, error)

GetPlaylistOpt is like GetPlaylist, but it accepts an optional fields parameter that can be used to filter the query.

fields is a comma-separated list of the fields to return. See the JSON tags on the FullPlaylist struct for valid field options. For example, to get just the playlist's description and URI:

fields = "description,uri"

A dot separator can be used to specify non-reoccurring fields, while parentheses can be used to specify reoccurring fields within objects. For example, to get just the added date and the user ID of the adder:

fields = "tracks.items(added_at,added_by.id)"

Use multiple parentheses to drill down into nested objects, for example:

fields = "tracks.items(track(name,href,album(name,href)))"

Fields can be excluded by prefixing them with an exclamation mark, for example;

fields = "tracks.items(track(name,href,album(!name,href)))"

func (*Client) GetPlaylistTracks

func (c *Client) GetPlaylistTracks(playlistID ID) (*PlaylistTrackPage, error)

GetPlaylistTracks gets full details of the tracks in a playlist, given the playlist's Spotify ID.

func (*Client) GetPlaylistTracksOpt

func (c *Client) GetPlaylistTracksOpt(playlistID ID,
	opt *Options, fields string) (*PlaylistTrackPage, error)

GetPlaylistTracksOpt is like GetPlaylistTracks, but it accepts optional parameters for sorting and filtering the results.

The field parameter is a comma-separated list of the fields to return. See the JSON struct tags for the PlaylistTrackPage type for valid field names. For example, to get just the total number of tracks and the request limit:

fields = "total,limit"

A dot separator can be used to specify non-reoccurring fields, while parentheses can be used to specify reoccurring fields within objects. For example, to get just the added date and user ID of the adder:

fields = "items(added_at,added_by.id

Use multiple parentheses to drill down into nested objects. For example:

fields = "items(track(name,href,album(name,href)))"

Fields can be excluded by prefixing them with an exclamation mark. For example:

fields = "items.track.album(!external_urls,images)"

func (*Client) GetPlaylistsForUser

func (c *Client) GetPlaylistsForUser(userID string) (*SimplePlaylistPage, error)

GetPlaylistsForUser gets a list of the playlists owned or followed by a particular Spotify user.

Private playlists and collaborative playlists are only retrievable for the current user. In order to read private playlists, the user must have granted the ScopePlaylistReadPrivate scope. Note that this scope alone will not return collaborative playlists, even though they are always private. In order to read collaborative playlists, the user must have granted the ScopePlaylistReadCollaborative scope.

func (*Client) GetPlaylistsForUserOpt

func (c *Client) GetPlaylistsForUserOpt(userID string, opt *Options) (*SimplePlaylistPage, error)

GetPlaylistsForUserOpt is like PlaylistsForUser, but it accepts optional parameters for filtering the results.

func (*Client) GetRecommendations

func (c *Client) GetRecommendations(seeds Seeds, trackAttributes *TrackAttributes, opt *Options) (*Recommendations, error)

GetRecommendations returns a list of recommended tracks based on the given seeds. Recommendations are generated based on the available information for a given seed entity and matched against similar artists and tracks. If there is sufficient information about the provided seeds, a list of tracks will be returned together with pool size details. For artists and tracks that are very new or obscure there might not be enough data to generate a list of tracks.

func (*Client) GetRelatedArtists

func (c *Client) GetRelatedArtists(id ID) ([]FullArtist, error)

GetRelatedArtists gets Spotify catalog information about artists similar to a given artist. Similarity is based on analysis of the Spotify community's listening history. This function returns up to 20 artists that are considered related to the specified artist.

func (*Client) GetTrack

func (c *Client) GetTrack(id ID) (*FullTrack, error)

GetTrack gets Spotify catalog information for a single track identified by its unique Spotify ID. API Doc: https://developer.spotify.com/documentation/web-api/reference/tracks/get-track/

func (*Client) GetTrackOpt

func (c *Client) GetTrackOpt(id ID, opt *Options) (*FullTrack, error)

GetTrackOpt is like GetTrack but it accepts additional arguments

func (*Client) GetTracks

func (c *Client) GetTracks(ids ...ID) ([]*FullTrack, error)

GetTracks gets Spotify catalog information for multiple tracks based on their Spotify IDs. It supports up to 50 tracks in a single call. Tracks are returned in the order requested. If a track is not found, that position in the result will be nil. Duplicate ids in the query will result in duplicate tracks in the result. API Doc: https://developer.spotify.com/documentation/web-api/reference/tracks/get-several-tracks/

func (*Client) GetTracksOpt

func (c *Client) GetTracksOpt(opt *Options, ids ...ID) ([]*FullTrack, error)

GetTracksOpt is like GetTracks but it accepts an additional country option for track relinking

func (*Client) GetUsersPublicProfile

func (c *Client) GetUsersPublicProfile(userID ID) (*User, error)

GetUsersPublicProfile gets public profile information about a Spotify User. It does not require authentication.

func (*Client) NewReleases

func (c *Client) NewReleases() (albums *SimpleAlbumPage, err error)

NewReleases gets a list of new album releases featured in Spotify. This call requires bearer authorization.

func (*Client) NewReleasesOpt

func (c *Client) NewReleasesOpt(opt *Options) (albums *SimpleAlbumPage, err error)

NewReleasesOpt is like NewReleases, but it accepts optional parameters for filtering the results.

func (*Client) Next

func (c *Client) Next() error

Next skips to the next track in the user's queue in the user's currently active device. This call requires ScopeUserModifyPlaybackState in order to modify the player state

func (*Client) NextAlbumResults

func (c *Client) NextAlbumResults(s *SearchResult) error

NextAlbumResults loads the next page of albums into the specified search result.

func (*Client) NextArtistResults

func (c *Client) NextArtistResults(s *SearchResult) error

NextArtistResults loads the next page of artists into the specified search result.

func (*Client) NextOpt

func (c *Client) NextOpt(opt *PlayOptions) error

NextOpt is like Next but with more options

Only expects PlayOptions.DeviceID, all other options will be ignored

func (*Client) NextPage

func (c *Client) NextPage(p pageable) error

NextPage fetches the next page of items and writes them into p. It returns ErrNoMorePages if p already contains the last page.

func (*Client) NextPlaylistResults

func (c *Client) NextPlaylistResults(s *SearchResult) error

NextPlaylistResults loads the next page of playlists into the specified search result.

func (*Client) NextTrackResults

func (c *Client) NextTrackResults(s *SearchResult) error

NextTrackResults loads the next page of tracks into the specified search result.

func (*Client) Pause

func (c *Client) Pause() error

Pause Playback on the user's currently active device.

Requires the ScopeUserModifyPlaybackState in order to modify the player state

func (*Client) PauseOpt

func (c *Client) PauseOpt(opt *PlayOptions) error

PauseOpt is like Pause but with more options

Only expects PlayOptions.DeviceID, all other options will be ignored

func (*Client) Play

func (c *Client) Play() error

Play Start a new context or resume current playback on the user's active device. This call requires ScopeUserModifyPlaybackState in order to modify the player state.

func (*Client) PlayOpt

func (c *Client) PlayOpt(opt *PlayOptions) error

PlayOpt is like Play but with more options

func (*Client) PlayerCurrentlyPlaying

func (c *Client) PlayerCurrentlyPlaying() (*CurrentlyPlaying, error)

PlayerCurrentlyPlaying gets information about the currently playing status for the current user.

Requires the ScopeUserReadCurrentlyPlaying scope or the ScopeUserReadPlaybackState scope in order to read information

func (*Client) PlayerCurrentlyPlayingOpt

func (c *Client) PlayerCurrentlyPlayingOpt(opt *Options) (*CurrentlyPlaying, error)

PlayerCurrentlyPlayingOpt is like PlayerCurrentlyPlaying, but it accepts additional options for sorting and filtering the results.

func (*Client) PlayerDevices

func (c *Client) PlayerDevices() ([]PlayerDevice, error)

PlayerDevices information about available devices for the current user.

Requires the ScopeUserReadPlaybackState scope in order to read information

func (*Client) PlayerRecentlyPlayed

func (c *Client) PlayerRecentlyPlayed() ([]RecentlyPlayedItem, error)

PlayerRecentlyPlayed gets a list of recently-played tracks for the current user. This call requires ScopeUserReadRecentlyPlayed.

func (*Client) PlayerRecentlyPlayedOpt

func (c *Client) PlayerRecentlyPlayedOpt(opt *RecentlyPlayedOptions) ([]RecentlyPlayedItem, error)

PlayerRecentlyPlayedOpt is like PlayerRecentlyPlayed, but it accepts additional options for sorting and filtering the results.

func (*Client) PlayerState

func (c *Client) PlayerState() (*PlayerState, error)

PlayerState gets information about the playing state for the current user

Requires the ScopeUserReadPlaybackState scope in order to read information

func (*Client) PlayerStateOpt

func (c *Client) PlayerStateOpt(opt *Options) (*PlayerState, error)

PlayerStateOpt is like PlayerState, but it accepts additional options for sorting and filtering the results.

func (*Client) Previous

func (c *Client) Previous() error

Previous skips to the Previous track in the user's queue in the user's currently active device. This call requires ScopeUserModifyPlaybackState in order to modify the player state

func (*Client) PreviousAlbumResults

func (c *Client) PreviousAlbumResults(s *SearchResult) error

PreviousAlbumResults loads the previous page of albums into the specified search result.

func (*Client) PreviousArtistResults

func (c *Client) PreviousArtistResults(s *SearchResult) error

PreviousArtistResults loads the previous page of artists into the specified search result.

func (*Client) PreviousOpt

func (c *Client) PreviousOpt(opt *PlayOptions) error

PreviousOpt is like Previous but with more options

Only expects PlayOptions.DeviceID, all other options will be ignored

func (*Client) PreviousPage

func (c *Client) PreviousPage(p pageable) error

PreviousPage fetches the previous page of items and writes them into p. It returns ErrNoMorePages if p already contains the last page.

func (*Client) PreviousPlaylistResults

func (c *Client) PreviousPlaylistResults(s *SearchResult) error

PreviousPlaylistResults loads the previous page of playlists into the specified search result.

func (*Client) PreviousTrackResults

func (c *Client) PreviousTrackResults(s *SearchResult) error

PreviousTrackResults loads the previous page of tracks into the specified search result.

func (*Client) QueueSong

func (c *Client) QueueSong(trackID ID) error

QueueSong adds a song to the user's queue on the user's currently active device. This call requires ScopeUserModifyPlaybackState in order to modify the player state

func (*Client) QueueSongOpt

func (c *Client) QueueSongOpt(trackID ID, opt *PlayOptions) error

QueueSongOpt is like QueueSong but with more options

Only expects PlayOptions.DeviceID, all other options will be ignored

func (*Client) RemoveTracksFromLibrary

func (c *Client) RemoveTracksFromLibrary(ids ...ID) error

RemoveTracksFromLibrary removes one or more tracks from the current user's "Your Music" library. This call requires the ScopeUserModifyLibrary scope. Trying to remove a track when you do not have the user's authorization results in a `spotify.Error` with the status code set to http.StatusUnauthorized.

func (*Client) RemoveTracksFromPlaylist

func (c *Client) RemoveTracksFromPlaylist(playlistID ID, trackIDs ...ID) (newSnapshotID string, err error)

RemoveTracksFromPlaylist removes one or more tracks from a user's playlist. This call requrles that the user has authorized the ScopePlaylistModifyPublic or ScopePlaylistModifyPrivate scopes.

If the track(s) occur multiple times in the specified playlist, then all occurrences of the track will be removed. If successful, the snapshot ID returned can be used to identify the playlist version in future requests.

func (*Client) RemoveTracksFromPlaylistOpt

func (c *Client) RemoveTracksFromPlaylistOpt(playlistID ID,
	tracks []TrackToRemove, snapshotID string) (newSnapshotID string, err error)

RemoveTracksFromPlaylistOpt is like RemoveTracksFromPlaylist, but it supports optional parameters that offer more fine-grained control. Instead of deleting all occurrences of a track, this function takes an index with each track URI that indicates the position of the track in the playlist.

In addition, the snapshotID parameter allows you to specify the snapshot ID against which you want to make the changes. Spotify will validate that the specified tracks exist in the specified positions and make the changes, even if more recent changes have been made to the playlist. If a track in the specified position is not found, the entire request will fail and no edits will take place. (Note: the snapshot is optional, pass the empty string if you don't care about it.)

func (*Client) ReorderPlaylistTracks

func (c *Client) ReorderPlaylistTracks(playlistID ID, opt PlaylistReorderOptions) (snapshotID string, err error)

ReorderPlaylistTracks reorders a track or group of tracks in a playlist. It returns a snapshot ID that can be used to identify the [newly modified] playlist version in future requests.

See the docs for PlaylistReorderOptions for information on how the reordering works.

Reordering tracks in the current user's public playlist requires ScopePlaylistModifyPublic. Reordering tracks in the user's private playlists (including collaborative playlists) requires ScopePlaylistModifyPrivate.

func (*Client) Repeat

func (c *Client) Repeat(state string) error

Repeat Set the repeat mode for the user's playback.

Options are repeat-track, repeat-context, and off.

Requires the ScopeUserModifyPlaybackState in order to modify the player state.

func (*Client) RepeatOpt

func (c *Client) RepeatOpt(state string, opt *PlayOptions) error

RepeatOpt is like Repeat but with more options

Only expects PlayOptions.DeviceID, all other options will be ignored.

func (*Client) ReplacePlaylistTracks

func (c *Client) ReplacePlaylistTracks(playlistID ID, trackIDs ...ID) error

ReplacePlaylistTracks replaces all of the tracks in a playlist, overwriting its existing tracks This can be useful for replacing or reordering tracks, or for clearing a playlist.

Modifying a public playlist requires that the user has authorized the ScopePlaylistModifyPublic scope. Modifying a private playlist requires the ScopePlaylistModifyPrivate scope.

A maximum of 100 tracks is permited in this call. Additional tracks must be added via AddTracksToPlaylist.

func (*Client) Search

func (c *Client) Search(query string, t SearchType) (*SearchResult, error)

Search gets Spotify catalog information about artists, albums, tracks, or playlists that match a keyword string. t is a mask containing one or more search types. For example, `Search(query, SearchTypeArtist|SearchTypeAlbum)` will search for artists or albums matching the specified keywords.

Matching of search keywords is NOT case sensitive. Keywords are matched in any order unless surrounded by double quotes. Searching for playlists will return results where the query keyword(s) match any part of the playlist's name or description. Only popular public playlists are returned.

The operator NOT can be used to exclude results. For example, query = "roadhouse NOT blues" returns items that match "roadhouse" but excludes those that also contain the keyword "blues". Similarly, the OR operator can be used to broaden the search. query = "roadhouse OR blues" returns all results that include either of the terms. Only one OR operator can be used in a query.

Operators should be specified in uppercase.

The asterisk (*) character can, with some limitations, be used as a wildcard (maximum of 2 per query). It will match a variable number of non-white-space characters. It cannot be used in a quoted phrase, in a field filter, or as the first character of a keyword string.

By default, results are returned when a match is found in any field of the target object type. Searches can be made more specific by specifying an album, artist, or track field filter. For example, "album:gold artist:abba type:album" will only return results with the text "gold" in the album name and the text "abba" in the artist's name.

The field filter "year" can be used with album, artist, and track searches to limit the results to a particular year. For example "bob year:2014" or "bob year:1980-2020".

The field filter "tag:new" can be used in album searches to retrieve only albums released in the last two weeks. The field filter "tag:hipster" can be used in album searches to retrieve only albums with the lowest 10% popularity.

Other possible field filters, depending on object types being searched, include "genre", "upc", and "isrc". For example "damian genre:reggae-pop".

func (*Client) SearchOpt

func (c *Client) SearchOpt(query string, t SearchType, opt *Options) (*SearchResult, error)

SearchOpt works just like Search, but it accepts additional parameters for filtering the output. See the documentation for Search more more information.

If the Country field is specified in the options, then the results will only contain artists, albums, and tracks playable in the specified country (playlist results are not affected by the Country option). Additionally, the constant MarketFromToken can be used with authenticated clients. If the client has a valid access token, then the results will only include content playable in the user's country.

func (*Client) Seek

func (c *Client) Seek(position int) error

Seek to the given position in the user’s currently playing track.

The position in milliseconds to seek to. Must be a positive number. Passing in a position that is greater than the length of the track will cause the player to start playing the next song.

Requires the ScopeUserModifyPlaybackState in order to modify the player state

func (*Client) SeekOpt

func (c *Client) SeekOpt(position int, opt *PlayOptions) error

SeekOpt is like Seek but with more options

Only expects PlayOptions.DeviceID, all other options will be ignored

func (*Client) SetPlaylistImage

func (c *Client) SetPlaylistImage(playlistID ID, img io.Reader) error

SetPlaylistImage replaces the image used to represent a playlist. This action can only be performed by the owner of the playlist, and requires ScopeImageUpload as well as ScopeModifyPlaylist{Public|Private}..

func (*Client) Shuffle

func (c *Client) Shuffle(shuffle bool) error

Shuffle switches shuffle on or off for user's playback.

Requires the ScopeUserModifyPlaybackState in order to modify the player state

func (*Client) ShuffleOpt

func (c *Client) ShuffleOpt(shuffle bool, opt *PlayOptions) error

ShuffleOpt is like Shuffle but with more options

Only expects PlayOptions.DeviceID, all other options will be ignored

func (*Client) Token

func (c *Client) Token() (*oauth2.Token, error)

Token gets the client's current token.

func (*Client) TransferPlayback

func (c *Client) TransferPlayback(deviceID ID, play bool) error

TransferPlayback transfers playback to a new device and determine if it should start playing.

Note that a value of false for the play parameter when also transferring to another device_id will not pause playback. To ensure that playback is paused on the new device you should send a pause command to the currently active device before transferring to the new device_id.

Requires the ScopeUserModifyPlaybackState in order to modify the player state

func (*Client) UnfollowArtist

func (c *Client) UnfollowArtist(ids ...ID) error

UnfollowArtist removes the current user as a follower of one or more Spotify artists.

Modifying the lists of artists or users the current user follows requires that the application has the ScopeUserFollowModify scope.

func (*Client) UnfollowPlaylist

func (c *Client) UnfollowPlaylist(owner, playlist ID) error

UnfollowPlaylist removes the current user as a follower of a playlist. Unfollowing a publicly followed playlist requires ScopePlaylistModifyPublic. Unfolowing a privately followed playlist requies ScopePlaylistModifyPrivate.

func (*Client) UnfollowUser

func (c *Client) UnfollowUser(ids ...ID) error

UnfollowUser removes the current user as a follower of one or more Spotify users.

Modifying the lists of artists or users the current user follows requires that the application has the ScopeUserFollowModify scope.

func (*Client) UserFollowsPlaylist

func (c *Client) UserFollowsPlaylist(playlistID ID, userIDs ...string) ([]bool, error)

UserFollowsPlaylist checks if one or more (up to 5) Spotify users are following a Spotify playlist, given the playlist's owner and ID.

Checking if a user follows a playlist publicly doesn't require any scopes. Checking if the user is privately following a playlist is only possible for the current user when that user has granted access to the ScopePlaylistReadPrivate scope.

func (*Client) UserHasTracks

func (c *Client) UserHasTracks(ids ...ID) ([]bool, error)

UserHasTracks checks if one or more tracks are saved to the current user's "Your Music" library.

func (*Client) Volume

func (c *Client) Volume(percent int) error

Volume set the volume for the user's current playback device.

Percent is must be a value from 0 to 100 inclusive.

Requires the ScopeUserModifyPlaybackState in order to modify the player state

func (*Client) VolumeOpt

func (c *Client) VolumeOpt(percent int, opt *PlayOptions) error

VolumeOpt is like Volume but with more options

Only expects PlayOptions.DeviceID, all other options will be ignored

type Copyright struct {
	// The copyright text for the album.
	Text string `json:"text"`
	// The type of copyright.
	Type string `json:"type"`
}

Copyright contains the copyright statement associated with an album.

type CurrentlyPlaying

type CurrentlyPlaying struct {
	// Timestamp when data was fetched
	Timestamp int64 `json:"timestamp"`
	// PlaybackContext current context
	PlaybackContext PlaybackContext `json:"context"`
	// Progress into the currently playing track.
	Progress int `json:"progress_ms"`
	// Playing If something is currently playing.
	Playing bool `json:"is_playing"`
	// The currently playing track. Can be null.
	Item *FullTrack `json:"item"`
}

CurrentlyPlaying contains the information about currently playing items

type Cursor

type Cursor struct {
	After string `json:"after"`
}

Cursor contains a key that can be used to find the next set of items.

type EpisodePage

type EpisodePage struct {
	// A URL to a 30 second preview (MP3 format) of the episode.
	AudioPreviewURL string `json:"audio_preview_url"`

	// A description of the episode.
	Description string `json:"description"`

	// The episode length in milliseconds.
	Duration_ms int `json:"duration_ms"`

	// Whether or not the episode has explicit content
	// (true = yes it does; false = no it does not OR unknown).
	Explicit bool `json:"explicit"`

	// 	External URLs for this episode.
	ExternalURLs map[string]string `json:"external_urls"`

	// A link to the Web API endpoint providing full details of the episode.
	Href string `json:"href"`

	// The Spotify ID for the episode.
	ID ID `json:"id"`

	// The cover art for the episode in various sizes, widest first.
	Images []Image `json:"images"`

	// True if the episode is hosted outside of Spotify’s CDN.
	IsExternallyHosted bool `json:"is_externally_hosted"`

	// True if the episode is playable in the given market.
	// Otherwise false.
	IsPlayable bool `json:"is_playable"`

	// A list of the languages used in the episode, identified by their ISO 639 code.
	Languages []string `json:"languages"`

	// The name of the episode.
	Name string `json:"name"`

	// The date the episode was first released, for example
	// "1981-12-15". Depending on the precision, it might
	// be shown as "1981" or "1981-12".
	ReleaseDate string `json:"release_date"`

	// The precision with which release_date value is known:
	// "year", "month", or "day".
	ReleaseDatePrecision string `json:"release_date_precision"`

	// The user’s most recent position in the episode. Set if the
	// supplied access token is a user token and has the scope
	// user-read-playback-position.
	ResumePoint ResumePointObject `json:"resume_point"`

	// The show on which the episode belongs.
	Show SimpleShow `json:"show"`

	// The object type: "episode".
	Type string `json:"type"`

	// The Spotify URI for the episode.
	URI URI `json:"uri"`
}

func (*EpisodePage) ReleaseDateTime

func (e *EpisodePage) ReleaseDateTime() time.Time

ReleaseDateTime converts the show's ReleaseDate to a time.TimeValue. All of the fields in the result may not be valid. For example, if ReleaseDatePrecision is "month", then only the month and year (but not the day) of the result are valid.

type Error

type Error struct {
	// A short description of the error.
	Message string `json:"message"`
	// The HTTP status code.
	Status int `json:"status"`
}

Error represents an error returned by the Spotify Web API.

func (Error) Error

func (e Error) Error() string

type Followers

type Followers struct {
	// The total number of followers.
	Count uint `json:"total"`
	// A link to the Web API endpoint providing full details of the followers,
	// or the empty string if this data is not available.
	Endpoint string `json:"href"`
}

Followers contains information about the number of people following a particular artist or playlist.

func (*Followers) UnmarshalJSON added in v1.1.5

func (f *Followers) UnmarshalJSON(data []byte) error

type FullAlbum

type FullAlbum struct {
	SimpleAlbum
	Copyrights []Copyright `json:"copyrights"`
	Genres     []string    `json:"genres"`
	// The popularity of the album, represented as an integer between 0 and 100,
	// with 100 being the most popular.  Popularity of an album is calculated
	// from the popularify of the album's individual tracks.
	Popularity  int               `json:"popularity"`
	Tracks      SimpleTrackPage   `json:"tracks"`
	ExternalIDs map[string]string `json:"external_ids"`
}

FullAlbum provides extra album data in addition to the data provided by SimpleAlbum.

type FullArtist

type FullArtist struct {
	SimpleArtist
	// The popularity of the artist, expressed as an integer between 0 and 100.
	// The artist's popularity is calculated from the popularity of the artist's tracks.
	Popularity int `json:"popularity"`
	// A list of genres the artist is associated with.  For example, "Prog Rock"
	// or "Post-Grunge".  If not yet classified, the slice is empty.
	Genres    []string  `json:"genres"`
	Followers Followers `json:"followers"`
	// Images of the artist in various sizes, widest first.
	Images []Image `json:"images"`
}

FullArtist provides extra artist data in addition to what is provided by SimpleArtist.

func (*FullArtist) UnmarshalJSON added in v1.1.5

func (f *FullArtist) UnmarshalJSON(data []byte) error

type FullArtistCursorPage

type FullArtistCursorPage struct {
	Artists []FullArtist `json:"items"`
	// contains filtered or unexported fields
}

FullArtistCursorPage is a cursor-based paging object containing a set of FullArtist objects.

type FullArtistPage

type FullArtistPage struct {
	Artists []FullArtist `json:"items"`
	// contains filtered or unexported fields
}

FullArtistPage contains FullArtists returned by the Web API.

type FullPlaylist

type FullPlaylist struct {
	SimplePlaylist
	// The playlist description.  Only returned for modified, verified playlists.
	Description string `json:"description"`
	// Information about the followers of this playlist.
	Followers Followers         `json:"followers"`
	Tracks    PlaylistTrackPage `json:"tracks"`
}

FullPlaylist provides extra playlist data in addition to the data provided by SimplePlaylist.

type FullShow

type FullShow struct {
	SimpleShow

	// A list of the show’s episodes.
	Episodes EpisodePage `json:"episode"`
}

FullShow contains full data about a show.

type FullTrack

type FullTrack struct {
	SimpleTrack
	// The album on which the track appears. The album object includes a link in href to full information about the album.
	Album SimpleAlbum `json:"album"`
	// Known external IDs for the track.
	ExternalIDs map[string]string `json:"external_ids"`
	// Popularity of the track.  The value will be between 0 and 100,
	// with 100 being the most popular.  The popularity is calculated from
	// both total plays and most recent plays.
	Popularity int `json:"popularity"`

	// IsPlayable defines if the track is playable. It's reported when the "market" parameter is passed to the tracks
	// listing API.
	// See: https://developer.spotify.com/documentation/general/guides/track-relinking-guide/
	IsPlayable *bool `json:"is_playable"`

	// LinkedFrom points to the linked track. It's reported when the "market" parameter is passed to the tracks listing
	// API.
	LinkedFrom *LinkedFromInfo `json:"linked_from"`
}

FullTrack provides extra track data in addition to what is provided by SimpleTrack.

func (*FullTrack) UnmarshalJSON added in v1.1.6

func (f *FullTrack) UnmarshalJSON(data []byte) error

type FullTrackPage

type FullTrackPage struct {
	Tracks []FullTrack `json:"items"`
	// contains filtered or unexported fields
}

FullTrackPage contains FullTracks returned by the Web API.

type ID

type ID string

ID is a base-62 identifier for an artist, track, album, etc. It can be found at the end of a spotify.URI.

func (*ID) String

func (id *ID) String() string

type Image

type Image struct {
	// The image height, in pixels.
	Height int `json:"height"`
	// The image width, in pixels.
	Width int `json:"width"`
	// The source URL of the image.
	URL string `json:"url"`
}

Image identifies an image associated with an item.

func (Image) Download

func (i Image) Download(dst io.Writer) error

Download downloads the image and writes its data to the specified io.Writer.

func (*Image) UnmarshalJSON added in v1.1.5

func (i *Image) UnmarshalJSON(data []byte) error

type Key

type Key int

Key represents a pitch using Pitch Class notation.

const (
	C Key = iota
	CSharp
	D
	DSharp
	E
	F
	FSharp
	G
	GSharp
	A
	ASharp
	B
	DFlat = CSharp
	EFlat = DSharp
	GFlat = FSharp
	AFlat = GSharp
	BFlat = ASharp
)

type LinkedFromInfo

type LinkedFromInfo struct {
	// ExternalURLs are the known external APIs for this track or album
	ExternalURLs map[string]string `json:"external_urls"`

	// Href is a link to the Web API endpoint providing full details
	Href string `json:"href"`

	// ID of the linked track
	ID ID `json:"id"`

	// Type of the link: album of the track
	Type string `json:"type"`

	// URI is the Spotify URI of the track/album
	URI string `json:"uri"`
}

LinkedFromInfo See: https://developer.spotify.com/documentation/general/guides/track-relinking-guide/

type Marker

type Marker struct {
	Start      float64 `json:"start"`
	Duration   float64 `json:"duration"`
	Confidence float64 `json:"confidence"`
}

Marker represents beats, bars, tatums and are used in segment and section descriptions.

type Mode

type Mode int

Mode indicates the modality (major or minor) of a track.

const (
	Minor Mode = iota
	Major
)

type Options

type Options struct {
	// Country is an ISO 3166-1 alpha-2 country code.  Provide
	// this parameter if you want the list of returned items to
	// be relevant to a particular country.  If omitted, the
	// results will be relevant to all countries.
	Country *string
	// Limit is the maximum number of items to return.
	Limit *int
	// Offset is the index of the first item to return.  Use it
	// with Limit to get the next set of items.
	Offset *int
	// Timerange is the period of time from which to return results
	// in certain API calls. The three options are the following string
	// literals: "short", "medium", and "long"
	Timerange *string
}

Options contains optional parameters that can be provided to various API calls. Only the non-nil fields are used in queries.

type PlayOptions

type PlayOptions struct {
	// DeviceID The id of the device this command is targeting. If not
	// supplied, the user's currently active device is the target.
	DeviceID *ID `json:"-"`
	// PlaybackContext Spotify URI of the context to play.
	// Valid contexts are albums, artists & playlists.
	PlaybackContext *URI `json:"context_uri,omitempty"`
	// URIs Array of the Spotify track URIs to play
	URIs []URI `json:"uris,omitempty"`
	// PlaybackOffset Indicates from where in the context playback should start.
	// Only available when context corresponds to an album or playlist
	// object, or when the URIs parameter is used.
	PlaybackOffset *PlaybackOffset `json:"offset,omitempty"`
	// PositionMs Indicates from what position to start playback.
	// Must be a positive number. Passing in a position that is greater
	// than the length of the track will cause the player to start playing the next song.
	// Defaults to 0, starting a track from the beginning.
	PositionMs int `json:"position_ms,omitempty"`
}

type PlaybackContext

type PlaybackContext struct {
	// ExternalURLs of the context, or null if not available.
	ExternalURLs map[string]string `json:"external_urls"`
	// Endpoint of the context, or null if not available.
	Endpoint string `json:"href"`
	// Type of the item's context. Can be one of album, artist or playlist.
	Type string `json:"type"`
	// URI is the Spotify URI for the context.
	URI URI `json:"uri"`
}

PlaybackContext is the playback context

type PlaybackOffset

type PlaybackOffset struct {
	// Position is zero based and can’t be negative.
	Position int `json:"position,omitempty"`
	// URI is a string representing the uri of the item to start at.
	URI URI `json:"uri,omitempty"`
}

PlaybackOffset can be specified either by track URI OR Position. If both are present the request will return 400 BAD REQUEST. If incorrect values are provided for position or uri, the request may be accepted but with an unpredictable resulting action on playback.

type PlayerDevice

type PlayerDevice struct {
	// ID of the device. This may be empty.
	ID ID `json:"id"`
	// Active If this device is the currently active device.
	Active bool `json:"is_active"`
	// Restricted Whether controlling this device is restricted. At present if
	// this is "true" then no Web API commands will be accepted by this device.
	Restricted bool `json:"is_restricted"`
	// Name The name of the device.
	Name string `json:"name"`
	// Type of device, such as "Computer", "Smartphone" or "Speaker".
	Type string `json:"type"`
	// Volume The current volume in percent.
	Volume int `json:"volume_percent"`
}

PlayerDevice contains information about a device that a user can play music on

type PlayerState

type PlayerState struct {
	CurrentlyPlaying
	// Device The device that is currently active
	Device PlayerDevice `json:"device"`
	// ShuffleState Shuffle is on or off
	ShuffleState bool `json:"shuffle_state"`
	// RepeatState off, track, context
	RepeatState string `json:"repeat_state"`
}

PlayerState contains information about the current playback.

type PlaylistOptions

type PlaylistOptions struct {
	Options
	// The desired language, consisting of a lowercase IO 639
	// language code and an uppercase ISO 3166-1 alpha-2
	// country code, joined by an underscore.  Provide this
	// parameter if you want the results returned in a particular
	// language.  If not specified, the result will be returned
	// in the Spotify default language (American English).
	Locale *string
	// A timestamp in ISO 8601 format (yyyy-MM-ddTHH:mm:ss).
	// use this parameter to specify the user's local time to
	// get results tailored for that specific date and time
	// in the day.  If not provided, the response defaults to
	// the current UTC time.
	Timestamp *string
}

PlaylistOptions contains optional parameters that can be used when querying for featured playlists. Only the non-nil fields are used in the request.

type PlaylistReorderOptions

type PlaylistReorderOptions struct {
	// The position of the first track to be reordered.
	// This field is required.
	RangeStart int `json:"range_start"`
	// The amount of tracks to be reordered.  This field is optional.  If
	// you don't set it, the value 1 will be used.
	RangeLength int `json:"range_length,omitempty"`
	// The position where the tracks should be inserted.  To reorder the
	// tracks to the end of the playlist, simply set this to the position
	// after the last track.  This field is required.
	InsertBefore int `json:"insert_before"`
	// The playlist's snapshot ID against which you wish to make the changes.
	// This field is optional.
	SnapshotID string `json:"snapshot_id,omitempty"`
}

PlaylistReorderOptions is used with ReorderPlaylistTracks to reorder a track or group of tracks in a playlist.

For example, in a playlist with 10 tracks, you can:

  • move the first track to the end of the playlist by setting RangeStart to 0 and InsertBefore to 10
  • move the last track to the beginning of the playlist by setting RangeStart to 9 and InsertBefore to 0
  • Move the last 2 tracks to the beginning of the playlist by setting RangeStart to 8 and RangeLength to 2.

type PlaylistTrack

type PlaylistTrack struct {
	// The date and time the track was added to the playlist.
	// You can use the TimestampLayout constant to convert
	// this field to a time.Time value.
	// Warning: very old playlists may not populate this value.
	AddedAt string `json:"added_at"`
	// The Spotify user who added the track to the playlist.
	// Warning: vary old playlists may not populate this value.
	AddedBy User `json:"added_by"`
	// Whether this track is a local file or not.
	IsLocal bool `json:"is_local"`
	// Information about the track.
	Track FullTrack `json:"track"`
}

PlaylistTrack contains info about a track in a playlist.

type PlaylistTrackPage

type PlaylistTrackPage struct {
	Tracks []PlaylistTrack `json:"items"`
	// contains filtered or unexported fields
}

PlaylistTrackPage contains information about tracks in a playlist.

type PlaylistTracks

type PlaylistTracks struct {
	// A link to the Web API endpoint where full details of
	// the playlist's tracks can be retrieved.
	Endpoint string `json:"href"`
	// The total number of tracks in the playlist.
	Total uint `json:"total"`
}

PlaylistTracks contains details about the tracks in a playlist.

type PrivateUser

type PrivateUser struct {
	User
	// The country of the user, as set in the user's account profile.
	// An ISO 3166-1 alpha-2 country code.  This field is only available when the
	// current user has granted acess to the ScopeUserReadPrivate scope.
	Country string `json:"country"`
	// The user's email address, as entered by the user when creating their account.
	// Note: this email is UNVERIFIED - there is no proof that it actually
	// belongs to the user.  This field is only available when the current user
	// has granted access to the ScopeUserReadEmail scope.
	Email string `json:"email"`
	// The user's Spotify subscription level: "premium", "free", etc.
	// The subscription level "open" can be considered the same as "free".
	// This field is only available when the current user has granted access to
	// the ScopeUserReadPrivate scope.
	Product string `json:"product"`
	// The user's date of birth, in the format 'YYYY-MM-DD'.  You can use
	// the DateLayout constant to convert this to a time.Time value.
	// This field is only available when the current user has granted
	// access to the ScopeUserReadBirthdate scope.
	Birthdate string `json:"birthdate"`
}

PrivateUser contains additional information about a user. This data is private and requires user authentication.

type RecentlyPlayedItem

type RecentlyPlayedItem struct {
	// Track is the track information
	Track SimpleTrack `json:"track"`

	// PlayedAt is the time that this song was played
	PlayedAt time.Time `json:"played_at"`

	// PlaybackContext is the current playback context
	PlaybackContext PlaybackContext `json:"context"`
}

type RecentlyPlayedOptions

type RecentlyPlayedOptions struct {
	// Limit is the maximum number of items to return. Must be no greater than
	// fifty.
	Limit int

	// AfterEpochMs is a Unix epoch in milliseconds that describes a time after
	// which to return songs.
	AfterEpochMs int64

	// BeforeEpochMs is a Unix epoch in milliseconds that describes a time
	// before which to return songs.
	BeforeEpochMs int64
}

RecentlyPlayedOptions describes options for the recently-played request. All fields are optional. Only one of `AfterEpochMs` and `BeforeEpochMs` may be given. Note that it seems as if Spotify only remembers the fifty most-recent tracks as of right now.

type RecentlyPlayedResult

type RecentlyPlayedResult struct {
	Items []RecentlyPlayedItem `json:"items"`
}

type RecommendationSeed

type RecommendationSeed struct {
	AfterFilteringSize int    `json:"afterFilteringSize"`
	AfterRelinkingSize int    `json:"afterRelinkingSize"`
	Endpoint           string `json:"href"`
	ID                 ID     `json:"id"`
	InitialPoolSize    int    `json:"initialPoolSize"`
	Type               string `json:"type"`
}

RecommendationSeed represents a recommendation seed after being processed by the Spotify API

type Recommendations

type Recommendations struct {
	Seeds  []RecommendationSeed `json:"seeds"`
	Tracks []SimpleTrack        `json:"tracks"`
}

Recommendations contains a list of recommended tracks based on seeds

type ResumePointObject

type ResumePointObject struct {
	// 	Whether or not the episode has been fully played by the user.
	FullyPlayed bool `json:"fully_played"`

	// The user’s most recent position in the episode in milliseconds.
	ResumePositionMs int `json:"resume_position_ms"`
}

type SavedAlbum

type SavedAlbum struct {
	// The date and time the track was saved, represented as an ISO
	// 8601 UTC timestamp with a zero offset (YYYY-MM-DDTHH:MM:SSZ).
	// You can use the TimestampLayout constant to convert this to
	// a time.Time value.
	AddedAt   string `json:"added_at"`
	FullAlbum `json:"album"`
}

SavedAlbum provides info about an album saved to an user's account.

type SavedAlbumPage

type SavedAlbumPage struct {
	Albums []SavedAlbum `json:"items"`
	// contains filtered or unexported fields
}

SavedAlbumPage contains SavedAlbums returned by the Web API.

type SavedShow

type SavedShow struct {
	// The date and time the show was saved, represented as an ISO
	// 8601 UTC timestamp with a zero offset (YYYY-MM-DDTHH:MM:SSZ).
	// You can use the TimestampLayout constant to convert this to
	// a time.Time value.
	AddedAt  string `json:"added_at"`
	FullShow `json:"show"`
}

type SavedShowPage

type SavedShowPage struct {
	Shows []SavedShow `json:"items"`
	// contains filtered or unexported fields
}

SavedShowPage contains SavedShows returned by the Web API

type SavedTrack

type SavedTrack struct {
	// The date and time the track was saved, represented as an ISO
	// 8601 UTC timestamp with a zero offset (YYYY-MM-DDTHH:MM:SSZ).
	// You can use the TimestampLayout constant to convert this to
	// a time.Time value.
	AddedAt   string `json:"added_at"`
	FullTrack `json:"track"`
}

SavedTrack provides info about a track saved to a user's account.

type SavedTrackPage

type SavedTrackPage struct {
	Tracks []SavedTrack `json:"items"`
	// contains filtered or unexported fields
}

SavedTrackPage contains SavedTracks return by the Web API.

type SearchResult

type SearchResult struct {
	Artists   *FullArtistPage     `json:"artists"`
	Albums    *SimpleAlbumPage    `json:"albums"`
	Playlists *SimplePlaylistPage `json:"playlists"`
	Tracks    *FullTrackPage      `json:"tracks"`
}

SearchResult contains the results of a call to Search. Fields that weren't searched for will be nil pointers.

type SearchType

type SearchType int

SearchType represents the type of a query used in the Search function.

type Section

type Section struct {
	Marker
	Loudness                float64 `json:"loudness"`
	Tempo                   float64 `json:"tempo"`
	TempoConfidence         float64 `json:"tempo_confidence"`
	Key                     Key     `json:"key"`
	KeyConfidence           float64 `json:"key_confidence"`
	Mode                    Mode    `json:"mode"`
	ModeConfidence          float64 `json:"mode_confidence"`
	TimeSignature           int     `json:"time_signature"`
	TimeSignatureConfidence float64 `json:"time_signature_confidence"`
}

Section represents a large variation in rhythm or timbre, e.g. chorus, verse, bridge, guitar solo, etc. Each section contains its own descriptions of tempo, key, mode, time_signature, and loudness.

type Seeds

type Seeds struct {
	Artists []ID
	Tracks  []ID
	Genres  []string
}

Seeds contains IDs of artists, genres and/or tracks to be used as seeds for recommendations

type Segment

type Segment struct {
	Marker
	LoudnessStart   float64   `json:"loudness_start"`
	LoudnessMaxTime float64   `json:"loudness_max_time"`
	LoudnessMax     float64   `json:"loudness_max"`
	LoudnessEnd     float64   `json:"loudness_end"`
	Pitches         []float64 `json:"pitches"`
	Timbre          []float64 `json:"timbre"`
}

Segment is characterized by it's perceptual onset and duration in seconds, loudness (dB), pitch and timbral content.

type SimpleAlbum

type SimpleAlbum struct {
	// The name of the album.
	Name string `json:"name"`
	// A slice of SimpleArtists
	Artists []SimpleArtist `json:"artists"`
	// The field is present when getting an artist’s
	// albums. Possible values are “album”, “single”,
	// “compilation”, “appears_on”. Compare to album_type
	// this field represents relationship between the artist
	// and the album.
	AlbumGroup string `json:"album_group"`
	// The type of the album: one of "album",
	// "single", or "compilation".
	AlbumType string `json:"album_type"`
	// The SpotifyID for the album.
	ID ID `json:"id"`
	// The SpotifyURI for the album.
	URI URI `json:"uri"`
	// The markets in which the album is available,
	// identified using ISO 3166-1 alpha-2 country
	// codes.  Note that al album is considered
	// available in a market when at least 1 of its
	// tracks is available in that market.
	AvailableMarkets []string `json:"available_markets"`
	// A link to the Web API enpoint providing full
	// details of the album.
	Endpoint string `json:"href"`
	// The cover art for the album in various sizes,
	// widest first.
	Images []Image `json:"images"`
	// Known external URLs for this album.
	ExternalURLs map[string]string `json:"external_urls"`
	// The date the album was first released.  For example, "1981-12-15".
	// Depending on the ReleaseDatePrecision, it might be shown as
	// "1981" or "1981-12". You can use ReleaseDateTime to convert this
	// to a time.Time value.
	ReleaseDate string `json:"release_date"`
	// The precision with which ReleaseDate value is known: "year", "month", or "day"
	ReleaseDatePrecision string `json:"release_date_precision"`
}

SimpleAlbum contains basic data about an album.

func (*SimpleAlbum) ReleaseDateTime

func (s *SimpleAlbum) ReleaseDateTime() time.Time

ReleaseDateTime converts the album's ReleaseDate to a time.TimeValue. All of the fields in the result may not be valid. For example, if ReleaseDatePrecision is "month", then only the month and year (but not the day) of the result are valid.

type SimpleAlbumPage

type SimpleAlbumPage struct {
	Albums []SimpleAlbum `json:"items"`
	// contains filtered or unexported fields
}

SimpleAlbumPage contains SimpleAlbums returned by the Web API.

type SimpleArtist

type SimpleArtist struct {
	Name string `json:"name"`
	ID   ID     `json:"id"`
	// The Spotify URI for the artist.
	URI URI `json:"uri"`
	// A link to the Web API enpoint providing full details of the artist.
	Endpoint     string            `json:"href"`
	ExternalURLs map[string]string `json:"external_urls"`
}

SimpleArtist contains basic info about an artist.

type SimplePlaylist

type SimplePlaylist struct {
	// Indicates whether the playlist owner allows others to modify the playlist.
	// Note: only non-collaborative playlists are currently returned by Spotify's Web API.
	Collaborative bool              `json:"collaborative"`
	ExternalURLs  map[string]string `json:"external_urls"`
	// A link to the Web API endpoint providing full details of the playlist.
	Endpoint string `json:"href"`
	ID       ID     `json:"id"`
	// The playlist image.  Note: this field is only  returned for modified,
	// verified playlists. Otherwise the slice is empty.  If returned, the source
	// URL for the image is temporary and will expire in less than a day.
	Images   []Image `json:"images"`
	Name     string  `json:"name"`
	Owner    User    `json:"owner"`
	IsPublic bool    `json:"public"`
	// The version identifier for the current playlist. Can be supplied in other
	// requests to target a specific playlist version.
	SnapshotID string `json:"snapshot_id"`
	// A collection to the Web API endpoint where full details of the playlist's
	// tracks can be retrieved, along with the total number of tracks in the playlist.
	Tracks PlaylistTracks `json:"tracks"`
	URI    URI            `json:"uri"`
}

SimplePlaylist contains basic info about a Spotify playlist.

type SimplePlaylistPage

type SimplePlaylistPage struct {
	Playlists []SimplePlaylist `json:"items"`
	// contains filtered or unexported fields
}

SimplePlaylistPage contains SimplePlaylists returned by the Web API.

type SimpleShow

type SimpleShow struct {
	// A list of the countries in which the show can be played,
	// identified by their ISO 3166-1 alpha-2 code.
	AvailableMarkets []string `json:"available_markets"`

	// The copyright statements of the show.
	Copyrights []Copyright `json:"copyrights"`

	// A description of the show.
	Description string `json:"description"`

	// Whether or not the show has explicit content
	// (true = yes it does; false = no it does not OR unknown).
	Explicit bool `json:"explicit"`

	// Known external URLs for this show.
	ExternalURLs map[string]string `json:"external_urls"`

	// A link to the Web API endpoint providing full details
	// of the show.
	Href string `json:"href"`

	// The SpotifyID for the show.
	ID ID `json:"id"`

	// The cover art for the show in various sizes,
	// widest first.
	Images []Image `json:"images"`

	// True if all of the show’s episodes are hosted outside
	// of Spotify’s CDN. This field might be null in some cases.
	IsExternallyHosted *bool `json:"is_externally_hosted"`

	// A list of the languages used in the show, identified by
	// their ISO 639 code.
	Languages []string `json:"languages"`

	// The media type of the show.
	MediaType string `json:"media_type"`

	// The name of the show.
	Name string `json:"name"`

	// The publisher of the show.
	Publisher string `json:"publisher"`

	// The object type: “show”.
	Type string `json:"type"`

	// The Spotify URI for the show.
	URI URI `json:"uri"`
}

SimpleShow contains basic data about a show.

type SimpleTrack

type SimpleTrack struct {
	Artists []SimpleArtist `json:"artists"`
	// A list of the countries in which the track can be played,
	// identified by their ISO 3166-1 alpha-2 codes.
	AvailableMarkets []string `json:"available_markets"`
	// The disc number (usually 1 unless the album consists of more than one disc).
	DiscNumber int `json:"disc_number"`
	// The length of the track, in milliseconds.
	Duration int `json:"duration_ms"`
	// Whether or not the track has explicit lyrics.
	// true => yes, it does; false => no, it does not.
	Explicit bool `json:"explicit"`
	// External URLs for this track.
	ExternalURLs map[string]string `json:"external_urls"`
	// A link to the Web API endpoint providing full details for this track.
	Endpoint string `json:"href"`
	ID       ID     `json:"id"`
	Name     string `json:"name"`
	// A URL to a 30 second preview (MP3) of the track.
	PreviewURL string `json:"preview_url"`
	// The number of the track.  If an album has several
	// discs, the track number is the number on the specified
	// DiscNumber.
	TrackNumber int `json:"track_number"`
	URI         URI `json:"uri"`
	// Type of the track
	Type string `json:"type"`
}

SimpleTrack contains basic info about a track.

func (SimpleTrack) String

func (st SimpleTrack) String() string

func (*SimpleTrack) TimeDuration

func (t *SimpleTrack) TimeDuration() time.Duration

TimeDuration returns the track's duration as a time.Duration value.

func (*SimpleTrack) UnmarshalJSON added in v1.1.7

func (f *SimpleTrack) UnmarshalJSON(data []byte) error

type SimpleTrackPage

type SimpleTrackPage struct {
	Tracks []SimpleTrack `json:"items"`
	// contains filtered or unexported fields
}

SimpleTrackPage contains SimpleTracks returned by the Web API.

type TrackAttributes

type TrackAttributes struct {
	// contains filtered or unexported fields
}

TrackAttributes contains various tuneable parameters that can be used for recommendations. For each of the tuneable track attributes, target, min and max values may be provided. Target:

Tracks with the attribute values nearest to the target values will be preferred.
For example, you might request TargetEnergy=0.6 and TargetDanceability=0.8.
All target values will be weighed equally in ranking results.

Max:

A hard ceiling on the selected track attribute’s value can be provided.
For example, MaxInstrumentalness=0.35 would filter out most tracks
that are likely to be instrumental.

Min:

A hard floor on the selected track attribute’s value can be provided.
For example, min_tempo=140 would restrict results to only those tracks
with a tempo of greater than 140 beats per minute.

func NewTrackAttributes

func NewTrackAttributes() *TrackAttributes

NewTrackAttributes returns a new TrackAttributes instance with no attributes set. Attributes can then be chained following a builder pattern:

ta := NewTrackAttributes().
		MaxAcousticness(0.15).
		TargetPopularity(90)

func (*TrackAttributes) MaxAcousticness

func (ta *TrackAttributes) MaxAcousticness(acousticness float64) *TrackAttributes

MaxAcousticness sets the maximum acousticness Acousticness is a confidence measure from 0.0 to 1.0 of whether the track is acoustic. A value of 1.0 represents high confidence that the track is acoustic.

func (*TrackAttributes) MaxDanceability

func (ta *TrackAttributes) MaxDanceability(danceability float64) *TrackAttributes

MaxDanceability sets the maximum danceability Danceability describes how suitable a track is for dancing based on a combination of musical elements including tempo, rhythm stability, beat strength, and overall regularity. A value of 0.0 is least danceable and 1.0 is most danceable.

func (*TrackAttributes) MaxDuration

func (ta *TrackAttributes) MaxDuration(duration int) *TrackAttributes

MaxDuration sets the maximum length of the track in milliseconds

func (*TrackAttributes) MaxEnergy

func (ta *TrackAttributes) MaxEnergy(energy float64) *TrackAttributes

MaxEnergy sets the maximum energy Energy is a measure from 0.0 to 1.0 and represents a perceptual mesaure of intensity and activity. Typically, energetic tracks feel fast, loud, and noisy.

func (*TrackAttributes) MaxInstrumentalness

func (ta *TrackAttributes) MaxInstrumentalness(instrumentalness float64) *TrackAttributes

MaxInstrumentalness sets the maximum instrumentalness Instrumentalness predicts whether a track contains no vocals. "Ooh" and "aah" sounds are treated as instrumental in this context. Rap or spoken word tracks are clearly "vocal". The closer the instrumentalness value is to 1.0, the greater likelihood the track contains no vocal content. Values above 0.5 are intended to represent instrumental tracks, but confidence is higher as the value approaches 1.0.

func (*TrackAttributes) MaxKey

func (ta *TrackAttributes) MaxKey(key int) *TrackAttributes

MaxKey sets the maximum key Integers map to pitches using standard Pitch Class notation (https://en.wikipedia.org/wiki/Pitch_class).

func (*TrackAttributes) MaxLiveness

func (ta *TrackAttributes) MaxLiveness(liveness float64) *TrackAttributes

MaxLiveness sets the maximum liveness Detects the presence of an audience in the recording. Higher liveness values represent an increased probability that the track was performed live. A value above 0.8 provides strong likelihook that the track is live.

func (*TrackAttributes) MaxLoudness

func (ta *TrackAttributes) MaxLoudness(loudness float64) *TrackAttributes

MaxLoudness sets the maximum loudness in decibels (dB) Loudness values are averaged across the entire track and are useful for comparing the relative loudness of tracks. Typical values range between -60 and 0 dB.

func (*TrackAttributes) MaxMode

func (ta *TrackAttributes) MaxMode(mode int) *TrackAttributes

MaxMode sets the maximum mode Mode indicates the modality (major or minor) of a track.

func (*TrackAttributes) MaxPopularity

func (ta *TrackAttributes) MaxPopularity(popularity int) *TrackAttributes

MaxPopularity sets the maximum popularity. The value will be between 0 and 100, with 100 being the most popular. The popularity is calculated by algorithm and is based, in the most part, on the total number of plays the track has had and how recent those plays are. Note: When applying track relinking via the market parameter, it is expected to find relinked tracks with popularities that do not match min_*, max_* and target_* popularities. These relinked tracks are accurate replacements for unplayable tracks with the expected popularity scores. Original, non-relinked tracks are available via the linked_from attribute of the relinked track response.

func (*TrackAttributes) MaxSpeechiness

func (ta *TrackAttributes) MaxSpeechiness(speechiness float64) *TrackAttributes

MaxSpeechiness sets the maximum speechiness. Speechiness detects the presence of spoken words in a track. The more exclusively speech-like the recording, the closer to 1.0 the speechiness will be. Values above 0.66 describe tracks that are probably made entirely of spoken words. Values between 0.33 and 0.66 describe tracks that may contain both music and speech, including such cases as rap music. Values below 0.33 most likely represent music and other non-speech-like tracks.

func (*TrackAttributes) MaxTempo

func (ta *TrackAttributes) MaxTempo(tempo float64) *TrackAttributes

MaxTempo sets the maximum tempo in beats per minute (BPM).

func (*TrackAttributes) MaxTimeSignature

func (ta *TrackAttributes) MaxTimeSignature(timeSignature int) *TrackAttributes

MaxTimeSignature sets the maximum time signature The time signature (meter) is a notational convention to specify how many beats are in each bar (or measure).

func (*TrackAttributes) MaxValence

func (ta *TrackAttributes) MaxValence(valence float64) *TrackAttributes

MaxValence sets the maximum valence. Valence is a measure from 0.0 to 1.0 describing the musical positiveness / conveyed by a track. Tracks with high valence sound more positive (e.g. happy, cheerful, euphoric), while tracks with low valence sound more negative (e.g. sad, depressed, angry).

func (*TrackAttributes) MinAcousticness

func (ta *TrackAttributes) MinAcousticness(acousticness float64) *TrackAttributes

MinAcousticness sets the minimum acousticness Acousticness is a confidence measure from 0.0 to 1.0 of whether the track is acoustic. A value of 1.0 represents high confidence that the track is acoustic.

func (*TrackAttributes) MinDanceability

func (ta *TrackAttributes) MinDanceability(danceability float64) *TrackAttributes

MinDanceability sets the minimum danceability Danceability describes how suitable a track is for dancing based on a combination of musical elements including tempo, rhythm stability, beat strength, and overall regularity. A value of 0.0 is least danceable and 1.0 is most danceable.

func (*TrackAttributes) MinDuration

func (ta *TrackAttributes) MinDuration(duration int) *TrackAttributes

MinDuration sets the minimum length of the track in milliseconds

func (*TrackAttributes) MinEnergy

func (ta *TrackAttributes) MinEnergy(energy float64) *TrackAttributes

MinEnergy sets the minimum energy Energy is a measure from 0.0 to 1.0 and represents a perceptual mesaure of intensity and activity. Typically, energetic tracks feel fast, loud, and noisy.

func (*TrackAttributes) MinInstrumentalness

func (ta *TrackAttributes) MinInstrumentalness(instrumentalness float64) *TrackAttributes

MinInstrumentalness sets the minimum instrumentalness Instrumentalness predicts whether a track contains no vocals. "Ooh" and "aah" sounds are treated as instrumental in this context. Rap or spoken word tracks are clearly "vocal". The closer the instrumentalness value is to 1.0, the greater likelihood the track contains no vocal content. Values above 0.5 are intended to represent instrumental tracks, but confidence is higher as the value approaches 1.0.

func (*TrackAttributes) MinKey

func (ta *TrackAttributes) MinKey(key int) *TrackAttributes

MinKey sets the minimum key Integers map to pitches using standard Pitch Class notation (https://en.wikipedia.org/wiki/Pitch_class).

func (*TrackAttributes) MinLiveness

func (ta *TrackAttributes) MinLiveness(liveness float64) *TrackAttributes

MinLiveness sets the minimum liveness Detects the presence of an audience in the recording. Higher liveness values represent an increased probability that the track was performed live. A value above 0.8 provides strong likelihook that the track is live.

func (*TrackAttributes) MinLoudness

func (ta *TrackAttributes) MinLoudness(loudness float64) *TrackAttributes

MinLoudness sets the minimum loudness in decibels (dB) Loudness values are averaged across the entire track and are useful for comparing the relative loudness of tracks. Typical values range between -60 and 0 dB.

func (*TrackAttributes) MinMode

func (ta *TrackAttributes) MinMode(mode int) *TrackAttributes

MinMode sets the minimum mode Mode indicates the modality (major or minor) of a track.

func (*TrackAttributes) MinPopularity

func (ta *TrackAttributes) MinPopularity(popularity int) *TrackAttributes

MinPopularity sets the minimum popularity. The value will be between 0 and 100, with 100 being the most popular. The popularity is calculated by algorithm and is based, in the most part, on the total number of plays the track has had and how recent those plays are. Note: When applying track relinking via the market parameter, it is expected to find relinked tracks with popularities that do not match min_*, max_* and target_* popularities. These relinked tracks are accurate replacements for unplayable tracks with the expected popularity scores. Original, non-relinked tracks are available via the linked_from attribute of the relinked track response.

func (*TrackAttributes) MinSpeechiness

func (ta *TrackAttributes) MinSpeechiness(speechiness float64) *TrackAttributes

MinSpeechiness sets the minimum speechiness. Speechiness detects the presence of spoken words in a track. The more exclusively speech-like the recording, the closer to 1.0 the speechiness will be. Values above 0.66 describe tracks that are probably made entirely of spoken words. Values between 0.33 and 0.66 describe tracks that may contain both music and speech, including such cases as rap music. Values below 0.33 most likely represent music and other non-speech-like tracks.

func (*TrackAttributes) MinTempo

func (ta *TrackAttributes) MinTempo(tempo float64) *TrackAttributes

MinTempo sets the minimum tempo in beats per minute (BPM).

func (*TrackAttributes) MinTimeSignature

func (ta *TrackAttributes) MinTimeSignature(timeSignature int) *TrackAttributes

MinTimeSignature sets the minimum time signature The time signature (meter) is a notational convention to specify how many beats are in each bar (or measure).

func (*TrackAttributes) MinValence

func (ta *TrackAttributes) MinValence(valence float64) *TrackAttributes

MinValence sets the minimum valence. Valence is a measure from 0.0 to 1.0 describing the musical positiveness / conveyed by a track. Tracks with high valence sound more positive (e.g. happy, cheerful, euphoric), while tracks with low valence sound more negative (e.g. sad, depressed, angry).

func (*TrackAttributes) TargetAcousticness

func (ta *TrackAttributes) TargetAcousticness(acousticness float64) *TrackAttributes

TargetAcousticness sets the target acousticness Acousticness is a confidence measure from 0.0 to 1.0 of whether the track is acoustic. A value of 1.0 represents high confidence that the track is acoustic.

func (*TrackAttributes) TargetDanceability

func (ta *TrackAttributes) TargetDanceability(danceability float64) *TrackAttributes

TargetDanceability sets the target danceability Danceability describes how suitable a track is for dancing based on a combination of musical elements including tempo, rhythm stability, beat strength, and overall regularity. A value of 0.0 is least danceable and 1.0 is most danceable.

func (*TrackAttributes) TargetDuration

func (ta *TrackAttributes) TargetDuration(duration int) *TrackAttributes

TargetDuration sets the target length of the track in milliseconds

func (*TrackAttributes) TargetEnergy

func (ta *TrackAttributes) TargetEnergy(energy float64) *TrackAttributes

TargetEnergy sets the target energy Energy is a measure from 0.0 to 1.0 and represents a perceptual mesaure of intensity and activity. Typically, energetic tracks feel fast, loud, and noisy.

func (*TrackAttributes) TargetInstrumentalness

func (ta *TrackAttributes) TargetInstrumentalness(instrumentalness float64) *TrackAttributes

TargetInstrumentalness sets the target instrumentalness Instrumentalness predicts whether a track contains no vocals. "Ooh" and "aah" sounds are treated as instrumental in this context. Rap or spoken word tracks are clearly "vocal". The closer the instrumentalness value is to 1.0, the greater likelihood the track contains no vocal content. Values above 0.5 are intended to represent instrumental tracks, but confidence is higher as the value approaches 1.0.

func (*TrackAttributes) TargetKey

func (ta *TrackAttributes) TargetKey(key int) *TrackAttributes

TargetKey sets the target key Integers map to pitches using standard Pitch Class notation (https://en.wikipedia.org/wiki/Pitch_class).

func (*TrackAttributes) TargetLiveness

func (ta *TrackAttributes) TargetLiveness(liveness float64) *TrackAttributes

TargetLiveness sets the target liveness Detects the presence of an audience in the recording. Higher liveness values represent an increased probability that the track was performed live. A value above 0.8 provides strong likelihook that the track is live.

func (*TrackAttributes) TargetLoudness

func (ta *TrackAttributes) TargetLoudness(loudness float64) *TrackAttributes

TargetLoudness sets the target loudness in decibels (dB) Loudness values are averaged across the entire track and are useful for comparing the relative loudness of tracks. Typical values range between -60 and 0 dB.

func (*TrackAttributes) TargetMode

func (ta *TrackAttributes) TargetMode(mode int) *TrackAttributes

TargetMode sets the target mode Mode indicates the modality (major or minor) of a track.

func (*TrackAttributes) TargetPopularity

func (ta *TrackAttributes) TargetPopularity(popularity int) *TrackAttributes

TargetPopularity sets the target popularity. The value will be between 0 and 100, with 100 being the most popular. The popularity is calculated by algorithm and is based, in the most part, on the total number of plays the track has had and how recent those plays are. Note: When applying track relinking via the market parameter, it is expected to find relinked tracks with popularities that do not match min_*, max_* and target_* popularities. These relinked tracks are accurate replacements for unplayable tracks with the expected popularity scores. Original, non-relinked tracks are available via the linked_from attribute of the relinked track response.

func (*TrackAttributes) TargetSpeechiness

func (ta *TrackAttributes) TargetSpeechiness(speechiness float64) *TrackAttributes

TargetSpeechiness sets the target speechiness. Speechiness detects the presence of spoken words in a track. The more exclusively speech-like the recording, the closer to 1.0 the speechiness will be. Values above 0.66 describe tracks that are probably made entirely of spoken words. Values between 0.33 and 0.66 describe tracks that may contain both music and speech, including such cases as rap music. Values below 0.33 most likely represent music and other non-speech-like tracks.

func (*TrackAttributes) TargetTempo

func (ta *TrackAttributes) TargetTempo(tempo float64) *TrackAttributes

TargetTempo sets the target tempo in beats per minute (BPM).

func (*TrackAttributes) TargetTimeSignature

func (ta *TrackAttributes) TargetTimeSignature(timeSignature int) *TrackAttributes

TargetTimeSignature sets the target time signature The time signature (meter) is a notational convention to specify how many beats are in each bar (or measure).

func (*TrackAttributes) TargetValence

func (ta *TrackAttributes) TargetValence(valence float64) *TrackAttributes

TargetValence sets the target valence. Valence is a measure from 0.0 to 1.0 describing the musical positiveness / conveyed by a track. Tracks with high valence sound more positive (e.g. happy, cheerful, euphoric), while tracks with low valence sound more negative (e.g. sad, depressed, angry).

type TrackToRemove

type TrackToRemove struct {
	URI       string `json:"uri"`
	Positions []int  `json:"positions"`
}

TrackToRemove specifies a track to be removed from a playlist. Positions is a slice of 0-based track indices. TrackToRemove is used with RemoveTracksFromPlaylistOpt.

func NewTrackToRemove

func NewTrackToRemove(trackID string, positions []int) TrackToRemove

NewTrackToRemove creates a new TrackToRemove object with the specified track ID and playlist locations.

type URI

type URI string

URI identifies an artist, album, track, or category. For example, spotify:track:6rqhFgbbKwnb9MLmUQDhG6

type User

type User struct {
	// The name displayed on the user's profile.
	// Note: Spotify currently fails to populate
	// this field when querying for a playlist.
	DisplayName string `json:"display_name"`
	// Known public external URLs for the user.
	ExternalURLs map[string]string `json:"external_urls"`
	// Information about followers of the user.
	Followers Followers `json:"followers"`
	// A link to the Web API endpoint for this user.
	Endpoint string `json:"href"`
	// The Spotify user ID for the user.
	ID string `json:"id"`
	// The user's profile image.
	Images []Image `json:"images"`
	// The Spotify URI for the user.
	URI URI `json:"uri"`
}

User contains the basic, publicly available information about a Spotify user.

Directories

Path Synopsis
examples
authenticate/authcode
This example demonstrates how to authenticate with Spotify using the authorization code flow.
This example demonstrates how to authenticate with Spotify using the authorization code flow.
authenticate/clientcreds
This example demonstrates how to authenticate with Spotify using the client credentials flow.
This example demonstrates how to authenticate with Spotify using the client credentials flow.
authenticate/pkce
This example demonstrates how to authenticate with Spotify using the authorization code flow with PKCE.
This example demonstrates how to authenticate with Spotify using the authorization code flow with PKCE.
player
This example demonstrates how to authenticate with Spotify.
This example demonstrates how to authenticate with Spotify.
profile
Command profile gets the public profile information about a Spotify user.
Command profile gets the public profile information about a Spotify user.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL