Skip to content
Client
Server

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

Function: searchLibrary() ​

ts
function searchLibrary(
   client, 
   term, 
   options
): Promise<tLibrarySearchResponse>;

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

Searches the listener's library for a term, and resolves to the results by type, each one a first page. limit and offset apply to every type asked for. A next link of a search answers with results by type again, not with a page, so paginate stops after the first page: to get more of one type, ask again with a larger offset. Against the live API on 18 October 2026, the whole name of a song of three words or more found nothing, while the first word of it found the song.

Parameters ​

client ​

tAppleMusicClient

The listener's client to ask with.

term ​

string

What to search for, 1 to 256 characters.

options ​

tSearchLibraryOptions

The types to look for, which have to be given; how many of each to send and where to start; and what to send beside each.

Returns ​

Promise<tLibrarySearchResponse>

What Apple answered: the results by type under results, each a first page of its own.

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.