Resources Overview
Access specific catalog resources via lazy-loaded getters on the MusicKit instance:
musicKit.songs // SongsResourcemusicKit.albums // AlbumsResourcemusicKit.artists // ArtistsResourcemusicKit.musicVideos // MusicVideosResourcemusicKit.storefronts // StorefrontsResourceParsed vs Raw
Section titled “Parsed vs Raw”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 ← simplifiedRaw (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].idResult Wrapper
Section titled “Result Wrapper”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}Error Handling
Section titled “Error Handling”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 nullconsole.log(result.data)When a request fails, data will be null and error will contain the response body.
Available Resources
Section titled “Available Resources”| 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?) |