Skip to content
Client
Server

Reference / @open-music-sdk/core / createClient

Function: createClient() ​

ts
function createClient(given): tAppleMusicClient;

Defined in: packages/core/src/client.ts:387

The client: one fetch wrapper that attaches the tokens, encodes the parameters, follows next links, reads Apple's statuses as tagged errors and retries what is worth retrying. The options are checked here, so a mistake fails at creation and not on the first request; what a provider gives, and what a store holds, are checked when they are used. Every function of the SDK takes what this gives.

Parameters ​

given ​

tClientOptions

The developer token, and whatever else: a listener's token or a store of them, a storefront, a fetch, a retry policy, a rate limiter and the hooks.

Returns ​

tAppleMusicClient

A client with request, paginate, storefront, as and forUser.

Throws ​

TypeError if given is no object, developerToken or userToken is neither a token nor a function, userTokenStore has no get, set and delete, storefront is not one segment of a path as segmentOf holds it to be, fetch, onRequest or onResponse is no function, retry is neither false nor a plain object, a field of retry is not what tRetryPolicy says, or rateLimit has no acquire.

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