Can't access chart playlists for a specific genre

I am trying to offer my users a wide variety of playlists, like Apple Music does in the "explore" section.

I fetched the charting playlists for the current storefront, but that's as far as I get. For example, I fetch the top charts genres first. If a user selects a genre I want to display the playlists for this genre, so I call the charts endpoint with the genre as the id but I can't get a response.

path = "/v1/catalog/\(storefrontID)/charts"

components.queryItems = [
    URLQueryItem(name: "types", value: "playlists"),
    URLQueryItem(name: "chart", value: "most-played")
]

if let id = id {
    let genreQuery = URLQueryItem(name: "genre", value: id)
    components.queryItems?.append(genreQuery)
}

Even weirder, I get exactly one genre "Musik" (which isn't a genre) with identifier "34" and storefrontId "de" where it works and I get my playlists. All other genre return empty responses.

I try to use AppleMusic API with MusicKit as an addition, but there doesn't seem to be a solution for this problem either.

Post not yet marked as solved Up vote post of D0nMalte Down vote post of D0nMalte
879 views

Replies

Yes, this seems like it should be a part of the API as Apple Music uses it extensively (on the search screen there are genres/categories, you can browse by generic the More To Explore section of the Browse tab).

I tried to get playlists for the Blues genre, for example:

var genrePlaylistRequest = MusicCatalogChartsRequest(genre: genre, types: [Playlist.self])
let genrePlaylistReponse = try await genrePlaylistRequest.response()

and here was the response:

MusicDataRequest.Error(
  status: 404,
  code: 40400,
  title: "Resource Not Found",
  detailText: "No chart(s) found for type(s) 'playlists', contexts '', genre '2'",
  id: "5BXPJ5652TVENA3NBWAR2XCD24",
  originalResponse: MusicDataResponse(
    data: 184 bytes,
    urlResponse: <NSHTTPURLResponse: 0x0000000282804120>
  )
)

As an added thought, this probably is intended behavior because playlists are not technically "charted" in the same way albums and songs are. However, I still think there should be a way to get playlists for a specific genre in the same way the Apple Music app can via MusicKit (maybe there is but I'm not exactly sure how).