Documentation / LemmeSee Hub

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

MethodHow
Access keySend X-Access-Key: <key> and X-Username: <username> with every request. Both are required, and they must belong to the same user.
Plugin keySend X-Access-Key: <plugin key> alone. Accepted only on the paths its scopes allow. See Plugin API keys.
Browser sessionSign in on the hub's sign-in page (/auth/login) with username and access key. The session cookie lasts 7 days.
Local adminA 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"}.

StatusMeaning
200, 201Success. 201 when something was created.
204Success with no body.
401Missing or invalid credentials.
403Signed in, but not allowed to do this.
404Not found, or not visible to you.
422A required field is missing or invalid.
429Too many requests (see Rate limits).
504A 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.

EndpointCalls per minute
POST /webhooks/{id}60
POST /api/feeds/{id}/proxy10
POST /api/feeds/{id}/items/{item_id}/action/{action_id}20
POST /api/named-filters/proxy and POST /api/named-filters/{id}/proxy, together10

Your account

MethodPathPurpose
GET/api/users/meWho you are.
POST/api/users/me/rotate-keyNew access key for yourself. Refused when called with a plugin key.
POST/api/users/{id}/rotate-keyNew access key for any user (needs sections.users.edit).
POST/api/auth/web-tokenA 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:

FieldMeaning
role_labelAdmin, Developer, Read Only, Listener, or Custom.
mqtt_usernameThe username to use on the broker: your username, or plugin_key_<id> when called with a plugin key.
web_sectionsThe hub web UI sections you can open.
hub_server_idThe 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.

MethodPathReturns
GET/api/manifestsAll 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

MethodPathNeedsPurpose
GET/api/feedsList feeds with their settings, generation and item_count.
POST/api/feedssections.feeds.editCreate a feed. Returns its settings with the new id (201).
GET/api/feeds/{id}A feed's items.
PATCH/api/feeds/{id}sections.feeds.editChange a feed's settings and rescan it.
DELETE/api/feeds/{id}sections.feeds.editDelete a feed (204).
POST/api/feeds/{id}/scansections.feeds.editScan now and return the feed's items.
POST/api/feeds/{id}/clearsections.feeds.editEmpty a plugin's feed (204).
POST/api/feeds/{id}/proxyFetch 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}/manifestExtra MQTT topics a plugin publishes for this feed.

Fields for creating or changing a feed (see Server feeds for what they do):

FieldDefaultValues
namerequiredDisplay name.
typestaticstatic, recreate, directory, or rss.
pathFile or folder to watch.
glob*Directory feeds.
modesnapshotDirectory feeds: snapshot, latest, or each.
formatrawFile feeds: raw, junit, lklog, or tabbody.
urlRSS feeds: the feed address.
thumbnailoffRSS feeds: off, feed, or fetch.
max_items50RSS feeds: items to keep.
filter_scripts[]Paths of filter scripts to run on new items, in order.
defaultBodyLeveldebugjunit feeds: the level given to passing test lines.
pollIntervalMinutes15Hint for phones.
iconUrlIcon address.
descriptionShort description.
privatefalsetrue 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

MethodPathPurpose
GET/api/named-filtersList filters: id, name, description, batch, private, proxyPath.
POST/api/named-filters/proxyRun an RSS address or a list of items through a chain of filters.
POST/api/named-filters/{id}/proxyThe 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

MethodPathPurpose
GET/api/statesEvery 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.

MethodPathNeedsPurpose
GET/streams/api/list{"enabled", "streams": [...]} for the streams you may see.
GET/streams/{name}/snapshot.jpgThe stream's current frame as a JPEG.
GET/streams/{name}/viewFull-screen player page.
GET/streams/group/{name}Tiled player page for a group.
PATCH/api/streams/{name}/metasections.streams.editSet iconUrl, description, and optionally private.
PATCH/api/streams/groups/{name}/metasections.streams.editSet 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

MethodPathNeedsPurpose
GET/api/tasksList the tasks you may see.
GET/api/tasks/{id}One task.
POST/api/taskssections.tasks.editCreate a task (201).
PATCH/api/tasks/{id}sections.tasks.editChange name, enabled, schedule, or config.
DELETE/api/tasks/{id}sections.tasks.editStop and delete a task (204).
POST/api/tasks/{id}/togglesections.tasks.editEnable or disable.
POST/api/tasks/{id}/runsections.tasks.editRun 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

MethodPathPurpose
GET/api/logs?limit=100The most recent log entries you may see, oldest first: level, source, msg, ts, and sometimes media_url. The hub keeps the last 200.

Webhooks

MethodPathNeedsPurpose
GET/api/webhooksList webhooks (without secrets).
POST/api/webhookssections.webhooks.editCreate a webhook (201).
PATCH/api/webhooks/{id}sections.webhooks.editChange 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.editDelete a webhook (204).
GET/api/webhook-handlerssections.webhooks.editNames of the handler scripts available.
POST/webhooks/{id}the webhook's secretTrigger a webhook. No user sign-in.
POST/webhooks/{script}signed-in userCall a handler script directly with a JSON body; returns what the script returns.
POST/api/echoTest 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

MethodPathNeedsPurpose
GET/api/actionssections.tasks.editRequests sent since the hub started, each with status pending, resolved, or expired.
POST/api/actions/testsections.tasks.editSend a request and wait for the answer.

See Approvals for the request fields and the answer.

Plugins

MethodPathPurpose
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

MethodPathNeedsPurpose
GET/api/userssections.users.viewList users.
POST/api/userssections.users.editCreate a user (201).
DELETE/api/users/{id}sections.users.editDelete a user (204). Not yourself.
POST/api/users/bootstrapnoneCreate 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.

MethodPathPurpose
GET/api/users/{id}/features{"features": [...]}
POST/api/users/{id}/featuresGrant {"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}/revocationsRevoke {"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

MethodPathNeedsPurpose
GET/api/users/plugin-keysYour own plugin keys.
POST/api/users/plugin-keysplugin_keys.mintCreate one: {"label", "scopes": [...]} (201).
POST/api/users/plugin-keys/{key_id}/revokeowner or sections.users.editRevoke a key.
DELETE/api/users/plugin-keys/{key_id}owner or sections.users.editDelete a key (204).
GET/api/users/{id}/plugin-keyssections.users.editAnother user's keys.
POST/api/users/{id}/plugin-keyssections.users.editCreate 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.

MethodPathPurpose
POST/api/invitesCreate 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/invitesInvites 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

MethodPathNeedsPurpose
POST/api/restartsections.diagnostics.editRestart the hub. Returns {"ok": true, "message": "restarting"} straight away.
GET/api/iconsIcons the hub offers in its icon picker: [{"name", "url"}].
POST/api/crash-reportRecord a crash report: {"exception", "stacktrace", "device"} (204). See Crash reports.