Skip to content

Resources Overview

Access specific catalog resources via lazy-loaded getters on the MusicKit instance:

musicKit.songs // SongsResource
musicKit.albums // AlbumsResource
musicKit.artists // ArtistsResource
musicKit.musicVideos // MusicVideosResource
musicKit.storefronts // StorefrontsResource

Every resource method accepts an optional raw flag as the last argument.

Parsed (default) — attributes are merged to the top level, relationships are simplified to arrays:

// song.data[0].name ← from attributes
// song.data[0].artistName ← from attributes
// song.data[0].relationships.albums[0].id ← simplified

Raw (true) — the original Apple Music API shape, with nested attributes and relationships containing href and data:

// raw.data[0].attributes.name
// raw.data[0].relationships.albums.href
// raw.data[0].relationships.albums.data[0].id

All methods return the same wrapper type:

{
status: number // HTTP status code
data: T // Response payload (array of items or search result)
error: string | null // Error message if the request failed
}

Check the error field before accessing data:

const result = await musicKit.songs.get("us", "invalid-id")
if (result.error) {
console.error(`Request failed (${result.status}):`, result.error)
return
}
// safe to access data when error is null
console.log(result.data)

When a request fails, data will be null and error will contain the response body.

Resource Methods
Songs get(storefront, id) · getByISRC(storefront, isrc)
Albums get(storefront, id) · getByUPC(storefront, upc)
Artists get(storefront, id)
Music Videos get(storefront, id) · getByISRC(storefront, isrc)
Storefronts getAll(props?) · get(storefront, props?)