Skip to main content

Class: SongsEndpoint

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

Strongly-typed helper for the Apple Music songs endpoint.

Methods

get()

get(params: SongParams): Promise<SongsResponse>;

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

Fetch a catalog song by identifier.

Parameters

ParameterTypeDescription
paramsSongParamsSongParams containing the song identifier and optional query filters.

Returns

Promise<SongsResponse>

Complete song 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 song = await appleMusic.Songs.get({ id: "1468058165" });
console.log(song.data[0].attributes?.name);

getRelationship()

getRelationship<T>(params: SongsRelationshipParams): Promise<SongsRelationshipResponse<T>>;

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

Fetch a direct relationship collection for a song.

Type Parameters

Type ParameterDefault type
T extends keyof SongRelationshipResourceMapkeyof SongRelationshipResourceMap

Parameters

ParameterTypeDescription
paramsSongsRelationshipParamsSongsRelationshipParams describing the song identifier, relationship name, and optional query options.

Returns

Promise<SongsRelationshipResponse<T>>

The requested relationship data.

Remarks

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

Throws

Error When the endpoint has not been initialized.

Throws

Error When Apple Music returns an unexpected response.

Example

const artists = await appleMusic.Songs.getRelationship({
id: "1468058165",
relationship: SongsEndpointTypes.IncludeOption.Artists,
});