SPTTrack Class Reference
| Inherits from | SPTPartialTrack : SPTJSONObjectBase : NSObject |
| Conforms to | SPTJSONObject |
| Declared in | SPTTrack.h |
Overview
This class represents a track on the Spotify service.
API Docs: https://developer.spotify.com/web-api/track-endpoints/
API Console: https://developer.spotify.com/web-api/console/tracks/
API Model: https://developer.spotify.com/web-api/object-model/#track-object-full
Tasks
Properties
-
popularityproperty -
externalIdsproperty
API Request Factories
-
+ createRequestForTrack:withAccessToken:market:error: -
+ createRequestForTracks:withAccessToken:market:error:
API Response Parsers
-
+ trackFromData:withResponse:error: -
+ trackFromDecodedJSON:error: -
+ tracksFromData:withResponse:error: -
+ tracksFromDecodedJSON:error:
Convenience Methods
Miscellaneous
Properties
Class Methods
createRequestForTrack:withAccessToken:market:error:
Create a request for fetching one track.
+ (NSURLRequest *)createRequestForTrack:(NSURL *)uri withAccessToken:(NSString *)accessToken market:(NSString *)market error:(NSError **)errorParameters
- uri
The Spotify URI of the track to request.
- accessToken
An access token.
- market
Either a ISO 3166-1 country code to filter the results to, or
from_tokento pick the market from the session (requires theuser-read-privatescope), ornilfor no market filtering.
- error
An optional pointer to an
NSErrorthat will receive the error code if operation failed.
Discussion
Parse the response into an SPTListPage using SPTTrack trackFromData:withResponse:error:
See https://developer.spotify.com/web-api/get-list-new-releases/ for more information on parameters
Declared In
SPTTrack.hcreateRequestForTracks:withAccessToken:market:error:
Create a request for fetching multiple rtacks
+ (NSURLRequest *)createRequestForTracks:(NSArray *)uris withAccessToken:(NSString *)accessToken market:(NSString *)market error:(NSError **)errorParameters
- uris
An array of Spotify Track URIs.
- accessToken
An access token.
- market
Either a ISO 3166-1 country code to filter the results to, or
from_tokento pick the market from the session (requires theuser-read-privatescope), ornilfor no market filtering.
- error
An optional pointer to an
NSErrorthat will receive the error code if operation failed.
Discussion
Parse the response into an NSArray of SPTTrack-objects using SPTTrack trackFromDecodedJSON:
See https://developer.spotify.com/web-api/get-list-new-releases/ for more information on parameters
Declared In
SPTTrack.hidentifierFromURI:
Returns the identifier for a Spotify Track uri.
+ (NSString *)identifierFromURI:(NSURL *)uriParameters
- uri
An track uri.
Return Value
The track id, or nil if an invalid track uri was passed.
Discussion
Note: This method takes Spotify URIs in the form spotify:*, NOT HTTP URLs.
Declared In
SPTTrack.hidentifiersFromArray:
Returns a list of track id’s from an array containing either SPTPartialTrack, SPTTrack or NSURL’s
+ (NSArray *)identifiersFromArray:(NSArray *)tracksParameters
- tracks
An array of tracks.
Return Value
An array of track id’s.
Declared In
SPTTrack.hisTrackURI:
Checks if the Spotify URI is a valid Spotify Track URI.
+ (BOOL)isTrackURI:(NSURL *)uriParameters
- uri
The Spotify URI to check.
Discussion
Note: This method takes Spotify URIs in the form spotify:*, NOT HTTP URLs.
Declared In
SPTTrack.htrackFromData:withResponse:error:
Parse an JSON object structure into an array of SPTTrack object.
+ (instancetype)trackFromData:(NSData *)data withResponse:(NSURLResponse *)response error:(NSError **)errorParameters
- data
The API response data
- response
The API response object
- error
An optional
NSErrorthat will be set if an error occured when parsing the data.
Return Value
an SPTTrack object, or nil if the parsing failed.
Declared In
SPTTrack.htrackFromDecodedJSON:error:
Parse an JSON object structure into an array of SPTTrack object.
+ (instancetype)trackFromDecodedJSON:(id)decodedObject error:(NSError **)errorParameters
- decodedObject
The decoded JSON structure to parse.
- error
An optional
NSErrorthat will be set if an error occured when parsing the data.
Return Value
an SPTAlbum object, or nil if the parsing failed.
Declared In
SPTTrack.htrackWithURI:accessToken:market:callback:
Request the track at the given Spotify URI.
+ (void)trackWithURI:(NSURL *)uri accessToken:(NSString *)accessToken market:(NSString *)market callback:(SPTRequestCallback)blockParameters
- uri
The Spotify URI of the track to request.
- accessToken
An access token.
- market
Either a ISO 3166-1 country code to filter the results to, or
from_tokento pick the market from the session (requires theuser-read-privatescope), ornilfor no market filtering.
- block
The block to be called when the operation is complete. The block will pass a Spotify SDK metadata object on success, otherwise an error.
Discussion
This is a convenience method on top of the SPTTrack createRequestForTracks:withAccessToken:error: and SPTRequest performRequest:callback: methods
See: https://developer.spotify.com/web-api/get-track/
Note: This method takes Spotify URIs in the form spotify:*, NOT HTTP URLs.
Declared In
SPTTrack.htracksFromData:withResponse:error:
Parse an JSON object structure into an array of SPTTrack object.
+ (NSArray *)tracksFromData:(NSData *)data withResponse:(NSURLResponse *)response error:(NSError **)errorParameters
- data
The API response data
- response
The API response object
- error
An optional
NSErrorthat will be set if an error occured when parsing the data.
Return Value
an array of SPTTrack objects, or nil if the parsing failed.
Declared In
SPTTrack.htracksFromDecodedJSON:error:
Parse an JSON object structure into an array of SPTTrack objects.
+ (NSArray *)tracksFromDecodedJSON:(id)decodedObject error:(NSError **)errorParameters
- decodedObject
The decoded JSON structure to parse.
- error
An optional
NSErrorthat will be set if an error occured when parsing the data.
Return Value
an SPTAlbum object, or nil if the parsing failed.
Declared In
SPTTrack.htracksWithURIs:accessToken:market:callback:
Request multiple tracks with given an array of Spotify URIs.
+ (void)tracksWithURIs:(NSArray *)uris accessToken:(NSString *)accessToken market:(NSString *)market callback:(SPTRequestCallback)blockParameters
- uris
An array of Spotify Track URIs.
- accessToken
An access token.
- market
Either a ISO 3166-1 country code to filter the results to, or
from_tokento pick the market from the session (requires theuser-read-privatescope), ornilfor no market filtering.
- block
The block to be called when the operation is complete. The block will pass an array of Spotify SDK metadata objects on success, otherwise an error.
Discussion
This is a convenience method on top of the SPTTrack createRequestForTracks:withAccessToken:error: and SPTRequest performRequest:callback: methods
See: https://developer.spotify.com/web-api/get-several-tracks/
Note: This method takes an array of Spotify URIs in the form spotify:*, NOT HTTP URLs.
Declared In
SPTTrack.huriStringsFromArray:
Returns a list of track uri’s as NSString’s from an array containing either SPTPartialTrack, SPTTrack or NSURL’s
+ (NSArray *)uriStringsFromArray:(NSArray *)tracksParameters
- tracks
An array of tracks.
Return Value
An array of track uri strings.
Declared In
SPTTrack.hurisFromArray:
Returns a list of track uri’s as NSURL’s from an array containing either SPTPartialTrack, SPTTrack or NSURL’s
+ (NSArray *)urisFromArray:(NSArray *)tracksParameters
- tracks
An array of tracks.
Return Value
An array of track uri’s.
Declared In
SPTTrack.h