Collection
protocol Collection : Sequence where Self.SubSequence : Collection
-
Creates and returns the request used to get audio features for the current collection of tracks.
Important
The maximum number of IDs the API can process for a single request to this endpoint is 100. If the current array contains more than 100 items, the request may result in an error.
Declaration
Swift
public func makeAudioFeaturesRequest() -> SKRequest
Return Value
An
SKRequest
instance with which to perform the API request. -
Gets audio feature information for the current collection of tracks.
Note
This method uses the
SPTAuth
default instance session to authenticate the underlying request. If this session does not contain a valid access token, the request will result in an error.Important
The maximum number of IDs the API can process for a single request to this endpoint is 100. If the current array contains more than 100 items, the request may result in an error.
Declaration
Swift
public func getAudioFeatures(completion handler: @escaping ([SKAudioFeatures?]?, Error?) -> Void)
Parameters
handler
The callback handler for the request. The parameters for this handler are:
features
: An array of audio features corresponding to the tracks in this array. If audio features for a particular track ID cannot be found, the resulting array will contain anil
value at the corresponding index.error
: An error identifying if and why the request failed, ornil
if the request was successful.
-
Adds the current authenticated user as a follower of the items in the collection.
Note
This method uses theSPTAuth
default instance session to authenticate the underlying request. If this session does not contain a valid access token, the request will result in an error. The access token must have been issued on behalf of the current user.Modifying the list of items that the current authenticated user follows also requires authorization of the
user-follow-modify
scope. See Using Scopes for more details.Declaration
Swift
public func follow(completion handler: @escaping SKErrorHandler)
Parameters
handler
The callback handler for the request, providing an error identifying if and why the request failed, or
nil
if the request was successful. -
Removes the current authenticated user as a follower of the items in the collection.
Note
This method uses theSPTAuth
default instance session to authenticate the underlying request. If this session does not contain a valid access token, the request will result in an error. The access token must have been issued on behalf of the current user.Modifying the list of items that the current authenticated user follows also requires authorization of the
user-follow-modify
scope. See Using Scopes for more details.Declaration
Swift
public func unfollow(completion handler: @escaping SKErrorHandler)
Parameters
handler
The callback handler for the request, providing an error identifying if and why the request failed, or
nil
if the request was successful. -
Checks whether the current authenticated user is following the items in the collection.
Note
This method uses theSPTAuth
default instance session to authenticate the underlying request. If this session does not contain a valid access token, the request will result in an error. The access token must have been issued on behalf of the current user.Reading the list of items that the current authenticated user follows also requires authorization of the
user-follow-read
scope. See Using Scopes for more details.Declaration
Swift
public func checkIfFollowing(completion handler: @escaping ([Bool]?, Error?) -> Void)
Parameters
handler
The callback handler for the request. The parameters for this handler are:
isFollowing
: An array of Boolean values indicating whether the current authenticated user is following the item at the corresponding index. If a particular item is followed by the current authenticated user, the resulting array will containtrue
at the corresponding index;false
otherwise.error
: An error identifying if and why the request failed, ornil
if the request was successful.
-
Saves the items in the collection to the current authenticated user’s Spotify music library. A maximum of 50 items can be saved in one request.
Note
This method uses theSPTAuth
default instance session to authenticate the underlying request. If this session does not contain a valid access token, the request will result in an error. The access token must have been issued on behalf of the current user.Modifying the current user’s
Your Music
collection requires authorization of theuser-library-modify
scope. See Using Scopes for more details.Declaration
Swift
public func saveToLibrary(completion handler: @escaping SKErrorHandler)
Parameters
handler
The callback handler for the request, providing an error identifying if and why the request failed, or
nil
if the request was successful. -
Removes the items in the collection from the current authenticated user’s Spotify music library. A maximum of 50 items can be removed in one request.
Note
This method uses theSPTAuth
default instance session to authenticate the underlying request. If this session does not contain a valid access token, the request will result in an error. The access token must have been issued on behalf of the current user.Modifying the current user’s
Your Music
collection requires authorization of theuser-library-modify
scope. See Using Scopes for more details.Declaration
Swift
public func removeFromLibrary(completion handler: @escaping SKErrorHandler)
Parameters
handler
The callback handler for the request, providing an error identifying if and why the request failed, or
nil
if the request was successful. -
Checks whether the items in the collection have been saved to the current authenticated user’s Spotify music library.
Note
This method uses theSPTAuth
default instance session to authenticate the underlying request. If this session does not contain a valid access token, the request will result in an error. The access token must have been issued on behalf of the current user.Reading the current user’s
Your Music
collection requires authorization of theuser-library-read
scope. See Using Scopes for more details.Declaration
Swift
public func checkIfSaved(completion handler: @escaping ([Bool]?, Error?) -> Void)
Parameters
handler
The callback handler for the request. The parameters for this handler are:
isSaved
: An array of Boolean values indicating whether the collection of items have been saved to the current user’s library. If a particular item in the collection is saved, the resulting array will containtrue
at the corresponding index;false
otherwise.error
: An error identifying if and why the request failed, ornil
if the request was successful.