How to Build a Live Chart from a REST API | PlotMarks
How to Build a Live Chart from a REST API
Fetch data, push it to a persistent chart slot, embed the URL. It updates automatically.
Blog › How to Build a Live Chart from a REST API
Published August 23, 2026 ·<br>By Marko M
You have a public REST API that returns data that changes over time. You want to embed a chart that reflects the current state of that data, without writing a frontend, without regenerating a new image on every update, and without requiring the viewer to reload the page to see new values.
This article shows how to do that. The example uses the free Open-Meteo weather API (no API key required), a short Python script, and PlotMarks for the persistent hosted chart.
What we are building
By the end of this article you will have a live line chart showing New York City's hourly temperature forecast for the day. A Python script fetches the forecast from the Open-Meteo weather API and pushes the data to a PlotMarks chart slot. The chart is embedded in any page via a single tag. While the page is open, the chart polls for new data automatically and re-renders in place, with no page reload or iframe reload.
The finished result: a live chart that updates in place each time the script pushes new data.
The script is about 60 lines of Python. There is no frontend to build or host. Once the chart slot is created you have a permanent embed URL that stays current for as long as the script is running.
The problem with the usual approaches
If you want to visualize live data without a frontend, the options usually involve one of:
Generating a chart image on demand. The script produces a PNG file and stores or serves it. Every new dataset means a new file and often a new URL, so anything that embeds the chart breaks.
Building and hosting a charting frontend. This works, but maintaining a small React or vanilla JS app just to show one chart is overhead that has nothing to do with the actual data.
Using a full dashboard product. Often more than you need if the goal is a single embeddable chart kept current by an external process.
The model this article uses is different: create a chart slot once, get a persistent embed URL, and push new data to that URL whenever you need to. The URL never changes. The browser handles polling for updates automatically.
Architecture
flowchart LR<br>A["Open-Meteo API"] -->|"GET /v1/forecast"| B["Python script\nfetch + transform"]<br>B -->|"POST /api/charts/{id}/data"| C[("PlotMarks\nchart slot")]<br>C -->|"persistent URL"| D["Embedded iframe\n(any page)"]<br>D -->|"polls every N sec"| C<br>The Python script owns the data pipeline. PlotMarks stores the latest dataset and serves it to whatever is embedding the chart. The producer (the script) and the viewer (the iframe) operate independently. The script can push whenever it has new data, and the browser polls PlotMarks on its own schedule.
Prerequisites
Python 3.8 or later
requests library (pip install requests)
A PlotMarks account and API key: sign up free at plotmarks.com
Step 1: Create a chart slot
A chart slot is a persistent resource with its own ID and embed URL. You create it once, and it stays at the same URL regardless of how many times you update its data.
Run this once to provision the slot:
import os<br>import requests
PLOTMARKS_API = "https://www.plotmarks.com"<br>API_KEY = os.environ["PLOTMARKS_API_KEY"]<br>HEADERS = {"X-API-Key": API_KEY, "Content-Type": "application/json"}
def create_chart() -> str:<br>payload = {<br>"type": "line",<br>"output_type": "live_iframe",<br>"refresh_interval": 300, # browser polls every 5 minutes<br>"config": {<br>"title": "NYC Hourly Temperature Forecast",<br>"xLabel": "Hour (local time)",<br>"yLabel": "Temperature (°C)"<br>res = requests.post(f"{PLOTMARKS_API}/api/charts", json=payload, headers=HEADERS)<br>res.raise_for_status()<br>data = res.json()<br>print(f"Chart ID : {data['id']}")<br>print(f"Embed URL: {data['embedUrl']}")<br>return data["id"]
if __name__ == "__main__":<br>create_chart()<br>Response shape:
"id": "ch_abc123",<br>"embedUrl": "https://www.plotmarks.com/charts/ch_abc123"<br>Save the chart ID. You will pass it to the data-push script on every subsequent run. You do not need to create a new chart slot each time you update the data.
output_type and refresh_interval:
live_iframe instructs the embedded iframe to poll PlotMarks for updates. The refresh_interval controls how often, in seconds. The minimum is 10 seconds; the free plan minimum is 30 seconds.
static_iframe creates a persistent slot that also loads the latest data, but does not automatically refresh while a viewer has the page open. Use it when a page reload on next visit is acceptable.
Step 2: Fetch and transform data from Open-Meteo
Open-Meteo's forecast API returns hourly temperature data for any coordinate with no authentication:
def fetch_temperature() -> list[dict]:<br>url =...