Reference / @open-music-sdk/client-user / addToFavorites
Function: addToFavorites()
function addToFavorites(
client,
ids,
options?
): Promise<void>;Defined in: clients/client-user/src/library.ts:144
Adds resources to the listener's favorites, 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 made a favorite had a rating of 1 at once, as a like does, and was put in the library too.
Parameters
client
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 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?
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 among the favorites.
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.