Skip to content

REST API: Cameras Endpoints Reference ​

The Cameras API manages camera records, RTSP stream parameters, retention policies, and live telemetry.


1. List Cameras (GET /api/cameras) ​

Returns all configured cameras and their real-time streaming health telemetry.

  • Required Role: viewer, operator, or admin
bash
curl -H "Authorization: Bearer <TOKEN>" http://localhost:8080/api/cameras

Response (200 OK):

json
[
  {
    "id": "cam-01",
    "url": "rtsp://admin:secret@192.168.1.100:554/live",
    "record": true,
    "retention_days": 7,
    "tags": ["entrance", "outdoor"],
    "folder_id": "building-a",
    "comment": "Main gate",
    "sim_phone": "+1234567890",
    "sim_iccid": "8901234567890123456",
    "lazy_hls": false,
    "transport": "tcp",
    "token_auth": false,
    "traffic_limit": 10737418240,
    "disabled": false,
    "state": "streaming",
    "fps": 25.0,
    "bitrate": 4096000,
    "codec": "h264",
    "resolution": "1920x1080",
    "width": 1920,
    "height": 1080,
    "uptime_sec": 86400,
    "traffic_used_mb": 1420.5
  }
]

2. Create Camera (POST /api/cameras) ​

  • Required Role: operator, admin, or service
bash
curl -X POST http://localhost:8080/api/cameras \
  -H "Authorization: Bearer <TOKEN>" \
  -H "Content-Type: application/json" \
  -d '{
    "id": "cam-dock",
    "url": "rtsp://admin:pass@192.168.1.105:554/stream1",
    "record": true,
    "retention_days": 14,
    "folder_id": "warehouse",
    "tags": ["warehouse", "dock"],
    "transport": "tcp",
    "lazy_hls": false
  }'

Response (201 Created): Returns the created camera JSON response.


3. Update Camera (PUT /api/cameras/:id) ​

Updates camera configuration in BadgerDB and restarts ingestion without affecting other streams.

bash
curl -X PUT http://localhost:8080/api/cameras/cam-dock \
  -H "Authorization: Bearer <TOKEN>" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "rtsp://admin:newpass@192.168.1.105:554/high_res",
    "record": true,
    "retention_days": 30
  }'

Response (200 OK).


4. Delete Camera (DELETE /api/cameras/:id) ​

  • Required Role: operator, admin, or service
bash
curl -X DELETE http://localhost:8080/api/cameras/cam-dock \
  -H "Authorization: Bearer <TOKEN>"

Response (200 OK): {"message": "camera deleted"}.


5. Generate Stream Token (GET /api/cameras/:id/stream-token) ​

Generates a short-lived (60 seconds) JWT token with stream_id claim for embedding protected playback sessions in web browsers.

bash
curl -H "Authorization: Bearer <TOKEN>" http://localhost:8080/api/cameras/cam-01/stream-token

Response (200 OK):

json
{
  "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
}

Released under the MIT License.