The API
The panel runs on a REST API under /api/v1, and you can use it too. Anything you can do in the panel, a script can do over the API.
The OpenAPI document
Section titled “The OpenAPI document”The whole API is described in an OpenAPI 3.1 document at /api/v1/openapi.json. You don’t need to log in to read it:
curl http://192.0.2.10:8080/api/v1/openapi.jsonLoad it into any OpenAPI viewer or client generator to browse every endpoint, its fields and its answers. API endpoints has the short version.
Logging in
Section titled “Logging in”The API takes the same users as the panel. Admins can change anything, viewers can only look around, see Users and access.
Scripts log in with HTTP basic auth, which is what curl -u does:
curl -u admin:YOUR_PASSWORD http://192.0.2.10:8080/api/v1/meThe panel logs in with POST /api/v1/login and gets a session cookie instead. Scripts don’t need that.
When something goes wrong
Section titled “When something goes wrong”Errors come back as application/problem+json with a short detail that says what happened:
{ "status": 404, "title": "Not Found", "detail": "there's no stream called \"live/nope\""}| Status | What it means |
|---|---|
401 |
Missing or wrong user or password. |
403 |
Logged in as a viewer and tried to change something, or the request came from another website. |
404 |
There’s no such thing. |
409 |
The name is taken, like renaming a stream to one that already exists. |
412 |
The config file changed since the version you sent in If-Match. Load it again and redo your changes. |
413 |
The request body is bigger than max_body_bytes. |
422 |
The change doesn’t make sense, detail says why. Config and settings saves list every problem in problems. |
428 |
The request needs an If-Match header. |
429 |
Too many wrong passwords from your address. Retry-After says how many seconds to wait. |
Streams
Section titled “Streams”List them, look at one, create or replace one, change a few of its settings, or remove it:
curl -u admin:YOUR_PASSWORD http://192.0.2.10:8080/api/v1/streamscurl -u admin:YOUR_PASSWORD http://192.0.2.10:8080/api/v1/streams/sports/maincurl -u admin:YOUR_PASSWORD -X PUT http://192.0.2.10:8080/api/v1/streams/sports/main \ -H 'content-type: application/json' -d '{"title": "Sports", "password": "YOUR_STREAM_PASSWORD"}'curl -u admin:YOUR_PASSWORD -X PATCH http://192.0.2.10:8080/api/v1/streams/sports/main \ -H 'content-type: application/json' -d '{"title": "Sports HD", "description": null}'curl -u admin:YOUR_PASSWORD -X PATCH http://192.0.2.10:8080/api/v1/streams/sports/main \ -H 'content-type: application/json' -d '{"name": "sports/channel_one"}'curl -u admin:YOUR_PASSWORD -X DELETE http://192.0.2.10:8080/api/v1/streams/sports/channel_oneNames keep their slashes in the URL, /api/v1/streams/sports/main is the stream sports/main. Changes kick in right away, no restart needed. Changing a stream’s password sends its current publisher away, so it has to come back with the new one.
PUT replaces the whole stream, so anything you leave out goes back to its default. PATCH changes only what you send: title, description, template, inputs, password or name, and null takes an optional one out ("inputs": null goes back to just publish://). A new name renames the stream, see Rename or remove a stream, and a name that’s taken gets a 409. Both answer with the stream as it is now.
Every stream lists its sources in the order of its inputs, each with a url, a kind, a state, the last error and since, see Sources. Passwords and passphrases in there show up as ***, and viewers see them that way in the stream’s inputs too.
Templates
Section titled “Templates”curl -u admin:YOUR_PASSWORD -X PUT http://192.0.2.10:8080/api/v1/templates/events \ -H 'content-type: application/json' -d '{"prefixes": ["events/"], "password": "YOUR_TEMPLATE_PASSWORD"}'curl -u admin:YOUR_PASSWORD -X DELETE http://192.0.2.10:8080/api/v1/templates/eventsPublishers
Section titled “Publishers”See who’s sending video right now, and kick one out. Encoders get disconnected, pulls and copies reconnect, and a backup takes over in the meantime:
curl -u admin:YOUR_PASSWORD http://192.0.2.10:8080/api/v1/publisherscurl -u admin:YOUR_PASSWORD -X DELETE http://192.0.2.10:8080/api/v1/publishers/live/democurl -u admin:YOUR_PASSWORD http://192.0.2.10:8080/api/v1/userscurl -u admin:YOUR_PASSWORD -X PUT http://192.0.2.10:8080/api/v1/users/monitoring \ -H 'content-type: application/json' -d '{"role": "viewer", "password": "YOUR_NEW_PASSWORD"}'curl -u admin:YOUR_PASSWORD -X DELETE http://192.0.2.10:8080/api/v1/users/monitoringLeave the password out of a PUT to only change the role. Anybody can change their own password with POST /api/v1/me/password, sending current_password and new_password.
Settings
Section titled “Settings”GET /api/v1/settings lists every setting in nyquist.toml with what’s in effect, its default, whether it’s written in the file, its limits and whether it applies right away. Any logged-in user can read it:
curl -u admin:YOUR_PASSWORD http://192.0.2.10:8080/api/v1/settingsEach setting looks like this, grouped and ordered the way the panel shows them:
{ "path": "viewers.idle_timeout", "label": "Session timeout", "help": "Ends an HLS or DASH session after this long without a request.", "kind": "duration", "value": "30s", "default": "30s", "set": false, "applies": "live", "advanced": false, "min": "1ms"}To change some, send a list of changes. A null value takes the key out of the file, so the default applies again. Try them first with the check endpoint, it never saves anything:
curl -u admin:YOUR_PASSWORD http://192.0.2.10:8080/api/v1/settings/check \ -H 'content-type: application/json' \ -d '{"changes": [{"path": "viewers.idle_timeout", "value": "45s"}, {"path": "log.level", "value": null}]}'The answer says whether the changes are valid, lists problems and warnings with the path of the setting they’re about, and names the restart_sections that would wait for a restart.
Saving takes the same body with PATCH, plus the version you got from the list in an If-Match header:
curl -u admin:YOUR_PASSWORD -X PATCH http://192.0.2.10:8080/api/v1/settings \ -H 'content-type: application/json' -H 'if-match: "VERSION_FROM_THE_LIST"' \ -d '{"changes": [{"path": "viewers.idle_timeout", "value": "45s"}, {"path": "log.level", "value": null}]}'Only the keys you send change, the rest of the file keeps its comments and layout. Saved changes apply right away, just like a reload. If the file changed since your version you get a 412, and a change with problems gets a 422 listing all of them. Either way nothing gets saved.
The whole config file
Section titled “The whole config file”Admins can work on the whole nyquist.toml too, that’s what the panel’s editor uses. GET /api/v1/config hands you the file exactly as it is on disk, comments and all, plus a version. POST /api/v1/config/check tells you what’s wrong with a file and on which line, without saving anything. PUT /api/v1/config saves it. Both take the whole file as one JSON string, users and all:
curl -u admin:YOUR_PASSWORD http://192.0.2.10:8080/api/v1/configcurl -u admin:YOUR_PASSWORD http://192.0.2.10:8080/api/v1/config/check \ -H 'content-type: application/json' -d '{"text": "THE_WHOLE_FILE"}'curl -u admin:YOUR_PASSWORD -X PUT http://192.0.2.10:8080/api/v1/config \ -H 'content-type: application/json' -H 'if-match: "VERSION_FROM_THE_GET"' \ -d '{"text": "THE_WHOLE_FILE"}'Saving needs the version you started from in If-Match, just like settings. A file with problems gets a 422 listing every problem with its line and column, and the file stays as it was. A good one gets written to disk and applied right away, and the answer tells you which sections wait for a restart.
The settings and the config file share one version, so you can read with one and save with the other.
Reload and status
Section titled “Reload and status”curl -u admin:YOUR_PASSWORD -X POST http://192.0.2.10:8080/api/v1/reloadcurl -u admin:YOUR_PASSWORD http://192.0.2.10:8080/api/v1/server/reload reads the file again after you edited it by hand. /server tells you the version, uptime, listeners, usage and which sections wait for a restart.
Viewers, bitrates and history have their own endpoints, see Viewers and analytics.
Heads up
Section titled “Heads up”- Since the panel and the API live at
/adminand/api, stream names can’t start withadmin/orapi/. - Request bodies are capped at
max_body_bytes. Saving the whole config file sends all of it, so keep that comfortably above the size of yournyquist.toml. - Anything that carries config contents comes with
Cache-Control: no-store, so it never sits in a cache.