UK postcode API: area codes, flood risk, crime and schools
Four government datasets describe a postcode: the ONS Postcode Directory, the Environment Agency’s flood risk data, police.uk and the schools register. Here is how each works, and how to get all four in one call.
Part of our Location APIs.
Area codes: the ONS Postcode Directory
The ONS Postcode Directory maps every current and terminated postcode in the UK to its local authority, ward, parliamentary constituency, census areas (output area, LSOA, MSOA), police force area, NHS boards and coordinates. It is published under the Open Government Licence with Ordnance Survey and Royal Mail attribution, except for Northern Ireland, which needs a separate commercial licence. The directory is a large quarterly download, so most teams load it into their own database or use a hosted lookup.
Flood risk: the Environment Agency
The Environment Agency publishes, for each postcode in England, how many addresses sit in areas at high, medium and low long-term risk of flooding from rivers and the sea and from surface water, plus groundwater alert areas. It is the data behind GOV.UK’s check long-term flood risk service.
Crime: police.uk
police.uk publishes street-level crime for England, Wales and Northern Ireland a couple of months in arrears, with locations anonymised to nearby points. Its API returns one month at a time around a point, and refuses areas with more than 10,000 crimes, so a 12-month summary takes a dozen calls and some care in busy city centres. Scotland is not included.
Schools and Ofsted
The Department for Education’s Get Information About Schools register lists every school in England with its location, phase and type. Ofsted publishes inspection outcomes monthly; since November 2025 new inspections use report cards instead of a single overall grade, so a good integration shows both.
All four in one call
One request to our postcode check API returns area codes, flood risk, 12 months of crime and the nearest schools, with the source and release date of each part. Get a free key and try it on your own postcode.
curl https://api.tychelabs.net/v1/postcodes/SW1A2AA \
-H "x-api-key: $TYCHE_API_KEY"const res = await fetch("https://api.tychelabs.net/v1/postcodes/SW1A2AA?schools=3", {
headers: { "x-api-key": process.env.TYCHE_API_KEY },
});
const { data } = await res.json();
console.log(data.areas.localAuthority.name); // Westminster
console.log(data.flood.addressesByRisk); // Environment Agency risk bands
console.log(data.crime.total, data.schools.items[0].name);import os, requests
r = requests.get(
"https://api.tychelabs.net/v1/postcodes/SW1A2AA",
params={"include": "areas,flood,schools"},
headers={"x-api-key": os.environ["TYCHE_API_KEY"]},
timeout=15,
)
pc = r.json()["data"]
print(pc["areas"]["ward"]["name"], pc["flood"]["addressesAtRisk"])Common questions
Is postcodes.io free?
Yes, postcodes.io is a free open source service built on the same ONS data. It covers area codes but not flood risk, crime or schools.
Can I get flood risk for an address?
The Environment Agency’s open postcode file gives counts of addresses per risk band in a postcode. Property-level risk needs the official checker or a licensed product.
Why is Northern Ireland not covered?
Northern Ireland postcode data in the ONS directory needs a separate commercial licence from Land and Property Services.
Postcode data in one call
100 free postcode checks a month, then from £15 a month for 1,000.