Accessing details about the Curator

Hi there!

How do I go about accessing the details of the curator?

For example, if I hit the following endpoint to access details about a playlist:

https://api.music.apple.com/v1/catalog/us/playlists/pl.047294ae14a24e5993d1f7ab2b127188

Then, in the response, I see the curator containing the ID under relationships:

"curator": {
 "href": "/v1/catalog/us/playlists/pl.047294ae14a24e5993d1f7ab2b127188/curator",
 "data": [
  {
   "id": "976439548",
   "type": "apple-curators",
   "href": "/v1/catalog/us/apple-curators/976439548"
  }
 ]
}

Using this ID, I can get more information like the editorial notes, kind, artwork, etc.

If I use MusicKit to get details about the playlist:

let id = MusicItemID("pl.047294ae14a24e5993d1f7ab2b127188")
let request = MusicCatalogResourceRequest<Playlist>(matching: \.id, equalTo: id)
let response = try await request.response()

guard let playlist = response.items.first else { return }

print(playlist.curatorName)

It does not expose the Curator object but only the curatorName.

How can I access the ID of the curator?

Answered by Frameworks Engineer in 716981022

Hello @snuff4,

I just wanted to let you know you no longer need to use MusicDataRequest on iOS 16 beta 1 to fetch the curator relationship of a Playlist.

Instead, you can load both the .curator and the .radioShow relationships of a playlist, and access them with the curator and radioShow accessors.

This is briefly mentioned in our new WWDC22 session video, Explore more content with MusicKit.

One thing to know though is that, if the curator relationship of the playlist in Apple Music API happened to point to a resources of type AppleCurators and kind equal to "Genre", then you still won't be able to access it, because those resources are not yet exposed in MusicKit.

Best regards,

Hello @snuff4,

Thank you for your question about accessing the curator relationship of a playlist.

When we looked at exposing Curators and AppleCurators in MusicKit framework, we decided to model it in Swift a little bit differently, with the hope of exposing data in a way that would be as clear as possible to Swift app developers.

What's interesting about AppleCurators in Apple Music API is that they have a kind attribute, which can be one of the three values:

  • "Curator";
  • "Show";
  • "Genre".

In addition to AppleCurators, Apple Music API has a completely separate Curators resource type.

The way these Apple Music API resources are mapped to MusicKit types is a bit subtle.

In this case, the curator of this playlist can be loaded with the following URL: https://api.music.apple.com/v1/catalog/us/playlists/pl.047294ae14a24e5993d1f7ab2b127188/curator.

The JSON representation of this resource looks like:

      {
         "attributes" : {
            [...]
            "kind" : "Genre",
            "name" : "Apple Music Pop",
            "shortName" : "Pop",
            "url" : "https://music.apple.com/us/curator/apple-music-pop/976439548"
         },
         "href" : "/v1/catalog/us/apple-curators/976439548",
         "id" : "976439548",
         "type" : "apple-curators"
      }

As you can see, this is a resource of type AppleCurators and kind equal to "Genre", and hence, it cannot be represented as one of the existing music item types in MusicKit.

I would encourage you to file a ticket on Feedback Assistant requesting better support for these kinds of curators in MusicKit.

But as always, for the time being, you could load this raw data using MusicDataRequest, define your own Decodable-conforming representation of this resource, and decode the response's data using MusicItemCollection and your own custom structure.

I hope this helps.

Best regards,

I haven't played around at all with the curator stuff -- @JoeKun, that post is a great overview and has me playing around in Postman.

One thing I haven't been able to figure out: is there any particular rhyme or reason to the order in which the API returns the Playlist relationships? Taking your example of Apple Music Pop, I had expected the API to return the playlists in an order roughly equivalent to the page in Music.app. The most popular playlists first, which as I look now at Music.app on my Mac are "Today's Hits" and "Viral Hits."

These are the two playlists returned from this endpoint, which I don't see anywhere on the Music.app Apple Music Pop page:

"name": "Tom Mann: Songbook",
"url": "https://music.apple.com/us/playlist/tom-mann-songbook/pl.b5a5fecc589d4056be182e8cafdc0fc0"

and

"url": "https://music.apple.com/us/playlist/ivan-dorn-essentials/pl.362b70aa54e54989a08a2e2df4ff48d3",
"name": "Ivan Dorn Essentials",

The Albums relationship for Artist seems to be more or less by popularity, but that doesn't seem to be the case here. Any hints at how to best make use of that resource?

Accepted Answer

Hello @snuff4,

I just wanted to let you know you no longer need to use MusicDataRequest on iOS 16 beta 1 to fetch the curator relationship of a Playlist.

Instead, you can load both the .curator and the .radioShow relationships of a playlist, and access them with the curator and radioShow accessors.

This is briefly mentioned in our new WWDC22 session video, Explore more content with MusicKit.

One thing to know though is that, if the curator relationship of the playlist in Apple Music API happened to point to a resources of type AppleCurators and kind equal to "Genre", then you still won't be able to access it, because those resources are not yet exposed in MusicKit.

Best regards,

Accessing details about the Curator
 
 
Q