Class: ArtistsEndpoint
Defined in: endpoints/Artists/index.ts:23
Strongly-typed helper for the Apple Music artists endpoint.
Methods
get()
get(params: ArtistParams): Promise<ArtistsResponse>;
Defined in: endpoints/Artists/index.ts:55
Fetch a catalog artist by identifier.
Parameters
| Parameter | Type | Description |
|---|---|---|
params | ArtistParams | ArtistParams containing the artist identifier and optional query filters. |
Returns
Promise<ArtistsResponse>
Complete artist 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 artist = await appleMusic.Artists.get({ id: "909253" });
console.log(artist.data[0].attributes?.name);
getView()
getView(params: ArtistViewParams): Promise<ArtistsViewResponse>;
Defined in: endpoints/Artists/index.ts:107
Fetch a curated relationship view on an artist.
Parameters
| Parameter | Type | Description |
|---|---|---|
params | ArtistViewParams | ArtistViewParams describing the artist identifier, view name, and optional query options. |
Returns
Promise<ArtistsViewResponse>
A collection representing the requested view.
Remarks
Wraps GET /v1/catalog/{storefront}/artists/{id}/view/{view}.
Throws
Error When the endpoint has not been initialized.
Throws
Error When Apple Music returns an unexpected response.
Example
const playlists = await appleMusic.Artists.getView({
id: "909253",
view: ArtistsEndpointTypes.ArtistViewName.FeaturedPlaylists,
});
getRelationship()
getRelationship<T>(params: ArtistRelationshipParams): Promise<ArtistsRelationshipResponse<T>>;
Defined in: endpoints/Artists/index.ts:165
Fetch a direct relationship collection for an artist.
Type Parameters
| Type Parameter | Default type |
|---|---|
T extends keyof ArtistRelationshipResourceMap | keyof ArtistRelationshipResourceMap |
Parameters
| Parameter | Type | Description |
|---|---|---|
params | ArtistRelationshipParams | ArtistRelationshipParams describing the artist identifier, relationship name, and optional query options. |
Returns
Promise<ArtistsRelationshipResponse<T>>
The requested relationship data.
Remarks
Wraps GET /v1/catalog/{storefront}/artists/{id}/{relationship}.
Throws
Error When the endpoint has not been initialized.
Throws
Error When Apple Music returns an unexpected response.
Example
const albums = await appleMusic.Artists.getRelationship({
id: "909253",
relationship: ArtistsEndpointTypes.IncludeOption.Albums,
});