Skip to content
Client
Server

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

Interface: tServerClientOptions ​

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

The key and its two ids, as developerTokenMinter takes them, and every option of createClient but the developer token, which the minter provides. origin is not among them: the server's own token never meets a browser, and the one that does is tokenEndpoint's. Invalid values throw a TypeError when the client is made.

Extends ​

Properties ​

fetch? ​

ts
optional fetch?: {
  (input, init?): Promise<Response>;
  (input, init?): Promise<Response>;
};

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

What sends each request. Default: the global fetch.

Call Signature ​

ts
(input, init?): Promise<Response>;

MDN Reference

Parameters ​
input ​

URL | RequestInfo

init? ​

RequestInit

Returns ​

Promise<Response>

Call Signature ​

ts
(input, init?): Promise<Response>;

MDN Reference

Parameters ​
input ​

string | Request | URL

init? ​

RequestInit

Returns ​

Promise<Response>

Inherited from ​

ts
Omit.fetch

keyId ​

ts
readonly keyId: string;

Defined in: packages/developer-token/src/mint.ts:19

The ID of the MusicKit key, the ten capital letters and digits in the file's name; becomes kid.

Inherited from ​

ts
Omit.keyId

onRequest? ​

ts
optional onRequest?: (req) => void;

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

Called just before each attempt is sent, with the final Request. Its headers hold the developer token and, where it is sent, the Music User Token, so a hook that logs requests logs both tokens.

Parameters ​

req ​

Request

Returns ​

void

Inherited from ​

ts
Omit.onRequest

onResponse? ​

ts
optional onResponse?: (res, req, outcome) => void;

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

Called once per response, after the client is done with it: the body has been read and the outcome decided. outcome.error is what the request will throw unless a retry succeeds. The body has been read, so take it from outcome.body, not from res.json(). req is the Request onRequest is handed, token headers and all, so a hook that logs it logs the tokens.

Parameters ​

res ​

Response

req ​

Request

outcome ​

tResponseOutcome

Returns ​

void

Inherited from ​

ts
Omit.onResponse

pem ​

ts
readonly pem: string;

Defined in: packages/developer-token/src/mint.ts:15

The contents of AuthKey_XXXXXXXXXX.p8: a PKCS8 PEM. Line breaks escaped as \n, as an environment variable usually holds them, are accepted, and so are Windows line endings, a byte order mark and whitespace around it.

Inherited from ​

ts
Omit.pem

rateLimit? ​

ts
optional rateLimit?: tRateLimiter;

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

Opt-in token bucket. Share one instance across every client using the same developer token.

Inherited from ​

ts
Omit.rateLimit

refreshAheadSeconds? ​

ts
readonly optional refreshAheadSeconds?: number;

Defined in: packages/developer-token/src/mint.ts:33

Mint a replacement this long before exp. Default, and at most, half the lifetime.

Inherited from ​

ts
Omit.refreshAheadSeconds

retry? ​

ts
optional retry?: false | tRetryPolicy;

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

false disables retries; a plain object sets the policy field by field. Default: 2 attempts, 250 ms base, 4 s cap, full jitter, Retry-After honoured.

Inherited from ​

ts
Omit.retry

storefront? ​

ts
optional storefront?: string;

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

Catalog storefront, by its id, such as "us": one segment of a path. Without it, storefront() resolves the listener's from /v1/me/storefront.

Inherited from ​

ts
Omit.storefront

teamId ​

ts
readonly teamId: string;

Defined in: packages/developer-token/src/mint.ts:17

Your Apple Developer Team ID, ten capital letters and digits as Apple issues it; becomes iss.

Inherited from ​

ts
Omit.teamId

ttlSeconds? ​

ts
readonly optional ttlSeconds?: number;

Defined in: packages/developer-token/src/mint.ts:21

Lifetime in whole seconds, from 60 to 15 777 000 (Apple's six months). Default one hour.

Inherited from ​

ts
Omit.ttlSeconds

userToken? ​

ts
optional userToken?: string | tTokenProvider;

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

Binds the client to one listener. Alternatively set userTokenStore and use forUser().

Inherited from ​

ts
Omit.userToken

userTokenStore? ​

ts
optional userTokenStore?: tUserTokenStore;

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

Where forUser() finds a listener's token. Needs get, set and delete; the client itself calls only get.

Inherited from ​

ts
Omit.userTokenStore

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