Get started: HTTP stream
This tutorial follows a feed that stays open. The source is an HTTP stream. Each JSON line becomes the value. A Lua transformer on the source keeps the last few lines as one text block. A Label on a data piece shows that block.
Use HTTP instead when each refresh is a normal request that finishes.
1. Create an HTTP stream data source
Open the menu → Data sources → Add data source. Set the type to HTTP stream.
- URL — the address that stays open, for example
https://example.com/events - Framing — NDJSON
- Keep connected — on
Save. Connection should move to Streaming when the server accepts the request. If the address is wrong, the state stays Blocked or Reconnecting.
2. Keep a short history
Open Data transformers pipe on the source and add Lua:
local line = type(value) == "table" and (value.text or value.message) or tostring(value)
local history = vars.lines or {}
table.insert(history, line)
while #history > 8 do
table.remove(history, 1)
end
vars.lines = history
return table.concat(history, "\n")
vars.lines is remembered between lines. The stored value is the joined text.
3. Show it
Add a data piece, set this source as the root data source, and keep the Label. It updates as each line arrives.
If the stream stops
- Stream ended — the server closed the response. With Keep connected on, the app connects again after Reconnect delay.
- No data for a while — nothing arrived before Idle timeout. The app treats that as a dead connection and connects again. A quiet feed can look idle; raise the timeout or set it to 0 to wait without a limit.
- Reconnecting — the app is waiting, then it opens the address again. After repeated failures the wait grows up to Max reconnect delay.
- Trigger data source(s) refreshes the data piece from the last value. It opens a connection only when the stream is down or Keep connected is off.
- Reconnect now on the source always starts a fresh connection.
See Data sources.