Skip to navigation

TypeScript SDK

Install, authenticate, and call every MediaKind API from one client.

Install

npm install @mediakind/sdk

Authenticate

The client reads a bearer token. Create one in the mk.io web application — see API tokens — and keep it in the environment rather than in source.

import { MediaKind } from "@mediakind/sdk";
const client = new MediaKind({
apiToken: process.env.MEDIAKIND_API_TOKEN,
});

Namespaces

Every API is reachable from the one client. The first segment selects the API:

NamespaceAPI
client.mediamk.io Media API
client.livemk.io Live API
client.managementmk.io Management API
client.templatesmk.io Templates API
client.channelsBeam Channels API
client.fleetsBeam Fleets API
client.infrastructureBeam Infrastructure API
client.vosHarmonic VOS API
// list on-demand assets
const assets = await client.media.assets.list();
// inspect a Beam device fleet
const devices = await client.fleets.devices.list();
// drive a VOS playout backend
const services = await client.vos.playoutBackend.list();

Error handling

Failed requests throw a typed error carrying the HTTP status and the parsed body.

import { MediaKindError } from "@mediakind/sdk";
try {
await client.media.assets.get("does-not-exist");
} catch (err) {
if (err instanceof MediaKindError) {
console.error(err.statusCode, err.body);
}
throw err;
}

This SDK is generated from the same specs that produce this site’s API reference, so the two never drift. See the source repository.