Skip to content
Client
Server

Open Music SDKThe Apple Music API for JavaScript and TypeScript

Open and community-led. A typed function for nearly every endpoint, tokens that look after themselves, and packages for servers, web pages and React.

Open Music SDK logo

Where to start ​

  1. Read Which package to install. Most apps need one package.
  2. Set up your MusicKit key. Every request needs a developer token, and you sign it with this key. The CLI's doctor tells you whether Apple takes it.
  3. Set up your server and your client, with the code for the ones you pick in the nav: a page with no framework, React or Next.js, and Express, Cloudflare Workers or Next.js.
  4. To try the listener's side with your own account before your app has a sign-in, get a Music User Token with the CLI's login. See The command-line tool.
  5. To see it all working together, run one of the sample apps on your machine. The example in each package's reference page, server, browser or react, is the shortest.

A first look ​

On your server, with your MusicKit key:

ts
import { createServerClient } from "@open-music-sdk/server";

const music = createServerClient({
  pem: process.env.APPLE_MUSIC_PRIVATE_KEY!,
  teamId: process.env.APPLE_MUSIC_TEAM_ID!,
  keyId: process.env.APPLE_MUSIC_KEY_ID!,
  storefront: "us",
});

const album = await music.catalog.getAlbum("1613600183");
console.log(album.attributes?.name);

How these docs are organised ​

  • Guides take you to one goal, such as signing a listener in or importing a playlist.
  • Concepts explain how the SDK works and why: its tokens, its security model and its errors.
  • The Reference lists every function, type and option of every package, generated from the source.
  • The Glossary explains the words these docs use.

MIT licensed. Not affiliated with, endorsed by, or sponsored by Apple Inc. Apple Music and MusicKit are trademarks of Apple Inc.