Skip to navigation

Python SDK

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

Install

pip install mediakind

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 os
from mediakind import MediaKind
client = MediaKind(api_token=os.environ["MEDIAKIND_API_TOKEN"])

An asynchronous client is available with the same surface:

import asyncio, os
from mediakind import AsyncMediaKind
client = AsyncMediaKind(api_token=os.environ["MEDIAKIND_API_TOKEN"])
async def main() -> None:
assets = await client.media.assets.list()
print(assets)
asyncio.run(main())

Namespaces

Every API is reachable from the one client. The first attribute 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
assets = client.media.assets.list()
devices = client.fleets.devices.list()
services = client.vos.playout_backend.list()

Error handling

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

from mediakind.core import ApiError
try:
client.media.assets.get("does-not-exist")
except ApiError as err:
print(err.status_code, err.body)

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