Documentation ¶
Overview ¶
Package spotify provides utilties for interfacing with Spotify's Web API.
Index ¶
- Constants
- Variables
- type AlbumType
- type AudioFeatures
- type Authenticator
- func (a Authenticator) AuthURL(state string) string
- func (a Authenticator) Exchange(code string) (*oauth2.Token, error)
- func (a Authenticator) NewClient(token *oauth2.Token) Client
- func (a *Authenticator) SetAuthInfo(clientID, secretKey string)
- func (a Authenticator) Token(state string, r *http.Request) (*oauth2.Token, error)
- type Category
- type CategoryPage
- type Client
- func (c *Client) AddTracksToLibrary(ids ...ID) error
- func (c *Client) AddTracksToPlaylist(userID string, playlistID ID, trackIDs ...ID) (snapshotID string, err error)
- func (c *Client) ChangePlaylistAccess(userID string, playlistID ID, public bool) error
- func (c *Client) ChangePlaylistName(userID string, playlistID ID, newName string) error
- func (c *Client) ChangePlaylistNameAndAccess(userID string, playlistID ID, newName string, public bool) error
- func (c *Client) CreatePlaylistForUser(userID, playlistName string, public bool) (*FullPlaylist, error)
- func (c *Client) CurrentUser() (*PrivateUser, error)
- func (c *Client) CurrentUserFollows(t string, ids ...ID) ([]bool, error)
- func (c *Client) CurrentUsersAlbums() (*SavedAlbumPage, error)
- func (c *Client) CurrentUsersAlbumsOpt(opt *Options) (*SavedAlbumPage, error)
- func (c *Client) CurrentUsersFollowedArtists() (*FullArtistCursorPage, error)
- func (c *Client) CurrentUsersFollowedArtistsOpt(limit int, after string) (*FullArtistCursorPage, error)
- func (c *Client) CurrentUsersPlaylists() (*SimplePlaylistPage, error)
- func (c *Client) CurrentUsersPlaylistsOpt(opt *Options) (*SimplePlaylistPage, error)
- func (c *Client) CurrentUsersTracks() (*SavedTrackPage, error)
- func (c *Client) CurrentUsersTracksOpt(opt *Options) (*SavedTrackPage, error)
- func (c *Client) FeaturedPlaylists() (message string, playlists *SimplePlaylistPage, e error)
- func (c *Client) FeaturedPlaylistsOpt(opt *PlaylistOptions) (message string, playlists *SimplePlaylistPage, e error)
- func (c *Client) Follow(ids ...ID) error
- func (c *Client) FollowPlaylist(owner ID, playlist ID, public bool) error
- func (c *Client) GetAlbum(id ID) (*FullAlbum, error)
- func (c *Client) GetAlbumTracks(id ID) (*SimpleTrackPage, error)
- func (c *Client) GetAlbumTracksOpt(id ID, limit, offset int) (*SimpleTrackPage, error)
- func (c *Client) GetAlbums(ids ...ID) ([]*FullAlbum, error)
- func (c *Client) GetArtist(id ID) (*FullArtist, error)
- func (c *Client) GetArtistAlbums(artistID ID) (*SimpleAlbumPage, error)
- func (c *Client) GetArtistAlbumsOpt(artistID ID, options *Options, t *AlbumType) (*SimpleAlbumPage, error)
- func (c *Client) GetArtists(ids ...ID) ([]*FullArtist, error)
- func (c *Client) GetArtistsTopTracks(artistID ID, country string) ([]FullTrack, error)
- func (c *Client) GetAudioFeatures(ids ...ID) ([]*AudioFeatures, error)
- func (c *Client) GetCategories() (*CategoryPage, error)
- func (c *Client) GetCategoriesOpt(opt *Options, locale string) (*CategoryPage, error)
- func (c *Client) GetCategory(id string) (Category, error)
- func (c *Client) GetCategoryOpt(id, country, locale string) (Category, error)
- func (c *Client) GetCategoryPlaylists(catID string) (*SimplePlaylistPage, error)
- func (c *Client) GetCategoryPlaylistsOpt(catID string, opt *Options) (*SimplePlaylistPage, error)
- func (c *Client) GetPlaylist(userID string, playlistID ID) (*FullPlaylist, error)
- func (c *Client) GetPlaylistOpt(userID string, playlistID ID, fields string) (*FullPlaylist, error)
- func (c *Client) GetPlaylistTracks(userID string, playlistID ID) (*PlaylistTrackPage, error)
- func (c *Client) GetPlaylistTracksOpt(userID string, playlistID ID, opt *Options, fields string) (*PlaylistTrackPage, error)
- func (c *Client) GetPlaylistsForUser(userID string) (*SimplePlaylistPage, error)
- func (c *Client) GetPlaylistsForUserOpt(userID string, opt *Options) (*SimplePlaylistPage, error)
- func (c *Client) GetRecommendations(seeds Seeds, trackAttributes *TrackAttributes, opt *Options) (*Recommendations, error)
- func (c *Client) GetRelatedArtists(id ID) ([]FullArtist, error)
- func (c *Client) GetTrack(id ID) (*FullTrack, error)
- func (c *Client) GetTracks(ids ...ID) ([]*FullTrack, error)
- func (c *Client) GetUsersPublicProfile(userID ID) (*User, error)
- func (c *Client) NewReleases() (albums *SimpleAlbumPage, err error)
- func (c *Client) NewReleasesOpt(opt *Options) (albums *SimpleAlbumPage, err error)
- func (c *Client) NextAlbumResults(s *SearchResult) error
- func (c *Client) NextArtistResults(s *SearchResult) error
- func (c *Client) NextPlaylistResults(s *SearchResult) error
- func (c *Client) NextTrackResults(s *SearchResult) error
- func (c *Client) PreviousAlbumResults(s *SearchResult) error
- func (c *Client) PreviousArtistResults(s *SearchResult) error
- func (c *Client) PreviousPlaylistResults(s *SearchResult) error
- func (c *Client) PreviousTrackResults(s *SearchResult) error
- func (c *Client) RemoveTracksFromLibrary(ids ...ID) error
- func (c *Client) RemoveTracksFromPlaylist(userID string, playlistID ID, trackIDs ...ID) (newSnapshotID string, err error)
- func (c *Client) RemoveTracksFromPlaylistOpt(userID string, playlistID ID, tracks []TrackToRemove, snapshotID string) (newSnapshotID string, err error)
- func (c *Client) ReorderPlaylistTracks(userID, playlistID ID, opt PlaylistReorderOptions) (snapshotID string, err error)
- func (c *Client) ReplacePlaylistTracks(userID string, playlistID ID, trackIDs ...ID) error
- func (c *Client) Search(query string, t SearchType) (*SearchResult, error)
- func (c *Client) SearchOpt(query string, t SearchType, opt *Options) (*SearchResult, error)
- func (c *Client) Unfollow(ids ...ID) error
- func (c *Client) UnfollowPlaylist(owner, playlist ID) error
- func (c *Client) UserFollowsPlaylist(ownerID string, playlistID ID, userIDs ...string) ([]bool, error)
- func (c *Client) UserHasTracks(ids ...ID) ([]bool, error)
- type Copyright
- type Cursor
- type Error
- type Followers
- type FullAlbum
- type FullArtist
- type FullArtistCursorPage
- type FullArtistPage
- type FullPlaylist
- type FullTrack
- type FullTrackPage
- type ID
- type Image
- type Key
- type Mode
- type Options
- type PlaylistOptions
- type PlaylistReorderOptions
- type PlaylistTrack
- type PlaylistTrackPage
- type PlaylistTracks
- type PrivateUser
- type RecommendationSeed
- type Recommendations
- type SavedAlbum
- type SavedAlbumPage
- type SavedTrack
- type SavedTrackPage
- type SearchResult
- type SearchType
- type Seeds
- type SimpleAlbum
- type SimpleAlbumPage
- type SimpleArtist
- type SimplePlaylist
- type SimplePlaylistPage
- type SimpleTrack
- type SimpleTrackPage
- type TrackAttributes
- func (ta *TrackAttributes) MaxAcousticness(acousticness float64) *TrackAttributes
- func (ta *TrackAttributes) MaxDanceability(danceability float64) *TrackAttributes
- func (ta *TrackAttributes) MaxDuration(duration int) *TrackAttributes
- func (ta *TrackAttributes) MaxEnergy(energy float64) *TrackAttributes
- func (ta *TrackAttributes) MaxInstrumentalness(instrumentalness float64) *TrackAttributes
- func (ta *TrackAttributes) MaxKey(key int) *TrackAttributes
- func (ta *TrackAttributes) MaxLiveness(liveness float64) *TrackAttributes
- func (ta *TrackAttributes) MaxLoudness(loudness float64) *TrackAttributes
- func (ta *TrackAttributes) MaxMode(mode int) *TrackAttributes
- func (ta *TrackAttributes) MaxPopularity(popularity int) *TrackAttributes
- func (ta *TrackAttributes) MaxSpeechiness(speechiness float64) *TrackAttributes
- func (ta *TrackAttributes) MaxTempo(tempo float64) *TrackAttributes
- func (ta *TrackAttributes) MaxTimeSignature(timeSignature int) *TrackAttributes
- func (ta *TrackAttributes) MaxValence(valence float64) *TrackAttributes
- func (ta *TrackAttributes) MinAcousticness(acousticness float64) *TrackAttributes
- func (ta *TrackAttributes) MinDanceability(danceability float64) *TrackAttributes
- func (ta *TrackAttributes) MinDuration(duration int) *TrackAttributes
- func (ta *TrackAttributes) MinEnergy(energy float64) *TrackAttributes
- func (ta *TrackAttributes) MinInstrumentalness(instrumentalness float64) *TrackAttributes
- func (ta *TrackAttributes) MinKey(key int) *TrackAttributes
- func (ta *TrackAttributes) MinLiveness(liveness float64) *TrackAttributes
- func (ta *TrackAttributes) MinLoudness(loudness float64) *TrackAttributes
- func (ta *TrackAttributes) MinMode(mode int) *TrackAttributes
- func (ta *TrackAttributes) MinPopularity(popularity int) *TrackAttributes
- func (ta *TrackAttributes) MinSpeechiness(speechiness float64) *TrackAttributes
- func (ta *TrackAttributes) MinTempo(tempo float64) *TrackAttributes
- func (ta *TrackAttributes) MinTimeSignature(timeSignature int) *TrackAttributes
- func (ta *TrackAttributes) MinValence(valence float64) *TrackAttributes
- func (ta *TrackAttributes) TargetAcousticness(acousticness float64) *TrackAttributes
- func (ta *TrackAttributes) TargetDanceability(danceability float64) *TrackAttributes
- func (ta *TrackAttributes) TargetDuration(duration int) *TrackAttributes
- func (ta *TrackAttributes) TargetEnergy(energy float64) *TrackAttributes
- func (ta *TrackAttributes) TargetInstrumentalness(instrumentalness float64) *TrackAttributes
- func (ta *TrackAttributes) TargetKey(key int) *TrackAttributes
- func (ta *TrackAttributes) TargetLiveness(liveness float64) *TrackAttributes
- func (ta *TrackAttributes) TargetLoudness(loudness float64) *TrackAttributes
- func (ta *TrackAttributes) TargetMode(mode int) *TrackAttributes
- func (ta *TrackAttributes) TargetPopularity(popularity int) *TrackAttributes
- func (ta *TrackAttributes) TargetSpeechiness(speechiness float64) *TrackAttributes
- func (ta *TrackAttributes) TargetTempo(tempo float64) *TrackAttributes
- func (ta *TrackAttributes) TargetTimeSignature(timeSignature int) *TrackAttributes
- func (ta *TrackAttributes) TargetValence(valence float64) *TrackAttributes
- type TrackToRemove
- type URI
- type User
Constants ¶
const ( AlbumTypeAlbum AlbumType = 1 << iota AlbumTypeSingle = 1 << iota AlbummTypeAppearsOn = 1 << iota AlbumTypeCompilation = 1 << iota )
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.
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" )
const ( // 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 acess 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" // ScopeUserReadBirthdate seeks read access to a user's birthdate. ScopeUserReadBirthdate = "user-read-birthdate" )
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.
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
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.
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" )
const ( // MarketFromToken can be used in place of the Market 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" )
const MaxNumberOfSeeds = 5
MaxNumberOfSeeds allowed by Spotify for a recommendation request
Variables ¶
var ( // DefaultClient is the default client that is used by the wrapper functions // that don't require authorization. If you need to authenticate, create // your own client with `Authenticator.NewClient`. DefaultClient = &Client{ http: new(http.Client), } )
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.
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) Exchange ¶
func (a Authenticator) Exchange(code string) (*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.
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 {
// contains filtered or unexported fields
}
Client is a client for working with the Spotify Web API. To create an authenticated client, use the `Authenticator.NewClient` method. If you don't need to authenticate, you can use `DefaultClient`.
func (*Client) AddTracksToLibrary ¶
AddTracksToLibrary saves one or more tracks to the current user's "Your Music" library. This call requires authorization (the ScopeUserLibraryModify scope). A track can only be saved once; duplicate IDs are ignored.
func (*Client) AddTracksToPlaylist ¶
func (c *Client) AddTracksToPlaylist(userID string, playlistID ID, trackIDs ...ID) (snapshotID string, err error)
AddTracksToPlaylist adds one or more tracks to a user's playlist. This call requires authorization (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 ¶
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) ChangePlaylistName ¶
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) ChangePlaylistNameAndAccess ¶
func (c *Client) ChangePlaylistNameAndAccess(userID string, 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 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.
This call requires authorization. Creating a public playlist for a user requires the ScopePlaylistModifyPublic scope; creating a private playlist requires the ScopePlaylistModifyPrivate scope.
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. This call requires authorization.
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 ¶
CurrentUserFollows checks to see if the current user is following one or more artists or other Spotify Users. This call requires authorization, and that the application has the ScopeUserFollowRead scope.
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 authorization, and 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. This call requires authorization. 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) 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 sorting and filtering the results.
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. This call requires authorization.
func (*Client) Follow ¶
Follow adds the current user as a follower of one or more artists or other spotify users, identified by their Spotify IDs. This call requires authorization.
Modifying the lists of artists or users the current user follows requires that the application has the ScopeUserFollowModify scope.
func (*Client) FollowPlaylist ¶
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) GetAlbum ¶
GetAlbum gets Spotify catalog information for a single album, given its Spotify ID.
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, limit, offset int) (*SimpleTrackPage, error)
GetAlbumTracksOpt behaves like GetAlbumTracks, with the exception that it allows you to specify extra parameters that limit the number of results returned. 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 reqeust the next set of results.
func (*Client) GetAlbums ¶
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) 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, t *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 type of album. Search for multiple types by OR-ing the types together.
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 ¶
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) 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 an error is thrown. This call requires authorization.
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). This call requires authorization.
func (*Client) GetCategoriesOpt ¶
func (c *Client) GetCategoriesOpt(opt *Options, locale string) (*CategoryPage, error)
GetCategoriesOpt is like GetCategories, but it accepts optional parameters. This call requires authorization.
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 ¶
GetCategory gets a single category used to tag items in Spotify (on, for example, the Spotify player's Browse tab). This call requires authorization.
func (*Client) GetCategoryOpt ¶
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 requries authorization.
func (*Client) GetCategoryPlaylists ¶
func (c *Client) GetCategoryPlaylists(catID string) (*SimplePlaylistPage, error)
GetCategoryPlaylists gets a list of Spotify playlists tagged with a paricular category. This call requires authorization.
func (*Client) GetCategoryPlaylistsOpt ¶
func (c *Client) GetCategoryPlaylistsOpt(catID string, opt *Options) (*SimplePlaylistPage, error)
GetCategoryPlaylistsOpt is like GetCategoryPlaylists, but it accepts optional arguments. This call requires authorization.
func (*Client) GetPlaylist ¶
func (c *Client) GetPlaylist(userID string, playlistID ID) (*FullPlaylist, error)
GetPlaylist gets a playlist owned by a Spotify user. This call requires authorization. Both public and private playlists belonging to any user are retrievable with a valid access token.
func (*Client) GetPlaylistOpt ¶
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(userID string, playlistID ID) (*PlaylistTrackPage, error)
GetPlaylistTracks gets full details of the tracks in a playlist, given the owner of the playlist and the playlist's Spotify ID. This call requires authorization.
func (*Client) GetPlaylistTracksOpt ¶
func (c *Client) GetPlaylistTracksOpt(userID string, playlistID ID, opt *Options, fields string) (*PlaylistTrackPage, error)
GetPlaylistTracksOpt is like GetPlaylistTracks, but it accepts optional parameters for sorting and filtering the results. This call requrles authorization.
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. This call requires authorization.
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 paramters 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 ¶
GetTrack gets Spotify catalog information for a single track identified by its unique Spotify ID.
func (*Client) GetTracks ¶
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.
func (*Client) GetUsersPublicProfile ¶
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) 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) 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) 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) 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) RemoveTracksFromLibrary ¶
RemoveTracksFromLibrary removes one or more tracks from the current user's "Your Music" library. This call requires authorization (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(userID string, 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(userID string, 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(userID, 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.
This call requires authorization. Rordering 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) ReplacePlaylistTracks ¶
ReplacePlaylistTracks replaces all of the tracks in a playlist, overwriting its exising tracks This can be useful for replacing or reordering tracks, or for clearing a playlist. This call requires authorization.
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 ¶
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.
Operators ¶
The operator NOT can be used to exclude results. For example, query = "roadhouse NOT blues" returns items that match "roadhouse" but exludes 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.
Wildcards ¶
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.
Field filters ¶
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) Unfollow ¶
Unfollow removes the current user as a follower of one or more artists or other Spotify users. This call requires authorization.
Modifying the lists of artists or users the current user follows requires that the application has the ScopeUserFollowModify scope.
func (*Client) UnfollowPlaylist ¶
UnfollowPlaylist removes the current user as a follower of a playlist. This call requires authorization. Unfollowing a publicly followed playlist requires the ScopePlaylistModifyPublic scope. Unfolowing a privately followed, playlist requies the ScopePlaylistModifyPrivate scope.
func (*Client) UserFollowsPlaylist ¶
func (c *Client) UserFollowsPlaylist(ownerID string, 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. This call requires authorization.
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.
type Copyright ¶
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 Cursor ¶
type Cursor struct {
After string `json:"after"`
}
Cursor contains a key that can be used to find the next set of items.
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.
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.
type FullAlbum ¶
type FullAlbum struct { SimpleAlbum Artists []SimpleArtist `json:"artists"` 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"` // 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"` Tracks SimpleTrackPage `json:"tracks"` ExternalIDs map[string]string `json:"external_ids"` }
FullAlbum provides extra album data in addition to the data provided by SimpleAlbum.
func (*FullAlbum) ReleaseDateTime ¶
ReleaseDateTime converts the album's ReleaseDate to a time.TimeValue. All of the fields in the result may not be valid. For example, if f.ReleaseDatePrecision is "month", then only the month and year (but not the day) of the result are valid.
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 // 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 GetArtist ¶
func GetArtist(id ID) (*FullArtist, error)
GetArtist is a wrapper around DefaultClient.GetArtist.
func GetArtists ¶
func GetArtists(ids ...ID) ([]*FullArtist, error)
GetArtists is a wrapper around DefaultClient.GetArtists.
func GetRelatedArtists ¶
func GetRelatedArtists(id ID) ([]FullArtist, error)
GetRelatedArtists is a wrapper around DefaultClient.GetRelatedArtists.
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 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"` }
FullTrack provides extra track data in addition to what is provided by SimpleTrack.
func GetArtistsTopTracks ¶
GetArtistsTopTracks is a wrapper around DefaultClient.GetArtistsTopTracks.
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.
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.
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 }
Options contains optional parameters that can be provided to various API calls. Only the non-nil fields are used in queries.
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 paramter 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"` // 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 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 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 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.
func Search ¶
func Search(query string, t SearchType) (*SearchResult, error)
Search is a wrapper around DefaultClient.Search.
func SearchOpt ¶
func SearchOpt(query string, t SearchType, opt *Options) (*SearchResult, error)
SearchOpt is a wrapper around DefaultClient.SearchOpt
type SearchType ¶
type SearchType int
SearchType represents the type of a query used in the Search function.
type Seeds ¶
Seeds contains IDs of artists, genres and/or tracks to be used as seeds for recommendations
type SimpleAlbum ¶
type SimpleAlbum struct { // The name of the album. Name string `json:"name"` // 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"` }
SimpleAlbum contains basic data about an album.
type SimpleAlbumPage ¶
type SimpleAlbumPage struct { Albums []SimpleAlbum `json:"items"` // contains filtered or unexported fields }
SimpleAlbumPage contains SimpleAlbums returned by the Web API.
func GetArtistAlbums ¶
func GetArtistAlbums(artistID ID) (*SimpleAlbumPage, error)
GetArtistAlbums is a wrapper around DefaultClient.GetArtistAlbums.
func GetArtistAlbumsOpt ¶
func GetArtistAlbumsOpt(artistID ID, options *Options, t *AlbumType) (*SimpleAlbumPage, error)
GetArtistAlbumsOpt is a wrapper around DefaultClient.GetArtistAlbumsOpt
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 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"` }
SimpleTrack contains basic info about a track.
func (*SimpleTrack) TimeDuration ¶
func (t *SimpleTrack) TimeDuration() time.Duration
TimeDuration returns the track's duration as a time.Duration value.
type SimpleTrackPage ¶
type SimpleTrackPage struct { Tracks []SimpleTrack `json:"items"` // contains filtered or unexported fields }
SimpleTrackPage contains SimpleTracks returned by the Web API.
func GetAlbumTracks ¶
func GetAlbumTracks(id ID) (*SimpleTrackPage, error)
GetAlbumTracks is a wrapper around DefaultClient.GetAlbumTracks.
func GetAlbumTracksOpt ¶
func GetAlbumTracksOpt(id ID, limit, offset int) (*SimpleTrackPage, error)
GetAlbumTracksOpt is a wrapper around DefaultClient.GetAlbumTracksOpt.
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 ¶
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.
func GetUsersPublicProfile ¶
GetUsersPublicProfile is a wrapper around DefaultClient.GetUsersPublicProfile.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
examples
|
|
authenticate
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. |