API Reference
OpenNVR exposes a powerful, documented REST API allowing developers to programmatically extract AI inference metadata, manage facial recognition registries, and query the raw database for historical camera recordings.
By default, the AI Adapters API runs at http://localhost:9100, while the Core NVR API runs at http://localhost:8000.
🧠 AI Adapter APIs (Port 9100)
The AI Adapter functions as a stateless routing engine. You submit a frame URI, and it returns inference JSON without requiring strict database authentication layers.
Core Discovery Endpoints
GET /health: Verify if the inference server is responsive.GET /capabilities: Returns an array of loaded task plugins (e.g.,["person_detection", "person_counting"]).GET /tasks: Detailed metadata mapping the hardware capabilities of every loaded model.GET /schema?task=<task_name>: Extremely crucial. Returns the strict JSON validation schema defining what exact keys the specified task will return.
The Global Inference Pipeline
POST /infer is the primary workhorse endpoint for executing analytical logic.
Requesting Embedded OpenNVR Edge Detection (e.g., YOLO):
curl -X POST "http://localhost:9100/infer" \
-H "Content-Type: application/json" \
-d '{
"task": "person_counting",
"input": {
"frame": { "uri": "opennvr://frames/camera_0/latest.jpg" }
}
}'
Requesting External Cloud Routing (e.g., Hugging Face):
curl -X POST "http://localhost:9100/infer" \
-H "Content-Type: application/json" \
-d '{
"task": "object_detection_detr",
"input_data": {
"model_name": "facebook/detr-resnet-50",
"inputs": { "image": "opennvr://camera_0/latest.jpg" }
}
}'
InsightFace Registration API
If you are running facial recognition logic, you must programmatically populate the backend vector data arrays mapping geometric face encodings to logical human identities.
- Register an Identity:
curl -X POST "http://localhost:9100/faces/register" \ -H "Content-Type: application/json" \ -d '{ "frame": {"uri": "opennvr://frames/camera_0/person.jpg"}, "person_id": "emp_001", "name": "John Doe", "category": "employee" }' - List Identities:
GET /faces/list?category=watchlist - Delete Identity:
DELETE /faces/{person_id}
🎥 Core NVR Content APIs (Port 8000)
The primary NVR FastApi backend controls the PostgreSQL database, user administration, and accessing physical MP4 files. All requests against Port 8000 mandate strict JWT Bearer authentication headers natively retrieved upon user login.
GET /api/v1/cameras: Fetch the topology of all connected NVR camera endpoints.GET /api/v1/recordings/{camera_id}?start_unix=X&end_unix=Y: Fetch an array of historical MP4 chunks available for timeline scrubbing.GET /api/v1/events/latest: Fetch the latest AI incident logs systematically tracked and permanently stored in the PostgreSQL database.