spotify

package module
Version: v0.0.0-...-eeceffb Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2017 License: Apache-2.0 Imports: 14 Imported by: 0

README

Spotify

GoDoc Build status Build Status

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/zmb3/spotify

Authentication

Most of the Web API functionality is available without authenticating. However, authenticated users benefit from increased rate limits.

Features that access a user's private data require authorization. All functions requiring authorization are explicitly marked as such in the godoc.

Spotify uses OAuth2 for authentication, which typically requires the user to login via a web browser. 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

Default Client

For API calls that require authorization, you should create your own spotify.Client using an Authenticator. For calls that don't require authorization, package level wrapper functions are provided (see spotify.Search for example)

These functions just proxy through spotify.DefaultClient, similar to the way the net/http package works.

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.

API Examples

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

Documentation

Overview

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

Index

Constants

View Source
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.

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 (
	// 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.

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 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"
)
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 (

	// 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),
	}
)
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.

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.

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.

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

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

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

func (c *Client) ChangePlaylistAccess(userID string, 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) ChangePlaylistName

func (c *Client) ChangePlaylistName(userID string, 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) 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

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

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. 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) GetAlbum

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

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

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

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) 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. This call requires authorization.

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

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). This call requires authorization.

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

func (c *Client) GetPlaylistOpt(userID string, 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(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

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

GetTrack gets Spotify catalog information for a single track identified by its unique Spotify ID.

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.

func (*Client) GetUserTopTracks

func (c *Client) GetUserTopTracks(opt *Options) (*UserTopTracks, error)

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

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

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

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 string, 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

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

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

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

UnfollowArtist removes the current user as a follower of one or more Spotify artists. 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

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

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

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

UnfollowUser removes the current user as a follower of one or more 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) 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.

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. This call requires authorization.

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.

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.

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 GetAlbums

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

GetAlbums is a wrapper around DefaultClient.GetAlbums.

func (*FullAlbum) ReleaseDateTime

func (f *FullAlbum) 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 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

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

GetArtistsTopTracks is a wrapper around DefaultClient.GetArtistsTopTracks.

func GetTrack

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

GetTrack is a wrapper around DefaultClient.GetTrack.

func GetTracks

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

GetTracks is a wrapper around DefaultClient.GetTracks.

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.

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

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(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

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 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"`
	Artists      []SimpleArtist    `json:"artists"`
}

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 {
	Album   SimpleAlbum    `json:"album"`
	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

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.

func GetUsersPublicProfile

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

GetUsersPublicProfile is a wrapper around DefaultClient.GetUsersPublicProfile.

type UserTopTracks

type UserTopTracks struct {
	Href  string `json:"href"`
	Items []struct {
		Album struct {
			AlbumType    string            `json:"album_type"`
			ExternalUrls map[string]string `json:"external_urls"`
			Href         string            `json:"href"`
			ID           ID                `json:"id"`
			Images       []Image           `json:"images"`
			Name         string            `json:"name"`
			Type         string            `json:"type"`
			URI          string            `json:"uri"`
		} `json:"album"`
		Artists []struct {
			ExternalUrls map[string]string `json:"external_urls"`
			Href         string            `json:"href"`
			ID           ID                `json:"id"`
			Name         string            `json:"name"`
			Type         string            `json:"type"`
			URI          string            `json:"uri"`
		} `json:"artists"`
		DiscNumber   int               `json:"disc_number"`
		DurationMs   int               `json:"duration_ms"`
		Explicit     bool              `json:"explicit"`
		ExternalIDs  map[string]string `json:"external_ids"`
		ExternalUrls map[string]string `json:"external_urls"`
		Href         string            `json:"href"`
		ID           ID                `json:"id"`
		IsPlayable   bool              `json:"is_playable"`
		Name         string            `json:"name"`
		Popularity   int               `json:"popularity"`
		PreviewURL   string            `json:"preview_url"`
		TrackNumber  int               `json:"track_number"`
		Type         string            `json:"type"`
		URI          string            `json:"uri"`
	} `json:"items"`
	Limit    int    `json:"limit"`
	Next     string `json:"next"`
	Offset   int    `json:"offset"`
	Previous string `json:"previous"`
	Total    int    `json:"total"`
}

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL