Public SSE stream of AI coaching for a shared session
const url = 'http://localhost:8000/api/shared/example/coaching/';const options = {method: 'GET'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request GET \ --url http://localhost:8000/api/shared/example/coaching/Public, token-gated SSE stream — same coaching analysis as the authenticated endpoint, but for a session that was shared via POST /api/sessions/<id>/share/. Anyone with the share URL already sees every metric on the report page; the AI paragraph is the same level of exposure. Same focus / lang / units query params as the authenticated stream. A single event: error frame with HTTP 404 is sent for an unknown token.
Auth: none — the token in the path is the credential.
Authorizations
Section titled “Authorizations”- None
Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”Query Parameters
Section titled “Query Parameters”Optional metric/area to bias the analysis toward.
en (default) or ru.
metric (default) or imperial.
Responses
Section titled “Responses”A text/event-stream (SSE) response. Frames arrive as event: <name>\ndata: <json>\n\n: one meta prelude, a sequence of token frames each carrying {text}, then a final done {ok: true}. On error a single error frame {detail} is sent and the HTTP status is set to 404 (unknown session/token).
Examples
SSE frame sequence (illustrative)
Server-sent events; the actual response is text/event-stream. The example shows the concatenated frames as they arrive — meta first, a sequence of token, done last.
event: metadata: {"session_id":"5c836d7d","activity":"running","client":"Anna Petrova","focus":null,"lang":"en","system":"metric","model":"…","provider":"…","mode":"live"}
event: tokendata: {"text":"Cadence "}
event: tokendata: {"text":"of "}
event: tokendata: {"text":"169 spm "}
event: tokendata: {"text":"is on the low side; "}
event: tokendata: {"text":"target 175-180 for this pace.\n"}
event: donedata: {"ok":true}object
Human-readable message, or a stable machine code for the cases a client branches on. The standard envelope for 400 (validation — a field-keyed object may appear instead), 401 (missing / invalid credentials), 403 (authenticated but not permitted), and 404 (absent — cross-team records are collapsed to 404 so the API never leaks the existence of another team’s data).
Examplegenerated
{ "detail": "example"}