Guides › Guides
Streaming logs
6 min · 5 steps · Languages: curl, node, python
Read a project's logs in pages, or follow a service's output live with Server-Sent Events.
1. Search logs in pages
List logs answers up to 750 lines per page, newest first. Filter by service, deployment, level, time and text, and page back with next_cursor.
cURL
curl "https://devapi.dispralabs.com/v1/cloud/projects/prj_01jdk3m9x2v7c4q8w5n6b1t0ra/logs?svc=svc_01jdk3n2f4g6h8j0k2l4z6x8ca&level=error&limit=200" \
-H "Authorization: Bearer dsp_live_YOUR_KEY"
2. Follow a service
Stream a service's logs starts with the newest 100 lines (tail=0 to 750 to choose), then sends each new line as it is written:
event: line
id: 2026-12-05T10:15:02.114Z
data: {"at":"2026-12-05T10:15:02.114Z","level":"info","message":"GET /healthz 200 3ms","replica":"r1"}
A comment line (: ping) comes every 15 seconds to keep the connection open.
cURL
curl -N "https://devapi.dispralabs.com/v1/cloud/services/svc_01jdk3n2f4g6h8j0k2l4z6x8ca/logs/stream?tail=200" \
-H "Authorization: Bearer dsp_live_YOUR_KEY" \
-H "Accept: text/event-stream"
Node
const res = await fetch("https://devapi.dispralabs.com/v1/cloud/services/svc_01jdk3n2f4g6h8j0k2l4z6x8ca/logs/stream?tail=200", {
headers: { Authorization: "Bearer dsp_live_YOUR_KEY", Accept: "text/event-stream" },
});
const decoder = new TextDecoder();
let buf = "";
for await (const chunk of res.body) {
buf += decoder.decode(chunk, { stream: true });
let i;
while ((i = buf.indexOf("\n\n")) >= 0) {
const frame = buf.slice(0, i);
buf = buf.slice(i + 2);
const event = /^event: (.*)$/m.exec(frame)?.[1];
const data = /^data: (.*)$/m.exec(frame)?.[1];
if (event === "line") console.log(JSON.parse(data).message);
if (event === "gap") console.warn("skipped", JSON.parse(data).skipped);
}
}
Python
import json, requests
with requests.get("https://devapi.dispralabs.com/v1/cloud/services/svc_01jdk3n2f4g6h8j0k2l4z6x8ca/logs/stream",
params={"tail": 200}, stream=True,
headers={"Authorization": "Bearer dsp_live_YOUR_KEY",
"Accept": "text/event-stream"}) as res:
event = None
for line in res.iter_lines(decode_unicode=True):
if line.startswith("event: "):
event = line[7:]
elif line.startswith("data: ") and event == "line":
print(json.loads(line[6:])["message"])
3. Handle bursts
A read never sends more than 750 lines. If more arrive at once, the newest 750 are sent after event: gap with {"skipped": n}. Read the skipped lines from List logs if you need them.
4. Follow a build
Stream a deployment's logs with kind=build sends the build output and ends with event: end and the deployment's final state (live, failed or cancelled).
5. Reconnect without missing lines
Long connections drop. Reconnect with since=<the at of the last line you saw>, or send the last id as Last-Event-ID: the stream continues after it, without repeating or missing lines.