Community data Governmental Free & Open

UK Office for National Statistics

The UK's national statistical institute. Publishes authoritative data on the UK economy, labour market, population, housing, and public finances. Open Government Licence, free commercial use with attribution.

API Quickstart

No quickstart snippet available for this source yet.

💳 Access & Pricing
Visit source →

Cost

Free

Access type

open

Signup required

No

Update alerts

Not offered

Coverage

europe

Update frequency

monthly

Source Documentation

What You're Getting

The UK Office for National Statistics is the national statistical institute for the UK. It publishes official data on the UK economy (GDP, CPI, trade, national accounts), labour market (employment, unemployment, earnings), population (census, projections, migration), housing (prices, construction), and public finance. Data is available as downloadable CSV/Excel datasets and via a beta JSON API.

Ingestion Strategy

Two paths: the beta API for structured pulls, or direct CSV download for bulk loads.

import requests
import pandas as pd

ONS_API = "https://api.beta.ons.gov.uk/v1"

# List available datasets
datasets_r = requests.get(f"{ONS_API}/datasets")
datasets = datasets_r.json()["items"]
print(f"Available datasets: {len(datasets)}")

# Direct CSV download — most reliable for bulk data
# CPI dataset (mm23)
csv_url = "https://www.ons.gov.uk/generator?format=csv&uri=/economy/inflationandpriceindices/datasets/consumerpriceinflation"
df_cpi = pd.read_csv(csv_url, skiprows=7)

Rate Limits & API Details

  • No published rate limit
  • Beta API: https://api.beta.ons.gov.uk/v1
  • Key publication codes: mm23 (CPI), qna (GDP), lms (Labour Market), hpssa (House Prices)
  • CSV/Excel via ons.gov.uk/generator?format=csv&uri={dataset_uri}

Schema Stability

Stable for headline publications (CPI, GDP, LMS). The beta API is actively developed. CSV column headers use period codes (e.g. 2024 JAN) — parse carefully.

Data Quality Gotchas

  • CSV header rows: ONS CSVs have 5–10 metadata rows before data — use skiprows
  • Period coding: time periods as 2024 Q1, 2024 JAN, or 2024 — normalize to ISO 8601 on ingest
  • Beta API coverage: not all 2,000+ datasets available via API; many require CSV download
  • Revisions: UK GDP has three rounds of revisions — store download timestamps
  • Geographic scope: some series are England-only or Great Britain, not UK-wide

Notable Datasets

8 total
  • GDP and National Accounts (QNA)
  • Consumer Price Inflation (CPI, RPI — mm23)
  • Labour Market Statistics (LMS)
  • House Price Index
  • Public Sector Finances
  • Population Estimates and Projections
  • International Trade
  • Business and Economic Indicators
Visit Data Source

Access

Cost
Free
Access type
Open
Update alerts
Not offered

Data Profile

Coverage
Europe
Frequency
Monthly
History from
1948
Source updated
Jan 2025

Data Formats

csv xlsx json api

How to Access

  • 🌐 Browser/UI
  • Automation Ready programmable

Index entry

Added: May 2, 2026

Last indexed: May 2, 2026

~ Community-sourced entry

Learn

Recent guides

View all →