# API Reference All endpoints are on the running camera app (`http://:8000`), not the portal. Everything is `GET` with query params, except the video stream. ## Stream & Status | Endpoint | Description | |---|---| | `GET /api/stream` | MJPEG video stream (`multipart/x-mixed-replace`) | | `GET /api/status` | `{status, is_running, mode, config, error}` - `status` is `connected` / `stopped` / `error` | | `GET /api/stats` | `{fps, detections_count, entry_count, exit_count, current_occupancy, people_in_area, daily_date}` | ## Camera control | Endpoint | Params | Description | |---|---|---| | `GET /api/start_camera` | - | Start the pipeline | | `GET /api/stop_camera` | - | Stop the pipeline (watchdog won't auto-restart while intentionally stopped) | | `GET /api/set_mode` | `mode` = `preview` \| `yolov6` \| `tracking` \| `yunet` \| `edges` | Switch detection mode (restarts the pipeline, ~1.2s) | ## Configuration | Endpoint | Params | Description | |---|---|---| | `GET /api/set_config` | `key`, `value` | Detection settings: `confidence`, `filter_mode` (`exclude`/`include`), `filter_classes` (comma-separated), `boundary_line_type` (`vertical`/`horizontal`), `boundary_line_pos` (0-1), `boundary_direction` (`normal`/anything else = reversed) | | `GET /api/set_camera` | `key`, `value` | Camera hardware settings: `brightness`, `contrast`, `saturation`, `auto_exposure`, `exposure_time`, `iso`, `auto_focus`, `focus_lens` | | `GET /api/reset_counters` | - | Zeroes today's in/out counts (persisted to `data/daily_counts.json`) | ## Zones | Endpoint | Params | Description | |---|---|---| | `GET /api/add_zone` | `name` | Add a detection zone (default box, drag/resize in the UI after) | | `GET /api/delete_zone` | `id` | Remove a zone | | `GET /api/toggle_zone` | `id`, `active` | Enable/disable a zone without deleting it | | `GET /api/update_zone` | `id`, `name?`, `active?`, `xmin?`, `ymin?`, `xmax?`, `ymax?` | Update zone geometry/name (all coords normalized 0-1) | ## Audio alerts | Endpoint | Params | Description | |---|---|---| | `GET /api/add_alert` | `item`, `sound`, `custom_path?`, `cooldown?`, `trigger_mode?` (`once`/`interval`) | Add an alert rule for a detected class | | `GET /api/delete_alert` | `id` | Remove an alert rule | | `GET /api/toggle_alert` | `id`, `active` | Enable/disable a rule | --- ## Portal API (this service) | Endpoint | Description | |---|---| | `GET /` | Homepage, lists all files by category | | `GET /files/{category}/{filename}` | Download a file (`category` = `packages` \| `service-files` \| `docs`) | | `GET /view/{category}/{filename}` | Render a markdown doc inline | | `POST /upload/{category}` | Upload a file - multipart `file` field, `X-Upload-Token` header must match `PORTAL_UPLOAD_TOKEN` | | `GET /healthz` | Health check |