Check the Setup
- Python 3.10 or newer
- A notebook environment such as Jupyter or Google Colab
- An internet connection
Official UK statistical datasets for building local labour, prices, and population tools from Office for National Statistics.
Report a ProblemFrom Source to Product Signal
The ONS API returns dataset metadata and observations. Start with one edition of CPIH or a labour dataset and a few observations. UK statistics have geography codes that do not match U.S. FIPS, and some tables are still Excel-only.
Install the packages, then run the notebook cell.
python -m pip install pandas requests
import pandas as pd
import requests
response = requests.get(
"https://api.beta.ons.gov.uk/v1/datasets/cpih01/editions/time-series/versions/1/observations",
params={"time": "latest", "geography": "K02000001"},
timeout=30,
)
response.raise_for_status()
observations = pd.json_normalize(response.json().get("observations", []))
observations["retrieved_at_utc"] = pd.Timestamp.now(tz="UTC")
print(observations.head())Test a Useful Signal
Test whether the ONS API can power a bounded UK prices card.
Office for National Statistics is a government source. Last verified 2026-08-18. Temporal coverage: dataset-specific ONS time series.