SPTArtist Class Reference
Inherits from | SPTPartialArtist : SPTJSONObjectBase : NSObject |
Conforms to | SPTJSONObject |
Declared in | SPTArtist.h |
Overview
This class represents an artist on the Spotify service.
API Docs: https://developer.spotify.com/web-api/get-artist/
API Console: https://developer.spotify.com/web-api/console/get-artist
API Model: https://developer.spotify.com/web-api/object-model/#artist-object-full
Tasks
Properties
-
externalIds
property -
genres
property -
images
property -
smallestImage
property -
largestImage
property -
popularity
property -
followerCount
property
API Request Factories
-
+ createRequestForArtist:withAccessToken:error:
-
+ createRequestForArtists:withAccessToken:error:
-
+ createRequestForAlbumsByArtist:ofType:withAccessToken:market:error:
-
+ createRequestForTopTracksForArtist:withAccessToken:market:error:
-
+ createRequestForArtistsRelatedTo:withAccessToken:error:
API Response Parsers
-
+ artistFromData:withResponse:error:
-
+ artistFromDecodedJSON:error:
-
+ artistsFromData:withResponse:error:
-
+ artistsFromDecodedJSON:error:
Convenience Methods
-
+ artistWithURI:accessToken:callback:
-
+ artistsWithURIs:accessToken:callback:
-
– requestAlbumsOfType:withAccessToken:availableInTerritory:callback:
-
– requestTopTracksForTerritory:withAccessToken:callback:
-
– requestRelatedArtistsWithAccessToken:callback:
Miscellaneous
Properties
externalIds
Any external IDs of the track, such as the ISRC code.
@property (nonatomic, readonly, copy) NSDictionary *externalIds
Declared In
SPTArtist.h
followerCount
The number of followers this artist has.
@property (nonatomic, readonly) long followerCount
Declared In
SPTArtist.h
genres
Returns a list of genre strings for the artist.
@property (nonatomic, readonly, copy) NSArray *genres
Declared In
SPTArtist.h
images
Returns a list of artist images in various sizes, as SPTImage
objects.
@property (nonatomic, readonly, copy) NSArray *images
Declared In
SPTArtist.h
largestImage
Convenience method that returns the largest available artist image.
@property (nonatomic, readonly) SPTImage *largestImage
Declared In
SPTArtist.h
Class Methods
artistFromData:withResponse:error:
Parse an API response into an SPTArtist
object.
+ (instancetype)artistFromData:(NSData *)data withResponse:(NSURLResponse *)response error:(NSError **)error
Parameters
- data
The API response data.
- response
The API response object.
- error
An optional
NSError
that will be set if an error occured when parsing the data.
Return Value
an SPTAlbum
object, or nil if the parsing failed.
Declared In
SPTArtist.h
artistFromDecodedJSON:error:
Parse an JSON object structure into an array of SPTAlbum
object.
+ (instancetype)artistFromDecodedJSON:(id)decodedObject error:(NSError **)error
Parameters
- decodedObject
The decoded JSON structure to parse.
- error
An optional
NSError
that will be set if an error occured when parsing the data.
Return Value
an SPTAlbum
object, or nil if the parsing failed.
Declared In
SPTArtist.h
artistWithURI:accessToken:callback:
Request the artist at the given Spotify URI.
+ (void)artistWithURI:(NSURL *)uri accessToken:(NSString *)accessToken callback:(SPTRequestCallback)block
Parameters
- uri
The Spotify URI of the artist to request.
- accessToken
An access token.
- 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 createRequestForArtist:withAccessToken:error:
and SPTRequest
performRequest:callback:
Note: This method takes Spotify URIs in the form spotify:*
, NOT HTTP URLs.
Declared In
SPTArtist.h
artistsFromData:withResponse:error:
Parse an API response into an array of SPTArtist
objects.
+ (NSArray *)artistsFromData:(NSData *)data withResponse:(NSURLResponse *)response error:(NSError **)error
Parameters
- data
The API response data.
- response
The API response object.
- error
An optional
NSError
that will be set if an error occured when parsing the data.
Return Value
an SPTAlbum
object, or nil if the parsing failed.
Declared In
SPTArtist.h
artistsFromDecodedJSON:error:
Parse an JSON object structure into an array of SPTAlbum
object.
+ (NSArray *)artistsFromDecodedJSON:(id)decodedObject error:(NSError **)error
Parameters
- decodedObject
The decoded JSON structure to parse.
- error
An optional
NSError
that will be set if an error occured when parsing the data.
Return Value
an SPTAlbum
object, or nil if the parsing failed.
Declared In
SPTArtist.h
artistsWithURIs:accessToken:callback:
Request multiple artists given an array of Spotify URIs.
+ (void)artistsWithURIs:(NSArray *)uris accessToken:(NSString *)accessToken callback:(SPTRequestCallback)block
Parameters
- uris
An array of Spotify URIs.
- accessToken
An access token.
- block
The block to be called when the operation is complete. The block will pass an array of
SPTArtist
objects on success, otherwise an error.
Discussion
This is a convenience method on top of the createRequestForArtists:withAccessToken:error:
and SPTRequest
performRequest:callback:
Note: This method takes an array Spotify URIs in the form spotify:*
, NOT HTTP URLs.
Declared In
SPTArtist.h
createRequestForAlbumsByArtist:ofType:withAccessToken:market:error:
Request the artist’s albums.
+ (NSURLRequest *)createRequestForAlbumsByArtist:(NSURL *)artist ofType:(SPTAlbumType)type withAccessToken:(NSString *)accessToken market:(NSString *)market error:(NSError **)error
Parameters
- artist
The Spotify URI of the artist.
- type
The type of albums to get.
- accessToken
An access token.
- market
An ISO 3166 country code of the territory to get albums for, or
nil
.
- error
An optional
NSError
that will be set if an error occured.
Discussion
The territory parameter of this method can be nil
to specify “any country”, but expect a lot of
duplicates as the Spotify catalog often has different albums for each country. Pair this with an
SPTUser
’s territory
property for best results.
Declared In
SPTArtist.h
createRequestForArtist:withAccessToken:error:
Create a request for fetching an artist
+ (NSURLRequest *)createRequestForArtist:(NSURL *)uri withAccessToken:(NSString *)accessToken error:(NSError **)error
Parameters
- uri
The Spotify URI of the artist to request.
- accessToken
An access token.
- error
An optional
NSError
that will be set if an error occured.
Return Value
A NSURLRequest for requesting the album
Discussion
Note: This method takes Spotify URIs in the form spotify:*
, NOT HTTP URLs.
Declared In
SPTArtist.h
createRequestForArtists:withAccessToken:error:
Create a request for fetching a multiple artists
+ (NSURLRequest *)createRequestForArtists:(NSArray *)uris withAccessToken:(NSString *)accessToken error:(NSError **)error
Parameters
- uris
An array of Spotify URIs.
- accessToken
An access token.
- error
An optional
NSError
that will be set if an error occured.
Return Value
A NSURLRequest for requesting the albums
Discussion
Note: This method takes Spotify URIs in the form spotify:*
, NOT HTTP URLs.
Declared In
SPTArtist.h
createRequestForArtistsRelatedTo:withAccessToken:error:
Request the artist’s related artists.
+ (NSURLRequest *)createRequestForArtistsRelatedTo:(NSURL *)artist withAccessToken:(NSString *)accessToken error:(NSError **)error
Parameters
- artist
The Spotify URI of the artist.
- accessToken
An access token.
- error
An optional
NSError
that will be set if an error occured.
Declared In
SPTArtist.h
createRequestForTopTracksForArtist:withAccessToken:market:error:
Request the artist’s top tracks.
+ (NSURLRequest *)createRequestForTopTracksForArtist:(NSURL *)artist withAccessToken:(NSString *)accessToken market:(NSString *)market error:(NSError **)error
Parameters
- artist
The Spotify URI of the artist.
- accessToken
An access token.
- market
An ISO 3166 country code of the territory to get top tracks for.
- error
An optional
NSError
that will be set if an error occured.
Discussion
The territory parameter of this method is required. Pair this with an
SPTUser
’s territory
property for best results.
Declared In
SPTArtist.h
identifierFromURI:
Get the identifier part of an Spotify Artist URI.
+ (NSString *)identifierFromURI:(NSURL *)uri
Parameters
- uri
The Spotify URI to check.
Return Value
The identifier part of the artist URI.
Discussion
Note: This method takes Spotify URIs in the form spotify:*
, NOT HTTP URLs.
Declared In
SPTArtist.h
Instance Methods
requestAlbumsOfType:withAccessToken:availableInTerritory:callback:
Request the artist’s albums.
- (void)requestAlbumsOfType:(SPTAlbumType)type withAccessToken:(NSString *)accessToken availableInTerritory:(NSString *)territory callback:(SPTRequestCallback)block
Parameters
- type
The type of albums to get.
- accessToken
An access token.
- territory
An ISO 3166 country code of the territory to get albums for, or
nil
.
- block
The block to be called when the operation is complete. The block will pass an
SPTListPage
object on success, otherwise an error.
Discussion
The territory parameter of this method can be nil
to specify “any country”, but expect a lot of
duplicates as the Spotify catalog often has different albums for each country. Pair this with an
SPTUser
’s territory
property for best results.
Declared In
SPTArtist.h
requestRelatedArtistsWithAccessToken:callback:
Request the artist’s related artists.
- (void)requestRelatedArtistsWithAccessToken:(NSString *)accessToken callback:(SPTRequestCallback)block
Parameters
- accessToken
An access token.
- block
The block to be called when the operation is complete. The block will pass an
NSArray
object containingSPTArtist
s on success, otherwise an error.
Declared In
SPTArtist.h
requestTopTracksForTerritory:withAccessToken:callback:
Request the artist’s top tracks.
- (void)requestTopTracksForTerritory:(NSString *)territory withAccessToken:(NSString *)accessToken callback:(SPTRequestCallback)block
Parameters
- territory
An ISO 3166 country code of the territory to get top tracks for.
- accessToken
An access token.
- block
The block to be called when the operation is complete. The block will pass an
NSArray
object containingSPTTrack
s on success, otherwise an error.
Discussion
The territory parameter of this method is required. Pair this with an
SPTUser
’s territory
property for best results.
Declared In
SPTArtist.h