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.

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

See Data sources.