API Reference

Everything you need to integrate Semantic Streaming and start saving on CDN costs.

Quick Start

Get up and running in under 10 minutes.

1. Install the SDK

npm install semantic-streaming-sdk

2. Initialize

import { SemanticStreamingSDK } from 'semantic-streaming-sdk';
const sdk = new SemanticStreamingSDK({ licenseKey: 'ss_live_your_key' });

3. Connect to your player

yourPlayer.onSkip((skip) => {
  const decision = sdk.analyzeSkip({
    duration: skip.seconds,
    currentQuality: skip.quality,
    platform: 'web'
  });
  if (decision.action === 'adjust_quality')
    yourPlayer.setQuality(decision.toQuality);
});

Authentication

All API endpoints (except health) require your API key in the request header.

X-API-Key: ss_live_your_api_key_here

Base URL: https://semantic-streaming-production.up.railway.app

Endpoints

Sign Up

POST/api/auth/signupRegister and receive your API key
ParameterTypeDescription
namerequiredstringYour full name
emailrequiredstringYour email address
companyoptionalstringCompany name
Response 201
{ "success": true, "apiKey": "ss_live_xxxx", "user": { "plan": "pilot" } }

Analyze Skip

POST/api/v1/analyzeCore endpoint — analyze skip, get quality decision
ParameterTypeDescription
durationrequirednumberSkip duration in seconds
currentQualityrequiredstring144p, 240p, 360p, 480p, 720p, 1080p, 2k, 4k
sessionIdoptionalstringYour session identifier
platformoptionalstringweb, ios, android
Response 200
{
  "action": "adjust_quality",
  "fromQuality": "1080p",
  "toQuality": "240p",
  "savings": { "savedMB": 14.65, "percentage": 91.1 },
  "restorationDelay": 2000
}

Get Stats

GET/api/v1/statsDashboard stats — savings in MB and USD
Query ParamTypeDescription
periodoptionalstringe.g. 2026-03 — defaults to current month

Health Check

GET/api/v1/healthPublic — no API key required
curl https://semantic-streaming-production.up.railway.app/api/v1/health

Integrations

HLS with hls.js — Real Quality Switching

// Works with hls.js — real CDN quality switching
const hls = new Hls();
hls.loadSource(videoUrl);
hls.attachMedia(video);

const sdk = new SemanticStreamingSDK({ licenseKey: 'ss_live_your_key' });

video.addEventListener('seeked', async () => {
  const duration = Math.abs(video.currentTime - lastTime);
  if (duration >= 2.0) {
    const decision = await sdk.analyzeSkip({ duration, currentQuality: '1080p' });
    if (decision.action === 'adjust_quality') {
      hls.currentLevel = findLevel(decision.toQuality); // REAL switch
      setTimeout(() => hls.currentLevel = -1, 2000); // restore
    }
  }
});

Try it yourself at semanticstreaming.netlify.app/demo

HTML5 Video

import { HTML5VideoIntegration } from 'semantic-streaming-sdk';
const optimizer = new HTML5VideoIntegration(videoElement, { minQuality: '360p' });
optimizer.on('savingsCalculated', (d) => console.log(`Saved ${d.savings.savedMB} MB`));

React

import { useRef, useEffect } from 'react';
import { HTML5VideoIntegration } from 'semantic-streaming-sdk';

function OptimizedPlayer({ src }) {
  const ref = useRef();
  useEffect(() => {
    const opt = new HTML5VideoIntegration(ref.current);
    return () => opt.destroy();
  }, []);
  return <video ref={ref} src={src} controls />;
}

Error Codes

StatusCodeDescription
400Bad RequestMissing or invalid parameters
401UnauthorizedMissing or invalid API key
409ConflictEmail already registered
429Too Many RequestsRate limit exceeded
500Server ErrorSomething went wrong on our end

Support

Questions? We respond within 24 hours.

Email: semanticstreaming@gmail.com

Start Free Pilot →