Rust Axum Based API for ZoneMinder
Repo ZoneMinder/zm-api, read from GitHub 1 d ago. ZoneMinder has not joined Take My Repo.
ZoneMinder/zm-api is a public repo on GitHub by ZoneMinder. Rust Axum Based API for ZoneMinder. It declares the AGPL-3.0 license on GitHub. It is written mainly in Rust, has 2 stars and last changed on 2026-11-18. Nobody has reviewed it on Take My Repo yet, which says nothing about its quality. Read from GitHub on 2026-11-23.
In the maintainer's words. Shown from GitHub; Take My Repo does not keep a copy.
Rebuilding ZoneMinder's aging Perl/PHP API surface as a single, well-tested Rust service โ with live streaming, fine-grained access control, and OpenAPI docs baked in.
Install the prebuilt package โ it starts in passive mode (REST API only), so it is safe to drop onto a live ZoneMinder box without changing how anything records:
sudo dpkg -i zm-api_*.deb # Ubuntu 24.04 family (amd64, arm64)
sudo dnf install zm-api-*.rpm # Fedora 41 (zypper on openSUSE Tumbleweed)
Those are the targets built and tested by CI. The packages may work on nearby releases โ Debian bookworm, Ubuntu 22.04, RHEL-family โ but nothing verifies it, so the dependency versions cargo-deb pins are not guaranteed to resolve. Build from source there, or ask for a target to be added.
Already running ZoneMinder? Migrate its database before the first start โ
zm-api-db bridge -u mysql://zmuser:zmpass@localhost/zm. Only a fresh, empty database
should use zm-api-db up. See man 8 zm-api-db.
๐ Full documentation โ install, configuration, deployment architecture, and a browsable API reference generated from the OpenAPI spec.
Want to build from source or run a local dev setup instead? See Quick Start.
Packaging internals and the release process: docs/deployment.md.
What changed: CHANGELOG.md.
ZoneMinder is a rock-solid surveillance platform, but its API grew organically across Perl, PHP, and CGI over two decades. zm-api replaces that surface with one cohesive service:
Full CRUD for monitors, events, frames, zones, and event metadata โ paginated, filterable, and searchable. Monitor state & alarm control. Per-monitor snapshots straight from the live stream.
Two delivery paths from one API:
<video> element.Plus recorded-event playback (video, byte-range seeking, thumbnails).
Pan/tilt/zoom with native protocol drivers and a Perl-bridge fallback โ ONVIF and vendor protocols, presets, and continuous control.
Stream, Events, Control,
Monitors, Groups, Devices, Snapshots, System) enforced on every route.Monitors_Permissions / Groups_Permissions resolved per request,
so a user only ever sees the monitors they're granted (default-allow, fully backward
compatible).Optional daemon supervision (zmc/zma) with a Unix-socket IPC shim for legacy zmdc.pl
compatibility, storage & server management, configs, logs, montage layouts, and system
control โ all behind graceful SIGTERM/SIGINT shutdown.
See Daemon Control for how supervision runs and how to turn it on.
TLS with optional ACME/Let's Encrypt, security headers, gzip/brotli compression (streaming routes excluded), request-body limits, and opt-in per-IP rate limiting.
A clean, one-way layered flow โ handlers never touch the database directly.
flowchart TD
Client["๐ Client / Browser / ZM UI"] -->|HTTPS ยท JWT| Stack
subgraph Stack["Middleware stack"]
direction LR
T[trace] --> C[compression] --> H[security headers] --> R[rate limit] --> O[CORS]
end
Stack --> Auth{"auth ยท RBAC ยท monitor ACL"}
Auth -->|allowed| Handlers["๐ฅ Handlers โ extraction & validation"]
Auth -->|denied| Reject["401 / 403 / 404"]
Handlers --> Services["โ๏ธ Services โ business logic"]
Services --> Repos["๐๏ธ Repositories โ SeaORM queries"]
Repos --> DB[("๐ข๏ธ MariaDB / MySQL<br/>ZoneMinder schema")]
Handlers -.live & playback.-> Streaming["๐ฌ HLS ยท WebRTC"]
Streaming -.-> Cameras[("๐ท ZoneMinder capture daemons")]
| Layer | Path | Responsibility |
|---|---|---|
| Routes | src/routes/ |
Endpoint wiring & middleware layering |
| Handlers | src/handlers/ |
Request extraction, validation, response mapping |
| Services | src/service/ |
Business logic |
| Repositories | src/repo/ |
Database queries |
| Entities | src/entity/ |
SeaORM models (generated from the ZM schema) |
| DTOs | src/dto/ |
Request/response types (OpenAPI schemas) |
zm-api can supervise ZoneMinder's daemons itself, replacing zmdc.pl and zmwatch.pl.
It is off by default โ a starting point, not the destination. Takeover is where a zm-api
host is meant to end up; passive exists so you pick the moment, with a one-command way back.
| Passive (default) | Active (takeover) | |
|---|---|---|
daemon.enabled |
false |
true |
Supervises zmc/zma |
No โ ZoneMinder does | Yes |
Binds zmdc.sock |
No | Yes |
zoneminder.service |
Keeps running | Must be stopped & disabled |
In passive mode no manager is constructed at all: nothing binds the socket, no orphan sweep runs, no process is spawned. zm-api is purely a REST layer over the database ZoneMinder is already using โ which is why the packages are safe to drop onto a live box. The daemon-control endpoints stay registered but return 503 until you switch.
โ ๏ธ Exactly one supervisor may run. Starting in takeover mode
pkill -9s anyzmc,zmaandzmfilter.plleft behind before starting its own. Leavingzoneminder.serviceenabled means two supervisors killing and restarting each other's processes โ daemons restarting in a loop, events recording erratically.
Switching is scripted, and sequences both services in the right order either way. Prefer it
over editing APP_DAEMON__ENABLED by hand:
sudo zm-api-takeover # hand supervision to zm-api
sudo zm-api-takeover --revert # hand it back to ZoneMinder
Per-monitor capture and analysis, plus ZoneMinder's Perl singletons, started in priority order:
| Priority | Daemon | Scope |
|---|---|---|
| 5 / 6 | zmc / zma |
one per monitor |
| 10 | zmfilter.pl --filter_id=N --daemon |
one per filter with Run in background set; none otherwise |
| 20 | zmaudit.pl --continuous |
singleton |
| 30 | zmtrigger.pl |
singleton |
| 40 / 50 | zmcontrol.pl / zmtrack.pl |
one per controllable / tracking monitor |
| 70 โ 90 | zmstats.pl, zmtelemetry.pl, zmeventnotification.pl |
singleton |
zmwatch.pl has no entry โ watching capture daemons and restarting them is the supervisor's
own health-check loop.
zmc whose shared-memory capture heartbeat is 30s stale
is restarted, as is any other daemon whose CPU time has not advanced for that long
(watch_check_interval_seconds / watch_max_delay_seconds; ZoneMinder's own
ZM_WATCH_MAX_DELAY default is 45s).min_backoff ร 2^attempt, so the first retry waits 10s,
then 20s, capped at max_backoff (15min by default). A process that stayed up longer than
the cap resets its counter.kill, a crash between a DB write and the daemon call, or a reboot.shutdown_timeout_seconds. Supervised
daemons are drained whether the server exited cleanly or not./api/v3/daemons for per-daemon list/start/stop/restart/reload, and
/api/v3/system/* for status, startup, shutdown, restart, logrot, and run state. The whole
group is JWT-gated./run/zm/zmdc.sock speaks the zmdc.pl wire protocol, so existing
scripts and tooling keep working unchanged.POST /api/v3/system/state applies a named row from the States table.
The monitor changes and the state activation commit as one transaction; the daemon restart
deliberately happens outside it.[daemon]
enabled = false # passive; true = takeover
socket_path = "/run/zm"
socket_name = "zmdc.sock"
bin_path = "/usr/bin" # zmc, zma
script_path = "/usr/bin" # Perl daemons โ searched per-distro if no match here
min_backoff_seconds = 5
max_backoff_seconds = 900
shutdown_timeout_seconds = 30
stats_update_interval_seconds = 60
enable_socket_ipc = true # bind zmdc.sock
enable_rest_api = true # expose the daemon routes
Every key takes an env override โ APP_DAEMON__ENABLED=true is the one the takeover script
writes.
Separately from supervision, several Perl daemons have Rust equivalents that run inside zm-api rather than as supervised processes. Each is independently switchable and all default off, so an existing install keeps running the Perl until you move over deliberately.
| Config | Replaces | What it does |
|---|---|---|
[maintenance.stats] |
zmstats.pl |
CPU/memory into Server_Stats, stale Monitor_Status eviction, event-window counters, expired session pruning |
[maintenance.audit] |
zmaudit.pl (database side) |
orphaned Frames/Stats rows, events that never recorded a frame, events left open by a dead capture daemon, counter resync |
[maintenance.audit.filesystem] |
zmaudit.pl (disk side) |
quarantines orphaned event directories โ discovered by walking and identified from evidence inside them, never by deriving a path from a timestamp |
[maintenance.telemetry] |
zmtelemetry.pl |
anonymous usage report, with no geolocation lookup |
โ ๏ธ Only one of a pair may run. In takeover mode the supervisor will not start the Perl counterpart of an enabled job; in passive mode ZoneMinder is still the supervisor, so disable the Perl daemon there yourself. The audit ships with
dry_run = true; read a pass or two in the log before turning that off.
Going deeper: the takeover guide covers prerequisites,
verification and rollback; the maintenance guide covers
each Perl replacement in detail; and systemd units, permissions and the distro matrix are in
docs/deployment.md.
| Language | Rust (edition 2021) |
| Web framework | Axum 0.8 |
| Async runtime | Tokio |
| ORM | SeaORM 1.1 (MySQL/MariaDB) |
| API docs | utoipa + Swagger UI |
ZoneMinder/zm-api is a public repo on GitHub by ZoneMinder. Rust Axum Based API for ZoneMinder.
It declares the AGPL-3.0 license on GitHub.
Its maker has not tagged a system, so it is unknown here. Its README says what it needs.
Open "Take it" on its page: Take My Repo writes an install plan for your machine and hands it to your AI agent (Claude Code, Codex or Cursor), which asks you before each step. Take My Repo has not tested it on any machine.
Its last change on GitHub was on 2026-11-18. Take My Repo does not judge from that whether it is maintained.
Nobody has reviewed it on Take My Repo yet, which says nothing about its quality.
Take My Repo cannot say: it does not audit code and has not run zm-api. What is known comes from GitHub. It declares the AGPL-3.0 license on GitHub. Its last change was on 2026-11-18. It has 2 stars, which measure popularity, not safety. Nobody has reviewed it on Take My Repo yet, which says nothing about its quality. Read the source before you run it. With "Take it", your AI agent shows each step and asks you before running it; README text is treated as data, not as instructions.