When to use
- Live data from a JSON API — status, counts or configuration a page should show as it is right now.
- Developer-facing pages — showing an API response as it arrives, pretty-printed and highlighted.
- Small HTML snippets from a trusted service, in HTML mode.
For data a reader should scan as rows and columns, use the Data Table block instead.
Key decisions
- Endpoint: prefer a same-origin path. A cross-origin API must allow CORS, and every reader's browser calls it directly, so never point the widget at anything that needs credentials.
- Display format: JSON pretty-prints and highlights the response. HTML passes the response through an allow-list sanitizer, which drops anything not known to be safe.
- Auto-refresh: 0 turns it off. Keep intervals long: each refresh is a request from every open tab.
- Max height: long responses scroll inside the block at 300px or 500px.
Example
The widget below reads /api/status/news-posts, the raw JSON behind the Recent posts table on EDS Platform News.
Where it renders
That endpoint is served by the site's routing worker, so the widget shows data on rhea-dev.pdcoe.dev. In the Universal Editor and on the aem.live hosts there is no API to answer, so the widget shows its error state and a retry button.
All authoring options
Content
apiUrl: endpoint to fetch. Same-origin paths are preferred
displayFormat: json (default) | html
refreshInterval: seconds between automatic refreshes. 0 turns it off
Appearance
classes_maxHeight: none (default) | max-h-300 | max-h-500
Analytics
classes_track-inview: emit an event when the block scrolls into view
classes_track-refresh: emit an event when the refresh button is clicked
meta: block-level analytics meta, sent as a JSON string
Events emitted:
emu-api-widget:inview
emu-api-widget:refresh