Skip to content
Client
Server

Reference / @open-music-sdk/client-user / addToLibrary

Function: addToLibrary() ​

ts
function addToLibrary(
   client, 
   ids, 
   options?
): Promise<void>;

Defined in: clients/client-user/src/library.ts:126

Adds catalog resources to the listener's library, by their ids: { songs: [...], albums: [...] }. It resolves to nothing: Apple accepts the request and adds them afterwards. Against the live API on 18 October 2026, a song, an album, a playlist and a music video each showed in the library within 4 seconds, and within 20 in a second run; the playlist's songs did not go into the library with it either time.

Parameters ​

client ​

tAppleMusicClient

The listener's client to ask with.

ids ​

Readonly<Partial<Record<"songs" | "music-videos" | "albums" | "playlists", readonly string[] | undefined>> & Record<string, readonly string[] | undefined>>

The ids of the catalog resources to add, by type: 1 to 32 types with 1 to 300 ids between them; a type whose list is undefined is left out.

options? ​

tAddOptions

What else to send with the request, such as a signal to abort it with.

Returns ​

Promise<void>

Nothing: it resolves once Apple has accepted the request, which is before the resources appear in the library.

Throws ​

TypeError if client is no client or an argument is not what it should be, before Apple is asked.

Throws ​

AppleMusicError if Apple, the network, or a token provider fails, or a schema finds issues; _tag says which.

Throws ​

The reason options.signal aborted with, when it does.

Throws ​

Whatever a token provider, store, schema, hook or rate limiter throws, as client.request passes it on.

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