Install
npm install @mediux/sdk
Public reads work in browsers. The private client requires a server running Node.js 22 or newer.
Read public resources
import { createPublicClient } from "@mediux/sdk";
const api = createPublicClient();
const show = await api.getShow(1399);
console.log(show.data);
const firstPage = await api.getAssetFeed();
const nextPage = firstPage.meta.nextPage
? await api.getAssetFeed({ pagePath: firstPage.meta.nextPage })
: null;
The client defaults to https://api.mediux.io and needs no credentials.
Detail, Set, group, and feed methods validate responses; YAML methods return
text. getEntityIndex(family, page?) and getEntitySets(family, id) return
unknown, which you must validate before use. Each request fetches one page.
Call protected operations
First connect your app with OAuth. Keep tokens on your server:
import { createPrivateClient } from "@mediux/sdk";
const api = createPrivateClient({
origin: "https://api.mediux.io",
accessToken: () => tokenStore.currentAccessToken(),
});
const relationships = await api.listRelationships({
kind: "follow",
limit: 50,
});
Supply your own server-side tokenStore. Your application handles login,
credential storage, refresh, and revocation. Both clients omit cookies and
reject redirects.
See personal operations for uploads and edits.
createMediaSet and editSet handle staged uploads and return an outcome,
including partial or unresolved results.
Handle errors and retries
| Error | Handling |
|---|---|
BackendError |
Read status and code; preserve details and field issues. |
TransportError |
Check outcome: an unknown mutation result needs reconciliation. |
MalformedResponseError |
Check outcome before retrying; a mutation may have committed. |
SdkInputError or SdkConfigurationError |
Correct the request or client configuration. |
Import these from @mediux/sdk or @mediux/sdk/errors. Separate public and
private entrypoints are also available at @mediux/sdk/public and
@mediux/sdk/private.
The SDK adds no cache or automatic mutation retries, token refresh, or conflict rebasing. After an uncertain write, keep its original identity and retrieve its status before submitting another change.