Skip to content

API Overview

The Flex Video REST API provides programmatic control over video pipelines, cameras, and system configuration.

Base URL

http://localhost:3539

Replace localhost with your server's IP for remote access.

Interactive Documentation

For interactive API exploration, use Swagger UI:

Swagger UI allows you to:

  • Browse all endpoints
  • View request/response schemas
  • Try API calls directly

Authentication

Authentication is optional. When enabled:

Session Token

Obtain a token via login:

curl -X POST http://localhost:3539/flex/auth/login \
  -H "Content-Type: application/json" \
  -d '{"password": "your-password"}'

Use the token in subsequent requests:

curl -H "Authorization: Bearer <token>" http://localhost:3539/flex/pipeline

API Key

For service-to-service authentication:

curl -H "X-API-Key: <key>" http://localhost:3539/flex/pipeline

The API key is auto-generated during installation and stored in .env.

Endpoints Overview

Health & Version

Method Endpoint Description
GET /flex/health Health check
GET /flex/healthz Kubernetes health check
GET /flex/version Version information

Pipelines

Method Endpoint Description
GET /flex/pipeline List pipelines
POST /flex/pipeline Create pipeline
GET /flex/pipeline/{id} Get pipeline
PUT /flex/pipeline/{id} Update pipeline
DELETE /flex/pipeline/{id} Delete pipeline
PUT /flex/pipeline/{id}/play Start pipeline
PUT /flex/pipeline/{id}/stop Stop pipeline
GET /flex/pipeline/{id}/status Get status

Cameras

Method Endpoint Description
GET /flex/cameras List cameras
GET /flex/camera?path= Get camera capabilities
GET /flex/cameras/events SSE camera events

Settings

Method Endpoint Description
GET /flex/settings Get settings
PUT /flex/settings Update settings

Files

Method Endpoint Description
GET /flex/files/screenshots List screenshots
GET /flex/files/screenshots/{file} Download screenshot
DELETE /flex/files/screenshots/{file} Delete screenshot

Response Format

Success Responses

{
  "id": "camera-1",
  "mode": "simple",
  "state": "playing",
  ...
}

Error Responses

{
  "message": "Human-readable error description",
  "code": "MACHINE_READABLE_CODE",
  "details": { ... }
}

Common Error Codes

Code HTTP Status Description
VALIDATION_ERROR 400 Invalid request data
UNAUTHORIZED 401 Authentication required
LICENSE_ERROR 402 License required
NOT_FOUND 404 Resource not found
CONFLICT 409 Resource conflict
GSTREAMER_ERROR 500 Pipeline error
SERVICE_UNAVAILABLE 503 Backend unavailable
PIPELINE_START_TIMEOUT 504 Pipeline didn't start

Server-Sent Events (SSE)

Real-time updates are available via SSE:

Pipeline Status Events

curl -N http://localhost:3539/flex/pipeline/camera-1/status/events

Events:

event: pipeline_status
data: {"id":"camera-1","state":"playing",...}

event: pipeline_error
data: {"message":"Connection lost"}

Camera Events

curl -N http://localhost:3539/flex/cameras/events

Events:

event: camera_added
data: {"device_path":"/dev/video0","device_name":"Webcam"}

event: camera_removed
data: {"device_path":"/dev/video0"}

Rate Limits

Endpoint Limit
DELETE /flex/files/screenshots/{file} 60/min
DELETE /flex/files/screenshots?pipeline_id= 10/min

Rate-limited responses include Retry-After header.

SDKs & Client Libraries

cURL Examples

Throughout this documentation, examples use cURL. Convert to your language:

import requests

response = requests.get('http://localhost:3539/flex/pipeline')
pipelines = response.json()
const response = await fetch('http://localhost:3539/flex/pipeline');
const pipelines = await response.json();
resp, err := http.Get("http://localhost:3539/flex/pipeline")
// Handle response

Next Steps