{ "openapi": "3.1.0", "info": { "title": "Cakra Intelligence — CCTV YOLO Analytics", "summary": "Realtime multi-camera CCTV analytics: embeddable MJPEG, REST metrics, WebSocket pushes, and an events log.", "description": "Each camera exposes an embeddable MJPEG stream with YOLO + ByteTrack overlays, REST endpoints for current/rollup metrics, a WebSocket channel for live metric pushes, and an incidents log backed by TimescaleDB.", "contact": { "name": "Cakra Intelligence", "email": "openscopelabs@gmail.com" }, "license": { "name": "Proprietary", "identifier": "LicenseRef-Proprietary" }, "version": "0.1.0" }, "paths": { "/": { "get": { "tags": [ "Meta" ], "summary": "Service metadata.", "operationId": "root__get", "responses": { "200": { "description": "Successful Response", "content": { "application/json": { "schema": { "type": "object", "title": "Response Root Get" } } } } } } }, "/health": { "get": { "tags": [ "Meta" ], "summary": "Liveness probe.", "operationId": "health_health_get", "responses": { "200": { "description": "Successful Response", "content": { "application/json": { "schema": { "type": "object", "title": "Response Health Health Get" } } } } } } }, "/api/v1/cameras": { "get": { "tags": [ "Cameras" ], "summary": "Paginated camera catalog from cctv_streams. Nothing is spawned by this call — use POST /connect to start a worker.", "operationId": "list_cameras_api_v1_cameras_get", "parameters": [ { "name": "page", "in": "query", "required": false, "schema": { "type": "integer", "minimum": 1, "default": 1, "title": "Page" } }, { "name": "page_size", "in": "query", "required": false, "schema": { "type": "integer", "maximum": 100, "minimum": 1, "default": 20, "title": "Page Size" } }, { "name": "status", "in": "query", "required": false, "schema": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "description": "online | offline | degraded", "title": "Status" }, "description": "online | offline | degraded" }, { "name": "city", "in": "query", "required": false, "schema": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "description": "Exact match on cctv_streams.city.", "title": "City" }, "description": "Exact match on cctv_streams.city." }, { "name": "q", "in": "query", "required": false, "schema": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "description": "Substring (ILIKE) match on name.", "title": "Q" }, "description": "Substring (ILIKE) match on name." }, { "name": "active_only", "in": "query", "required": false, "schema": { "type": "boolean", "description": "Only cameras with a running worker.", "default": false, "title": "Active Only" }, "description": "Only cameras with a running worker." } ], "responses": { "200": { "description": "Successful Response", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/CameraCatalog" } } } }, "503": { "description": "Pipeline not ready or upstream unavailable.", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ServiceUnavailableEnvelope" } } } }, "500": { "description": "Unexpected server error.", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/InternalErrorEnvelope" } } } }, "422": { "description": "Request payload failed validation.", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ValidationErrorEnvelope" } } } } } } }, "/api/v1/cameras/{camera_id}": { "get": { "tags": [ "Cameras" ], "summary": "View one camera — metadata + embed/metric URLs. `is_active=false` means call /connect first to spawn a worker.", "operationId": "get_camera_api_v1_cameras__camera_id__get", "parameters": [ { "name": "camera_id", "in": "path", "required": true, "schema": { "type": "string", "title": "Camera Id" } } ], "responses": { "200": { "description": "Successful Response", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/CameraItem" } } } }, "404": { "description": "Resource does not exist.", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/NotFoundEnvelope" } } } }, "503": { "description": "Pipeline not ready or upstream unavailable.", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ServiceUnavailableEnvelope" } } } }, "500": { "description": "Unexpected server error.", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/InternalErrorEnvelope" } } } }, "422": { "description": "Request payload failed validation.", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ValidationErrorEnvelope" } } } } } } }, "/api/v1/cameras/{camera_id}/connect": { "post": { "tags": [ "Cameras" ], "summary": "Spawn a YOLO worker for this camera. Idempotent — returns current state when already connected.", "operationId": "connect_camera_api_v1_cameras__camera_id__connect_post", "parameters": [ { "name": "camera_id", "in": "path", "required": true, "schema": { "type": "string", "title": "Camera Id" } } ], "responses": { "200": { "description": "Successful Response", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/CameraItem" } } } }, "404": { "description": "Resource does not exist.", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/NotFoundEnvelope" } } } }, "503": { "description": "Pipeline not ready or upstream unavailable.", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ServiceUnavailableEnvelope" } } } }, "500": { "description": "Unexpected server error.", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/InternalErrorEnvelope" } } } }, "422": { "description": "Request payload failed validation.", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ValidationErrorEnvelope" } } } } } } }, "/api/v1/cameras/{camera_id}/disconnect": { "post": { "tags": [ "Cameras" ], "summary": "Stop the YOLO worker for this camera. Idempotent — succeeds even if no worker was running.", "operationId": "disconnect_camera_api_v1_cameras__camera_id__disconnect_post", "parameters": [ { "name": "camera_id", "in": "path", "required": true, "schema": { "type": "string", "title": "Camera Id" } } ], "responses": { "200": { "description": "Successful Response", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/CameraItem" } } } }, "404": { "description": "Resource does not exist.", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/NotFoundEnvelope" } } } }, "503": { "description": "Pipeline not ready or upstream unavailable.", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ServiceUnavailableEnvelope" } } } }, "500": { "description": "Unexpected server error.", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/InternalErrorEnvelope" } } } }, "422": { "description": "Request payload failed validation.", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ValidationErrorEnvelope" } } } } } } }, "/api/v1/cameras/{camera_id}/hls/playlist.m3u8": { "get": { "tags": [ "Stream" ], "summary": "HLS playlist for the camera's annotated stream. Bboxes are baked into the encoded video — embed `