SDKs

There are two kinds. The web SDK plays and publishes video on a page. The server SDKs call the API from your backend, and hold your API key where a viewer can never see it.

On this page

Install

The web player and the Node SDK are on npm, and the Python client is on PyPI, all under the Apache-2.0 licence:

npm install @creekx/web
npm install @creekx/sdk
pip install creekx

Or load the web player on any page without a build step:

<script type="module" src="https://cdn.jsdelivr.net/npm/@creekx/[email protected]/dist/creekx-web.js"></script>

The Go, PHP, Java and .NET clients are not on their package registries yet. Until they are, generate a client from /openapi.json on your server, or call the REST API directly.

Which one you want

You are building Use It does
A web page that plays or publishes @creekx/web WebRTC playback with HLS behind it, private tokens, going live by WHIP
A backend in Node or TypeScript @creekx/sdk Every API path, typed, with webhook checks
A backend in Python creekx on PyPI Streams, tokens, videos and webhooks, with no dependencies
A backend in Go, PHP, Java or .NET The creekX client for that language (registry release to come) Streams, tokens, videos and webhooks, with no dependencies
Anything else /openapi.json Generate a client: all 210 operations have stable names

There are no native iOS, Android, Flutter, React Native or Unity SDKs yet. Those apps can publish and play today with any WHIP or WHEP client: the API gives the address and the pass. An Android kiosk app for one watch link is available.

Play on your own site

Add your site to the server first, or browsers will refuse it. In /etc/creekx/creekx.env, list each address exactly, then restart:

CREEKX_LIVE_ORIGINS=https://live.example.com,https://auctions.example.com
sudo creekx restart

That opens the public watch routes and the live server to that site, and nothing else in the API. * is refused on purpose: it would let any page on the internet drive a creator's browser into publishing.

Then one tag does it:

<script type="module" src="https://cdn.jsdelivr.net/npm/@creekx/[email protected]/dist/creekx-web.js"></script>
<creekx-player
  server="https://live.example.com"
  stream="STREAM_ID"
  code="CODE_FROM_THE_WATCH_LINK"
></creekx-player>

It starts in real time. If the network will not carry WebRTC, it moves to HLS by itself, so a viewer always gets a picture. It starts muted, because browsers refuse to start sound on their own. A slow start is not treated as a blocked network: it waits up to 45 seconds for the server before moving.

Listen for what it is doing:

player.addEventListener('creekx-state', (event) => {
  const { state, mode, why } = event.detail;
  // state: waiting, connecting, playing, reconnecting, stopped
  // mode: webrtc or hls. why: the reason it moved or stopped, in words.
});

A private viewer or a paid event

code can also be a play token that runs out by itself. Make it on your server and hand it to the page. Never put an API key or a stream key on a page.

const token = await creekx.streams.createToken(streamId, {
  use: 'play',
  expiresInSeconds: 86400,
});
// Give token.token to the page, as the player's code.

Go live from a page

Browsers only give a camera to https pages. Make a publish token on your server, and hand the page the publish.browser from its answer:

import { publish } from '@creekx/web';

const live = await publish({ whipUrl, bearerToken }); // Asks for the camera and microphone.
await live.stop();

Pass stream to send a canvas, a screen or any other MediaStream.

From your server

All of them do the same things: an idempotency key on every POST, waiting and trying again when the server answers 429 or 503, and errors that carry the server's remedy.

Node and TypeScript

import { CreekX } from '@creekx/sdk';

const creekx = new CreekX({ server: 'https://live.example.com', apiKey });
const stream = await creekx.streams.create({ name: 'Auction 12' });
const { obs } = await creekx.streams.revealKey(stream.id);

Python

from creekx import CreekX

creekx = CreekX("https://live.example.com", api_key=api_key)
stream = creekx.streams.create(name="Auction 12")

Go

client := creekx.New("https://live.example.com", apiKey)
stream, err := client.Streams.Create(ctx, "Auction 12")

PHP

$creekx = new CreekX\Client('https://live.example.com', $apiKey);
$stream = $creekx->streams->create('Auction 12');

Java

CreekX creekx = new CreekX("https://live.example.com", apiKey);
Map<String, Object> stream = creekx.streams.create("Auction 12");

C# and .NET

var creekx = new CreekXClient("https://live.example.com", apiKey);
var stream = await creekx.Streams.CreateAsync("Auction 12");

Check a webhook

Every server SDK checks the CreekX-Signature header and refuses anything more than five minutes old. Use the body exactly as it arrived: parsing it and writing it back out changes it. See REST API, keys and webhooks for the events.

const event = await verifyWebhook({
  rawBody,
  signature: request.headers['creekx-signature'],
  secret,
});
Follow the build