Skip to content
Client
Server

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

Interface: tRelationshipEndpoint()<Rels, C> ​

Defined in: packages/core/src/endpoint.ts:541

A function for a resource's relationships: GET {collection}/{id}/{name}. Rels is the resource's relationships as the generated types have them, such as tAlbumRelationships: its keys are the names that may be asked for, and the name asked for decides what comes back, and so what a schema for it has to be a schema of.

Type Parameters ​

Rels ​

Rels

C ​

C = tNone

ts
tRelationshipEndpoint<K>(
   client, 
   id, 
   name, 
   options?
): Promise<tRelationshipPage<Rels, K>>;

Defined in: packages/core/src/endpoint.ts:558

One page of the relationship, as Apple answers it. id and name are each checked as one segment of a path, and options as tEndpointOptions, before Apple is asked.

Type Parameters ​

K ​

K extends string

Parameters ​

client ​

tAppleMusicClient

The client to ask with.

id ​

string

The resource's id.

name ​

K

The relationship's name, one of the keys of Rels, such as "albums".

options? ​

tReadOptions<tRelationshipPage<Rels, K>> & C & object & tWalkOptions

What everyone's options are, the collection's, and maxPages, which this call has no use for.

Returns ​

Promise<tRelationshipPage<Rels, K>>

What Apple answered: the first page of the relationship, with next when there is more.

Throws ​

TypeError if client is no client, id or name is not one segment of a path, an option is not what it should be, or the collection's path could not be asked for as written; before this endpoint is asked.

Throws ​

AppleMusicError as client.request rejects with, _tag says which; or as client.storefront() rejects with, where the collection asks it.

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.

Properties ​

bound ​

ts
readonly bound: (client) => <K>(id, name, options?) => AsyncIterable<tItem<NonNullable<Rels[K]>>>;

Defined in: packages/core/src/endpoint.ts:565

The same call with the client fixed, walking every page: the resources the relationship holds, one at a time, for as many pages as maxPages allows. Binding checks the client; the arguments are checked as the bound function is called, and a mistake is thrown from the call. Apple is asked for nothing until a loop starts, and the loop throws what client.paginate does.

Parameters ​

client ​

tAppleMusicClient

Returns ​

<K>(id, name, options?) => AsyncIterable<tItem<NonNullable<Rels[K]>>>


unwrap ​

ts
readonly unwrap: "pages";

Defined in: packages/core/src/endpoint.ts:569

Always "pages": the bound form walks them.

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