
Aperidata
One official ISTAT statistic a day, turned into an Instagram carousel, vertical slides and an animated video. Every number is computed from the data: nothing is invented.
What it produces


How the pipeline works
From a calendar entry to an approved post, in six steps.
- 1
Pick
Reads a weekly calendar of themes, finds the ISTAT datasets for the day’s topic and takes the most recent one not used yet.
- 2
Select the series
Chooses the right series inside the dataset (the total, the indicator, the full territory) with explicit rules.
- 3
Download and check
Fetches the data from ISTAT’s SDMX REST API with rate limiting, retries and an on-disk Parquet cache, then validates it.
- 4
Compute the story
Calculates every number (latest value, changes, peaks, averages) in code and composes cover, chart and closing slide from templates.
- 5
Render
Draws the slides in HTML/CSS with Chromium (4:5 and 9:16 JPEGs) and builds a 12-second MP4 where the chart is drawn period by period.
- 6
Review
A local review tool lets me edit texts, switch chart or series and approve each post before anything is published.
Design choices
No AI, on purpose
A post about data is only worth something if it’s true. Numbers come from the code and texts from templates, so nothing can be hallucinated. The review tool also rejects any number not present in the data.
Respect for the API
ISTAT accepts few requests a minute. The client waits between calls, caches everything on disk and remembers for weeks what it has learned about each dataset.
A person decides
The code prepares, a person approves. A post can’t be approved if units are missing, if ISTAT codes appear in the text or if numbers aren’t in the data.
Data-quality rules born from real mistakes
| The risk | What the code does |
|---|---|
| A part passed off as the whole | Residual items are discarded and every chosen part is declared in the title. |
| A ranking with a missing area | Only complete breakdowns of Italy are accepted, and they are checked against the national figure. |
| An index number with no meaning to readers | The post tells the change, not the level. |
| Near-flat series told as percentages ("+0.0%") | It reports the difference in absolute value, and says so. |
| Stale data | Every frequency has its own freshness threshold. |
Each rule exists because a wrong post was actually generated, and each has a test.
An interesting bug
A video came out frozen after a "Save and regenerate". The MP4 had two moov blocks: two close requests to the review tool were writing the same file at once. The fix has three parts: write to a temporary file and replace it atomically, run one regeneration at a time, and disable the button while it runs. A test reproduces the failure with two processes.
Stack
- Python
- SDMX REST API
- Parquet
- Jinja2
- Playwright / Chromium
- ffmpeg
- pytest
- Git / GitHub
Known limits
ISTAT’s API sometimes doesn’t answer, so the first exploration is slow. Texts are template-based and refined in review. Publishing on Instagram is manual.
Code under MIT license. Data: ISTAT, CC BY 4.0. The name and logo "aperidata" are not covered by the code license.