API Reference

Complete API documentation for LegacyStream server endpoints and WebSocket interfaces.

API Overview

The LegacyStream API provides programmatic access to server statistics, stream management, and real-time monitoring capabilities.

Base URL

All API endpoints are relative to: http://localhost:8000/api

Response Format

All API responses are returned in JSON format with the following structure:

{
  "success": true,
  "data": {
    // Response data here
  },
  "timestamp": "2025-01-15T10:30:00Z"
}

Authentication

Most API endpoints require authentication using HTTP Basic Auth or API keys.

HTTP Basic Authentication

curl -u "admin:password" \
  http://localhost:8000/api/server/stats

API Key Authentication

curl -H "X-API-Key: your-api-key" \
  http://localhost:8000/api/server/stats

Stream Endpoints

GET /api/streams List all active streams
GET /api/streams/{mount} Get stream information
POST /api/streams/{mount}/start Start a stream
POST /api/streams/{mount}/stop Stop a stream

Server Endpoints

GET /api/server/stats Get server statistics
GET /api/server/performance Get performance metrics
POST /api/server/restart Restart the server

WebSocket API

Real-time updates are available via WebSocket connections.

Connection

const ws = new WebSocket('ws://localhost:8000/ws');

ws.onmessage = function(event) {
    const data = JSON.parse(event.data);
    console.log('Received:', data);
};

Message Types

stream_update {"type": "stream_update", "mount": "/live", "listeners": 1250} Real-time stream statistics
server_stats {"type": "server_stats", "cpu": 45.2, "memory": 67.8} Server performance metrics

Error Codes

Code Message Description
400 Bad Request Invalid request parameters
401 Unauthorized Authentication required
404 Not Found Resource not found
500 Internal Server Error Server error occurred