Suggestion plugins
TravStats finds the stops in your location history (TravTrack) and suggests them as place visits in the inbox. A suggestion plugin is a small HTTPS service you run yourself, or one you trust, that TravStats asks about such a stop: “what was here?”. Its answer appears in the inbox as a suggestion with the plugin named as its source. You decide; nothing is accepted by itself.
A plugin answers, it never writes. It cannot create entries, read your history or ask TravStats anything. It sees one stop at a time, rounded to the precision you chose.
- Settings: TravTrack → Erkennung & Vorschläge → Externe Vorschlagsquellen (EN: External suggestion sources). At most five per account.
- The admin can switch plugins off for the whole server (Dienste → Externe Vorschlagsquellen); the internet master switch covers them too.
- A template (about a hundred lines of Node, no dependencies, with a Dockerfile,
a compose snippet and a test that replays signed requests) and the contract as
JSON Schema, exported from the server’s own OpenAPI document, ship in the
TravStats repository under
packages/travstats-plugin-template.
What is sent, and what is not
Section titled “What is sent, and what is not”Per stop a plugin receives the stop’s start and end, its time zone and its coordinates rounded to the plugin’s precision:
| Precision | Coordinates | Also sent |
|---|---|---|
exact | 5 decimals (~1 m) | nearest own place, the venue found, the address |
100m (default) | 3 decimals (~100 m) | nearest own place, the venue found, the address |
1km | 2 decimals (~1 km) | nothing else |
Never sent: your account, user name, name or e-mail, the location history, other stops, other entries. A plugin that logs coordinates should keep them no longer than it needs them: they are someone’s whereabouts.
The request
Section titled “The request”POST <your url> with a JSON body and these headers:
Content-Type: application/jsonTravStats-Plugin-Version: 1TravStats-Timestamp: 1763900000TravStats-Request-Id: 0b9f6a2e-4c1d-4e7a-9a53-2f1d6c8e7b10TravStats-Signature: v1=<hex HMAC-SHA256>{ "version": 1, "kind": "stop", "requestId": "0b9f6a2e-4c1d-4e7a-9a53-2f1d6c8e7b10", "stop": { "start": "2026-11-23T08:12:00.000Z", "end": "2026-11-23T10:40:00.000Z", "timeZone": "Europe/Berlin", "lat": 48.69, "lon": 9.31, "precisionMeters": 100, "nearestPlace": { "name": "Office", "distanceMeters": 40 }, "venue": { "name": "Business park", "category": "other" }, "address": { "street": "Example Street 5", "town": "Example Town", "country": "DE" } }, "locale": "de"}kind is "test" when the user presses the settings page’s test button: the stop
is then a fixed public square and carries no account data. nearestPlace,
venue and address are optional. An optional signed GET <your url> with an
empty body may answer { "name": "…", "version": 1, "kinds": ["stop"] }; the test
button shows it.
Verifying the signature
Section titled “Verifying the signature”The signature is HMAC-SHA256 with the plugin’s secret over
METHOD + "\n" + path + "\n" + timestamp + "\n" + requestId + "\n" + body— the upper-case method, the path including its query string, the
TravStats-Timestamp value, the TravStats-Request-Id value and the exact body
bytes as received (do not re-serialise the JSON). The header is v1= followed
by the lower-case hex digest.
A plugin MUST:
- compare the signature in constant time (
crypto.timingSafeEqual); - refuse a timestamp more than 300 s away from its own clock;
- keep a request-id replay cache for at least the timestamp window and refuse an id it has seen — without it a captured request could be sent again.
Refuse with 401; TravStats shows that as “auth”. The secret is 32 random bytes
(base64url) generated when you add the plugin, shown once on adding and on
Neues Geheimnis (rotate), and never again.
Test vector, secret test-secret-0123456789abcdef0123456789: a POST to
/hooks/travstats?x=1 at timestamp 1763900000, request id
0b9f6a2e-4c1d-4e7a-9a53-2f1d6c8e7b10 and body {"version":1} signs to
v1=c1611e231a9667ee0bc0a11707bb4d8c49791ed150df97a7794e552469b68c2a.
The response
Section titled “The response”200 with
{ "version": 1, "suggestions": [ { "name": "Project 4711", "address": "Example Street 5, Example Town", "lat": 48.6901, "lon": 9.3102, "purpose": "business", "note": "maintenance", "externalRef": "4711", "url": "https://archive.example.com/projects/4711", "confidence": 0.95 } ]}- Every field but
nameandconfidenceis optional; at most 5 suggestions;confidenceis 0..1;purposeisprivateorbusiness;urlmust behttps:and is shown as a plain link, never fetched. 204, or an emptysuggestionslist, means “nothing here”. That is a real answer: TravStats does not ask about the stop again unless it moves by more than 300 m or you press Neu fragen.- A suggestion more than 1 km from the stop is dropped.
externalRefmakes the place findable again: accepting a suggestion links the place asplugin:<pluginId>:<externalRef>, so a second visit finds it.- The body is capped at 64 KB; strings are length-capped (name 200, address 300, note 500 characters).
Name matches
Section titled “Name matches”A suggestion may say why it was made. reason is distance or name;
distanceMeters, matchedToken and lowPrecision are optional. A name
suggestion matched a distinctive word of the stop’s venue name further away than
the plugin’s distance radius; the inbox then reads “Name passt (MSA), 780 m”. The
response may carry nameRadiusMeters, the radius the plugin searched names in: a
name suggestion is accepted up to that radius, capped at 2 km. Everything
else keeps the 1 km rule. Unknown fields are ignored on both sides.
A list of the plugin’s places (optional)
Section titled “A list of the plugin’s places (optional)”The signed hello (GET <url>) may announce a list:
{ "name": "My plugin", "version": 1, "kinds": ["stop"], "list": { "defaultName": { "de": "Kunden", "en": "Customers" }, "columns": [{ "key": "no", "label": { "de": "Nr.", "en": "No." } }] }}A suggestion then carries its reference as an object:
"externalRef": { "id": "4711", "label": "Hall 3", "fields": { "no": "4711" } }.
A plain string still works and means { "id": "…" }.
TravStats keeps one list per plugin, named defaultName in the user’s
language. Its members are the places of the plugin’s accepted suggestions,
never an unaccepted one. Up to 6 columns; keys match ^[A-Za-z][A-Za-z0-9_]{0,31}$;
fields values are at most 200 characters. An optional refNamespace (for
example "proj") lets places that already carry a reference proj:<id> join the
list; the prefixes TravStats writes itself (plugin, osm, wikidata, …) are
refused. The place list shows the plugin’s
columns. If you vendor the contract, keep an exact copy of
contract/v1.schema.json from the template.
Location maintenance (optional)
Section titled “Location maintenance (optional)”A plugin that announces capabilities: ["maintenance"] offers to maintain the
locations in its own data. The settings card then has Standorte pflegen;
without the capability the button is not drawn. Calls are signed like a stop call
and go to <plugin url>/maintenance/<action>:
| Call | Body | Answer |
|---|---|---|
POST maintenance/proposals | version, requestId, locale, stops[] (at most 2000) | rows with issues (noCoordinates, noStreet, lowPrecision), proposals with confidence and evidence, and the already applied changes |
POST maintenance/confirm | kind (apply or undo) and exactly the values about to be written | a single-use token and its expiresAt; writes nothing |
POST maintenance/apply | rowId, lat, lon, optional street, postcode, town, source (stop, geocoder, manual) and the token | undoId, what was written |
POST maintenance/undo | undoId and a token | what was restored |
POST maintenance/ignore | rowId, ignored | the new state |
TravStats sends the stops with each proposals request: the account’s venue-named
TravTrack findings of the last two years, rounded to the plugin’s precision. At
precision 1km none are sent. The plugin uses them for that answer only and must
not keep a location history.
TravStats asks for a confirmation ticket when you confirm in the dialog and
sends it with apply or undo. The plugin must refuse a write without a valid
ticket: it is single use and bound to exactly the values you saw, so nothing else
can be written under it.
The plugin writes only on apply: the coordinates, and the street only when
the row’s own street is empty. It keeps the previous values in a local undo log;
undo restores them and answers 409 {"error":"changed"} when the row was edited
since. A data source that refuses writes answers 409 {"error":"readOnly"}; an
unknown row 404 {"error":"notFound"}. Timeout 15 s, body cap 1 MB. Only the
account that owns the registration reaches its plugin’s maintenance, not an admin.
The template
Section titled “The template”A working plugin — about a hundred lines of Node, no dependencies, with a
Dockerfile, a compose snippet and a test that replays signed requests — is in the
TravStats repository:
packages/travstats-plugin-template.
The contract is exported as JSON Schema (contract/v1.schema.json) from the
server’s own OpenAPI document, and a test keeps the two equal.
Errors and limits
Section titled “Errors and limits”What the settings page shows as the plugin’s “letzter Fehler”:
| The plugin … | Reason |
|---|---|
| does not answer within 5 s (connect 2 s) | timeout |
| cannot be reached | unreachable |
| answers 401 or 403 | auth |
| answers 429 | rateLimited — Retry-After is honoured |
| answers 5xx | server |
answers bad JSON, a body outside the schema, an unknown major version, a redirect | protocol |
| sits on the LAN and the account is not the admin | privateTarget |
After a failure TravStats waits 15 minutes, doubling up to 6 hours. Per plugin it
makes at most 60 calls an hour and 300 a day, one at a time. version is an
integer major; inside a major, fields may be added and must be ignored when
unknown.
Where a plugin may live
Section titled “Where a plugin may live”An ordinary account’s plugin must be a public https address. The admin’s own
plugin may be a container beside TravStats on the LAN, and only there plain http
(for example http://travstats-plugin:8080/). Redirects are never followed.
A minimal plugin in Node
Section titled “A minimal plugin in Node”const http = require("node:http");const crypto = require("node:crypto");
const SECRET = process.env.PLUGIN_SECRET;const seen = new Map(); // request id -> time: the mandatory replay cache
function valid(req, body) { const ts = Number(req.headers["travstats-timestamp"]); const id = String(req.headers["travstats-request-id"] || ""); const now = Math.floor(Date.now() / 1000); if (!Number.isInteger(ts) || Math.abs(now - ts) > 300 || seen.has(id)) return false; const text = `${req.method}\n${req.url}\n${ts}\n${id}\n${body}`; const expected = Buffer.from(`v1=${crypto.createHmac("sha256", SECRET).update(text).digest("hex")}`); const given = Buffer.from(String(req.headers["travstats-signature"] || "")); if (given.length !== expected.length || !crypto.timingSafeEqual(given, expected)) return false; seen.set(id, now); for (const [k, at] of seen) if (now - at > 600) seen.delete(k); return true;}
http .createServer((req, res) => { let body = ""; req.on("data", (c) => (body += c)); req.on("end", () => { if (!valid(req, body)) return res.writeHead(401).end(); const { stop } = JSON.parse(body); const suggestions = lookUp(stop); // your source: a database, an API, a file if (!suggestions.length) return res.writeHead(204).end(); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({ version: 1, suggestions })); }); }) .listen(8080);
function lookUp(stop) { return []; // e.g. [{ name: "…", lat: stop.lat, lon: stop.lon, confidence: 0.8 }]}Past days
Section titled “Past days”Vergangene Tage abfragen asks one plugin about the stops of up to 90 past days, as a job, if the plugin allows it (Vergangene Tage abfragen erlauben). The same hourly and daily limits apply; it skips stops the plugin has already answered and only ever suggests.