Skip to main content

Class: AlbumsEndpoint

Defined in: endpoints/Albums/index.ts:23

Strongly-typed helper for the Apple Music albums endpoint.

Methods

get()

get(params: AlbumParams): Promise<AlbumsResponse>;

Defined in: endpoints/Albums/index.ts:53

Fetch a catalog album by identifier.

Parameters

ParameterTypeDescription
paramsAlbumParamsAlbumParams containing the album identifier and optional query filters.

Returns

Promise<AlbumsResponse>

Complete album resource payload returned by Apple Music.

Throws

Error When the endpoint has not been initialized.

Throws

Error When Apple Music returns an unexpected response.

Example

const album = await appleMusic.Albums.get({ id: "310730204" });
console.log(album.data[0].attributes?.name);

getView()

getView(params: AlbumViewParams): Promise<AlbumsViewResponse>;

Defined in: endpoints/Albums/index.ts:105

Fetch a curated relationship view on an album.

Parameters

ParameterTypeDescription
paramsAlbumViewParamsAlbumViewParams describing the album identifier, view name, and optional query options.

Returns

Promise<AlbumsViewResponse>

A collection representing the requested view.

Remarks

Wraps GET /v1/catalog/{storefront}/albums/{id}/view/{view}.

Throws

Error When the endpoint has not been initialized.

Throws

Error When Apple Music returns an unexpected response.

Example

const livePerformances = await appleMusic.Albums.getView({
id: "310730204",
view: "related-videos",
});

getRelationship()

getRelationship<T>(params: AlbumRelationshipParams): Promise<AlbumsRelationshipResponse<T>>;

Defined in: endpoints/Albums/index.ts:163

Fetch a direct relationship collection for an album.

Type Parameters

Type ParameterDefault type
T extends AlbumRelationshipNameAlbumRelationshipName

Parameters

ParameterTypeDescription
paramsAlbumRelationshipParamsAlbumRelationshipParams describing the album identifier, relationship name, and optional query options.

Returns

Promise<AlbumsRelationshipResponse<T>>

The requested relationship data.

Remarks

Wraps GET /v1/catalog/{storefront}/albums/{id}/{relationship}.

Throws

Error When the endpoint has not been initialized.

Throws

Error When Apple Music returns an unexpected response.

Example

const tracks = await appleMusic.Albums.getRelationship({
id: "310730204",
relationship: AlbumsEndpointTypes.IncludeOption.Tracks,
});