3️⃣ Stream Events
The sequence explains why the cursor belongs to the provider's public stream contract rather than the browser: a provider may replay retained events after a validated cursor, while keep-alive comments distinguish a quiet network from a dead connection and are not application events. Validate event ids and deduplicate locally; retention, reset behavior, duplicate delivery, and keep-alive cadence are provider-specific. Consult the deployment's /openapi.json and published event-log policy.
Keep the API key out of curl arguments
Create one restrictive curl configuration file for this page instead of expanding NEXUS_API_KEY into each stream command. Hidden input keeps the terminal from echoing the value; the trap removes the file and unsets the variable, while same-user process inspection can still observe the key until the shell or child process exits:
Do not type export NEXUS_API_KEY='...', put a real key in command history, or commit the configuration file; the stream commands pass only its path to curl.
Open the stream
GET /events/stream is a standard Server-Sent Events endpoint (text/event-stream). It requires the events:read scope and is exempt from ordinary request-timeout handling; the client, provider, or transport can still close the connection, so use the cursor/reconnect behavior below:
Each frame carries one self-contained event for parsing — no extra fetch is needed merely to decode the frame:
A fresh connection starts at the current tip: you receive only what happens from now on. A provider may emit keep-alive comments on its documented cadence; do not assume a universal interval:
curl -N shows these; a browser's EventSource swallows them, which is the correct behavior for a comment frame.
The frame is a wake/invalidation signal, not a second database. After parsing it, re-read the authoritative resource through the relay; projection lag or replay can make the frame arrive before the REST view catches up.
Filter by kind
Omit kinds and you get every event on the network. The Run Watcher only cares about runs, so narrow the feed — comma-separated kind names, trailing Event suffix optional:
The kind strings are the on-chain event names — the same kind field you see in each frame. An unknown kinds value fails before the stream opens with HTTP 400 and INVALID_FILTER_VALUE; it does not produce a silent stream.
Kill it and resume under the provider contract
The frame's id is a cursor supplied by the provider's event-log contract. Note the last validated id, Ctrl-C the stream, wait a bit, then request retained replay after that id when the provider documents that behavior:
Retained events may replay first and then the stream may go live, but the provider defines retention, duplicate delivery, and reset behavior. Browsers automatically echo the last id back as the Last-Event-ID header on reconnect, but that transport behavior is not a guarantee that the provider can replay the cursor. Validate and deduplicate complete frames locally. If the provider rejects a stale or reset cursor, discard it and restart at the current tip only when the provider documents that recovery; do not assume that every invalid cursor is clamped.
When the provider documents current-tip recovery, clear last_event_id entirely before opening the replacement stream:
This cursor is a request for provider-defined retained replay, not a promise of a complete history. Re-read the authoritative REST resource after reconnecting, because projection lag or retention boundaries can make the event stream incomplete.
Close this step when finished
After the stream demonstration, clean the configuration and disarm its trap. This explicit boundary makes the three tutorial pages safe to concatenate in one shell while retaining the EXIT cleanup if any earlier command fails:
Next: assemble the Run Watcher.
Last updated

