Introduction

Welcome to the StarWave Entertainment API documentation. This guide covers everything you need to integrate with our platform — from content management and media processing to live streaming and analytics.

ℹ️
API Versioning

This documentation covers API version 3.x. We maintain backward compatibility within major versions. See our migration guide for upgrading from v2.

Platform Overview

The StarWave Entertainment API is a comprehensive RESTful API that powers our global entertainment distribution platform. It provides programmatic access to:

Base URL

All API requests are made to the following base URL:

URL
https://api.starwave.io/v3

Response Format

All API responses are returned in JSON format. Successful responses include a data field, while errors include a error object.

JSON — Success Response
{
  "status: "success",
  "data: {
    "id: "cnt_abc123",
    "title: "Beyond the Horizon",
    "type: "film",
    "status: "published",
    "created_at: "2024-01-15T10:30:00Z"
  },
  "meta: {
    "request_id: "req_xyz789",
    "timestamp: "2024-01-15T10:30:05Z"
  }
}

Quick Start

Get up and running with the StarWave API in under 5 minutes. This guide walks you through account setup, authentication, and making your first API call.

Step 1: Create an Account

Sign up at dashboard.starwave.io to create your developer account. Once registered, navigate to Settings → API Keys to generate your credentials.

Step 2: Get Your API Key

You'll need two types of keys:

Key Type Description Permissions
SW_PUB_xxxxxx Public key for client-side operations Read-only content access
SW_SEC_xxxxxx Secret key for server-side operations Full read/write access
SW_TOKEN_xxxxxx Short-lived JWT token (auto-generated) Session-based access
⚠️
Security Notice

Never expose your secret key in client-side code. Store it securely on your server and use environment variables.

Step 3: Make Your First Request

Here's how to fetch your first piece of content using cURL:

Bash
$ curl -X GET https://api.starwave.io/v3/content \
  -H "Authorization: Bearer SW_TOKEN_abc123" \
  -H "Content-Type: application/json" \
  -d '{
    "filter": {
      "type": "film",
      "status": "published"
    },
    "limit": 10
  }'

Step 4: Install an SDK

We offer official SDKs for popular languages. Choose your preferred language:

Terminal
$ npm install @starwave/sdk
JavaScript
const StarWave = require('@starwave/sdk');

const sw = new StarWave({
  apiKey: process.env.STARWAVE_SECRET_KEY,
  version: 'v3'
});

// List all published content
const content = await sw.content.list({
  filter: { status: 'published' },
  limit: 20
});

console.log(`Found ${content.data.length} items`);
Terminal
$ pip install starwave-sdk
Python
from starwave import Client

sw = Client(api_key=os.getenv("STARWAVE_SECRET_KEY"))

# List all published content
content = sw.content.list(
    filter={"status": "published"},
    limit=20
)

print(f"Found {len(content.data)} items")
Terminal
$ composer require starwave/sdk
PHP
<?php
use StarWave\Client;

$sw = new Client([
    'api_key' => getenv('STARWAVE_SECRET_KEY'),
]);

// List all published content
$content = $sw->content()->list([
    'filter' => ['status' => 'published'],
    'limit' => 20,
]);

echo "Found {count($content->data)} items";
Terminal
$ go get github.com/starwave/sdk-go/v3
Go
package main

import (
    "fmt"
    "os"
    "github.com/starwave/sdk-go/v3"
)

func main() {
    sw := starwave.New(starwave.Config{
        APIKey: os.Getenv("STARWAVE_SECRET_KEY"),
    })

    content, _ := sw.ListContent(starwave.ContentFilter{
        Status: "published",
        Limit:  20,
    })

    fmt.Printf("Found %d items\n", len(content.Data))
}

Authentication

StarWave API uses multiple authentication methods depending on the operation type. All API requests require authentication except for public content discovery endpoints.

Authentication Methods

🔑 API Key

Long-lived keys for server-to-server communication. Best for background jobs and scheduled tasks.

"Authorization": "Bearer SW_SEC_xxxxx"

🎫 JWT Token

Short-lived tokens for user sessions. Recommended for web and mobile applications.

"Authorization": "Bearer eyJhbG..."

🔒 OAuth 2.0

Full OAuth 2.0 flow for third-party integrations and delegated access.

"Authorization": "Bearer oauth_token"

Obtaining a JWT Token

Exchange your API key for a short-lived JWT token:

POST /v3/auth/token

Request a JWT token using your API credentials.

Request Body
{
  "grant_type": "api_key",
  "api_key": "SW_SEC_your_secret_key",
  "expires_in": 3600
}
Response
{
  "status": "success",
  "data": {
    "access_token": "eyJhbGciOiJSUzI1NiIs...",
    "token_type": "Bearer",
    "expires_in": 3600,
    "scope": "read write"
  }
}

Rate Limits

To ensure fair usage and platform stability, API requests are rate-limited based on your account tier. All rate limit information is included in response headers.

Rate Limit Tiers

Tier Requests / Minute Requests / Day Burst Limit
Starter 60 10,000 10
Professional 300 100,000 50
Enterprise 1,000 Unlimited 200
Partner Custom Custom Custom

Response Headers

Every API response includes rate limit information in the headers:

HTTP Headers
X-RateLimit-Limit: 300
X-RateLimit-Remaining: 298
X-RateLimit-Reset: 1705312200
X-RateLimit-Burst-Limit: 50
X-RateLimit-Burst-Remaining: 48
💡
Best Practice

Implement exponential backoff with jitter when you receive a 429 Too Many Requests response. Wait time should double with each retry, up to 30 seconds maximum.

List Content

Retrieve a paginated list of content items with optional filtering, sorting, and field selection.

GET /v3/content

Returns a paginated collection of content items. Supports filtering by type, status, genre, and date range.

Query Parameters

Parameter Type Required Description
type string Optional Filter by content type: film, series, short, documentary
status string Optional Filter by status: draft, processing, published, archived
limit integer Optional Number of results (default: 20, max: 100)
offset integer Optional Pagination offset
sort string Optional Sort field: created_at, updated_at, title, views
order string Optional Sort direction: asc or desc (default: desc)
fields string Optional Comma-separated list of fields to include in response

Example Request

Bash
$ curl -X GET "https://api.starwave.io/v3/content?type=film&status=published&limit=10&sort=created_at" \
  -H "Authorization: Bearer SW_TOKEN_abc123"

Example Response

JSON — 200 OK
{
  "status": "success",
  "data": [
    {
      "id": "cnt_abc123",
      "title": "Beyond the Horizon",
      "type": "film",
      "status": "published",
      "genre": ["sci-fi", "drama"],
      "duration": 7320,
      "views": 2450000,
      "thumbnail": "https://cdn.starwave.io/thumbs/cnt_abc123.jpg",
      "created_at": "2024-01-15T10:30:00Z",
      "updated_at": "2024-01-16T08:00:00Z"
    }
  ],
  "pagination": {
    "total": 142,
    "limit": 10,
    "offset": 0,
    "has_more": true,
    "next_cursor": "eyJpZCI6ImNudF94eXo3ODkifQ"
  }
}

Status Codes

200 Success — Content list returned
400 Bad Request — Invalid filter or parameter
401 Unauthorized — Invalid or expired token
429 Too Many Requests — Rate limit exceeded

Create Content

Create a new content item in the system. After creation, upload media files using the returned upload URL.

POST /v3/content

Creates a new content record. The content enters draft status by default.

Request Body

Parameter Type Required Description
title string Required Content title (max 200 characters)
type string Required Content type: film, series, short, documentary
description string Optional Content description (max 5000 characters)
genre string[] Optional Array of genre tags
language string Optional Primary language code (ISO 639-1)
subtitles object[] Optional Subtitle track configurations
drm_enabled boolean Optional Enable DRM protection (default: false)
metadata object Optional Custom key-value metadata

Example Request

JavaScript
const response = await sw.content.create({
  title: "Thunder Strike",
  type: "film",
  description: "An action-packed thriller set in the heart of the storm...",
  genre: ["action", "thriller"],
  language: "en",
  drm_enabled: true,
  metadata: {
    director: "James Chen",
    studio: "StarWave Studios",
    budget_tier: "blockbuster"
  }
});

console.log(`Created: ${response.data.id}`);
console.log(`Upload URL: ${response.data.upload_url}`);

Upload Media

Upload video, audio, and image assets to the StarWave media processing pipeline. Files are automatically transcoded into multiple formats for optimal playback.

POST /v3/media/upload

Upload a media file for processing. Supports video (MP4, MOV, AVI, MKV), audio (MP3, WAV, AAC), and image (JPG, PNG, WEBP) formats. Maximum file size: 50GB.

Upload Methods

We support three upload methods depending on your file size and use case:

📤 Direct Upload

For files under 500MB. Simple multipart/form-data POST request.

☁️ Presigned URL

For files 500MB–50GB. Get a presigned S3 URL and upload directly to cloud storage.

🔄 Chunked Upload

For unreliable networks. Upload files in 5MB chunks with automatic resume support.

Presigned URL Upload

First, request a presigned URL:

JavaScript
// Step 1: Request presigned URL
const upload = await sw.media.requestUpload({
  content_id: "cnt_abc123",
  filename: "movie_final.mp4",
  content_type: "video/mp4",
  file_size: 4294967296, // 4GB
  method: "presigned"
});

// Step 2: Upload directly to the URL
await fetch(upload.presigned_url, {
  method: "PUT",
  body: fileBuffer,
  headers: {
    "Content-Type": "video/mp4"
  }
});

// Step 3: Confirm upload
const result = await sw.media.confirmUpload(upload.upload_id);
console.log(`Processing started: ${result.status}`);
Automatic Transcoding

Once uploaded, files are automatically transcoded into HLS (HTTP Live Streaming) and DASH formats with multiple bitrate ladders. You'll receive a webhook when processing completes.

Webhooks

Receive real-time notifications when events occur in your StarWave account. Configure webhook endpoints through the dashboard or API.

Event Types

Event Trigger Payload
content.created New content item created Content object
content.published Content published and live Content + stream URLs
media.uploaded Media file uploaded successfully Media + upload info
media.transcoded Transcoding completed Media + format list
media.transcoding_failed Transcoding error Media + error details
live.started Live stream begins Stream + viewer count
live.ended Live stream ends Stream + analytics summary
analytics.daily Daily analytics report ready Analytics summary

Webhook Payload Structure

JSON
{
  "id": "evt_abc123",
  "type": "media.transcoded",
  "timestamp": "2024-01-15T14:22:00Z",
  "data": {
    "media_id": "med_xyz789",
    "content_id": "cnt_abc123",
    "formats": [
      { "quality": "1080p", "bitrate": 5000000, "url": "..." },
      { "quality": "720p",  "bitrate": 2500000, "url": "..." },
      { "quality": "480p",  "bitrate": 1000000, "url": "..." }
    ],
    "duration": 7320,
    "size_bytes": 107374182400
  }
}

Signature Verification

Every webhook includes a X-Webhook-Signature header. Verify it using your webhook secret:

JavaScript
const crypto = require('crypto');

function verifyWebhook(payload, signature, secret) {
  const expected = crypto
    .createHmac('sha256', secret)
    .update(payload)
    .digest('hex');

  return crypto.timingSafeEqual(
    Buffer.from(signature),
    Buffer.from(expected)
  );
}

Changelog

Track changes to the StarWave API. We follow semantic versioning and maintain backward compatibility within major versions.

v3.2.1 January 15, 2024 Fix
  • Fixed pagination cursor encoding for special characters in content IDs
  • Resolved timeout issues on presigned URL uploads >10GB
  • Improved webhook retry logic with exponential backoff
v3.2.0 January 8, 2024 Feature
  • Added live chat API for real-time audience interaction
  • New analytics.realtime endpoint for live stream viewer counts
  • Support for AV1 codec in transcoding pipeline
  • Webhook event live.viewer_milestone for viewer count thresholds
v3.1.0 December 20, 2023 Feature
  • Added bulk content operations endpoint
  • Enhanced filter operators: gte, lte, in, contains
  • New DRM configuration options for FairPlay and Widevine
  • CDN edge location management via API
v3.0.0 November 1, 2023 Breaking
  • Complete API restructuring with resource-based URLs
  • Authentication migrated from API keys to JWT tokens
  • Response format standardized with status, data, meta wrapper
  • Deprecated v2 endpoints will sunset on March 1, 2024
  • New cursor-based pagination replacing offset pagination

Error Reference

All error responses follow a consistent format. The error object includes a machine-readable code and a human-readable message.

JSON — Error Format
{
  "status": "error",
  "error": {
    "code": "CONTENT_NOT_FOUND",
    "message": "No content found with ID 'cnt_invalid'",
    "type": "not_found",
    "details": {
      "content_id": "cnt_invalid"
    },
    "request_id": "req_xyz789"
  }
}

Common Error Codes

HTTP Status Error Code Description
400 INVALID_REQUEST Malformed request body or invalid parameters
401 UNAUTHORIZED Missing, invalid, or expired authentication token
403 FORBIDDEN Insufficient permissions for the requested operation
404 NOT_FOUND Requested resource does not exist
409 CONFLICT Resource conflict (e.g., duplicate title)
422 VALIDATION_ERROR Request body failed validation
429 RATE_LIMITED Too many requests — rate limit exceeded
500 INTERNAL_ERROR Unexpected server error — contact support
503 SERVICE_UNAVAILABLE Service temporarily unavailable (maintenance)

Migration Guide: v2 → v3

Moving from API v2 to v3? This guide covers all breaking changes and migration steps.

🚨
v2 Sunset Date: March 1, 2024

All v2 API endpoints will be decommissioned after this date. Migrate before then to avoid service interruption.

Breaking Changes Summary

Area v2 Behavior v3 Behavior
Base URL /v2/content /v3/content
Auth API key in query param Bearer token in header
Pagination Offset-based Cursor-based
Response format Direct data array Wrapped in {status, data, meta}
ID format Numeric IDs Prefix + string (e.g., cnt_abc123)
Dates Unix timestamps ISO 8601 strings

Migration Steps

  1. Update your base URL from /v2 to /v3
  2. Replace API key authentication with JWT Bearer tokens
  3. Update pagination logic to use cursor-based pagination
  4. Wrap response parsing to handle the new response format
  5. Update ID references from numeric to prefixed string format
  6. Replace Unix timestamps with ISO 8601 date parsing
JavaScript — Before (v2) vs After (v3)
// ❌ v2 (Deprecated)
const res = await fetch(
  `/v2/content?api_key=abc123&offset=0&limit=20`
);
const items = await res.json(); // Direct array

// ✅ v3 (Current)
const res = await fetch(
  `/v3/content?limit=20`,
  { headers: { "Authorization": "Bearer ${token}" } }
);
const { data, pagination } = await res.json();
// Use pagination.next_cursor for next page