ONS (UK Statistics) API
Free Office for National Statistics API with no key: UK census, population, inflation, employment and economic statistics as structured datasets. Tested.
Endpoint tested and returned HTTP 200 on 2026-08-20
What is the ONS (UK Statistics) API?
The Office for National Statistics API is a free, key-free API providing official UK statistics — census data, population estimates, inflation, employment, GDP and health statistics — as structured, versioned datasets.
ONS is the UK's national statistical institute, and this API exposes its published datasets programmatically rather than as spreadsheet downloads. Everything is versioned with editions, so you can pin to a specific release for reproducibility.
The structure takes some getting used to: a dataset has editions, an edition has versions, and a version has observations along dimensions such as time and geography. That hierarchy is what makes the data properly citable, but it means several requests to reach actual numbers.
Quick facts
- Base URL
https://api.beta.ons.gov.uk/v1- Authentication
- No API key required.
- Rate limit
- No published hard limit; it is a beta service, so expect occasional changes.
- Pricing
- Free under the Open Government Licence.
- CORS
- Not enabled — call it from your server
- Official docs
- Read the docs
How to use the ONS (UK Statistics) API
Every request below was executed against the live API on 2026-08-20, and the response shown is the real body it returned — not an illustration.
1. List available ONS datasets
GET https://api.beta.ons.gov.uk/v1/datasets?limit=1
curl 'https://api.beta.ons.gov.uk/v1/datasets?limit=1'const res = await fetch("https://api.beta.ons.gov.uk/v1/datasets?limit=1");
if (!res.ok) throw new Error(`Request failed: ${res.status}`);
const data = await res.json();
console.log(data);import requests
res = requests.get("https://api.beta.ons.gov.uk/v1/datasets?limit=1", timeout=20)
res.raise_for_status()
print(res.json()){
"items": [
{
"contacts": [
{
"email": "qualityoflife@ons.gov.uk",
"name": "Will Shufflebottom, Owain Birrell, Pavan Bains and Geeta Kerai",
"telephone": "+44 300 0671543"
}
],
"description": "Seasonally and non seasonally-adjusted quarterly estimates of life satisfaction, feeling that the things done in life are worthwhile, happiness and anxiety in the UK.",
"keywords": [
"well-being"
],
"id": "wellbeing-quarterly",
"last_updated": "2023-12-13T09:40:24.204Z",
"links": {
"editions": {
"href": "https://api.beta.ons.gov.uk/v1/datasets/wellbeing-quarterly/editions"
},
"latest_version": {
"href": "https://api.beta.ons.gov.uk/v1/datasets/wellbeing-quarterly/editions/time-series/versions/9",
"id": "9"
},
"self": {
"href": "https://api.beta.ons.gov.uk/v1/datasets/wellbeing-quarterly"
},
"taxonomy": {
"href": "https://api.beta.ons.gov.uk/v1/peoplepopulationandcommunity/wellbeing"
}
},
"methodologies": [
{
"href": "https://www.ons.gov.uk/peoplepopulationandcommunity/wellbeing/methodologies/personalwellbeingquarterlyestimatestechnicalreport",
"title": "Personal well-being quarterly estimates technical report"
}
],
"national_statistic": false,
"next_release": "TBC",
"qmi": {
"href": "https://www.ons.gov.uk/peoplepopulationandcommunity/wellbeing/methodologies/personalwellbeingintheukqmi"Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
datasets | path | Optional | List all published datasets. datasets |
limit / offset | integer | Optional | Pagination controls. 20 |
datasets/<id>/editions | path | Optional | Editions of a dataset. editions |
...versions/<n>/observations | path | Optional | Actual observations for a version. observations |
Response fields
itemsarray- The datasets or editions returned.
items[].idstring- Dataset identifier used in subsequent requests.
items[].titlestring- Dataset title.
items[].descriptionstring- What the dataset covers.
items[].contactsarray- ONS statisticians responsible, with email.
items[].links.latest_versionobject- Link straight to the most recent version.
items[].keywordsarray- Topic keywords.
What you can build with the ONS (UK Statistics) API
- Chart UK inflation, employment or population trends
- Pull census data for a specific geography
- Build dashboards backed by official UK statistics
- Automate reporting that must cite authoritative sources
Common errors and how to fix them
Several requests to reach numbers
The dataset/edition/version hierarchy is deliberate.
Fix: Follow links.latest_version to skip straight to the current release.
Beta API changes
It is explicitly a beta service.
Fix: Pin to specific dataset versions and expect occasional structural changes.
Empty observations
The dimension filter matched nothing.
Fix: Check the version's dimension options before requesting observations.
ONS (UK Statistics) API — frequently asked questions
Is the ONS API free?
Yes, free with no API key, under the Open Government Licence which requires attribution.
Why does it take several requests to get data?
The hierarchy is dataset → edition → version → observations. It exists so figures are properly versioned and citable. Follow links.latest_version to shortcut to the current release.
Does it include census data?
Yes, alongside population estimates, inflation, employment, GDP and health statistics — the full range of UK official statistics.
Is the API stable?
It is explicitly labelled beta, so pin to specific dataset versions and expect occasional structural changes.
Tools that pair with this API
JSON Formatter
Format, beautify and minify JSON online with 2-space, 4-space or tab indentation. Sort keys alphabetically and catch syntax errors instantly — free and private.
CSV to JSON Converter
Convert CSV to a JSON array of objects online. Header-row detection, comma/semicolon/tab delimiters and pretty-printed output — 100% in your browser.
Percentage Calculator
Calculate what X% of a number is, what percent one number is of another, and percentage increase or decrease between two values — instantly and free.
ONS (UK Statistics) is an independent third-party service and is not affiliated with ByteTools or ByteVancer. Details on this page were verified on 2026-08-20; always check the official documentation before relying on this API in production, as terms and limits can change.