Postlad/Guides/Embed a live sensor chart on any website

Embed a live sensor chart on any website

Once a device is sending readings to Postlad, its chart can sit on your own website, blog, WordPress post or Notion page and keep itself up to date. It is one script tag, or a plain iframe where scripts are not allowed. This page covers every option the embed actually accepts, the one-number value badge, and what to do on sites that strip both.

How a Postlad embed reaches a web pageA sensor sends a reading to api.postlad.com. The host web page loads a script from app.postlad.com, which inserts an iframe. The iframe draws the chart and polls app.postlad.com for new readings at the interval the server sets.SensorHTTP GET /uPostladapi.postlad.comapp.postlad.com/e.js/embed/<ref>Your pageiframepoll ≥10 s
The embed is an iframe served by app.postlad.com. The script tag only inserts it, sizes it and passes your page's theme in.

Before you start

You need a stream that is already receiving readings and whose sharing is set to Public or Secret link. If you have not sent anything yet, start with Send ESP32 data to the cloud or Send sensor data with one HTTP request.

The stream's page in the dashboard has an Embed panel with every snippet below already filled in for that stream, a copy button for each, and a live preview at the real size. This guide explains what those snippets do and how to change them.

The script tag

This is the version to use wherever your page allows scripts. Replace greenhouse with your stream's public address, or with its secret link token.

html
<script src="https://app.postlad.com/e.js"
        data-stream="greenhouse"
        data-range="24h"
        data-theme="auto"
        data-height="260"
        async></script>

The script does four things and nothing else:

  1. Inserts an iframe right after itself, pointing at https://app.postlad.com/embed/greenhouse with your options on the address.
  2. Gives the iframe loading="lazy", referrerpolicy="no-referrer" and a sandbox that allows only scripts and opening links in a new tab.
  3. Resizes the iframe to fit the chart once it has loaded, so there is no inner scrollbar.
  4. With data-theme="auto", tells the chart whether the reader's system is in light or dark mode and passes on the background colour of the element the chart sits in, so it blends into your page.

The chart itself lives inside the iframe, so your page's CSS cannot break it and its CSS cannot leak into your page. You can put several script tags on one page, one per chart.

The plain iframe

Where scripts are stripped or not wanted, paste the iframe directly. It needs no JavaScript on your page.

html
<iframe src="https://app.postlad.com/embed/greenhouse?range=24h&theme=auto"
        width="100%" height="260" frameborder="0" loading="lazy"
        title="Greenhouse — live chart by Postlad"></iframe>

Two differences from the script tag. Nothing resizes the iframe, so the height you give it is the height it keeps; 260 pixels suits the default chart. And theme=auto follows only the reader's light or dark system setting, because there is no script on your page to report your page's own background.

The chart is drawn on the server, so it appears even in a browser with JavaScript switched off. It just does not update until the page is reloaded.

Every option

On the script tag each option is a data- attribute. On the iframe it is a query parameter on the /embed/ address. Values the embed does not understand are ignored and the default is used, so a typo gives you a working chart rather than an error.

OptionScript attributeValuesDefault
Streamdata-streamThe public address, or the secret link token. In the iframe it is the path: /embed/<ref>Required
rangedata-range1h, 6h, 24h, 7d, 30d, 1y, all (lower case)Fitted to the stream: the shortest of these that covers its whole history
themedata-themelight, dark, autoauto
fieldsdata-fieldsComma list from f1 to f16, for example f1,f2Every field the stream has
pointsdata-points50 to 500; outside values are clamped180
legenddata-legend1 or 0 (also true/false, yes/no)1
tilesdata-tiles1 or 0: current-value tiles above the chart0
bgdata-bgtransparent or a six-digit #rrggbbThe theme's background
modedata-modevalue for the one-number badge; anything else is a chartChart
Heightdata-heightPixels. On the iframe, use its own height attribute260 for a chart, 128 for a badge
Titledata-titleThe name screen readers announce for the frame“Live chart” or “Live reading”

A few notes that save debugging time:

  • Height with the script tag is only a starting size. Once the chart loads it reports its real height and the script resizes the iframe to match, up to 1,200 pixels.
  • bg in an iframe address must have its # written as %23, for example bg=%23ffffff. A bare # ends the address and the colour never arrives. The script tag encodes it for you.
  • points is the number of time buckets across the chart, not a count of readings. Each bucket shows the average with a band for its minimum and maximum, so a spike inside a bucket is still visible.
  • fields draws the chosen fields as lines on one chart, with the legend saying which is which.

A dark chart of the last seven days of temperature and humidity, with value tiles and no legend:

html
<script src="https://app.postlad.com/e.js"
        data-stream="greenhouse"
        data-range="7d"
        data-fields="f1,f2"
        data-theme="dark"
        data-tiles="1"
        data-legend="0"
        async></script>

The value badge: one number instead of a chart

Often what a page wants is just the current reading: the greenhouse is at 23.4 °C. Add mode=value and the same embed becomes a badge with the stream name, the value and its unit, and a sentence saying when that reading arrived. A sensor that stopped last spring says so in words rather than showing a stale number as if it were current.

html
<script src="https://app.postlad.com/e.js"
        data-stream="greenhouse"
        data-mode="value"
        data-fields="f2"
        data-theme="auto"
        async></script>

Or as a plain iframe:

html
<iframe src="https://app.postlad.com/embed/greenhouse?mode=value&fields=f2"
        width="100%" height="128" frameborder="0" loading="lazy"
        title="Greenhouse humidity — live reading by Postlad"></iframe>
  • A badge shows one field. Name it with fields; without it, the badge shows the stream's first field.
  • It opens at 128 pixels and the script tag shrinks or grows it to fit. The plain iframe keeps 128, so give it more room if the field name is long and wraps.
  • range only changes the sentence shown when there is no reading in that window, for example “no reading in the last 24h”.
  • It refreshes on the same schedule as the chart, and its first refresh waits for that schedule, because the number is already in the page when it loads.

Which streams can be embedded

Stream sharingEmbed addressWhat readers see
Public/embed/<public address>The live chart
Secret link/embed/<secret token>The live chart; the stream is not listed anywhere, but anyone who can see your page's source can find the token
PrivateNone offered“This chart is not available. It may have been unshared, or the link may be wrong.”

A private stream's Embed panel shows no snippets; it asks you to switch sharing to Secret link or Public first. If you later make an embedded stream private, every embed of it shows the sentence above instead of a chart. It never shows a blank box, and it never says which of the two reasons applies.

Embeds are read-only. Nobody viewing one can change the stream, and no viewer needs a Postlad account.

What the embed does on your page

  • No cookies. The frame sets no cookies, stores nothing in localStorage and sends no analytics beacon.
  • The server sets the refresh rate. The chart asks for new readings at the interval Postlad tells it: never faster than every 10 seconds, roughly your device's own sending interval up to a minute, and once a minute for a device that has gone quiet.
  • It pauses when nobody is looking. A chart scrolled out of view, or in a background tab, stops asking for data and resumes when it comes back. A post with a dozen charts costs about what one costs.
  • It says when it is held back. If one reader's browser refreshes far too often, the frame keeps the last good chart and shows a small “paused” note until it may continue.
  • It is not indexed. Search engines are told not to index the frame itself; your page is unaffected.

The “live chart by Postlad” link

Embeds of streams on a Free account carry a small “live chart by Postlad ↗” link in the bottom-right corner, at reduced opacity until hovered. It is drawn by the server inside the frame, so it cannot be hidden with CSS from your page or with an option.

Hobby ($6/month) and Lab embeds show no link at all. The options and refresh behaviour described here are the same on every plan. See pricing.

WordPress

In the block editor, add a Custom HTML block and paste the script tag or the iframe. Use Preview in the block to check it before publishing.

  • On a self-hosted site, WordPress lets administrators and editors save scripts and iframes; it removes them from posts saved by accounts without the unfiltered_html capability, such as authors and contributors, and on multisite installs from everyone but super admins.
  • Some hosted WordPress plans also remove script tags, and sometimes iframes, when the post is saved. If the script tag disappears, try the plain iframe. If that disappears too, your plan or a plugin is filtering it; an embed or iframe plugin permitted on your plan, or the image link described below, are the remaining routes.
  • Caching and optimisation plugins that defer or combine scripts can move the script tag away from where you placed it. The plain iframe is unaffected by them.

Notion

Notion pages do not run pasted script tags. Type /embed, choose Embed, and paste the /embed/ address itself, not the HTML around it:

text
https://app.postlad.com/embed/greenhouse?range=24h&theme=light

Drag the block's lower edge to set its height. Because Notion follows its own light and dark setting rather than the system's, an explicit theme=light or theme=dark matching your workspace usually looks better than auto.

GitHub README and forums

GitHub, and most forums, remove iframes and scripts from what you post. A live chart is not possible there, but a picture of it that links to the live page is. For a public stream the Embed panel has a Markdown snippet:

markdown
[![Greenhouse](https://app.postlad.com/og/greenhouse.png)](https://app.postlad.com/s/greenhouse)

The image is the stream's social card: a 1200 × 630 PNG snapshot of the chart, drawn from current readings and cached for up to ten minutes at Postlad's edge. Clicking it opens the live share page. GitHub fetches images through its own proxy, which keeps its own copy, so the picture can lag the live chart; the link always opens the live one.

Secret-link streams have no card on purpose: an image of the readings stored on someone else's server would leak exactly what the secret link is meant to keep unlisted. For those, post a plain link to the share page.

Content-Security-Policy on your page

If your site sends a Content-Security-Policy header, it has to allow Postlad's frame, and the script if you use the script tag:

text
Content-Security-Policy: script-src 'self' https://app.postlad.com; frame-src https://app.postlad.com

Merge these sources into your existing directives rather than replacing them. With only the iframe, frame-src is all you need. If your policy has no frame-src but has child-src or default-src, the browser falls back to those, so add the origin there instead.

Nothing is needed in the other direction. The embed page is served with frame-ancestors *, so it can be framed by any site, and no X-Frame-Options header that would block it.

Keys and addresses: what can and cannot break an embed

  • Rotating the write key never breaks an embed. Embeds address the stream by its public address or secret token; the write key only lets a device add readings. The old write key keeps working for 24 hours after rotation, so devices can be updated without a gap.
  • Changing a public stream's address keeps the old one working, and it always will, so embeds made with it keep showing the chart.
  • Regenerating the read key does break secret-link embeds. The read key is the token inside the secret link, and regenerating it revokes old secret links immediately. That is the point of the button: use it when a secret link has gone somewhere it should not have, then paste the new snippet where you still want the chart.
  • Making the stream private replaces every embed with the “not available” sentence until you share it again.

Troubleshooting

Nothing appears where the script tag was

Check the browser console. A Content-Security-Policy error means your site's policy is blocking app.postlad.com; see above. If the tag is not in the page source at all, your editor removed it; use the iframe.

The chart says “Waiting for this device's first reading”

The stream exists and is shared but has never received a reading. Once the device's first request returns ok, the chart fills in on its next refresh.

The chart says “No readings in this window”

The device has sent readings, just none inside the chosen range. Widen the range, or check that the device is still sending.

The iframe has a scrollbar or cuts off

The plain iframe does not resize itself. Increase its height, or switch to the script tag, which sizes the frame to its content.

FAQ

Does the embed set cookies?

No. The frame sets no cookies, stores nothing in localStorage and sends no analytics beacon.

Can I embed a private stream?

No. An embed of a private stream shows a sentence saying the chart is not available. Set the stream's sharing to Secret link or Public and the Embed panel offers the snippets.

Will rotating the write key break my embed?

No. Embeds use the stream's public address or secret token, never the write key. Regenerating the read key is different: it revokes old secret links immediately, and secret-link embeds with them.

How often does the embedded chart update?

Postlad's server sets the pace: never faster than every 10 seconds, roughly the device's own sending interval up to once a minute, and once a minute for a device that has gone quiet. It stops asking for data while it is off screen or in a background tab.

It appears on embeds of streams owned by Free accounts. Hobby and Lab embeds have none. It cannot be removed with CSS or an option, because it is drawn inside the frame by the server.

Can I put a live chart in a GitHub README?

Not a live one, because GitHub removes iframes and scripts. For a public stream, use the Markdown snippet: a snapshot image of the chart that links to the live share page.

Get a chart to embed

Create a free account, point a device at its write key, set the stream to Public or Secret link, and copy the snippet from its Embed panel.

Create your free account →

Sources and verification