Documentation ¶
Overview ¶
Package spotify provides utilities for interfacing with Spotify's Web API.
Index ¶
- Constants
- Variables
- type AdditionalType
- type AlbumType
- type AnalysisMeta
- type AnalysisTrack
- type AudioAnalysis
- type AudioFeatures
- type Category
- type CategoryPage
- type Client
- func (c *Client) AddAlbumsToLibrary(ctx context.Context, ids ...ID) error
- func (c *Client) AddTracksToLibrary(ctx context.Context, ids ...ID) error
- func (c *Client) AddTracksToPlaylist(ctx context.Context, playlistID ID, trackIDs ...ID) (snapshotID string, err error)
- func (c *Client) ChangePlaylistAccess(ctx context.Context, playlistID ID, public bool) error
- func (c *Client) ChangePlaylistDescription(ctx context.Context, playlistID ID, newDescription string) error
- func (c *Client) ChangePlaylistName(ctx context.Context, playlistID ID, newName string) error
- func (c *Client) ChangePlaylistNameAccessAndDescription(ctx context.Context, playlistID ID, newName, newDescription string, ...) error
- func (c *Client) ChangePlaylistNameAndAccess(ctx context.Context, playlistID ID, newName string, public bool) error
- func (c *Client) CreatePlaylistForUser(ctx context.Context, userID, playlistName, description string, public bool, ...) (*FullPlaylist, error)
- func (c *Client) CurrentUser(ctx context.Context) (*PrivateUser, error)
- func (c *Client) CurrentUserFollows(ctx context.Context, t string, ids ...ID) ([]bool, error)
- func (c *Client) CurrentUsersAlbums(ctx context.Context, opts ...RequestOption) (*SavedAlbumPage, error)
- func (c *Client) CurrentUsersFollowedArtists(ctx context.Context, opts ...RequestOption) (*FullArtistCursorPage, error)
- func (c *Client) CurrentUsersPlaylists(ctx context.Context, opts ...RequestOption) (*SimplePlaylistPage, error)
- func (c *Client) CurrentUsersShows(ctx context.Context, opts ...RequestOption) (*SavedShowPage, error)
- func (c *Client) CurrentUsersTopArtists(ctx context.Context, opts ...RequestOption) (*FullArtistPage, error)
- func (c *Client) CurrentUsersTopTracks(ctx context.Context, opts ...RequestOption) (*FullTrackPage, error)
- func (c *Client) CurrentUsersTracks(ctx context.Context, opts ...RequestOption) (*SavedTrackPage, error)
- func (c *Client) FeaturedPlaylists(ctx context.Context, opts ...RequestOption) (message string, playlists *SimplePlaylistPage, e error)
- func (c *Client) FollowArtist(ctx context.Context, ids ...ID) error
- func (c *Client) FollowPlaylist(ctx context.Context, playlist ID, public bool) error
- func (c *Client) FollowUser(ctx context.Context, ids ...ID) error
- func (c *Client) GetAlbum(ctx context.Context, id ID, opts ...RequestOption) (*FullAlbum, error)
- func (c *Client) GetAlbumTracks(ctx context.Context, id ID, opts ...RequestOption) (*SimpleTrackPage, error)
- func (c *Client) GetAlbums(ctx context.Context, ids []ID, opts ...RequestOption) ([]*FullAlbum, error)
- func (c *Client) GetArtist(ctx context.Context, id ID) (*FullArtist, error)
- func (c *Client) GetArtistAlbums(ctx context.Context, artistID ID, ts []AlbumType, opts ...RequestOption) (*SimpleAlbumPage, error)
- func (c *Client) GetArtists(ctx context.Context, ids ...ID) ([]*FullArtist, error)
- func (c *Client) GetArtistsTopTracks(ctx context.Context, artistID ID, country string) ([]FullTrack, error)
- func (c *Client) GetAudioAnalysis(ctx context.Context, id ID) (*AudioAnalysis, error)
- func (c *Client) GetAudioFeatures(ctx context.Context, ids ...ID) ([]*AudioFeatures, error)
- func (c *Client) GetAvailableGenreSeeds(ctx context.Context) ([]string, error)
- func (c *Client) GetCategories(ctx context.Context, opts ...RequestOption) (*CategoryPage, error)
- func (c *Client) GetCategory(ctx context.Context, id string, opts ...RequestOption) (Category, error)
- func (c *Client) GetCategoryPlaylists(ctx context.Context, catID string, opts ...RequestOption) (*SimplePlaylistPage, error)
- func (c *Client) GetEpisode(ctx context.Context, id string, opts ...RequestOption) (*EpisodePage, error)
- func (c *Client) GetPlaylist(ctx context.Context, playlistID ID, opts ...RequestOption) (*FullPlaylist, error)
- func (c *Client) GetPlaylistItems(ctx context.Context, playlistID ID, opts ...RequestOption) (*PlaylistItemPage, error)
- func (c *Client) GetPlaylistTracks(ctx context.Context, playlistID ID, opts ...RequestOption) (*PlaylistTrackPage, error)deprecated
- func (c *Client) GetPlaylistsForUser(ctx context.Context, userID string, opts ...RequestOption) (*SimplePlaylistPage, error)
- func (c *Client) GetQueue(ctx context.Context) (*Queue, error)
- func (c *Client) GetRecommendations(ctx context.Context, seeds Seeds, trackAttributes *TrackAttributes, ...) (*Recommendations, error)
- func (c *Client) GetRelatedArtists(ctx context.Context, id ID) ([]FullArtist, error)
- func (c *Client) GetShow(ctx context.Context, id ID, opts ...RequestOption) (*FullShow, error)
- func (c *Client) GetShowEpisodes(ctx context.Context, id string, opts ...RequestOption) (*SimpleEpisodePage, error)
- func (c *Client) GetTrack(ctx context.Context, id ID, opts ...RequestOption) (*FullTrack, error)
- func (c *Client) GetTracks(ctx context.Context, ids []ID, opts ...RequestOption) ([]*FullTrack, error)
- func (c *Client) GetUsersPublicProfile(ctx context.Context, userID ID) (*User, error)
- func (c *Client) NewReleases(ctx context.Context, opts ...RequestOption) (albums *SimpleAlbumPage, err error)
- func (c *Client) Next(ctx context.Context) error
- func (c *Client) NextAlbumResults(ctx context.Context, s *SearchResult) error
- func (c *Client) NextArtistResults(ctx context.Context, s *SearchResult) error
- func (c *Client) NextEpisodeResults(ctx context.Context, s *SearchResult) error
- func (c *Client) NextOpt(ctx context.Context, opt *PlayOptions) error
- func (c *Client) NextPage(ctx context.Context, p pageable) error
- func (c *Client) NextPlaylistResults(ctx context.Context, s *SearchResult) error
- func (c *Client) NextShowResults(ctx context.Context, s *SearchResult) error
- func (c *Client) NextTrackResults(ctx context.Context, s *SearchResult) error
- func (c *Client) Pause(ctx context.Context) error
- func (c *Client) PauseOpt(ctx context.Context, opt *PlayOptions) error
- func (c *Client) Play(ctx context.Context) error
- func (c *Client) PlayOpt(ctx context.Context, opt *PlayOptions) error
- func (c *Client) PlayerCurrentlyPlaying(ctx context.Context, opts ...RequestOption) (*CurrentlyPlaying, error)
- func (c *Client) PlayerDevices(ctx context.Context) ([]PlayerDevice, error)
- func (c *Client) PlayerRecentlyPlayed(ctx context.Context) ([]RecentlyPlayedItem, error)
- func (c *Client) PlayerRecentlyPlayedOpt(ctx context.Context, opt *RecentlyPlayedOptions) ([]RecentlyPlayedItem, error)
- func (c *Client) PlayerState(ctx context.Context, opts ...RequestOption) (*PlayerState, error)
- func (c *Client) Previous(ctx context.Context) error
- func (c *Client) PreviousAlbumResults(ctx context.Context, s *SearchResult) error
- func (c *Client) PreviousArtistResults(ctx context.Context, s *SearchResult) error
- func (c *Client) PreviousEpisodeResults(ctx context.Context, s *SearchResult) error
- func (c *Client) PreviousOpt(ctx context.Context, opt *PlayOptions) error
- func (c *Client) PreviousPage(ctx context.Context, p pageable) error
- func (c *Client) PreviousPlaylistResults(ctx context.Context, s *SearchResult) error
- func (c *Client) PreviousShowResults(ctx context.Context, s *SearchResult) error
- func (c *Client) PreviousTrackResults(ctx context.Context, s *SearchResult) error
- func (c *Client) QueueSong(ctx context.Context, trackID ID) error
- func (c *Client) QueueSongOpt(ctx context.Context, trackID ID, opt *PlayOptions) error
- func (c *Client) RemoveAlbumsFromLibrary(ctx context.Context, ids ...ID) error
- func (c *Client) RemoveTracksFromLibrary(ctx context.Context, ids ...ID) error
- func (c *Client) RemoveTracksFromPlaylist(ctx context.Context, playlistID ID, trackIDs ...ID) (newSnapshotID string, err error)
- func (c *Client) RemoveTracksFromPlaylistOpt(ctx context.Context, playlistID ID, tracks []TrackToRemove, snapshotID string) (newSnapshotID string, err error)
- func (c *Client) ReorderPlaylistTracks(ctx context.Context, playlistID ID, opt PlaylistReorderOptions) (snapshotID string, err error)
- func (c *Client) Repeat(ctx context.Context, state string) error
- func (c *Client) RepeatOpt(ctx context.Context, state string, opt *PlayOptions) error
- func (c *Client) ReplacePlaylistItems(ctx context.Context, playlistID ID, items ...URI) (string, error)
- func (c *Client) ReplacePlaylistTracks(ctx context.Context, playlistID ID, trackIDs ...ID) error
- func (c *Client) SaveShowsForCurrentUser(ctx context.Context, ids []ID) error
- func (c *Client) Search(ctx context.Context, query string, t SearchType, opts ...RequestOption) (*SearchResult, error)
- func (c *Client) Seek(ctx context.Context, position int) error
- func (c *Client) SeekOpt(ctx context.Context, position int, opt *PlayOptions) error
- func (c *Client) SetPlaylistImage(ctx context.Context, playlistID ID, img io.Reader) error
- func (c *Client) Shuffle(ctx context.Context, shuffle bool) error
- func (c *Client) ShuffleOpt(ctx context.Context, shuffle bool, opt *PlayOptions) error
- func (c *Client) Token() (*oauth2.Token, error)
- func (c *Client) TransferPlayback(ctx context.Context, deviceID ID, play bool) error
- func (c *Client) UnfollowArtist(ctx context.Context, ids ...ID) error
- func (c *Client) UnfollowPlaylist(ctx context.Context, playlist ID) error
- func (c *Client) UnfollowUser(ctx context.Context, ids ...ID) error
- func (c *Client) UserFollowsPlaylist(ctx context.Context, playlistID ID, userIDs ...string) ([]bool, error)
- func (c *Client) UserHasAlbums(ctx context.Context, ids ...ID) ([]bool, error)
- func (c *Client) UserHasTracks(ctx context.Context, ids ...ID) ([]bool, error)
- func (c *Client) Volume(ctx context.Context, percent int) error
- func (c *Client) VolumeOpt(ctx context.Context, percent int, opt *PlayOptions) error
- type ClientOption
- type Copyright
- type CurrentlyPlaying
- type Cursor
- type EpisodePage
- type Error
- type Followers
- type FullAlbum
- type FullArtist
- type FullArtistCursorPage
- type FullArtistPage
- type FullPlaylist
- type FullShow
- type FullTrack
- type FullTrackPage
- type ID
- type Image
- type Key
- type LinkedFromInfo
- type Marker
- type Mode
- type Numeric
- type PlayOptions
- type PlaybackContext
- type PlaybackOffset
- type PlayerDevice
- type PlayerState
- type PlaylistItem
- type PlaylistItemPage
- type PlaylistItemTrack
- type PlaylistReorderOptions
- type PlaylistTrack
- type PlaylistTrackPage
- type PlaylistTracks
- type PrivateUser
- type Queue
- type Range
- type RecentlyPlayedItem
- type RecentlyPlayedOptions
- type RecentlyPlayedResult
- type RecommendationSeed
- type Recommendations
- type RequestOption
- func AdditionalTypes(types ...AdditionalType) RequestOption
- func After(after string) RequestOption
- func Country(code string) RequestOption
- func Fields(fields string) RequestOption
- func Limit(amount int) RequestOption
- func Locale(code string) RequestOption
- func Market(code string) RequestOption
- func Offset(amount int) RequestOption
- func Timerange(timerange Range) RequestOption
- func Timestamp(ts string) RequestOption
- type ResumePointObject
- type SavedAlbum
- type SavedAlbumPage
- type SavedShow
- type SavedShowPage
- type SavedTrack
- type SavedTrackPage
- type SearchResult
- type SearchType
- type Section
- type Seeds
- type Segment
- type SimpleAlbum
- type SimpleAlbumPage
- type SimpleArtist
- type SimpleEpisodePage
- type SimplePlaylist
- type SimplePlaylistPage
- type SimpleShow
- type SimpleShowPage
- 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 TrackExternalIDs
- type TrackToRemove
- type URI
- type User
Constants ¶
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 ( EpisodeAdditionalType = "episode" TrackAdditionalType = "track" )
const ( SearchTypeAlbum SearchType = 1 << iota SearchTypeArtist = 1 << iota SearchTypePlaylist = 1 << iota SearchTypeTrack = 1 << iota SearchTypeShow = 1 << iota SearchTypeEpisode = 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 Options.Country parameter // if the Client has a valid access token. In this case, the // results will be limited to content that is playable in the // country associated with the user's account. The user must have // granted access to the user-read-private scope when the access // token was issued. MarketFromToken = "from_token" )
const MaxNumberOfSeeds = 5
MaxNumberOfSeeds allowed by Spotify for a recommendation request
const Version = "1.0.0"
Version is the version of this library.
Variables ¶
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 AdditionalType ¶ added in v2.1.0
type AdditionalType string
type AlbumType ¶
type AlbumType int
AlbumType represents the type of an album. It can be used to filter results when searching for albums.
type AnalysisMeta ¶
type AnalysisMeta struct { AnalyzerVersion string `json:"analyzer_version"` Platform string `json:"platform"` DetailedStatus string `json:"detailed_status"` StatusCode int `json:"status"` Timestamp int64 `json:"timestamp"` AnalysisTime float64 `json:"analysis_time"` InputProcess string `json:"input_process"` }
AnalysisMeta describes details about Spotify's audio analysis of the track
type AnalysisTrack ¶
type AnalysisTrack struct { NumSamples int64 `json:"num_samples"` Duration float64 `json:"duration"` SampleMD5 string `json:"sample_md5"` OffsetSeconds Numeric `json:"offset_seconds"` WindowSeconds Numeric `json:"window_seconds"` AnalysisSampleRate int64 `json:"analysis_sample_rate"` AnalysisChannels Numeric `json:"analysis_channels"` EndOfFadeIn float64 `json:"end_of_fade_in"` StartOfFadeOut float64 `json:"start_of_fade_out"` Loudness float64 `json:"loudness"` Tempo float64 `json:"tempo"` TempoConfidence float64 `json:"tempo_confidence"` TimeSignature Numeric `json:"time_signature"` TimeSignatureConfidence float64 `json:"time_signature_confidence"` Key Key `json:"key"` KeyConfidence float64 `json:"key_confidence"` Mode Mode `json:"mode"` ModeConfidence float64 `json:"mode_confidence"` CodeString string `json:"codestring"` CodeVersion float64 `json:"code_version"` EchoprintString string `json:"echoprintstring"` EchoprintVersion float64 `json:"echoprint_version"` SynchString string `json:"synchstring"` SynchVersion float64 `json:"synch_version"` RhythmString string `json:"rhythmstring"` RhythmVersion float64 `json:"rhythm_version"` }
AnalysisTrack contains audio analysis data about the track as a whole
type AudioAnalysis ¶
type AudioAnalysis struct { Bars []Marker `json:"bars"` Beats []Marker `json:"beats"` Meta AnalysisMeta `json:"meta"` Sections []Section `json:"sections"` Segments []Segment `json:"segments"` Tatums []Marker `json:"tatums"` Track AnalysisTrack `json:"track"` }
AudioAnalysis contains a detailed audio analysis for a single track identified by its unique Spotify ID. See: https://developer.spotify.com/web-api/get-audio-analysis/
type AudioFeatures ¶
type AudioFeatures struct { // Acousticness is a confidence measure from 0.0 to 1.0 of whether // the track is acoustic. A value of 1.0 represents high confidence // that the track is acoustic. Acousticness float32 `json:"acousticness"` // An HTTP URL to access the full audio analysis of the track. // The URL is cryptographically signed and configured to expire // after roughly 10 minutes. Do not store these URLs for later use. AnalysisURL string `json:"analysis_url"` // Danceability describes how suitable a track is for dancing based // on a combination of musical elements including tempo, rhythm stability, // beat strength, and overall regularity. A value of 0.0 is least danceable // and 1.0 is most danceable. Danceability float32 `json:"danceability"` // The length of the track in milliseconds. Duration Numeric `json:"duration_ms"` // Energy is a measure from 0.0 to 1.0 and represents a perceptual measure // 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 Numeric `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 likelihood 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 Numeric `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 Numeric `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 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. It is best to create this using spotify.New()
func New ¶
func New(httpClient *http.Client, opts ...ClientOption) *Client
New returns a client for working with the Spotify Web API. The provided httpClient must provide Authentication with the requests. The auth package may be used to generate a suitable client.
func (*Client) AddAlbumsToLibrary ¶
AddAlbumsToLibrary saves one or more albums to the current user's "Your Albums" library. This call requires the ScopeUserLibraryModify scope. A track can only be saved once; duplicate IDs are ignored.
func (*Client) AddTracksToLibrary ¶
AddTracksToLibrary saves one or more tracks to the current user's "Your Music" library. This call requires the ScopeUserLibraryModify scope. A track can only be saved once; duplicate IDs are ignored.
func (*Client) AddTracksToPlaylist ¶
func (c *Client) AddTracksToPlaylist(ctx context.Context, playlistID ID, trackIDs ...ID) (snapshotID string, err error)
AddTracksToPlaylist adds one or more tracks to a user's playlist. This call requires ScopePlaylistModifyPublic or ScopePlaylistModifyPrivate. A maximum of 100 tracks can be added per call. It returns a snapshot ID that can be used to identify this version (the new version) of the playlist in future requests.
func (*Client) ChangePlaylistAccess ¶
ChangePlaylistAccess modifies the public/private status of a playlist. This call requires that the user has authorized the ScopePlaylistModifyPublic or ScopePlaylistModifyPrivate scopes (depending on whether the playlist is currently public or private). The current user must own the playlist in order to modify it.
func (*Client) ChangePlaylistDescription ¶
func (c *Client) ChangePlaylistDescription(ctx context.Context, playlistID ID, newDescription string) error
ChangePlaylistDescription modifies the description of a playlist. This call requires that the user has authorized the ScopePlaylistModifyPublic or ScopePlaylistModifyPrivate scopes (depending on whether the playlist is currently public or private). The current user must own the playlist in order to modify it.
func (*Client) ChangePlaylistName ¶
ChangePlaylistName changes the name of a playlist. This call requires that the user has authorized the ScopePlaylistModifyPublic or ScopePlaylistModifyPrivate scopes (depending on whether the playlist is public or private). The current user must own the playlist in order to modify it.
func (*Client) ChangePlaylistNameAccessAndDescription ¶
func (c *Client) ChangePlaylistNameAccessAndDescription(ctx context.Context, playlistID ID, newName, newDescription string, public bool) error
ChangePlaylistNameAccessAndDescription combines ChangePlaylistName, ChangePlaylistAccess, and ChangePlaylistDescription into a single Web API call. It requires that the user has authorized the ScopePlaylistModifyPublic or ScopePlaylistModifyPrivate scopes (depending on whether the playlist is currently public or private). The current user must own the playlist in order to modify it.
func (*Client) ChangePlaylistNameAndAccess ¶
func (c *Client) ChangePlaylistNameAndAccess(ctx context.Context, 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(ctx context.Context, userID, playlistName, description string, public bool, collaborative bool) (*FullPlaylist, error)
CreatePlaylistForUser creates a playlist for a Spotify user. The playlist will be empty until you add tracks to it. The playlistName does not need to be unique - a user can have several playlists with the same name.
Creating a public playlist for a user requires ScopePlaylistModifyPublic; creating a private playlist requires ScopePlaylistModifyPrivate.
On success, the newly created playlist is returned.
func (*Client) CurrentUser ¶
func (c *Client) CurrentUser(ctx context.Context) (*PrivateUser, error)
CurrentUser gets detailed profile information about the current user.
Reading the user's email address requires that the application has the ScopeUserReadEmail scope. Reading the country, display name, profile images, and product subscription level requires that the application has the ScopeUserReadPrivate scope.
Warning: The email address in the response will be the address that was entered when the user created their spotify account. This email address is unverified - do not assume that Spotify has checked that the email address actually belongs to the user.
func (*Client) CurrentUserFollows ¶
CurrentUserFollows checks to see if the current user is following one or more artists or other Spotify Users. This call requires ScopeUserFollowRead.
The t argument indicates the type of the IDs, and must be either "user" or "artist".
The result is returned as a slice of bool values in the same order in which the IDs were specified.
func (*Client) CurrentUsersAlbums ¶
func (c *Client) CurrentUsersAlbums(ctx context.Context, opts ...RequestOption) (*SavedAlbumPage, error)
CurrentUsersAlbums gets a list of albums saved in the current Spotify user's "Your Music" library.
Supported options: Market, Limit, Offset
func (*Client) CurrentUsersFollowedArtists ¶
func (c *Client) CurrentUsersFollowedArtists(ctx context.Context, opts ...RequestOption) (*FullArtistCursorPage, error)
CurrentUsersFollowedArtists gets the current user's followed artists. This call requires that the user has granted the ScopeUserFollowRead scope. Supported options: Limit, After
func (*Client) CurrentUsersPlaylists ¶
func (c *Client) CurrentUsersPlaylists(ctx context.Context, opts ...RequestOption) (*SimplePlaylistPage, error)
CurrentUsersPlaylists gets a list of the playlists owned or followed by the current spotify user.
Private playlists require the ScopePlaylistReadPrivate scope. Note that this scope alone will not return collaborative playlists, even though they are always private. In order to retrieve collaborative playlists the user must authorize the ScopePlaylistReadCollaborative scope.
Supported options: Limit, Offset
func (*Client) CurrentUsersShows ¶
func (c *Client) CurrentUsersShows(ctx context.Context, opts ...RequestOption) (*SavedShowPage, error)
CurrentUsersShows gets a list of shows saved in the current Spotify user's "Your Music" library.
API Doc: https://developer.spotify.com/documentation/web-api/reference-beta/#endpoint-get-users-saved-shows
Supported options: Limit, Offset
func (*Client) CurrentUsersTopArtists ¶
func (c *Client) CurrentUsersTopArtists(ctx context.Context, opts ...RequestOption) (*FullArtistPage, error)
CurrentUsersTopArtists fetches a list of the user's top artists over the specified Timerange. The default is medium term.
Supported options: Limit, Timerange
func (*Client) CurrentUsersTopTracks ¶
func (c *Client) CurrentUsersTopTracks(ctx context.Context, opts ...RequestOption) (*FullTrackPage, error)
CurrentUsersTopTracks fetches the user's top tracks over the specified Timerange sensible defaults. The default limit is 20 and the default timerange is medium_term. This call requires ScopeUserTopRead.
Supported options: Limit, Timerange, Offset
func (*Client) CurrentUsersTracks ¶
func (c *Client) CurrentUsersTracks(ctx context.Context, opts ...RequestOption) (*SavedTrackPage, error)
CurrentUsersTracks gets a list of songs saved in the current Spotify user's "Your Music" library.
API Doc: https://developer.spotify.com/documentation/web-api/reference-beta/#endpoint-get-users-saved-tracks
Supported options: Limit, Country, Offset
func (*Client) FeaturedPlaylists ¶
func (c *Client) FeaturedPlaylists(ctx context.Context, opts ...RequestOption) (message string, playlists *SimplePlaylistPage, e error)
FeaturedPlaylistsOpt gets a list of playlists featured by Spotify. Supported options: Locale, Country, Timestamp, Limit, Offset
func (*Client) FollowArtist ¶
FollowArtist adds the current user as a follower of one or more spotify artists, identified by their Spotify IDs.
Modifying the lists of artists or users the current user follows requires that the application has the ScopeUserFollowModify scope.
func (*Client) FollowPlaylist ¶
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 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 ¶
FollowUser adds the current user as a follower of one or more spotify users, identified by their Spotify IDs.
Modifying the lists of artists or users the current user follows requires that the application has the ScopeUserFollowModify scope.
func (*Client) GetAlbum ¶
GetAlbum gets Spotify catalog information for a single album, given its Spotify ID. Supported options: Market
func (*Client) GetAlbumTracks ¶
func (c *Client) GetAlbumTracks(ctx context.Context, id ID, opts ...RequestOption) (*SimpleTrackPage, error)
GetAlbumTracks gets the tracks for a particular album. If you only care about the tracks, this call is more efficient than GetAlbum.
Supported Options: Market, Limit, Offset
func (*Client) GetAlbums ¶
func (c *Client) GetAlbums(ctx context.Context, ids []ID, opts ...RequestOption) ([]*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.
Doc API: https://developer.spotify.com/documentation/web-api/reference/albums/get-several-albums/
Supported options: Market
func (*Client) GetArtist ¶
GetArtist gets Spotify catalog information for a single artist, given its Spotify ID.
func (*Client) GetArtistAlbums ¶
func (c *Client) GetArtistAlbums(ctx context.Context, artistID ID, ts []AlbumType, opts ...RequestOption) (*SimpleAlbumPage, error)
GetArtistAlbums gets Spotify catalog information about an artist's albums. It is equivalent to GetArtistAlbumsOpt(artistID, nil).
The AlbumType argument can be used to find a particular types of album. If the Market is not specified, Spotify will likely return a lot of duplicates (one for each market in which the album is available
Supported options: Market
func (*Client) GetArtists ¶
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(ctx context.Context, artistID ID, country string) ([]FullTrack, error)
GetArtistsTopTracks gets Spotify catalog information about an artist's top tracks in a particular country. It returns a maximum of 10 tracks. The country is specified as an ISO 3166-1 alpha-2 country code.
func (*Client) GetAudioAnalysis ¶
GetAudioAnalysis queries the Spotify web API for an audio analysis of a single track.
func (*Client) GetAudioFeatures ¶
GetAudioFeatures queries the Spotify Web API for various high-level acoustic attributes of audio tracks. Objects are returned in the order requested. If an object is not found, a nil value is returned in the appropriate position.
func (*Client) GetAvailableGenreSeeds ¶
GetAvailableGenreSeeds retrieves a list of available genres seed parameter values for recommendations.
func (*Client) GetCategories ¶
func (c *Client) GetCategories(ctx context.Context, opts ...RequestOption) (*CategoryPage, error)
GetCategories gets a list of categories used to tag items in Spotify
Supported options: Country, Locale, Limit, Offset
func (*Client) GetCategory ¶
func (c *Client) GetCategory(ctx context.Context, id string, opts ...RequestOption) (Category, error)
GetCategory gets a single category used to tag items in Spotify.
Supported options: Country, Locale
func (*Client) GetCategoryPlaylists ¶
func (c *Client) GetCategoryPlaylists(ctx context.Context, catID string, opts ...RequestOption) (*SimplePlaylistPage, error)
GetCategoryPlaylists gets a list of Spotify playlists tagged with a particular category. Supported options: Country, Limit, Offset
func (*Client) GetEpisode ¶ added in v2.4.0
func (c *Client) GetEpisode(ctx context.Context, id string, opts ...RequestOption) (*EpisodePage, error)
GetEpisode gets an episode from a show. API reference: https://developer.spotify.com/documentation/web-api/reference/get-an-episode
func (*Client) GetPlaylist ¶
func (c *Client) GetPlaylist(ctx context.Context, playlistID ID, opts ...RequestOption) (*FullPlaylist, error)
GetPlaylist fetches a playlist from spotify. Supported options: Fields
func (*Client) GetPlaylistItems ¶ added in v2.1.0
func (c *Client) GetPlaylistItems(ctx context.Context, playlistID ID, opts ...RequestOption) (*PlaylistItemPage, error)
GetPlaylistItems gets full details of the items in a playlist, given the playlist's Spotify ID.
Supported options: Limit, Offset, Market, Fields
func (*Client) GetPlaylistTracks
deprecated
func (c *Client) GetPlaylistTracks( ctx context.Context, playlistID ID, opts ...RequestOption, ) (*PlaylistTrackPage, error)
GetPlaylistTracks gets full details of the tracks in a playlist, given the playlist's Spotify ID.
Supported options: Limit, Offset, Market, Fields
Deprecated: the Spotify api is moving towards supporting both tracks and episodes. Use GetPlaylistItems which supports these.
func (*Client) GetPlaylistsForUser ¶
func (c *Client) GetPlaylistsForUser(ctx context.Context, userID string, opts ...RequestOption) (*SimplePlaylistPage, error)
GetPlaylistsForUser gets a list of the playlists owned or followed by a particular Spotify user.
Private playlists and collaborative playlists are only retrievable for the current user. In order to read private playlists, the user must have granted the ScopePlaylistReadPrivate scope. Note that this scope alone will not return collaborative playlists, even though they are always private. In order to read collaborative playlists, the user must have granted the ScopePlaylistReadCollaborative scope.
Supported options: Limit, Offset
func (*Client) GetQueue ¶ added in v2.3.1
GetQueue gets the user's queue on the user's currently active device. This call requires ScopeUserReadPlaybackState
func (*Client) GetRecommendations ¶
func (c *Client) GetRecommendations(ctx context.Context, seeds Seeds, trackAttributes *TrackAttributes, opts ...RequestOption) (*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.
Supported options: Limit, Country
func (*Client) GetRelatedArtists ¶
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) GetShow ¶
GetShow retrieves information about a specific show. API reference: https://developer.spotify.com/documentation/web-api/reference/#endpoint-get-a-show Supported options: Market
func (*Client) GetShowEpisodes ¶
func (c *Client) GetShowEpisodes(ctx context.Context, id string, opts ...RequestOption) (*SimpleEpisodePage, error)
GetShowEpisodes retrieves paginated episode information about a specific show. API reference: https://developer.spotify.com/documentation/web-api/reference/#endpoint-get-a-shows-episodes Supported options: Market, Limit, Offset
func (*Client) GetTrack ¶
GetTrack gets Spotify catalog information for a single track identified by its unique Spotify ID.
API Doc: https://developer.spotify.com/documentation/web-api/reference/tracks/get-track/
Supported options: Market
func (*Client) GetTracks ¶
func (c *Client) GetTracks(ctx context.Context, ids []ID, opts ...RequestOption) ([]*FullTrack, error)
GetTracks gets Spotify catalog information for multiple tracks based on their Spotify IDs. It supports up to 50 tracks in a single call. Tracks are returned in the order requested. If a track is not found, that position in the result will be nil. Duplicate ids in the query will result in duplicate tracks in the result.
API Doc: https://developer.spotify.com/documentation/web-api/reference/tracks/get-several-tracks/
Supported options: Market
func (*Client) GetUsersPublicProfile ¶
GetUsersPublicProfile gets public profile information about a Spotify User. It does not require authentication.
func (*Client) NewReleases ¶
func (c *Client) NewReleases(ctx context.Context, opts ...RequestOption) (albums *SimpleAlbumPage, err error)
NewReleases gets a list of new album releases featured in Spotify. Supported options: Country, Limit, Offset
func (*Client) Next ¶
Next skips to the next track in the user's queue in the user's currently active device. This call requires ScopeUserModifyPlaybackState in order to modify the player state
func (*Client) NextAlbumResults ¶
func (c *Client) NextAlbumResults(ctx context.Context, s *SearchResult) error
NextAlbumResults loads the next page of albums into the specified search result.
func (*Client) NextArtistResults ¶
func (c *Client) NextArtistResults(ctx context.Context, s *SearchResult) error
NextArtistResults loads the next page of artists into the specified search result.
func (*Client) NextEpisodeResults ¶ added in v2.3.0
func (c *Client) NextEpisodeResults(ctx context.Context, s *SearchResult) error
NextEpisodeResults loads the next page of episodes into the specified search result.
func (*Client) NextOpt ¶
func (c *Client) NextOpt(ctx context.Context, opt *PlayOptions) error
NextOpt is like Next but with more options
Only expects PlayOptions.DeviceID, all other options will be ignored
func (*Client) NextPage ¶
NextPage fetches the next page of items and writes them into p. It returns ErrNoMorePages if p already contains the last page.
func (*Client) NextPlaylistResults ¶
func (c *Client) NextPlaylistResults(ctx context.Context, s *SearchResult) error
NextPlaylistResults loads the next page of playlists into the specified search result.
func (*Client) NextShowResults ¶ added in v2.3.0
func (c *Client) NextShowResults(ctx context.Context, s *SearchResult) error
NextShowResults loads the next page of shows into the specified search result.
func (*Client) NextTrackResults ¶
func (c *Client) NextTrackResults(ctx context.Context, s *SearchResult) error
NextTrackResults loads the next page of tracks into the specified search result.
func (*Client) Pause ¶
Pause Playback on the user's currently active device.
Requires the ScopeUserModifyPlaybackState in order to modify the player state
func (*Client) PauseOpt ¶
func (c *Client) PauseOpt(ctx context.Context, opt *PlayOptions) error
PauseOpt is like Pause but with more options
Only expects PlayOptions.DeviceID, all other options will be ignored
func (*Client) Play ¶
Play Start a new context or resume current playback on the user's active device. This call requires ScopeUserModifyPlaybackState in order to modify the player state.
func (*Client) PlayOpt ¶
func (c *Client) PlayOpt(ctx context.Context, opt *PlayOptions) error
PlayOpt is like Play but with more options
func (*Client) PlayerCurrentlyPlaying ¶
func (c *Client) PlayerCurrentlyPlaying(ctx context.Context, opts ...RequestOption) (*CurrentlyPlaying, error)
PlayerCurrentlyPlaying gets information about the currently playing status for the current user.
Requires the ScopeUserReadCurrentlyPlaying scope or the ScopeUserReadPlaybackState scope in order to read information
Supported options: Market
func (*Client) PlayerDevices ¶
func (c *Client) PlayerDevices(ctx context.Context) ([]PlayerDevice, error)
PlayerDevices information about available devices for the current user.
Requires the ScopeUserReadPlaybackState scope in order to read information
func (*Client) PlayerRecentlyPlayed ¶
func (c *Client) PlayerRecentlyPlayed(ctx context.Context) ([]RecentlyPlayedItem, error)
PlayerRecentlyPlayed gets a list of recently-played tracks for the current user. This call requires ScopeUserReadRecentlyPlayed.
func (*Client) PlayerRecentlyPlayedOpt ¶
func (c *Client) PlayerRecentlyPlayedOpt(ctx context.Context, opt *RecentlyPlayedOptions) ([]RecentlyPlayedItem, error)
PlayerRecentlyPlayedOpt is like PlayerRecentlyPlayed, but it accepts additional options for sorting and filtering the results.
func (*Client) PlayerState ¶
func (c *Client) PlayerState(ctx context.Context, opts ...RequestOption) (*PlayerState, error)
PlayerState gets information about the playing state for the current user Requires the ScopeUserReadPlaybackState scope in order to read information
Supported options: Market
func (*Client) Previous ¶
Previous skips to the Previous track in the user's queue in the user's currently active device. This call requires ScopeUserModifyPlaybackState in order to modify the player state
func (*Client) PreviousAlbumResults ¶
func (c *Client) PreviousAlbumResults(ctx context.Context, s *SearchResult) error
PreviousAlbumResults loads the previous page of albums into the specified search result.
func (*Client) PreviousArtistResults ¶
func (c *Client) PreviousArtistResults(ctx context.Context, s *SearchResult) error
PreviousArtistResults loads the previous page of artists into the specified search result.
func (*Client) PreviousEpisodeResults ¶ added in v2.3.0
func (c *Client) PreviousEpisodeResults(ctx context.Context, s *SearchResult) error
PreviousEpisodeResults loads the previous page of episodes into the specified search result.
func (*Client) PreviousOpt ¶
func (c *Client) PreviousOpt(ctx context.Context, opt *PlayOptions) error
PreviousOpt is like Previous but with more options
Only expects PlayOptions.DeviceID, all other options will be ignored
func (*Client) PreviousPage ¶
PreviousPage fetches the previous page of items and writes them into p. It returns ErrNoMorePages if p already contains the last page.
func (*Client) PreviousPlaylistResults ¶
func (c *Client) PreviousPlaylistResults(ctx context.Context, s *SearchResult) error
PreviousPlaylistResults loads the previous page of playlists into the specified search result.
func (*Client) PreviousShowResults ¶ added in v2.3.0
func (c *Client) PreviousShowResults(ctx context.Context, s *SearchResult) error
PreviousShowResults loads the previous page of shows into the specified search result.
func (*Client) PreviousTrackResults ¶
func (c *Client) PreviousTrackResults(ctx context.Context, s *SearchResult) error
PreviousTrackResults loads the previous page of tracks into the specified search result.
func (*Client) QueueSong ¶
QueueSong adds a song to the user's queue on the user's currently active device. This call requires ScopeUserModifyPlaybackState in order to modify the player state
func (*Client) QueueSongOpt ¶
QueueSongOpt is like QueueSong but with more options
Only expects PlayOptions.DeviceID, all other options will be ignored
func (*Client) RemoveAlbumsFromLibrary ¶
RemoveAlbumsFromLibrary removes one or more albums from the current user's "Your Albums" library. This call requires the ScopeUserModifyLibrary scope. Trying to remove a track when you do not have the user's authorization results in a `spotify.Error` with the status code set to http.StatusUnauthorized.
func (*Client) RemoveTracksFromLibrary ¶
RemoveTracksFromLibrary removes one or more tracks from the current user's "Your Music" library. This call requires the ScopeUserModifyLibrary scope. Trying to remove a track when you do not have the user's authorization results in a `spotify.Error` with the status code set to http.StatusUnauthorized.
func (*Client) RemoveTracksFromPlaylist ¶
func (c *Client) RemoveTracksFromPlaylist(ctx context.Context, playlistID ID, trackIDs ...ID) (newSnapshotID string, err error)
RemoveTracksFromPlaylist removes one or more tracks from a user's playlist. This call requires 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( ctx context.Context, 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(ctx context.Context, playlistID ID, opt PlaylistReorderOptions) (snapshotID string, err error)
ReorderPlaylistTracks reorders a track or group of tracks in a playlist. It returns a snapshot ID that can be used to identify the [newly modified] playlist version in future requests.
See the docs for PlaylistReorderOptions for information on how the reordering works.
Reordering tracks in the current user's public playlist requires ScopePlaylistModifyPublic. Reordering tracks in the user's private playlists (including collaborative playlists) requires ScopePlaylistModifyPrivate.
func (*Client) Repeat ¶
Repeat Set the repeat mode for the user's playback.
Options are track, context, and off.
Requires the ScopeUserModifyPlaybackState in order to modify the player state.
func (*Client) RepeatOpt ¶
RepeatOpt is like Repeat but with more options
Only expects PlayOptions.DeviceID, all other options will be ignored.
func (*Client) ReplacePlaylistItems ¶ added in v2.2.0
func (c *Client) ReplacePlaylistItems(ctx context.Context, playlistID ID, items ...URI) (string, error)
ReplacePlaylistItems replaces all the items in a playlist, overwriting its existing tracks This can be useful for replacing or reordering tracks, or for clearing a playlist.
Modifying a public playlist requires that the user has authorized the ScopePlaylistModifyPublic scope. Modifying a private playlist requires the ScopePlaylistModifyPrivate scope.
A maximum of 100 tracks is permited in this call. Additional tracks must be added via AddTracksToPlaylist.
func (*Client) ReplacePlaylistTracks ¶
ReplacePlaylistTracks replaces all of the tracks in a playlist, overwriting its existing tracks This can be useful for replacing or reordering tracks, or for clearing a playlist.
Modifying a public playlist requires that the user has authorized the ScopePlaylistModifyPublic scope. Modifying a private playlist requires the ScopePlaylistModifyPrivate scope.
A maximum of 100 tracks is permitted in this call. Additional tracks must be added via AddTracksToPlaylist.
func (*Client) SaveShowsForCurrentUser ¶ added in v2.3.1
SaveShowsForCurrentUser saves one or more shows to current Spotify user's library. API reference: https://developer.spotify.com/documentation/web-api/reference/#/operations/save-shows-user
func (*Client) Search ¶
func (c *Client) Search(ctx context.Context, query string, t SearchType, opts ...RequestOption) (*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 excludes those that also contain the keyword "blues". Similarly, the OR operator can be used to broaden the search. query = "roadhouse OR blues" returns all results that include either of the terms. Only one OR operator can be used in a query.
Operators should be specified in uppercase.
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".
If the Market 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 Market 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.
Limit, Market and Offset request options are supported
func (*Client) Seek ¶
Seek to the given position in the user’s currently playing track.
The position in milliseconds to seek to. Must be a positive number. Passing in a position that is greater than the length of the track will cause the player to start playing the next song.
Requires the ScopeUserModifyPlaybackState in order to modify the player state
func (*Client) SeekOpt ¶
SeekOpt is like Seek but with more options
Only expects PlayOptions.DeviceID, all other options will be ignored
func (*Client) SetPlaylistImage ¶
SetPlaylistImage replaces the image used to represent a playlist. This action can only be performed by the owner of the playlist, and requires ScopeImageUpload as well as ScopeModifyPlaylist{Public|Private}..
func (*Client) Shuffle ¶
Shuffle switches shuffle on or off for user's playback.
Requires the ScopeUserModifyPlaybackState in order to modify the player state
func (*Client) ShuffleOpt ¶
ShuffleOpt is like Shuffle but with more options
Only expects PlayOptions.DeviceID, all other options will be ignored
func (*Client) TransferPlayback ¶
TransferPlayback transfers playback to a new device and determine if it should start playing.
Note that a value of false for the play parameter when also transferring to another device_id will not pause playback. To ensure that playback is paused on the new device you should send a pause command to the currently active device before transferring to the new device_id.
Requires the ScopeUserModifyPlaybackState in order to modify the player state
func (*Client) UnfollowArtist ¶
UnfollowArtist removes the current user as a follower of one or more Spotify artists.
Modifying the lists of artists or users the current user follows requires that the application has the ScopeUserFollowModify scope.
func (*Client) UnfollowPlaylist ¶
UnfollowPlaylist removes the current user as a follower of a playlist. Unfollowing a publicly followed playlist requires ScopePlaylistModifyPublic. Unfolowing a privately followed playlist requies ScopePlaylistModifyPrivate.
func (*Client) UnfollowUser ¶
UnfollowUser removes the current user as a follower of one or more Spotify users.
Modifying the lists of artists or users the current user follows requires that the application has the ScopeUserFollowModify scope.
func (*Client) UserFollowsPlaylist ¶
func (c *Client) UserFollowsPlaylist(ctx context.Context, playlistID ID, userIDs ...string) ([]bool, error)
UserFollowsPlaylist checks if one or more (up to 5) Spotify users are following a Spotify playlist, given the playlist's owner and ID.
Checking if a user follows a playlist publicly doesn't require any scopes. Checking if the user is privately following a playlist is only possible for the current user when that user has granted access to the ScopePlaylistReadPrivate scope.
func (*Client) UserHasAlbums ¶
UserHasAlbums checks if one or more albums are saved to the current user's "Your Albums" library.
func (*Client) UserHasTracks ¶
UserHasTracks checks if one or more tracks are saved to the current user's "Your Music" library.
type ClientOption ¶
type ClientOption func(client *Client)
func WithAcceptLanguage ¶
func WithAcceptLanguage(lang string) ClientOption
WithAcceptLanguage configures the client to provide the accept language header on all requests.
func WithBaseURL ¶
func WithBaseURL(url string) ClientOption
WithBaseURL provides an alternative base url to use for requests to the Spotify API. This can be used to connect to a staging or other alternative environment.
func WithRetry ¶
func WithRetry(shouldRetry bool) ClientOption
WithRetry configures the Spotify API client to automatically retry requests that fail due to rate limiting.
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 CurrentlyPlaying ¶
type CurrentlyPlaying struct { // Timestamp when data was fetched Timestamp int64 `json:"timestamp"` // PlaybackContext current context PlaybackContext PlaybackContext `json:"context"` // Progress into the currently playing track. Progress Numeric `json:"progress_ms"` // Playing If something is currently playing. Playing bool `json:"is_playing"` // The currently playing track. Can be null. Item *FullTrack `json:"item"` }
CurrentlyPlaying contains the information about currently playing items
type Cursor ¶
type Cursor struct {
After string `json:"after"`
}
Cursor contains a key that can be used to find the next set of items.
type EpisodePage ¶
type EpisodePage struct { // A URL to a 30 second preview (MP3 format) of the episode. AudioPreviewURL string `json:"audio_preview_url"` // A description of the episode. Description string `json:"description"` // The episode length in milliseconds. Duration_ms Numeric `json:"duration_ms"` // Whether or not the episode has explicit content // (true = yes it does; false = no it does not OR unknown). Explicit bool `json:"explicit"` // External URLs for this episode. ExternalURLs map[string]string `json:"external_urls"` // A link to the Web API endpoint providing full details of the episode. Href string `json:"href"` // The Spotify ID for the episode. ID ID `json:"id"` // The cover art for the episode in various sizes, widest first. Images []Image `json:"images"` // True if the episode is hosted outside of Spotify’s CDN. IsExternallyHosted bool `json:"is_externally_hosted"` // True if the episode is playable in the given market. // Otherwise false. IsPlayable bool `json:"is_playable"` // A list of the languages used in the episode, identified by their ISO 639 code. Languages []string `json:"languages"` // The name of the episode. Name string `json:"name"` // The date the episode was first released, for example // "1981-12-15". Depending on the precision, it might // be shown as "1981" or "1981-12". ReleaseDate string `json:"release_date"` // The precision with which release_date value is known: // "year", "month", or "day". ReleaseDatePrecision string `json:"release_date_precision"` // The user’s most recent position in the episode. Set if the // supplied access token is a user token and has the scope // user-read-playback-position. ResumePoint ResumePointObject `json:"resume_point"` // The show on which the episode belongs. Show SimpleShow `json:"show"` // The object type: "episode". Type string `json:"type"` // The Spotify URI for the episode. URI URI `json:"uri"` }
func (*EpisodePage) ReleaseDateTime ¶
func (e *EpisodePage) ReleaseDateTime() time.Time
ReleaseDateTime converts the show's ReleaseDate to a time.TimeValue. All of the fields in the result may not be valid. For example, if ReleaseDatePrecision is "month", then only the month and year (but not the day) of the result are valid.
type Error ¶
type Error struct { // A short description of the error. Message string `json:"message"` // The HTTP status code. Status int `json:"status"` }
Error represents an error returned by the Spotify Web API.
type Followers ¶
type Followers struct { // The total number of followers. Count Numeric `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 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 popularity of the album's individual tracks. Popularity Numeric `json:"popularity"` Tracks SimpleTrackPage `json:"tracks"` ExternalIDs map[string]string `json:"external_ids"` }
FullAlbum provides extra album data in addition to the data provided by SimpleAlbum.
type FullArtist ¶
type FullArtist struct { SimpleArtist // The popularity of the artist, expressed as an integer between 0 and 100. // The artist's popularity is calculated from the popularity of the artist's tracks. Popularity Numeric `json:"popularity"` // A list of genres the artist is associated with. For example, "Prog Rock" // or "Post-Grunge". If not yet classified, the slice is empty. Genres []string `json:"genres"` Followers Followers `json:"followers"` // Images of the artist in various sizes, widest first. Images []Image `json:"images"` }
FullArtist provides extra artist data in addition to what is provided by SimpleArtist.
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 // Information about the followers of this playlist. Followers Followers `json:"followers"` Tracks PlaylistTrackPage `json:"tracks"` }
FullPlaylist provides extra playlist data in addition to the data provided by SimplePlaylist.
type FullShow ¶
type FullShow struct { SimpleShow // A list of the show’s episodes. Episodes SimpleEpisodePage `json:"episodes"` }
FullShow contains full data about a show.
type FullTrack ¶
type FullTrack struct { SimpleTrack // The album on which the track appears. The album object includes a link in href to full information about the album. Album SimpleAlbum `json:"album"` // Known external IDs for the track. ExternalIDs map[string]string `json:"external_ids"` // Popularity of the track. The value will be between 0 and 100, // with 100 being the most popular. The popularity is calculated from // both total plays and most recent plays. Popularity Numeric `json:"popularity"` // IsPlayable defines if the track is playable. It's reported when the "market" parameter is passed to the tracks // listing API. // See: https://developer.spotify.com/documentation/general/guides/track-relinking-guide/ IsPlayable *bool `json:"is_playable"` // LinkedFrom points to the linked track. It's reported when the "market" parameter is passed to the tracks listing // API. LinkedFrom *LinkedFromInfo `json:"linked_from"` }
FullTrack provides extra track data in addition to what is provided by SimpleTrack.
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 Numeric `json:"height"` // The image width, in pixels. Width Numeric `json:"width"` // The source URL of the image. URL string `json:"url"` }
Image identifies an image associated with an item.
type LinkedFromInfo ¶
type LinkedFromInfo struct { // ExternalURLs are the known external APIs for this track or album ExternalURLs map[string]string `json:"external_urls"` // Href is a link to the Web API endpoint providing full details Href string `json:"href"` // ID of the linked track ID ID `json:"id"` // Type of the link: album of the track Type string `json:"type"` // URI is the Spotify URI of the track/album URI string `json:"uri"` }
LinkedFromInfo See: https://developer.spotify.com/documentation/general/guides/track-relinking-guide/
type Marker ¶
type Marker struct { Start float64 `json:"start"` Duration float64 `json:"duration"` Confidence float64 `json:"confidence"` }
Marker represents beats, bars, tatums and are used in segment and section descriptions.
type Numeric ¶ added in v2.4.2
type Numeric int
Numeric is a convenience type for handling numbers sent as either integers or floats.
func (*Numeric) UnmarshalJSON ¶ added in v2.4.2
UnmarshalJSON unmarshals a JSON number (float or int) into the Numeric type.
type PlayOptions ¶
type PlayOptions struct { // DeviceID The id of the device this command is targeting. If not // supplied, the user's currently active device is the target. DeviceID *ID `json:"-"` // PlaybackContext Spotify URI of the context to play. // Valid contexts are albums, artists & playlists. PlaybackContext *URI `json:"context_uri,omitempty"` // URIs Array of the Spotify track URIs to play URIs []URI `json:"uris,omitempty"` // PlaybackOffset Indicates from where in the context playback should start. // Only available when context corresponds to an album or playlist // object, or when the URIs parameter is used. PlaybackOffset *PlaybackOffset `json:"offset,omitempty"` // PositionMs Indicates from what position to start playback. // Must be a positive number. Passing in a position that is greater // than the length of the track will cause the player to start playing the next song. // Defaults to 0, starting a track from the beginning. PositionMs Numeric `json:"position_ms,omitempty"` }
type PlaybackContext ¶
type PlaybackContext struct { // ExternalURLs of the context, or null if not available. ExternalURLs map[string]string `json:"external_urls"` // Endpoint of the context, or null if not available. Endpoint string `json:"href"` // Type of the item's context. Can be one of album, artist or playlist. Type string `json:"type"` // URI is the Spotify URI for the context. URI URI `json:"uri"` }
PlaybackContext is the playback context
type PlaybackOffset ¶
type PlaybackOffset struct { // Position is zero based and can’t be negative. Position *int `json:"position,omitempty"` // URI is a string representing the uri of the item to start at. URI URI `json:"uri,omitempty"` }
PlaybackOffset can be specified either by track URI OR Position. If the Position field is set to a non-nil pointer, it will be taken into consideration when specifying the playback offset. If the Position field is set to a nil pointer, it will be ignored and only the URI will be used to specify the offset. If both are present the request will return 400 BAD REQUEST. If incorrect values are provided for position or uri, the request may be accepted but with an unpredictable resulting action on playback.
type PlayerDevice ¶
type PlayerDevice struct { // ID of the device. This may be empty. ID ID `json:"id"` // Active If this device is the currently active device. Active bool `json:"is_active"` // Restricted Whether controlling this device is restricted. At present if // this is "true" then no Web API commands will be accepted by this device. Restricted bool `json:"is_restricted"` // Name The name of the device. Name string `json:"name"` // Type of device, such as "Computer", "Smartphone" or "Speaker". Type string `json:"type"` // Volume The current volume in percent. Volume Numeric `json:"volume_percent"` }
PlayerDevice contains information about a device that a user can play music on
type PlayerState ¶
type PlayerState struct { CurrentlyPlaying // Device The device that is currently active Device PlayerDevice `json:"device"` // ShuffleState Shuffle is on or off ShuffleState bool `json:"shuffle_state"` // RepeatState off, track, context RepeatState string `json:"repeat_state"` }
PlayerState contains information about the current playback.
type PlaylistItem ¶ added in v2.1.0
type PlaylistItem 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: very old playlists may not populate this value. AddedBy User `json:"added_by"` // Whether this track is a local file or not. IsLocal bool `json:"is_local"` // Information about the track. Track PlaylistItemTrack `json:"track"` }
PlaylistItem contains info about an item in a playlist.
type PlaylistItemPage ¶ added in v2.1.0
type PlaylistItemPage struct { Items []PlaylistItem `json:"items"` // contains filtered or unexported fields }
PlaylistItemPage contains information about items in a playlist.
type PlaylistItemTrack ¶ added in v2.1.0
type PlaylistItemTrack struct { Track *FullTrack Episode *EpisodePage }
PlaylistItemTrack is a union type for both tracks and episodes. If both values are null, it's likely that the piece of content is not available in the configured market.
func (*PlaylistItemTrack) UnmarshalJSON ¶ added in v2.1.0
func (t *PlaylistItemTrack) UnmarshalJSON(b []byte) error
UnmarshalJSON customises the unmarshalling based on the type flags set.
type PlaylistReorderOptions ¶
type PlaylistReorderOptions struct { // The position of the first track to be reordered. // This field is required. RangeStart Numeric `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 Numeric `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 Numeric `json:"insert_before"` // The playlist's snapshot ID against which you wish to make the changes. // This field is optional. SnapshotID string `json:"snapshot_id,omitempty"` }
PlaylistReorderOptions is used with ReorderPlaylistTracks to reorder a track or group of tracks in a playlist.
For example, in a playlist with 10 tracks, you can:
- move the first track to the end of the playlist by setting RangeStart to 0 and InsertBefore to 10
- move the last track to the beginning of the playlist by setting RangeStart to 9 and InsertBefore to 0
- Move the last 2 tracks to the beginning of the playlist by setting RangeStart to 8 and RangeLength to 2.
type PlaylistTrack ¶
type PlaylistTrack struct { // The date and time the track was added to the playlist. // You can use the TimestampLayout constant to convert // this field to a time.Time value. // Warning: very old playlists may not populate this value. AddedAt string `json:"added_at"` // The Spotify user who added the track to the playlist. // Warning: vary old playlists may not populate this value. AddedBy User `json:"added_by"` // Whether this track is a local file or not. IsLocal bool `json:"is_local"` // Information about the track. Track FullTrack `json:"track"` }
PlaylistTrack contains info about a track in a playlist.
type PlaylistTrackPage ¶
type PlaylistTrackPage struct { Tracks []PlaylistTrack `json:"items"` // contains filtered or unexported fields }
PlaylistTrackPage contains information about tracks in a playlist.
type PlaylistTracks ¶
type PlaylistTracks struct { // A link to the Web API endpoint where full details of // the playlist's tracks can be retrieved. Endpoint string `json:"href"` // The total number of tracks in the playlist. Total Numeric `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 access 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 Range ¶
type Range string
const ( // LongTermRange is calculated from several years of data, including new data where possible LongTermRange Range = "long_term" // MediumTermRange is approximately the last six months MediumTermRange Range = "medium_term" // ShortTermRange is approximately the last four weeks ShortTermRange Range = "short_term" )
type RecentlyPlayedItem ¶
type RecentlyPlayedItem struct { // Track is the track information Track SimpleTrack `json:"track"` // PlayedAt is the time that this song was played PlayedAt time.Time `json:"played_at"` // PlaybackContext is the current playback context PlaybackContext PlaybackContext `json:"context"` }
type RecentlyPlayedOptions ¶
type RecentlyPlayedOptions struct { // Limit is the maximum number of items to return. Must be no greater than // fifty. Limit Numeric // AfterEpochMs is a Unix epoch in milliseconds that describes a time after // which to return songs. AfterEpochMs int64 // BeforeEpochMs is a Unix epoch in milliseconds that describes a time // before which to return songs. BeforeEpochMs int64 }
RecentlyPlayedOptions describes options for the recently-played request. All fields are optional. Only one of `AfterEpochMs` and `BeforeEpochMs` may be given. Note that it seems as if Spotify only remembers the fifty most-recent tracks as of right now.
type RecentlyPlayedResult ¶
type RecentlyPlayedResult struct {
Items []RecentlyPlayedItem `json:"items"`
}
type RecommendationSeed ¶
type RecommendationSeed struct { AfterFilteringSize Numeric `json:"afterFilteringSize"` AfterRelinkingSize Numeric `json:"afterRelinkingSize"` Endpoint string `json:"href"` ID ID `json:"id"` InitialPoolSize Numeric `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 RequestOption ¶
type RequestOption func(*requestOptions)
func AdditionalTypes ¶ added in v2.1.0
func AdditionalTypes(types ...AdditionalType) RequestOption
AdditionalTypes is a list of item types that your client supports besides the default track type. Valid types are: EpisodeAdditionalType and TrackAdditionalType.
func After ¶
func After(after string) RequestOption
After is the last ID retrieved from the previous request. This allows pagination.
func Country ¶
func Country(code string) RequestOption
Country enables a specific region to be specified for region-specific suggestions e.g popular playlists The Country option takes an ISO 3166-1 alpha-2 country code. It can be used to ensure that the category exists for a particular country.
func Fields ¶
func Fields(fields string) RequestOption
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 Limit ¶
func Limit(amount int) RequestOption
Limit sets the number of entries that a request should return
func Locale ¶
func Locale(code string) RequestOption
Locale enables a specific language to be used when returning results. 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).
func Offset ¶
func Offset(amount int) RequestOption
Offset sets the index of the first entry to return
func Timerange ¶
func Timerange(timerange Range) RequestOption
Timerange sets the time period that spoty will use when returning information. Use LongTermRange, MediumTermRange and ShortTermRange to set the appropriate period.
func Timestamp ¶
func Timestamp(ts string) RequestOption
Timestamp in ISO 8601 format (yyyy-MM-ddTHH:mm:ss). use this parameter to specify the user's local time to get results tailored for that specific date and time in the day. If not provided, the response defaults to the current UTC time.
type ResumePointObject ¶
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 SavedShowPage ¶
type SavedShowPage struct { Shows []SavedShow `json:"items"` // contains filtered or unexported fields }
SavedShowPage contains SavedShows returned by the Web API
type SavedTrack ¶
type SavedTrack struct { // The date and time the track was saved, represented as an ISO // 8601 UTC timestamp with a zero offset (YYYY-MM-DDTHH:MM:SSZ). // You can use the TimestampLayout constant to convert this to // a time.Time value. AddedAt string `json:"added_at"` FullTrack `json:"track"` }
SavedTrack provides info about a track saved to a user's account.
type SavedTrackPage ¶
type SavedTrackPage struct { Tracks []SavedTrack `json:"items"` // contains filtered or unexported fields }
SavedTrackPage contains SavedTracks return by the Web API.
type SearchResult ¶
type SearchResult struct { Artists *FullArtistPage `json:"artists"` Albums *SimpleAlbumPage `json:"albums"` Playlists *SimplePlaylistPage `json:"playlists"` Tracks *FullTrackPage `json:"tracks"` Shows *SimpleShowPage `json:"shows"` Episodes *SimpleEpisodePage `json:"episodes"` }
SearchResult contains the results of a call to Search. Fields that weren't searched for will be nil pointers.
type SearchType ¶
type SearchType int
SearchType represents the type of a query used in the Search function.
type Section ¶
type Section struct { Marker Loudness float64 `json:"loudness"` Tempo float64 `json:"tempo"` TempoConfidence float64 `json:"tempo_confidence"` Key Key `json:"key"` KeyConfidence float64 `json:"key_confidence"` Mode Mode `json:"mode"` ModeConfidence float64 `json:"mode_confidence"` TimeSignature Numeric `json:"time_signature"` TimeSignatureConfidence float64 `json:"time_signature_confidence"` }
Section represents a large variation in rhythm or timbre, e.g. chorus, verse, bridge, guitar solo, etc. Each section contains its own descriptions of tempo, key, mode, time_signature, and loudness.
type Seeds ¶
Seeds contains IDs of artists, genres and/or tracks to be used as seeds for recommendations
type Segment ¶
type Segment struct { Marker LoudnessStart float64 `json:"loudness_start"` LoudnessMaxTime float64 `json:"loudness_max_time"` LoudnessMax float64 `json:"loudness_max"` LoudnessEnd float64 `json:"loudness_end"` Pitches []float64 `json:"pitches"` Timbre []float64 `json:"timbre"` }
Segment is characterized by it's perceptual onset and duration in seconds, loudness (dB), pitch and timbral content.
type SimpleAlbum ¶
type SimpleAlbum struct { // The name of the album. Name string `json:"name"` // A slice of SimpleArtists Artists []SimpleArtist `json:"artists"` // The field is present when getting an artist’s // albums. Possible values are “album”, “single”, // “compilation”, “appears_on”. Compare to album_type // this field represents relationship between the artist // and the album. AlbumGroup string `json:"album_group"` // The type of the album: one of "album", // "single", or "compilation". AlbumType string `json:"album_type"` // The SpotifyID for the album. ID ID `json:"id"` // The SpotifyURI for the album. URI URI `json:"uri"` // The markets in which the album is available, // identified using ISO 3166-1 alpha-2 country // codes. Note that al album is considered // available in a market when at least 1 of its // tracks is available in that market. AvailableMarkets []string `json:"available_markets"` // A link to the Web API endpoint providing full // details of the album. Endpoint string `json:"href"` // The cover art for the album in various sizes, // widest first. Images []Image `json:"images"` // Known external URLs for this album. ExternalURLs map[string]string `json:"external_urls"` // The date the album was first released. For example, "1981-12-15". // Depending on the ReleaseDatePrecision, it might be shown as // "1981" or "1981-12". You can use ReleaseDateTime to convert this // to a time.Time value. ReleaseDate string `json:"release_date"` // The precision with which ReleaseDate value is known: "year", "month", or "day" ReleaseDatePrecision string `json:"release_date_precision"` // The number of tracks on the album. TotalTracks Numeric `json:"total_tracks"` }
SimpleAlbum contains basic data about an album.
func (*SimpleAlbum) ReleaseDateTime ¶
func (s *SimpleAlbum) ReleaseDateTime() time.Time
ReleaseDateTime converts the album's ReleaseDate to a time.TimeValue. All of the fields in the result may not be valid. For example, if ReleaseDatePrecision is "month", then only the month and year (but not the day) of the result are valid.
type SimpleAlbumPage ¶
type SimpleAlbumPage struct { Albums []SimpleAlbum `json:"items"` // contains filtered or unexported fields }
SimpleAlbumPage contains SimpleAlbums returned by the Web API.
type SimpleArtist ¶
type SimpleArtist struct { Name string `json:"name"` ID ID `json:"id"` // The Spotify URI for the artist. URI URI `json:"uri"` // A link to the Web API endpoint 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 SimpleEpisodePage ¶
type SimpleEpisodePage struct { Episodes []EpisodePage `json:"items"` // contains filtered or unexported fields }
SimpleEpisodePage contains EpisodePage returned by the Web API.
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"` // The playlist description. Empty string if no description is set. Description string `json:"description"` ExternalURLs map[string]string `json:"external_urls"` // A link to the Web API endpoint providing full details of the playlist. Endpoint string `json:"href"` ID ID `json:"id"` // The playlist image. Note: this field is only returned for modified, // verified playlists. Otherwise the slice is empty. If returned, the source // URL for the image is temporary and will expire in less than a day. Images []Image `json:"images"` Name string `json:"name"` Owner User `json:"owner"` IsPublic bool `json:"public"` // The version identifier for the current playlist. Can be supplied in other // requests to target a specific playlist version. SnapshotID string `json:"snapshot_id"` // A collection to the Web API endpoint where full details of the playlist's // tracks can be retrieved, along with the total number of tracks in the playlist. Tracks PlaylistTracks `json:"tracks"` URI URI `json:"uri"` }
SimplePlaylist contains basic info about a Spotify playlist.
type SimplePlaylistPage ¶
type SimplePlaylistPage struct { Playlists []SimplePlaylist `json:"items"` // contains filtered or unexported fields }
SimplePlaylistPage contains SimplePlaylists returned by the Web API.
type SimpleShow ¶
type SimpleShow struct { // A list of the countries in which the show can be played, // identified by their ISO 3166-1 alpha-2 code. AvailableMarkets []string `json:"available_markets"` // The copyright statements of the show. Copyrights []Copyright `json:"copyrights"` // A description of the show. Description string `json:"description"` // Whether or not the show has explicit content // (true = yes it does; false = no it does not OR unknown). Explicit bool `json:"explicit"` // Known external URLs for this show. ExternalURLs map[string]string `json:"external_urls"` // A link to the Web API endpoint providing full details // of the show. Href string `json:"href"` // The SpotifyID for the show. ID ID `json:"id"` // The cover art for the show in various sizes, // widest first. Images []Image `json:"images"` // True if all of the show’s episodes are hosted outside // of Spotify’s CDN. This field might be null in some cases. IsExternallyHosted *bool `json:"is_externally_hosted"` // A list of the languages used in the show, identified by // their ISO 639 code. Languages []string `json:"languages"` // The media type of the show. MediaType string `json:"media_type"` // The name of the show. Name string `json:"name"` // The publisher of the show. Publisher string `json:"publisher"` // The object type: “show”. Type string `json:"type"` // The Spotify URI for the show. URI URI `json:"uri"` }
SimpleShow contains basic data about a show.
type SimpleShowPage ¶ added in v2.3.0
type SimpleShowPage struct { Shows []FullShow `json:"items"` // contains filtered or unexported fields }
SimpleShowPage contains ShowPage 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 Numeric `json:"disc_number"` // The length of the track, in milliseconds. Duration Numeric `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"` // ExternalIDs are IDs for this track in other databases ExternalIDs TrackExternalIDs `json:"external_ids"` // 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 Numeric `json:"track_number"` URI URI `json:"uri"` // Type of the track Type string `json:"type"` }
SimpleTrack contains basic info about a track.
func (SimpleTrack) String ¶
func (st SimpleTrack) String() string
func (*SimpleTrack) TimeDuration ¶
func (t *SimpleTrack) TimeDuration() time.Duration
TimeDuration returns the track's duration as a time.Duration value.
type SimpleTrackPage ¶
type SimpleTrackPage struct { Tracks []SimpleTrack `json:"items"` // contains filtered or unexported fields }
SimpleTrackPage contains SimpleTracks returned by the Web API.
type TrackAttributes ¶
type TrackAttributes struct {
// contains filtered or unexported fields
}
TrackAttributes contains various tuneable parameters that can be used for recommendations. For each of the tuneable track attributes, target, min and max values may be provided. Target:
Tracks with the attribute values nearest to the target values will be preferred. For example, you might request TargetEnergy=0.6 and TargetDanceability=0.8. All target values will be weighed equally in ranking results.
Max:
A hard ceiling on the selected track attribute’s value can be provided. For example, MaxInstrumentalness=0.35 would filter out most tracks that are likely to be instrumental.
Min:
A hard floor on the selected track attribute’s value can be provided. For example, min_tempo=140 would restrict results to only those tracks with a tempo of greater than 140 beats per minute.
func NewTrackAttributes ¶
func NewTrackAttributes() *TrackAttributes
NewTrackAttributes returns a new TrackAttributes instance with no attributes set. Attributes can then be chained following a builder pattern:
ta := NewTrackAttributes(). MaxAcousticness(0.15). TargetPopularity(90)
func (*TrackAttributes) MaxAcousticness ¶
func (ta *TrackAttributes) MaxAcousticness(acousticness float64) *TrackAttributes
MaxAcousticness sets the maximum acousticness Acousticness is a confidence measure from 0.0 to 1.0 of whether the track is acoustic. A value of 1.0 represents high confidence that the track is acoustic.
func (*TrackAttributes) MaxDanceability ¶
func (ta *TrackAttributes) MaxDanceability(danceability float64) *TrackAttributes
MaxDanceability sets the maximum danceability Danceability describes how suitable a track is for dancing based on a combination of musical elements including tempo, rhythm stability, beat strength, and overall regularity. A value of 0.0 is least danceable and 1.0 is most danceable.
func (*TrackAttributes) MaxDuration ¶
func (ta *TrackAttributes) MaxDuration(duration int) *TrackAttributes
MaxDuration sets the maximum length of the track in milliseconds
func (*TrackAttributes) MaxEnergy ¶
func (ta *TrackAttributes) MaxEnergy(energy float64) *TrackAttributes
MaxEnergy sets the maximum energy Energy is a measure from 0.0 to 1.0 and represents a perceptual measure 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 likelihood 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 measure 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 likelihood 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 measure 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 likelihood 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 TrackExternalIDs ¶ added in v2.3.1
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.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
examples
|
|
authenticate/authcode
This example demonstrates how to authenticate with Spotify using the authorization code flow.
|
This example demonstrates how to authenticate with Spotify using the authorization code flow. |
authenticate/clientcreds
This example demonstrates how to authenticate with Spotify using the client credentials flow.
|
This example demonstrates how to authenticate with Spotify using the client credentials flow. |
authenticate/pkce
This example demonstrates how to authenticate with Spotify using the authorization code flow with PKCE.
|
This example demonstrates how to authenticate with Spotify using the authorization code flow with PKCE. |
player
This example demonstrates how to authenticate with Spotify.
|
This example demonstrates how to authenticate with Spotify. |
profile
Command profile gets the public profile information about a Spotify user.
|
Command profile gets the public profile information about a Spotify user. |