Skip to content
Client
Server

Reference / @open-music-sdk/server / createServerClient

Function: createServerClient() ​

ts
function createServerClient(options): tMusic;

Defined in: integrations/server/src/client.ts:44

A client that mints its own developer token from the key it is handed, replaced in the background halfway through its life, with the catalog, the listener's library and the playlist verbs on it. The options are checked and taken here, once: what the minter checks it names itself, and so does createClient. Nothing is asked of Apple until a call. Make it once, at module level: on a worker that is handed its secrets per request, a client made per request imports the key and signs a token on every one.

Parameters ​

options ​

tServerClientOptions

The key and its two ids, and every option of core's client but the developer token.

Returns ​

tMusic

The client, frozen, with the three namespaces made for it.

Throws ​

TypeError if options is not a plain object, holds origin, or a value in it is not what the minter or createClient takes; a pem that is a string but no key is found at the first call, as the TypeError the minter throws then.

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