Documentation

Everything you need to add live streaming to your game.

Try It Now

Use these credentials to test streaming immediately against our hosted API.

API URLhttps://substream-sdk-production.up.railway.app
Child IDdemo-child-001
Auth Tokendemo-token
Viewer Tokendemo-viewer-token

Quick Start

Web Games (5 min)

Stream any HTML5 canvas game with 5 lines of code. Works with Phaser, Three.js, PixiJS, Unity WebGL, and more.

import Substream from '@substream/web-sdk';

const session = await Substream.startStream({
  canvasElement: document.querySelector('canvas'),
  backendUrl: 'https://your-api.com',
  authToken: 'your-token',
});

Unity Native

Copy the SDK scripts into your Unity project, add the streaming component, and configure your backend URL.

// 1. Add IVSRealTimeStreamControl to a GameObject
// 2. Configure in Inspector:
//    Backend URL: https://your-api.com
//    Streamer ID: player-123
//    Auth Token:  your-token
// 3. Start streaming:
streamControl.StartStreaming(); // or press 'U'

Script Tags (zero build step)

For the simplest integration, just add two script tags. No npm, no bundler.

<script src="https://web-broadcast.live-video.net/1.32.0/amazon-ivs-web-broadcast.js"></script>
<script src="substream.js"></script>
<script>
  const session = await Substream.startStream({
    canvas: document.getElementById('game-canvas'),
    backendUrl: 'https://your-api.com',
    childId: 'player-123',
    authToken: 'your-token',
  });
</script>

Core Concepts

Streams

A stream is created when a player starts broadcasting. The SDK captures the canvas, encodes it via WebRTC, and publishes to an IVS Real-Time stage. Streams are tracked in the dashboard with live status, duration, and viewer count.

Recordings

Every stream is automatically recorded to S3 via IVS. Recordings appear in the dashboard once the stream ends. They can be played back as VODs or used as input for AI highlight generation.

AI Highlights

The highlight service analyzes recordings using Google Cloud Video Intelligence and Gemini to identify the best moments. It scores segments by visual action, audio intensity, and AI analysis, then assembles a polished highlight reel with crossfade transitions.

Webhooks

Register webhook endpoints to receive real-time notifications. Events include stream.started, stream.stopped, viewer.joined, and viewer.left. Payloads are HMAC-signed for security.

API Reference

All endpoints require an Authorization: Bearer <token> header.

POST/api/streams/web-publishStart a stream (allocate IVS stage, get publish token)
DELETE/api/streams/web-publishStop a stream (release stage)
GET/api/streams/web-publishCheck stage pool status
POST/api/streams/whipStart a stream via WHIP (Unity)
GET/api/streams/{streamId}/viewerGet viewer subscribe token
POST/api/webhooksRegister a webhook endpoint
GET/api/webhooksList registered webhooks
DELETE/api/webhooksRemove a webhook
GET/api/healthService health check

SDK Reference

SubstreamSDK.startStream(config)

Start streaming a canvas element. Returns a session object with stop(), streamId, viewerUrl, and isLive.

canvasElementHTMLCanvasElementYesThe canvas to capture
backendUrlstringYesSubstream API URL
streamerIdstringYesUnique player/streamer ID
authTokenstringYesAPI key or JWT
orgIdstringNoOrganization ID
titlestringNoStream title
fpsnumberNoFrame rate (default: 30)
audiobooleanNoInclude audio (default: true)
onLivefunctionNoCalled when live
onErrorfunctionNoCalled on error
onStoppedfunctionNoCalled when stopped

SubstreamSDK.captureAudio()

Enable automatic audio capture. Must be called before the game engine creates its AudioContext. Monkey-patches AudioNode.connect to tee audio into a MediaStream. Audio still plays through speakers normally.

Interactive DemoDashboardGitHubnpm Package