API Overview¶
The Flex Video REST API provides programmatic control over video pipelines, cameras, and system configuration.
Base URL¶
Replace localhost with your server's IP for remote access.
Interactive Documentation¶
For interactive API exploration, use Swagger UI:
- URL: http://localhost:8081
- Requires:
--profile docsflag or macOS development setup
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:
API Key¶
For service-to-service authentication:
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¶
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¶
Events:
event: pipeline_status
data: {"id":"camera-1","state":"playing",...}
event: pipeline_error
data: {"message":"Connection lost"}
Camera 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:
Next Steps¶
- Authentication - Auth flows in detail
- Pipelines API - Pipeline management
- Webhooks - MediaMTX integration