Data Sources
KindTech wraps two UK public data APIs that aren't prominently documented for developers. This page documents the APIs, their quirks, and how this package's ingestion scripts work.
ONS Open Geography Portal (ArcGIS)
The Open Geography Portal serves UK
boundary data as an Esri ArcGIS Hub deployment
under the ONS organisation ID ESMARspQHYMw9BZ9. It was
launched in July 2020,
though the ONS Geography team has used
ArcGIS Online since June 2015.
Endpoints
| Endpoint | Description |
|---|---|
https://services1.arcgis.com/ESMARspQHYMw9BZ9/arcgis/rest/services?f=json |
Service catalog (JSON) |
.../{service_name}/FeatureServer?f=json |
The layers a service holds. Most hold one, numbered 0, but not all |
.../{service_name}/FeatureServer/{layer}/query?where=1%3D1&outFields=*&f=geojson |
Query features as GeoJSON |
https://www.arcgis.com/sharing/rest/portals/ESMARspQHYMw9BZ9?f=json |
Organisation metadata |
https://www.arcgis.com/sharing/rest/community/users/ONSGeography_data?f=json |
User profile |
Standard ArcGIS REST API. No authentication needed. Licensed under OGL v3.0. ONS does not publish their own API documentation — they rely on Esri's standard reference.
Catalog discovery
The portal's
services listing page
renders with client-side JavaScript — HTML scraping returns an empty <ul>.
Appending ?f=json returns a machine-readable JSON catalog of ~3,700 services
(~1,200 FeatureServers plus MapServers, lookup tables, and other types).
Rate limiting
The JSON endpoint is intermittently rate-limited. Some requests return an
empty services array. If ingestion returns 0 services, wait and retry.
Service naming conventions
The catalog uses two naming conventions, both following the GSS Coding and Naming Policy (implemented 1 January 2011):
Short form (post-2021):
LAD_DEC_2024_UK_BGC
│ │ │ │ └── Resolution: Generalised Clipped Boundaries
│ │ │ └───── Coverage: United Kingdom
│ │ └────────── Year: 2024
│ └────────────── Month: December
└────────────────── Geography: Local Authority Districts
Long form (pre-2021):
Local_Authority_Districts_December_2024_Boundaries_UK_BGC
The transition happened around 2021 (see Boundary Dataset Guidance: 2021 Onwards).
Resolution codes
The ONS digital boundaries page defines five standard resolutions:
| Code | Full name | Detail |
|---|---|---|
| BFE | Full resolution, Extent of the Realm | Mean Low Water mark |
| BFC | Full resolution, Clipped to coastline | Mean High Water mark |
| BGC | Generalised Clipped | 20m tolerance |
| BSC | Super Generalised Clipped | 200m tolerance |
| BUC | Ultra Generalised Clipped | 500m tolerance |
Older ArcGIS service names use rearranged abbreviations:
| Old suffix | Current suffix |
|---|---|
| FCB | BFC |
| FEB | BFE |
| GCB | BGC |
| SGCB | BSC |
| UGCB | BUC |
These old codes don't appear in official ONS documentation — they are an ArcGIS-internal convention. The ingestion normalises all of them to the current standard.
Catalog quirks
Historical datasets (1921-present):
| Service | Year | Geography |
|---|---|---|
CTRY_DEC_1921_GB_BGC |
1921 | Countries |
CTY_DEC_1921_EW_BGC |
1921 | Counties |
ED_1971_EW_BGC |
1971 | Enumeration Districts |
ED_1981_EW_BGC |
1981 | Enumeration Districts |
WD_1998_UK_BGC |
1998 | Wards |
The 1921 boundaries were digitised around the 2021 Census centenary. The 1971/1981 entries are Enumeration Districts (EDs) — operational units used for censuses 1961-1991, each representing one enumerator's workload. EDs were superseded by Output Areas for the 2001 Census.
May vs December releases:
Administrative boundaries change during the year. May boundaries reflect changes taking effect on local election day (first Thursday in May). December boundaries provide a year-end snapshot aligned with the 1 December reference date used for electoral statistics since 2001.
Composite-key duplicates (9 cases):
- Short-form + long-form names for the same dataset — harmless duplicates
- NHSER variants — "NHS England Regions" (
nhser18cd) vs "NHS England Region Local Offices" (nhsrlo18cd), different administrative levels. Local Offices were created in 2015 (from 27 Area Teams of 2013) and abolished by April 2020 - OA RUC variants — Output Areas with and without the Rural-Urban Classification (12 vs 17 columns). The RUC, first introduced in 2004, classifies OAs as urban or rural
- Trailing underscore typos — stripped during ingestion
All entries are kept in the catalog. No skip lists, no manual curation.
Geo ingestion
Parses ~2,500 ArcGIS services down to 654 boundary datasets across 24
geography types, spanning 1921-2026. Stdlib-only (csv, re, requests).
uv run python -m uk_open_data.geo._ingestion
NOMIS API
NOMIS is a web-based database of labour market and population statistics, operated by the University of Durham on behalf of ONS since 1981. Licensed under the Open Government Licence.
Endpoints
| Endpoint | Description |
|---|---|
dataset/def.sdmx.json |
Bulk listing of all datasets (SDMX JSON) |
dataset/{id}.data.csv?{params} |
Data download as CSV |
contenttype/sources.json |
Source groupings |
dataset/{id}.overview.json |
Dataset overview |
dataset/{id}/{concept}/def.sdmx.xml |
Dimension metadata (SDMX-ML) |
Base URL: https://www.nomisweb.co.uk/api/v01/
SDMX format
NOMIS uses SDMX 2.0 structures (KeyFamilies, Dimensions,
Codelists). The .sdmx.json format is a NOMIS-specific convenience — not the
standard SDMX-JSON from SDMX 2.1
(ISO 17369). The standard format is XML
(.sdmx.xml).
Rate limits and authentication
| Access level | Limit |
|---|---|
| Guest (unauthenticated) | 25,000 cells per request |
| Authenticated (with UID) | No cell limit |
| KML / RSS formats | 1,000 cells |
Authentication is free — create an account on nomisweb.co.uk and get a UID from "my account" > "web services".
Cell limit
A cell is one figure, which is one row of the CSV that load_ons reads.
Each row says how many rows the query has (RECORD_COUNT). Without a
UID, load_ons asks for the next 25,000 (recordoffset) until it has
them all. A query that sets recordlimit, or a negative recordoffset,
is sent once, as it is.
Source annotations in the bulk listing
The bulk listing (dataset/def.sdmx.json) includes source annotations
embedded in each dataset's annotations array:
{
"id": "NM_1_1",
"name": {"value": "Jobseeker's Allowance with rates and proportions"},
"annotations": {
"annotation": [
{"annotationtitle": "contenttype/sources", "annotationtext": "jsa"},
{"annotationtitle": "LastUpdated", "annotationtext": "2025-01-14"}
]
}
}
1,572 out of 1,615 datasets have the contenttype/sources annotation in the
bulk listing. The remaining 43 genuinely lack source information.
Catalog quirks
- 31 datasets from the 1961 Census (NM_1230-NM_1257) — digitised around January 2021, covering England and Wales at district, county, parish, ward, and enumeration district levels
- 1981/1991 Census data — small area and workplace statistics
- 1968 SIC VAT registrations — industrial classification data
NOMIS is a long-term statistical archive, not just current data.
NOMIS ingestion
Makes one HTTP request to dataset/def.sdmx.json, extracts IDs, names,
and source annotations. Completes in ~6 seconds for 1,615 datasets.
Stdlib-only (csv, requests).
uv run python -m uk_open_data.ons._ingestion
Community packages
No official client libraries from NOMIS, ONS, or Durham University. All wrappers are community-built:
| Package | Language | Notes |
|---|---|---|
| nomisr | R | Evan Odell, rOpenSci. JOSS (2018). Removed from CRAN July 2025 |
| UKCensusAPI | Python | virgesmith |
| nomisweb | Python | Tony Hirst |
| Consensus | Python | Ilkka-LBL |
postcodes.io
postcodes.io is a free, open-source REST API that
resolves UK postcodes to administrative and statistical geographies. KindTech's
postcodes module wraps it so address data joins to the same
geography_code used by the geo and ONS modules.
Endpoints
Base URL: https://api.postcodes.io
| Endpoint | Description |
|---|---|
POST /postcodes |
Bulk lookup, up to 100 postcodes per request |
GET /postcodes/{postcode} |
Single postcode lookup |
GET /postcodes?lon={lon}&lat={lat} |
Reverse geocode — nearest postcodes to a point |
GET /outcodes/{outcode} |
Outcode info: spanned Local Authorities + centroid |
No authentication is required. KindTech batches bulk lookups at 100 per request and preserves input order.
Returned geography codes
A postcode lookup returns a codes object with standard ONS GSS codes.
KindTech surfaces these aligned to its geography types:
| KindTech level | postcodes.io codes key |
Example |
|---|---|---|
| LSOA | lsoa21 |
E01034394 |
| MSOA | msoa21 |
E02007008 |
| OA | oa21 |
E00182613 |
| LAD | admin_district |
E09000023 |
| WD (ward) | admin_ward |
E05013727 |
| ICB | icb |
E54000030 |
| TTWA | ttwa |
E30000234 |
2021 Census geographies (lsoa21, msoa21, oa21) are preferred so codes
match Census 2021 statistics and current boundary data.
Licensing
postcodes.io code is MIT licensed; the underlying data is Open Government Licence v3.0, containing OS data © Crown copyright and database right, Royal Mail data © Royal Mail copyright and database right, and National Statistics data © Crown copyright and database right. Maintained by Ideal Postcodes.
UK deprivation indices (IMD)
KindTech's imd module serves each nation's official deprivation index for
single-nation work, and the mySociety composite for comparing across nations.
The official per-nation indices are the primary path; the composite exists only
because there is no official UK-wide index.
Official national indices
A single-nation call fetches that nation's official index directly from its government source (not the composite):
load_imd(nation=...) |
Index | Geography | Source | Format |
|---|---|---|---|---|
"England" (default year=2025) |
IoD 2025 (30 Oct 2025) | LSOA 2021 | gov.uk File 7 | CSV |
"England", year=2019 |
IoD 2019 | LSOA 2011 | gov.uk File 7 | CSV |
"Wales" (default year=2025) |
WIMD 2025 (27 Nov 2025, revised 6 Feb 2026) | LSOA 2021 | StatsWales API, with residents from Nomis | CSV |
"Wales", year=2019 |
WIMD 2019 | LSOA 2011 | gov.wales | ODS |
"Scotland" |
SIMD 2020v2 | Data Zone 2011 | gov.scot | XLSX |
"Northern Ireland" |
NIMDM 2017 | SOA 2001 | Open Data NI | CSV |
England's File 7 carries all seven domains as score + rank + decile plus a
population denominator. Wales/Scotland/NI publish ranks (1 = most deprived),
so KindTech surfaces the overall imd_rank, a within-nation imd_decile
derived from it, and a <domain>_rank per domain — with nation-specific
domain sets (Wales adds community safety + physical environment, Scotland adds
crime + a population denominator, NI adds living environment + crime &
disorder). All sources are fetched live and cached for the session; the
spreadsheet sources (Wales ODS, Scotland XLSX) are read with
python-calamine.
WIMD 2025 comes from the StatsWales API, which needs no key. The dataset
"index and domain ranks and groups, for Lower layer Super Output Areas" has
the id 9706edd9-73ad-4902-bb12-7ccd7038626e:
GET https://api.stats.gov.wales/v2/<id>/data?lang=en-gb&format=csvgives one long table, a row for each area, measure and domain, with the columnsData values,Data description,Area code,Area name,DomainandNotes. KindTech keeps theRankandDecilerows of the 1,917 neighbourhoods (W01…) and drops the rows for local authorities.GET https://api.stats.gov.wales/v2/<id>/filterslists each local authority (W06…) with its neighbourhoods, which giveslad_codeandlad_name.- The residents are the 2021-based small-area estimates on Nomis
(
NM_2014_1) for mid-2022, all ages, asked for Wales's neighbourhoods only (geography=2092957700TYPE151). That is the same year England's 2025 index uses for its population.
The result has the columns England's index has for an analysis
(geography_code, geography_name, lad_code, lad_name, imd_rank,
imd_decile, population), plus a rank and decile for each of WIMD's eight
domains. WIMD publishes no scores. Scotland and NI have no 2025 release.
Licensing: Open Government Licence v3.0 — England IoD (MHCLG), WIMD (Welsh Government), SIMD (Scottish Government), NIMDM (NISRA / Open Data NI).
Composite UK IMD
All single-nation rankings are within-nation — an English "decile 1" and a Scottish "decile 1" are not the same thing, because each official index ranks areas only within its own nation, on different geographies and methodologies:
| Nation | Index | Publisher | Geography |
|---|---|---|---|
| England | IMD 2019 | MHCLG | LSOA (2011) |
| Wales | WIMD 2019 | Welsh Government | LSOA (2011) |
| Scotland | SIMD 2020 | Scottish Government | Data Zone (2011) |
| Northern Ireland | NIMDM 2017 | NISRA | Super Output Area |
To compare across nations you need one shared ranking, and there is no
official UK-wide index. So for nation="UK" KindTech uses the
composite UK Index of Multiple Deprivation
— a research dataset by mySociety — which re-ranks
every area (42,619 in total) onto one scale using the income and employment
domains shared by all four indices.
| Item | Value |
|---|---|
| File | data/uk_index/UK_IMD_E.csv (England-anchored) |
| Host | raw.githubusercontent.com/mysociety/composite_uk_imd |
| Rows | 42,619 (England 32,844 · Scotland 6,976 · Wales 1,909 · NI 890) |
| Key column | lsoa — LSOA/Data Zone/SOA code depending on nation |
| UK ranking | UK_IMD_E_rank, UK_IMD_E_pop_decile, UK_IMD_E_pop_quintile |
Fetched live and cached in-process for the session (a static research release);
column names are mapped to KindTech's conventions (lsoa → geography_code).
Licensing: the composite is Creative Commons Attribution 4.0 — attribute mySociety when redistributing. The underlying national indices are Open Government Licence v3.0; the composite code is MIT licensed.
DfT transport connectivity metric
The Department for Transport publishes the transport connectivity metric as one OpenDocument spreadsheet, with no API.
| Item | Value |
|---|---|
| File | connectivity_metrics_2025.ods, 68 MB, on assets.publishing.service.gov.uk |
| Sheets | Metadata, then scores by OA, LSOA, LAD and RGN |
| Sheet read | LSOA: two lines of title, the header on the third row, then 35,672 rows |
| Key column | LSOA21CD, 2021 codes, renamed geography_code |
| Scores | 35 columns named Purpose (mode), plus a last column Overall |
The address changes with each edition, so a new edition means a new constant in
connectivity/api.py. The LAD sheet names the councils of 2022 and has no
codes, so it is not read. Reading the file takes a few seconds, so
download_connectivity() keeps the neighbourhood scores as a JSON file in the
data folder, and load_connectivity() reads that from then on.
Licensing: Open Government Licence v3.0, as for all gov.uk content. The
file's metadata says license: TBA.
MHCLG statutory homelessness tables
MHCLG publishes the
live tables on homelessness
as files on one gov.uk page, with no API of its own. The page's files are
listed by the gov.uk content API, which needs no key:
https://www.gov.uk/api/content/government/statistical-data-sets/live-tables-on-homelessness
returns JSON whose details.attachments hold each file's title and url.
| Item | Value |
|---|---|
| File read | The latest "Detailed local authority level tables: |
| Files left out | Financial years, "Accessible" copies, and older tables by region |
| Tables read | A1 (assessments) and TA1 (temporary accommodation), one sheet each |
| Header | The row whose first cell is "Organisation Identification Code", below a title of a few lines. Headings hold line breaks and [note n] marks |
| Rows | England (E92), regions (E12), "Rest of England" ([z]), then each council (E06, E07, E08, E09) |
| Markers | [x] no figures sent, [c] held back to protect households, [z] not applicable |
The attachments are not in date order, and a quarter gets a revised file later,
so the loader picks the latest quarter by the months in each title, prefers a
revised file for it, and reads only .ods and .xlsx files.
DESNZ sub-regional fuel poverty statistics
DESNZ publishes each year's
sub-regional fuel poverty statistics
on a release page of their own, as XLSX and ODS files, with no API. The page's
files are listed by the gov.uk content API:
https://www.gov.uk/api/content/government/statistics/sub-regional-fuel-poverty-data-2026-2024-data
returns JSON whose title names the year of data, such as "(2024 data)", and
whose details.attachments hold each file's title and url.
| Item | Value |
|---|---|
| File read | The release's .xlsx file. The .ods file holds the same tables |
| Table read | Table 2, fuel poverty by local authority |
| Header | The row whose first cell is "Local Authority code [Note 4]", below a title and a blank line |
| Rows | England (E92), regions (E12), counties and similar (E10, E11, E13), then each council (E06, E07, E08, E09), followed by blank lines and "Back to contents" |
| Names | A district's name is in "Local Authority District". A unitary authority's is in "County or Unitary Authority", with the district left blank. Some names end in a space |
| Figures | Households, households in fuel poverty, and the share in fuel poverty as a percentage from 0 to 100 |
| Codes | Today's council codes, the same the analyses compare in |
| Tables left out | Table 4, by LSOA: DESNZ says to treat those estimates with caution, as they rest on very small samples |
DESNZ's
collection of fuel poverty statistics
does not list the 2026 release, and gov.uk search does not find it reliably, so
the loader cannot follow a "latest" link. It reads the one release page in
RELEASE_PAGE, in fuel_poverty/api.py, and a new edition, each May, means
changing that address.
Licensing: Open Government Licence v3.0, as for all gov.uk content. The figures are modelled estimates, published as Official Statistics in Development.
DfE statistics API
The Department for Education serves the data sets behind
Explore education statistics
through a statistics API at
https://api.education.gov.uk/statistics/v1. It needs no key, and publishes an
OpenAPI document.
Endpoints
| Endpoint | What it gives | Page size |
|---|---|---|
GET /publications |
Each publication's id, title, slug, summary and lastPublished |
20 by default, at most 40 |
GET /publications/{id}/data-sets |
Each data set's id, title, summary, status, and its latestVersion: version, time periods, levels, filters and indicators, by name |
10 by default, at most 20 |
GET /data-sets/{id} |
One data set's entry, as in the listing, with its newest version's number | Not paged |
GET /data-sets/{id}/meta |
What the data set holds: geographicLevels, locations, filters, indicators and timePeriods, each with its id and name |
Not paged |
GET /data-sets/{id}/query |
The figures, filtered | 1,000 by default, at most 10,000 |
A paged answer is {"paging": {"page", "pageSize", "totalResults",
"totalPages"}, "results": [...]}, and the next page is asked for with page=.
A page size above the limit is refused with a 400 that names the limit.
Queries
The loader asks for one level, one time period and the indicators it wants:
GET /data-sets/{id}/query?dataSetVersion=1.0&geographicLevels.eq=LA
&timePeriods.eq=2024/2025|AY&indicators=emgou&indicators=TuAuP
&page=1&pageSize=10000
- Each filter takes an operator:
geographicLevels.eq, notgeographicLevels, which is refused as an unknown field. - A time period is
{period}|{code}, such as2024/2025|AYfor an academic year or2026|W45for a week. The meta gives each period'speriod,codeandlabel, such as "2024/25". The loader takes the latest from the data set's entry,latestVersion.timePeriods.end, which is a label, and finds it among the meta's labels. - A
POSTto the same address takes the same query as JSON, and can combine conditions withand,orandnot. The loader needs none of that, so it usesGET.
Each result is all ids:
{"timePeriod": {"code": "AY", "period": "2024/2025"}, "geographicLevel": "LA",
"locations": {"LA": "rQkNj", "NAT": "dP0Zw", "REG": "lZVcB"},
"filters": {"daL0Z": "qYfzj", "OS5CL": "X5Vmf"},
"values": {"emgou": "7226", "TuAuP": "17.92429"}}
The loader turns them into names and codes with the meta. An id is unique only
within its level or filter: one data set uses 1Nei3 for both East Midlands
and Tuesday. Each filter and indicator in the meta also has a label, such as
"Absence type", and a column, the header of DfE's CSV file, such as
absence_type; the loader names its columns by column. A local authority's option has an id, label, code, such as
E09000002, and oldCode, DfE's older three-digit number, such as 301. The
options list every council the data set has ever had: 165 in the persistent
absence data set, of which 153 have figures for 2024/25.
Values are strings. A figure DfE does not give is a symbol, as its
guidance for statisticians
sets out: z not applicable, x (or the older :) not available, c
confidential, low or k (or the older ~) rounds to 0, and u low
reliability. Some indicators hold text, such as a reference date.
Levels
Levels have a code and a name: NAT National, REG Regional, LA Local
authority, LAD Local authority district, PCON Parliamentary constituency,
WARD Ward, and others. SCH School, PROV Provider, INST Institution,
MAT and SPON Sponsor list organisations rather than areas, and the loader
does not read them. The data set listing names levels; the query takes codes.
Versions and limits
Each data set has numbered versions. A request that names no
dataSetVersion gets the newest. The loader reads the newest version's number
from GET /data-sets/{id} (latestVersion.version, such as 1.0) and passes
it as dataSetVersion to the meta and to every page of the query, so ids and
names always come from the same version. A version that does not exist is a
404. A new major version can remove filters or indicators. The docs give no rate limit; the API
answers 429 when it is asked too often, and the package then waits and asks
again, as it does for every source.
Licensing: Open Government Licence v3.0, unless a data set says otherwise.
DWP children in low income families
DWP publishes the
children in low income families: local area statistics
once a year, as one spreadsheet on a new release page each time, with no API
of its own. The gov.uk content API lists the collection:
https://www.gov.uk/api/content/government/collections/children-in-low-income-families-local-area-statistics
returns JSON whose details.collection_groups name each group's documents by
their content_id, and whose links.documents give each document's
base_path. The release page, at https://www.gov.uk/api/content<base_path>,
lists its files in details.attachments.
| Item | Value |
|---|---|
| Release read | The first document in the group titled "Latest release" whose path starts /government/statistics/, such as "Children in low income families: local area statistics 2022 to 2025". Today the group holds only that one |
| File read | The release's ODS spreadsheet. Its other attachment is a page of commentary |
| Tables read | 7_BHC_Relative_LA (before housing costs, from FYE 2022) and 2_AHC_Relative_LA (after housing costs, from FYE 2024), one sheet each |
| Header | The row whose first cell is "Local Authority [note 2]", below eight lines of title. Headings hold line breaks and marks such as [note n] and (%). The loader takes the marks out, so a renumbered note or a new mark such as [p] does not stop it |
| Columns | The name, Area Code, then "Number of children FYE |
| Rows | The United Kingdom (K02), then each council (E06, E07, E08, E09, W06, S12 and N09), on the codes of April 2023 |
| Names | A Welsh council has its English and Welsh names, such as "Cardiff / Caerdydd". The loader keeps the English one, as ONS gives it |
| Shares | Fractions, such as 0.272. The loader turns them into percentages, such as 27.2, as every share in the package is |
| Markers | [x] not available, [low] nil or negligible. Neither appears in the council tables of 2022 to 2025 |
The loader takes the latest year that both tables have. The tables are calibrated to DWP's Households Below Average Income survey, and the release revises earlier years, so the loader reads only the latest release.
UKHSA childhood vaccinations (COVER)
UKHSA publishes the
COVER programme's statistics
once a year, as one spreadsheet of tables on a new release page each time,
with no API of its own. The loader finds the release through the gov.uk content
API, as for DWP's statistics: the
collection at
https://www.gov.uk/api/content/government/collections/cover-of-vaccination-evaluated-rapidly-cover-programme-statistics
names its groups' documents, and the release page lists its files.
| Item | Value |
|---|---|
| Release read | The first document in the group titled "COVER annual reports" whose path starts /government/statistics/, such as "Cover of vaccination evaluated rapidly (COVER) programme: April 2025 to March 2026". The year is read from that title. The group "COVER quarterly reports" is not read |
| File read | The release's ODS file whose address holds data-tables, such as cover-annual-data-tables-2025-to-2026.ods. Its other files are a page of commentary and the figures by GP practice |
| Tables read | T4b_UTLA12m, T5b_UTLA24m and T6b_UTLA5y: the numbers by upper-tier council at 12 months, 24 months and 5 years. The a tables beside them give the same as percentages |
| Header | The row whose first cell is "Code", below a title and a few notes. The loader takes marks such as [note n] out of the headings |
| Columns | Code, Upper tier local authority, Region name, Organisation data service code, Note, then "Number of children aged |
| Rows | England (E92), its regions (E12), then each upper-tier council (E06, E08, E09 and E10). Barnsley and Sheffield have their codes before April 2025 |
| Areas counted in another's | Notes 18 to 20: the City of London in Hackney, the Isles of Scilly in Cornwall, and Rutland in Leicestershire. They have no rows |
| Markers | [x] not available, [c] confidential, [z] not applicable. A figure corrected after release is text with a note, such as "4,647 [note 25]" for County Durham's 6-in-1 at 24 months in 2025 to 2026. The loader reads it as its number |
ONS police recorded crime
ONS publishes police recorded crime by community safety partnership in its
Crime in England and Wales: Police Force Area data tables,
a new edition each quarter. Its dataset of figures by partnership alone was
discontinued in October 2024, when they moved here. The ONS website gives
each page as JSON at the page's address followed by /data.
| Item | Value |
|---|---|
| Edition read | The first in the dataset page's datasets list, which is the latest, such as …/policeforceareadatatables/yearendingjune2026. Its own /data gives its name, in description.edition, and its files, in downloads |
| File read | The edition's .xlsx file, at https://www.ons.gov.uk/file?uri=<edition>/<file> |
| Table read | Table C2, the number of offences by partnership. Table C4 gives rates and Table C5 the year before |
| Header | The row whose first cell is "Police Force Area code", below the title and notes. Headings hold line breaks and marks such as "(excluding fraud)", which the loader takes out |
| Columns | The force's code and name, the partnership's code and name, the council's code and name (or "Combined Local Authorities"), then one column per kind of offence |
| Rows | Each force's total (no partnership code), its partnerships (E22 and W14), and its "Unassigned" offences (no code). The loader keeps the partnerships |
| Marked rows | A partnership ONS marks with a note, on its force's name, such as "Kent [note 5]". The notes are in the sheet Notes - CSP, by number. When a row's note says offences are recorded as "Unassigned", as note 5 does of five Kent partnerships in the year ending June 2026, the loader gives the partnership no figures. The note's number changes between editions. Notes about other things, such as Northumbria's undercount of robbery in the year ending March 2025, have been on a force's total, not its partnerships |
| Codes | The partnerships' codes match local_authority_lookup("community_safety_partnership"): all 314 in the year ending June 2026 |
Dataset Aliases
Instead of remembering NOMIS dataset IDs like NM_2002_1, you can use
friendly aliases:
from uk_open_data import load_ons
# These are equivalent
df = load_ons("population", geography_type="LAD", time="latest")
df = load_ons("NM_2002_1", geography_type="LAD", time="latest")
Raw NM_* IDs are passed through unchanged — aliases are just a convenience.
Available aliases
| Alias | NOMIS ID | Description |
|---|---|---|
population |
NM_2002_1 | Mid-year population estimates |
population_by_age |
NM_2002_1 | Same as population |
population_by_age_band |
NM_31_1 | Population by broad age band |
population_lsoa |
NM_2014_1 | Population estimates (LSOA level) |
jsa |
NM_1_1 | Jobseeker's Allowance |
claimant_count |
NM_162_1 | Claimant count |
annual_population_survey |
NM_17_1 | Annual Population Survey |
earnings |
NM_30_1 | Annual Survey of Hours and Earnings |
jobs_density |
NM_57_1 | Jobs density |
vacancies |
NM_19_1 | Vacancy survey |
vat_registrations |
NM_29_1 | VAT registrations/deregistrations |
census_2021 |
NM_2021_1 | Census 2021 |
census_2011 |
NM_144_1 | Census 2011 |
census_2001 |
NM_58_1 | Census 2001 |
To list aliases programmatically:
from uk_open_data import list_dataset_aliases
for a in list_dataset_aliases():
print(f"{a['alias']:30s} → {a['dataset_id']}")
Geography Crosswalk
The geo module uses ONS geography type codes (LAD, LSOA, MSOA, etc.)
while NOMIS uses internal TYPE codes (TYPE424, TYPE151, etc.). KindTech
maps between them so you don't have to.
Using geography_type in load_ons()
Instead of looking up NOMIS TYPE codes, pass the same geography type you
use with load_geodata():
from uk_open_data import load_geodata, load_ons
# Same geography concept, different APIs
boundaries = load_geodata(geography_type="LAD", year="2024")
statistics = load_ons("NM_1_1", geography_type="LAD", time="latest")
The raw geography="TYPE424" parameter still works if you need it.
TYPE code mapping
NOMIS assigns different TYPE codes to the same geography at different time
points. KindTech resolves these automatically based on the time parameter:
| Geography | Year range | NOMIS TYPE |
|---|---|---|
| LAD | 2023+ | TYPE424 |
| LAD | 2021-2022 | TYPE431 |
| LAD | 2019-2020 | TYPE434 |
| LAD | 2015-2018 | TYPE446 |
| LAD | pre-2015 | TYPE464 |
| CTYUA | 2023+ | TYPE423 |
| CTYUA | 2021-2022 | TYPE431 |
| CTYUA | 2015-2020 | TYPE446 |
| CTYUA | pre-2015 | TYPE463 |
| LSOA | 2021+ | TYPE151 |
| LSOA | pre-2021 | TYPE304 |
| MSOA | 2021+ | TYPE152 |
| MSOA | pre-2021 | TYPE305 |
| RGN | all | TYPE480 |
| CTRY | all | TYPE499 |
| WD | 2025+ | TYPE182 |
| CAUTH | 2025+ | TYPE442 |
| TTWA | 2011+ | TYPE447 |
| TTWA | pre-2011 | TYPE444 |
| ITL | 2025+ | TYPE419 |
| ITL | 2021-2024 | TYPE421 |
Source: NOMIS geography dimension metadata. To list all mappings programmatically:
from uk_open_data import list_geography_mappings
for m in list_geography_mappings():
print(m)
Join keys
Both APIs return standard ONS geography codes (e.g. E06000001):
- ArcGIS returns fields like
LAD24CD(code) andLAD24NM(name), where the field name includes a 2-digit year suffix - NOMIS returns
GEOGRAPHY_CODEandGEOGRAPHY_NAMEcolumns
KindTech normalises both sources so they share a common geography_code
column:
load_ons(normalize=True)(the default) lowercases NOMIS columns, producinggeography_codeandgeography_namegeodata_to_properties()maps year-stamped ArcGIS fields (e.g.LAD24CD) togeography_codeandgeography_name
from uk_open_data import load_geodata, load_ons, geodata_to_properties
import pandas as pd
geojson = load_geodata(geography_type="LAD", year="2024")
geo_df = pd.DataFrame(geodata_to_properties(geojson, "LAD", 2024))
ons_df = load_ons("population", geography_type="LAD", time="latest")
merged = geo_df.merge(ons_df, on="geography_code")
Under the hood, geo_code_field() and geo_name_field() derive the
ArcGIS field names:
from uk_open_data._mapping import geo_code_field, geo_name_field
geo_code_field("LAD", 2024) # "LAD24CD"
geo_name_field("LAD", 2024) # "LAD24NM"
Datasets the package uses
list_datasets() lists every published dataset the package loads, each
described once. The Datasets page shows the same list as a
table. In code:
from uk_open_data.analyses import list_datasets
for dataset in list_datasets():
print(dataset.source.id, dataset.topic, dataset.nations, dataset.used_by)
# iod-2025 people ('E',) ('reach-deprivation', 'reach-connectivity')
# nomis-nm_2124_1 business-and-economy ('E', 'W') ('need-reach', ...)
# ...
| Field | What it holds |
|---|---|
source |
The published source: id, name, publisher, address, licence, edition and credit lines. A result cites it by the same source.id, with its own words for what it was used for and the edition of any copy kept on the machine |
topic |
The data.gov.uk collection it belongs under: people, business-and-economy, environment, government-and-parliament, land-and-property or transport |
area |
The kind of area its figures are for, with its edition, such as "Lower layer Super Output Areas (2021)" |
nations |
The nations the package reads it for: E, W, S and N |
used_by |
The analyses that can cite it. It is empty for an index that only load_imd offers |
downloads |
What download_datasets() calls to keep it on the machine, one call for each file. It is empty for a live service, a table that comes with the package, and data held in memory only |
Every source an analysis result cites is in the list, and a test checks this. The list leaves out a Nomis table that you choose yourself as the need, and the boundary outlines a map draws. Maps credit the outlines in their footnote rather than citing them as a source.
How requests are made
Every loader fetches the same way:
- Each request names the package in its
User-Agentheader, asuk-open-data/<version> (+https://github.com/KindTechUK/uk-open-data), so a publisher can tell who is asking. - A request is tried again, up to three times in all, when the connection
fails or drops part way through an answer, or the source answers 429, 500,
502, 503 or 504. It waits one second and then two, or as long as the
source's
Retry-Afterheader asks, up to 30 seconds. A source that is too slow to answer is not asked again, because it would only be slow again; nor is one whose certificate or proxy fails. - A source that still fails, or answers with another error, raises a
requests.RequestException. The ONS boundary service can answer with an error in the body of a successful reply, and that raises too. Some calls turn the error into one of their own:download_postcode_tableraisesPostcodeTableError, anddownload_centresraisesValueError, which the access and distance analysis gives as anAnalysisInputError. - No loader returns an empty table or collection because a request failed.
An empty result means the source has nothing that matches, with one
exception:
load_geodatagives an empty collection, and logs an error, when a boundary service keeps paging without end or gives the same page twice, so that a part of a layer is never taken for the whole.
Architecture
KindTech ingests from two completely separate APIs into two independent CSV catalogs. They share no data or endpoints — one provides geographic boundaries (maps), the other provides statistical tables (numbers).
┌─────────────────────────────────────────────────────────────────────┐
│ TWO SEPARATE DATA SOURCES │
├──────────────────────────────┬──────────────────────────────────────┤
│ │ │
│ ONS Open Geography Portal │ NOMIS │
│ (ArcGIS FeatureServer) │ (Durham University for ONS) │
│ geoportal.statistics.gov.uk │ nomisweb.co.uk │
│ │ │
│ What: UK boundary maps │ What: UK statistics │
│ Format: GeoJSON polygons │ Format: CSV tabular data │
│ │ │
├──────────────────────────────┼──────────────────────────────────────┤
│ │ │
│ INGESTION (dev-time) │ INGESTION (dev-time) │
│ │ │
│ Source URL: │ Source URL: │
│ services1.arcgis.com/ │ nomisweb.co.uk/api/v01/ │
│ ESMARspQHYMw9BZ9/ │ dataset/def.sdmx.json │
│ arcgis/rest/services │ │
│ ?f=json │ 1 HTTP request → parse JSON │
│ │ → extract id, name, source │
│ 1 HTTP request → parse JSON │ from annotations │
│ → regex-parse ~3,700 │ │
│ service names │ Output: │
│ → normalise resolution │ ons/data/nomis_tables.csv │
│ codes │ (1,615 datasets) │
│ │ │
│ Output: │ uv run python -m │
│ geo/data/arcgis_services.csv│ uk_open_data.ons._ingestion │
│ (654 boundary datasets) │ │
│ │ │
│ uv run python -m │ │
│ uk_open_data.geo._ingestion │ │
│ │ │
├──────────────────────────────┼──────────────────────────────────────┤
│ │ │
│ RUNTIME (user-facing) │ RUNTIME (user-facing) │
│ │ │
│ load_geodata("LAD") │ load_ons("population", │
│ → look up CSV catalog │ geography_type="LAD") │
│ → query ArcGIS │ → resolve alias → NM_2002_1 │
│ FeatureServer │ → resolve geography → TYPE424 │
│ → return GeoJSON dict │ → query NOMIS .data.csv │
│ │ → return DataFrame │
│ │ (pandas or polars) │
│ │ │
└──────────────────────────────┴──────────────────────────────────────┘
Both ingestion scripts are stdlib-only (csv, re, requests). The
resulting CSV catalogs ship with the package. Users never run ingestion —
they call load_geodata() or load_ons() and get data back as GeoJSON or
a DataFrame.
To refresh the catalogs when ONS publishes updates:
# Geo boundaries — from ArcGIS
uv run python -m uk_open_data.geo._ingestion
# Statistics — from NOMIS
uv run python -m uk_open_data.ons._ingestion
Then commit the updated CSV files.
References
ONS Open Geography Portal
- Portal homepage
- ONS Geography overview
- Digital boundaries (resolution types)
- Names, codes and lookups (GSS policy)
- Boundary Dataset Guidance: 2021 Onwards
- Boundary changes — May vs December release cycle
- Rural-Urban Classification
- Health geographies — NHSER, ICB, Local Offices
- Statistical geographies — OA, LSOA, MSOA hierarchy
- Enumeration Districts and Output Areas
- Licensing terms (OGL v3.0)
- ArcGIS REST services directory
- ArcGIS REST API reference (Esri)
- ONS ArcGIS Online organisation
NOMIS
- NOMIS homepage
- About NOMIS — University of Durham for ONS, since 1981
- API documentation
- Copyright and licensing — OGL, "Source: Office for National Statistics"
- Dataset listing (SDMX JSON)
- Content type sources
- Query builder