BYTETOOLS

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.

No API key requiredHTTPSFree tier

Endpoint tested and returned HTTP 200 on 20 Aug 2026

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 20 Aug 2026, 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
curl 'https://api.beta.ons.gov.uk/v1/datasets?limit=1'
JavaScript (fetch)
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);
Python (requests)
import requests

res = requests.get("https://api.beta.ons.gov.uk/v1/datasets?limit=1", timeout=20)
res.raise_for_status()
print(res.json())
Response — HTTP 200 (truncated)
{
  "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

ParameterTypeRequiredDescription
datasetspathOptionalList all published datasets. datasets
limit / offsetintegerOptionalPagination controls. 20
datasets/<id>/editionspathOptionalEditions of a dataset. editions
...versions/<n>/observationspathOptionalActual 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

Alternatives to ONS (UK Statistics) API

If ONS (UK Statistics) does not fit, these government & open data apis cover similar ground. Every one was called before publishing, and each links to its own reference page with a working curl command and the response it returned.

APIWhat it doesAuthCORSLast verified
Federal RegisterFree US Federal Register API with no key: executive orders, rules, notices and proposed regulations with full text search back to 1994. Tested curl example.No keyYes19 Aug 2026
USAspendingFree US federal spending API with no key: agency budgets, contracts, grants and award data covering trillions in government spending. Tested curl example.No keyNo19 Aug 2026
UK Parliament MembersFree UK Parliament Members API with no key: MPs and Lords, constituencies, party affiliation, contact details and voting records. Tested curl example.No keyNo19 Aug 2026
UK Police DataFree UK Police API with no key: street-level crime data, police forces, neighbourhood teams and stop-and-search records by location and month. Tested example.No keyYes19 Aug 2026
opendata.swissFree Swiss open data API with no key: federal, cantonal and municipal datasets across transport, health, environment and statistics via CKAN. Tested.No keyYes20 Aug 2026
OpenFECOpenFEC API for US campaign finance: 54,000+ candidates, committees, contributions and spending filings from the Federal Election Commission. Free key. Tested example.KeyYes21 Aug 2026
All Government & Open Data APIs

ONS (UK Statistics) is an independent third-party service and is not affiliated with ByteTools or ByteVancer. Details on this page were verified on 20 Aug 2026; always check the official documentation before relying on this API in production, as terms and limits can change.