Inherits from SPTPartialAlbum : SPTJSONObjectBase : NSObject
Conforms to SPTJSONObject
SPTTrackProvider
Declared in SPTAlbum.h

Overview

This class represents an album on the Spotify service.

API Docs: https://developer.spotify.com/web-api/get-album/

API Console: https://developer.spotify.com/web-api/console/albums/

API Model: https://developer.spotify.com/web-api/object-model/#album-object-full

Example usage:

[SPTAlbum albumWithURI:[NSURL URLWithString:@"spotify:album:58Dbqi6VBskSmnSsbXbgrs"]
    accessToken:accessToken
    market:@"UK"
    callback:^(NSError *error, id object) {
        if (error != nil) { handle error  }
        NSLog(@"Got album %@", object);
}];

Properties

artists

An array of artists for this album, as SPTPartialArtist objects.

@property (nonatomic, readonly) NSArray *artists

Declared In

SPTAlbum.h

externalIds

Any external IDs of the album, such as the UPC code.

@property (nonatomic, readonly, copy) NSDictionary *externalIds

Declared In

SPTAlbum.h

firstTrackPage

The tracks contained by this album, as a page of SPTPartialTrack objects.

@property (nonatomic, readonly) SPTListPage *firstTrackPage

Declared In

SPTAlbum.h

genres

Returns a list of genre strings for the album.

@property (nonatomic, readonly, copy) NSArray *genres

Declared In

SPTAlbum.h

popularity

The popularity of the album as a value between 0.0 (least popular) to 100.0 (most popular).

@property (nonatomic, readonly) double popularity

Declared In

SPTAlbum.h

releaseDate

Day-accurate release date of the track if known, otherwise nil.

@property (nonatomic, readonly) NSDate *releaseDate

Declared In

SPTAlbum.h

releaseYear

The release year of the album if known, otherwise 0.

@property (nonatomic, readonly) NSInteger releaseYear

Declared In

SPTAlbum.h

Class Methods

albumFromData:withResponse:error:

Parse an API Response into an SPTAlbum object.

+ (instancetype)albumFromData:(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

SPTAlbum.h

albumFromDecodedJSON:error:

Parse an JSON object structure into an SPTAlbum object.

+ (instancetype)albumFromDecodedJSON:(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

SPTAlbum.h

albumWithURI:accessToken:market:callback:

Request the album at the given Spotify URI.

+ (void)albumWithURI:(NSURL *)uri accessToken:(NSString *)accessToken market:(NSString *)market callback:(SPTRequestCallback)block

Parameters

uri

The Spotify URI of the album to request.

accessToken

An access token.

market

An optional market parameter. Can be nil.

block

The block to be called when the operation is complete. The block will pass a SPTAlbum object on success, otherwise an error.

Discussion

This is a convenience method on top of the [SPTAlbum createRequestForAlbum:withAccessToken:market:error:] and the shared SPTRequest handler.

Note: This method takes Spotify URIs in the form spotify:*, NOT HTTP URLs.

Declared In

SPTAlbum.h

albumsFromDecodedJSON:error:

Parse an JSON object structure into an array of SPTAlbum object.

+ (NSArray *)albumsFromDecodedJSON:(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

SPTAlbum.h

albumsWithURIs:accessToken:market:callback:

Request multiple albums given an array of Spotify URIs.

+ (void)albumsWithURIs:(NSArray *)uris accessToken:(NSString *)accessToken market:(NSString *)market callback:(SPTRequestCallback)block

Parameters

uris

An array of Spotify URIs.

accessToken

An access token.

market

An optional market parameter. Can be nil.

block

The block to be called when the operation is complete. The block will pass an array of SPTAlbum objects on success, otherwise an error.

Discussion

This is a convenience method on top of the [SPTAlbum createRequestForAlbums:withAccessToken:market:error:] and the shared SPTRequest handler.

Note: This method takes Spotify URIs in the form spotify:*, NOT HTTP URLs.

Declared In

SPTAlbum.h

createRequestForAlbum:withAccessToken:market:error:

Create a request for getting an album.

+ (NSURLRequest *)createRequestForAlbum:(NSURL *)uri withAccessToken:(NSString *)accessToken market:(NSString *)market error:(NSError **)error

Parameters

uri

The Spotify URI of the album to request.

accessToken

An access token.

market

An optional market parameter. Can be nil.

error

An optional NSError that will be set if an error occured.

Return Value

A NSURLRequest for requesting the album

Discussion

API Docs: https://developer.spotify.com/web-api/get-album/

Try it: https://developer.spotify.com/web-api/console/get-album/

Note: This method takes Spotify URIs in the form spotify:*, NOT HTTP URLs.

Declared In

SPTAlbum.h

createRequestForAlbums:withAccessToken:market:error:

Create a request for getting multiple albums.

+ (NSURLRequest *)createRequestForAlbums:(NSArray *)uris withAccessToken:(NSString *)accessToken market:(NSString *)market error:(NSError **)error

Parameters

uris

An array of Spotify URIs. A maxiumum of 20 URIs can be supplied per request.

accessToken

An access token.

market

An optional market parameter. Can be nil.

error

An optional NSError that will be set if an error occured.

Return Value

A NSURLRequest for requesting the albums

Discussion

API Docs: https://developer.spotify.com/web-api/get-several-albums/

Try it: https://developer.spotify.com/web-api/console/get-several-albums/

Note: This method takes Spotify URIs in the form spotify:*, NOT HTTP URLs.

Declared In

SPTAlbum.h

isAlbumURI:

Checks if the Spotify URI is a valid Spotify Album URI.

+ (BOOL)isAlbumURI:(NSURL *)uri

Parameters

uri

The Spotify URI to check.

Discussion

Note: This method takes Spotify URIs in the form spotify:*, NOT HTTP URLs.

Declared In

SPTAlbum.h