No Preview

Sorry, but you either have no stories or none are selected somehow.

If the problem persists, check the browser console, or the terminal you've run Storybook from.

Article

Accessing Music Content via the Apple Music API

MusicKit on the Web’s passthrough API method is able to make requests to the Apple Music API, which gives your app access to the entire Apple Music catalog as well as users’ iCloud Music Library.

The passthrough API method can make requests to any API documented under the Apple Music API, with the added convience of automatically decorating requests with the Developer Token provided during MusicKit configuration, as well as the Music User Token, where necessary, after the user has authorized your app.


Example making a non-personalized API request

const music = MusicKit.getInstance();
const result = await music.api.music(
  `/v1/catalog/us/search`,
  { term: 'SEARCH_TERM', types: 'albums'}
);

Cloud Library API

The Cloud Library gives you access to all the media saved by a user from Apple Music to their Cloud Library.

You can access the Cloud Library API through Apple Music Web Service API methods that start with v1/me/library.

Example

const music = MusicKit.getInstance();
// You should check authorization before accessing user's iCloud Music Library:
await music.authorize();
const result = await music.api.music('v1/me/library/albums');