ZEQ · SDKzeqstate.com

Connect over HTTP

A running machine serves a versioned HTTP API. Within API version 1, routes and fields are only ever added, never changed or removed. GET /openapi.json describes every route as OpenAPI 3.1, generated from the routes the server actually answers. You can generate a client from it in any language. The API reference lists them.

Base address

WhereBase URL
Your own machine (--launch)http://127.0.0.1:8777
An unattended machine (--launch agent PORT)http://127.0.0.1:PORT, behind a TLS terminator
This nodehttps://zeqstate.com (also reachable under https://zeqstate.com/api/…)

Keys

Every route takes Authorization: Bearer KEY except these public ones:

The owner's key is in machine.owner.key. Give everyone else a key of their own:

python3 zeq.py --key issue "Ana's laptop" read 30   # drop, read, write or admin, for 30 days
python3 zeq.py --key list
python3 zeq.py --key revoke zeq_key_AbCdEfGhIjKlMn   # the key's prefix; refused from its next request

A key is shown once and kept only as a hash. Scopes form a ladder:

ScopeAllows
dropdelivering parcels to /inbox only
readreading the log and verifying
writealso asking (/ask, /mcp, …)
adminalso managing keys, deploying skins, setting connections

Ask

curl -s https://HOST/ask \
  -H "Authorization: Bearer $KEY" -H 'Content-Type: application/json' \
  -d '{"question": "F ? F = m*a | m = 2 kg, a = 3 m/s^2"}'

From JavaScript (browser or Node), with no library:

const r = await fetch("https://HOST/ask", {
  method: "POST",
  headers: { "Authorization": `Bearer ${KEY}`, "Content-Type": "application/json" },
  body: JSON.stringify({ question: "F ? F = m*a | m = 2 kg, a = 3 m/s^2" }),
});
const sealed = await r.json();   // the sealed envelope; sealed.answer holds value_si, unit, verification…

From Python with the standard library:

import json, urllib.request
req = urllib.request.Request("https://HOST/ask", method="POST",
    data=json.dumps({"question": "F ? F = m*a | m = 2 kg, a = 3 m/s^2"}).encode(),
    headers={"Authorization": f"Bearer {KEY}", "Content-Type": "application/json"})
sealed = json.load(urllib.request.urlopen(req))

Live streams

GET /pulse is server-sent events, one per Zeqond: zeqond, phase and R_t. ?n= stops after n events. A browser's EventSource cannot send a key, so read the stream with fetch and its body reader, as the state skin does. A stream holds its connection for 600 s at most; open it again after it ends. GET /feed is the log as RSS 2.0.

Limits

LimitValue
RequestsZEQ_RATE_LIMIT per 60 s per client address, default 120; then 429
Connections64 at once, 8 from one host; then 503 with Retry-After: 1
Body1 MiB (a parcel at /inbox, 2 MiB); then 413
One question15 s from accept; past it, refused by name and nothing sealed
/log pages250 rows at most (?after=N&limit=M)
/pulse600 s per stream, two streams per address

Errors

StatusMeaning
401no key, or a key the machine never issued or has revoked
403the key's scope does not allow this route
421the request's Host is not the machine's public name (ZEQ_PUBLIC_HOST)
429 / 503rate or connection limit; retry later

A refusal comes back as JSON with a refused field naming the reason. An answer the machine computed but would not certify is not an HTTP error: it is a 200 with verification: "refused" and the step that stopped it.

Browsers

ZEQ_ORIGINS lists the origins allowed to call the API from a page (CORS). A machine's own skins at /ui/NAME/ need no CORS: they are served by the machine itself, sandboxed, and talk to it alone.