REST API
The hub's REST API is what its web UI and LemmeKnow use, and you can call it from your own scripts. Requests and responses are JSON, at the hub's web address (http://localhost:8765 on the hub machine by default).
Every endpoint on this page needs a signed-in caller unless it says otherwise, and each one checks the caller's permissions. Lists only contain what the caller may see, and something the caller can't see answers 404, the same as something that doesn't exist. See Permissions and grants.
Authentication
| Method | How |
|---|---|
| Access key | Send X-Access-Key: <key> and X-Username: <username> with every request. Both are required, and they must belong to the same user. |
| Plugin key | Send X-Access-Key: <plugin key> alone. Accepted only on the paths its scopes allow. See Plugin API keys. |
| Browser session | Sign in on the hub's sign-in page (/auth/login) with username and access key. The session cookie lasts 7 days. |
| Local admin | A request from the hub machine itself with no X-Access-Key header is treated as an admin while local_admin is on in config.json. See Configuration. |
curl http://localhost:8765/api/users/me \
-H "X-Access-Key: YOUR_ACCESS_KEY" -H "X-Username: alice"
A key that matches nothing, or a username that doesn't match the key, answers 401. A valid caller without the permission an endpoint needs gets 403. Each refusal is also recorded in the hub's User Authentication feed with a hint on what to fix.
Responses and errors
Errors are JSON with a detail field, for example {"detail": "Feed not found"}.
| Status | Meaning |
|---|---|
| 200, 201 | Success. 201 when something was created. |
| 204 | Success with no body. |
| 401 | Missing or invalid credentials. |
| 403 | Signed in, but not allowed to do this. |
| 404 | Not found, or not visible to you. |
| 422 | A required field is missing or invalid. |
| 429 | Too many requests (see Rate limits). |
| 504 | A filter chain ran out of time. |
Rate limits
These endpoints accept a limited number of calls per minute from each address. Calls over the limit answer 429 and don't count.
| Endpoint | Calls per minute |
|---|---|
POST /webhooks/{id} | 60 |
POST /api/feeds/{id}/proxy | 10 |
POST /api/feeds/{id}/items/{item_id}/action/{action_id} | 20 |
POST /api/named-filters/proxy and POST /api/named-filters/{id}/proxy, together | 10 |
Your account
| Method | Path | Purpose |
|---|---|---|
GET | /api/users/me | Who you are. |
POST | /api/users/me/rotate-key | New access key for yourself. Refused when called with a plugin key. |
POST | /api/users/{id}/rotate-key | New access key for any user (needs sections.users.edit). |
POST | /api/auth/web-token | A one-time token to sign a browser in. |
GET /api/users/me returns your user record (username, created_at, active, features, revocations, and your routing topic_id) plus:
| Field | Meaning |
|---|---|
role_label | Admin, Developer, Read Only, Listener, or Custom. |
mqtt_username | The username to use on the broker: your username, or plugin_key_<id> when called with a plugin key. |
web_sections | The hub web UI sections you can open. |
hub_server_id | The hub's server id, as used in its MQTT topics. |
Both rotate routes return the user record with the new access_key, shown only this once; /me/rotate-key leaves out id. A key can be rotated once a minute. The old key stops working immediately for the API, and every browser signed in with it is signed out. If you rotate your own key from a signed-in browser, that browser stays signed in. Phones and scripts connected to the broker with the old key are disconnected within a few seconds and need the new key to connect again. This needs broker_snapshot_path set; see MQTT and Mosquitto.
POST /api/auth/web-token returns {"token": "..."}. Open /auth/redeem?token=<token> in a browser within 60 seconds to sign it in as you. Each token works once, and only over HTTPS.
Manifests
Manifests are the lists LemmeKnow fetches when it connects: everything of each kind that you may see.
| Method | Path | Returns |
|---|---|---|
GET | /api/manifests | All kinds at once: streams, stream_groups, feeds, plugins, pings, logs, webhooks, feed_filters, named_filters. |
GET | /api/feeds/manifest | {"feeds": [...]} |
GET | /api/streams/manifest | {"streams": [...], "groups": [...]} |
GET | /api/plugins/manifest | {"plugins": [...]} |
GET | /api/pings/manifest | {"pings": {"<code>": "<label>"}} |
GET | /api/logs/manifest | {"logs": {"<source>": "<label>"}} |
GET | /api/webhooks/manifest | {"webhooks": [...]} |
GET | /api/feed_filters/manifest | {"feed_filters": [...]}, one per RSS feed. |
GET | /api/named_filters/manifest | {"named_filters": [...]} |
A feed entry has id, name, pollPath (where to fetch its items), pollIntervalMinutes, iconUrl, description, private, and for RSS feeds proxyPath. A stream entry has name, viewers, private, iconUrl, description, and viewPath; a group has name, label, members, iconUrl, description, and viewPath.
Feeds
| Method | Path | Needs | Purpose |
|---|---|---|---|
GET | /api/feeds | List feeds with their settings, generation and item_count. | |
POST | /api/feeds | sections.feeds.edit | Create a feed. Returns its settings with the new id (201). |
GET | /api/feeds/{id} | A feed's items. | |
PATCH | /api/feeds/{id} | sections.feeds.edit | Change a feed's settings and rescan it. |
DELETE | /api/feeds/{id} | sections.feeds.edit | Delete a feed (204). |
POST | /api/feeds/{id}/scan | sections.feeds.edit | Scan now and return the feed's items. |
POST | /api/feeds/{id}/clear | sections.feeds.edit | Empty a plugin's feed (204). |
POST | /api/feeds/{id}/proxy | Fetch an RSS feed fresh and run its filters. | |
POST | /api/feeds/{id}/items/{item_id}/action/{action_id} | Press an item's action button. | |
GET | /api/feeds/{id}/manifest | Extra MQTT topics a plugin publishes for this feed. |
Fields for creating or changing a feed (see Server feeds for what they do):
| Field | Default | Values |
|---|---|---|
name | required | Display name. |
type | static | static, recreate, directory, or rss. |
path | File or folder to watch. | |
glob | * | Directory feeds. |
mode | snapshot | Directory feeds: snapshot, latest, or each. |
format | raw | File feeds: raw, junit, lklog, or tabbody. |
url | RSS feeds: the feed address. | |
thumbnail | off | RSS feeds: off, feed, or fetch. |
max_items | 50 | RSS feeds: items to keep. |
filter_scripts | [] | Paths of filter scripts to run on new items, in order. |
defaultBodyLevel | debug | junit feeds: the level given to passing test lines. |
pollIntervalMinutes | 15 | Hint for phones. |
iconUrl | Icon address. | |
description | Short description. | |
private | false | true makes the feed private. |
PATCH changes only the fields you send and keeps the rest. To clear url or filter_scripts, send an empty value ("" or []).
curl -X POST http://localhost:8765/api/feeds \
-H "X-Access-Key: YOUR_ACCESS_KEY" -H "X-Username: alice" \
-H "Content-Type: application/json" \
-d '{"name": "Backups", "type": "static", "path": "/var/log/backups/feed.log", "format": "tabbody"}'
GET /api/feeds/{id} returns {"id", "generation", "items": [...], "ts"}. Add ?since=<ms> to get only items newer than that time. When generation changes, the feed was reset and earlier items are gone. Feeds published by plugins also return keep_ids (the ids still current; ?keep_ids=0 leaves it out) and, for items sent to you alone, dropped_guids. Items are described in Named filters.
POST /api/feeds/{id}/proxy takes {"seen_guids": [...]} and returns {"items": [...], "dropped_guids": [...]} with the items not in seen_guids. RSS feeds only.
The item action endpoint takes an optional {"choice", "inputs"} body and returns {"ok": true}. It fires the button's webhook and URL and removes the item (or, for an item a plugin keeps as current state, its buttons).
Named filters
| Method | Path | Purpose |
|---|---|---|
GET | /api/named-filters | List filters: id, name, description, batch, private, proxyPath. |
POST | /api/named-filters/proxy | Run an RSS address or a list of items through a chain of filters. |
POST | /api/named-filters/{id}/proxy | The same with a single filter. The RSS address can also go in the rss_url query parameter. |
See Named filters for the proxy's fields and responses.
States
| Method | Path | Purpose |
|---|---|---|
GET | /api/states | Every published state you may see. |
Each entry has name, label, plugin (display name), slug (the plugin's name in topics and permission keys), value, display, alarm, interval, sort_order, and fields. States are published by plugins; there is no endpoint to set one. See States.
Streams
While streams are turned off, /streams/api/list returns {"enabled": false, "streams": []} and the player and snapshot addresses answer 404. See Streams.
| Method | Path | Needs | Purpose |
|---|---|---|---|
GET | /streams/api/list | {"enabled", "streams": [...]} for the streams you may see. | |
GET | /streams/{name}/snapshot.jpg | The stream's current frame as a JPEG. | |
GET | /streams/{name}/view | Full-screen player page. | |
GET | /streams/group/{name} | Tiled player page for a group. | |
PATCH | /api/streams/{name}/meta | sections.streams.edit | Set iconUrl, description, and optionally private. |
PATCH | /api/streams/groups/{name}/meta | sections.streams.edit | Set a group's iconUrl and description. |
curl -o porch.jpg http://localhost:8765/streams/porch/snapshot.jpg \
-H "X-Access-Key: YOUR_ACCESS_KEY" -H "X-Username: alice"
Tasks
| Method | Path | Needs | Purpose |
|---|---|---|---|
GET | /api/tasks | List the tasks you may see. | |
GET | /api/tasks/{id} | One task. | |
POST | /api/tasks | sections.tasks.edit | Create a task (201). |
PATCH | /api/tasks/{id} | sections.tasks.edit | Change name, enabled, schedule, or config. |
DELETE | /api/tasks/{id} | sections.tasks.edit | Stop and delete a task (204). |
POST | /api/tasks/{id}/toggle | sections.tasks.edit | Enable or disable. |
POST | /api/tasks/{id}/run | sections.tasks.edit | Run now, or restart a daemon or plugin. |
A task is {"name", "type", "enabled", "schedule", "config"}. type is daemon, script, urlwatch, or plugin. schedule is {"type": "interval", "minutes": 5} or {"type": "cron", "cron": "0 9 * * 1-5"}, and is ignored for daemons and plugins. Responses add id, last_run, last_status (never, ok, or error) and last_message. See Tasks for each type's config.
curl -X POST http://localhost:8765/api/tasks/TASK_ID/run \
-H "X-Access-Key: YOUR_ACCESS_KEY" -H "X-Username: alice"
Logs
| Method | Path | Purpose |
|---|---|---|
GET | /api/logs?limit=100 | The most recent log entries you may see, oldest first: level, source, msg, ts, and sometimes media_url. The hub keeps the last 200. |
Webhooks
| Method | Path | Needs | Purpose |
|---|---|---|---|
GET | /api/webhooks | List webhooks (without secrets). | |
POST | /api/webhooks | sections.webhooks.edit | Create a webhook (201). |
PATCH | /api/webhooks/{id} | sections.webhooks.edit | Change any of name, secret, enabled, log_level, source, handler, private. Fields left out keep their value, and so does a blank secret. The address doesn't change. |
DELETE | /api/webhooks/{id} | sections.webhooks.edit | Delete a webhook (204). |
GET | /api/webhook-handlers | sections.webhooks.edit | Names of the handler scripts available. |
POST | /webhooks/{id} | the webhook's secret | Trigger a webhook. No user sign-in. |
POST | /webhooks/{script} | signed-in user | Call a handler script directly with a JSON body; returns what the script returns. |
POST | /api/echo | Test target: logs the body and returns {"ok": true, "received": "..."}. |
Create fields: name and secret (required), source (default webhook), log_level (default important), handler (a script name), enabled (default true) and private (default false).
To trigger a webhook, sign the raw body with its secret in X-Hub-Signature-256: sha256=<hex HMAC-SHA256>, or send Authorization: Bearer <secret>. The hub logs the body's body or message field and returns {"ok": true}. See Webhooks.
curl -X POST http://localhost:8765/webhooks/WEBHOOK_ID \
-H "Authorization: Bearer WEBHOOK_SECRET" \
-H "Content-Type: application/json" \
-d '{"message": "Deploy finished"}'
Approvals
| Method | Path | Needs | Purpose |
|---|---|---|---|
GET | /api/actions | sections.tasks.edit | Requests sent since the hub started, each with status pending, resolved, or expired. |
POST | /api/actions/test | sections.tasks.edit | Send a request and wait for the answer. |
See Approvals for the request fields and the answer.
Plugins
| Method | Path | Purpose |
|---|---|---|
GET | /api/plugins/manifest | {"plugins": [...]}: the plugins with an enabled task that you may see. |
Each plugin entry has name, label, description, private, actions (its pages, each with title, url, and optional icon_url, description, and show_in_monitor) and the other settings from its file, such as settings, url_prefix, and dashboard_tab. See Writing a LemmeSee plugin.
Users
| Method | Path | Needs | Purpose |
|---|---|---|---|
GET | /api/users | sections.users.view | List users. |
POST | /api/users | sections.users.edit | Create a user (201). |
DELETE | /api/users/{id} | sections.users.edit | Delete a user (204). Not yourself. |
POST | /api/users/bootstrap | none | Create the first admin. Only while no users exist. |
POST /api/users takes {"username", "preset", "features"}: preset is listener (default), read_only, developer, or admin, and features is a list of extra keys. The username can only contain letters, numbers, underscores, and hyphens; anything else answers 400. It returns the user with its access_key, shown only this once.
POST /api/users/bootstrap takes {"username", "bootstrap_key"} with the key the hub printed at startup, and returns the new admin (the same username rule applies) with its access_key. See First run.
Grants and revocations
All need sections.users.edit. Connected phones refresh their lists after each change.
| Method | Path | Purpose |
|---|---|---|
GET | /api/users/{id}/features | {"features": [...]} |
POST | /api/users/{id}/features | Grant {"key": "<pattern>"}. Returns {"granted", "features"} (201). |
DELETE | /api/users/{id}/features/{key} | Remove a grant. Returns {"revoked", "features"}. |
GET | /api/users/{id}/revocations | {"revocations": [...]} |
POST | /api/users/{id}/revocations | Revoke {"key": "<pattern>"}. Returns {"revoked_pattern", "revocations"} (201). |
DELETE | /api/users/{id}/revocations/{key} | Remove a revocation. Returns {"restored", "revocations"}. |
POST | /api/users/{id}/allow-plugin-keys | {"allow": true} or false: grant or remove plugin_keys.mint. |
URL-encode a key in a path, since patterns can contain *, [, |, and ].
curl -X POST http://localhost:8765/api/users/USER_ID/features \
-H "X-Access-Key: YOUR_ACCESS_KEY" -H "X-Username: alice" \
-H "Content-Type: application/json" \
-d '{"key": "feeds.private.backups"}'
Plugin keys
| Method | Path | Needs | Purpose |
|---|---|---|---|
GET | /api/users/plugin-keys | Your own plugin keys. | |
POST | /api/users/plugin-keys | plugin_keys.mint | Create one: {"label", "scopes": [...]} (201). |
POST | /api/users/plugin-keys/{key_id}/revoke | owner or sections.users.edit | Revoke a key. |
DELETE | /api/users/plugin-keys/{key_id} | owner or sections.users.edit | Delete a key (204). |
GET | /api/users/{id}/plugin-keys | sections.users.edit | Another user's keys. |
POST | /api/users/{id}/plugin-keys | sections.users.edit | Create a key for another user, who must hold plugin_keys.mint. |
A key record has id, user_id, label, scopes, created_at, last_used_at, and revoked_at. Creating one also returns access_key (only this once), mqtt_username and hub_server_id. See Plugin API keys.
Invites
All need sections.users.edit.
| Method | Path | Purpose |
|---|---|---|
POST | /api/invites | Create an invite: {"preset", "features", "expires_days"}, where expires_days is 1 to 30 and defaults to 7. Returns the invite with its token, shown only this once (201). |
GET | /api/invites | Invites not yet used or expired: id, features, created_at, expires_at, used. |
DELETE | /api/invites/{id} | Revoke an invite (204). |
The invite link is /invite/<token> on the hub's address. See Invites.
Hub
| Method | Path | Needs | Purpose |
|---|---|---|---|
POST | /api/restart | sections.diagnostics.edit | Restart the hub. Returns {"ok": true, "message": "restarting"} straight away. |
GET | /api/icons | Icons the hub offers in its icon picker: [{"name", "url"}]. | |
POST | /api/crash-report | Record a crash report: {"exception", "stacktrace", "device"} (204). See Crash reports. |