Appearance
Handling streaming responses
Streaming responses let an API Endpoint send multiple updates while it is still running.
This is useful when an API Endpoint would otherwise take a long time and you want your interface to show progress (or display content as it arrives).
When to use streaming
- A long import/export (show progress)
- A file generation workflow (show steps like “preparing”, “generating”, “uploading”)
- AI responses (display text as it arrives)
Streaming in plain terms
Normally, an API Endpoint works like this:
- You call it.
- You wait.
- You get one final response when it’s done.
Streaming changes the “wait” part:
- You call it once.
- While it’s working, it sends small updates (like “10% done”, “still working”, or “here’s the next piece of text”).
- At the end, it finishes like a normal API call.
This is helpful for users because the interface can show what’s happening instead of looking stuck.
How streaming works in WeWeb
In an API Endpoint workflow:
- The first time you run
Send streaming response, WeWeb starts the stream. - Each next
Send streaming responseadds another message to the same stream. - The stream ends when the API Endpoint finishes.
Set up a streaming API Endpoint
- Create or open an API Endpoint in
Data & API → Workflows. - In your API Endpoint workflow, add
Send streaming responsewherever you want to send an update. - In
Event Data, send an object that your interface can use.
Example Event Data objects:
{ "status": "starting" }{ "status": "progress", "done": 3, "total": 10 }{ "status": "chunk", "text": "Hello " }{ "status": "done" }
Receive streaming updates in the interface
To see streaming updates while the API Endpoint runs, you must enable stream handling on the action that calls the API Endpoint:
- In the
Interfacetab, create a workflow (for exampleOn click). - Click
+ Add action, then go toWorkflows→APIand select your API Endpoint. - Open the action’s
Advancedsection and enableHandle stream.
When streaming is enabled, you can use:
stream.chunk: The latest message receivedstream.chunks: All messages received so far
This makes it easy to bind live progress into your UI (text, progress bars, or a “live output” area).
Practical example: generate a report with live progress
What you’re building
- A button in your interface: “Generate report”
- An API Endpoint that takes ~10–30 seconds
- A progress message in the UI while it runs (and a final download link at the end)
1) API Endpoint workflow (server-side)
In your API Endpoint workflow:
- Add
Send streaming responsewith:{ "status": "starting" }
- Run your report steps (for example: retrieve records, calculate totals, create a file).
- After each big step, add another
Send streaming response, for example:{ "status": "progress", "label": "Retrieving data", "done": 1, "total": 3 }{ "status": "progress", "label": "Generating file", "done": 2, "total": 3 }
- When done, send a last message with what the interface needs next:
{ "status": "done", "downloadUrl": "https://..." }
KEEP EVENT DATA SMALL
It is recommended to keep Event Data small and consistent so it’s easy to use in bindings.
2) Interface workflow (the button click)
- Create a workflow on your button (for example
On click). - Add your API Endpoint action from
Workflows→API. - Open
Advancedand enableHandle stream.
Now you can bind streaming updates into your UI:
- Show the latest update:
stream.chunk.statusandstream.chunk.label - Build a progress bar:
- Value:
stream.chunk.done - Max:
stream.chunk.total
- Value:
- When the final message arrives, use
stream.chunk.downloadUrlto show a “Download” button.
Best practices
- Send small updates: Prefer short objects over large data.
- Give your data a consistent shape: For example, always send a
status. - Avoid too many messages: If you’re looping, send updates every few steps instead of every single item.

