Its there a way to get all Artists / Albums / Songs

Ive been looking at MusicKit hoping there is a way I can get a list of all Artists, Albums or Songs for a users Library.

I can get these for a search term (see code), but what if I want to just return all Albums from the catalog ? I can't seem to find a method or search term to do this. Is it possible ?

Thanks

 do {
                let searchRequest = MusicCatalogSearchRequest(term: "Muse", types: [Album.self])
                let searchResponse = try await searchRequest.response()
                print(searchResponse.albums.count)
                print(searchResponse.albums)
            } catch {
                print("Failed to load albums")
            }
Accepted Answer

Hello @Dinalli,

In your question, you asked about two completely different things. First you asked for a way to:

get a list of all Artists, Albums or Songs for a users Library.

Then you asked about:

what if I want to just return all Albums from the catalog?

The catalog is a completely different data set than the user's library. I'm going to assume you really care about the user's library though.

In iOS 15, there is no structured request in MusicKit framework to get items from the user's library.

However, you could use our general purpose data request for this purpose: MusicDataRequest.

I've actually already shown in detail how this can be used to get the list of artists in the user's library, in this thread. You can easily apply the same pattern for albums and songs too.

I hope this helps.

Best regards,

Hello @Dinalli,

I just wanted to let you know you no longer need to use MusicDataRequest on iOS 16 beta 1 to fetch artists, albums, and songs from the user's library.

Instead, you can use the brand new MusicLibraryRequest in MusicKit.

Please check our new WWDC22 session video, Explore more content with MusicKit, which goes into this, and much more!

I hope you'll like it!

Best regards,

Its there a way to get all Artists / Albums / Songs
 
 
Q