Store API
See When to Use Meta vs CAS for guidance on structuring frame data.
The supervisor exposes a HTTP API for interacting with the store. See Topics for naming rules and wildcards. By default, it
listens on a Unix domain socket at ./store/sock.
Endpoints
GET /
Cat the stream
# Cat all frames
# Long poll for new frames
Query parameters are the read options: follow, new,
after, from, limit, last, topic, and with-timestamp. A follow
value may be true or a heartbeat interval in milliseconds.
Response: newline-delimited JSON frames or SSE stream, based on Accept header.
Use "Accept: text/event-stream" for SSE.
POST /append/{topic}
Append frame to topic
Query Parameters:
ttl- Time-to-live for frame:forever- Never expireephemeral- Not stored; only active subscribers receive ittime:<ms>- Expire after durationlast:<n>- Keep only N most recent frames
with-timestamp- Include RFC3339 timestamp extracted from frame ID
Headers:
xs-meta- Optional Base64-encoded JSON metadata. Must be encoded using standard Base64 to support Unicode characters.
Response: Frame JSON
POST /append-batch
Append several frames in one request
|
Body: newline-delimited JSON, one frame per line. Each line takes:
topic- Requiredmeta- Optional JSON metadatattl- Optional, as for/append/{topic}; defaults toforeverhash- Optional integrity hash of content already stored withPOST /cas
The frames get consecutive IDs, with no other append interleaved, and are committed together: a reader sees all of them or none. A malformed line returns 400 and an invalid topic rejects the batch; either way nothing is stored.
A batch holds at most 1024 frames; a bigger one returns 400, with nothing stored. Split it into several requests.
Query Parameters:
with-timestamp- Include RFC3339 timestamp extracted from frame ID
Response: newline-delimited JSON, the stored frames in order
GET /{id}
Get frame by id
Query Parameters:
with-timestamp- Include RFC3339 timestamp extracted from frame ID
Response: Frame JSON or 404 if not found
DELETE /{id}
Remove frame
Response: 204 on success
GET /last[/{topic}]
Get most recent frame(s), optionally filtered by topic.
Query parameters are the read options last (default: 1;
returns NDJSON when > 1), follow, and with-timestamp.
Response: Most recent frame(s) as JSON (single) or NDJSON (multiple/follow), or 404 if not found
POST /cas
Store content in CAS
Response: Content hash
GET /cas/{hash}
Get content from CAS
Response: Raw content or 404 if not found
POST /gc
Delete content no frame uses
Removing or trimming a frame leaves its content in CAS, and an ephemeral
frame's content is never kept by a stored frame. This deletes every content
file no stored frame points at and that was written more than an hour ago. The
hour leaves time for content uploaded with POST /cas to be appended, and for
readers following the stream to fetch an ephemeral frame's content. The server
also does this once each time it starts.
Response: JSON, what was found and deleted
POST /import
Import frame as-is
Response: Imported frame JSON
POST /eval
Evaluate a Nushell script against the store. The request body is the script
(UTF-8). The script runs with the store commands available (.cat, .last,
.append, plus the core commands), so it can read from and write to the stream.
Response: depends on the type the pipeline returns:
- single string/int/float/bool -
text/plain - any other single value (record, etc.) -
application/json - a list stream -
application/x-ndjson(one JSON value per line, streamed) - a byte stream -
application/octet-stream(streamed) - nothing - 204 No Content
A script that fails to evaluate returns 500 with the error text.
GET /version
Get version info
Response: Version information JSON
Status Codes
- 200 - Success
- 204 - Success (no content)
- 400 - Bad request
- 404 - Not found
- 500 - Internal server error