Dead simple, very quick, rich, straightforward and free UK postcode lookup API - as an HTML page, JSON or Markdown.
Sample Postcodes
- ex46px .json .md Exeter
- iv55 8wg .json .md Isle of Skye
- EC1A-1BB .json .md City of London
- sw1a1aa .json .md Westminster
- W1A 1AA .json .md Broadcasting House
- bs1 4dj .json .md Bristol
- CF101EP .json .md Cardiff
- ll554ty .json .md Snowdonia
- B2 4QA .json .md Birmingham
- ls1-1ur .json .md Leeds
- M11AE .json .md Manchester
- NE1 4ST .json .md Newcastle
- eh1 1bb .json .md Edinburgh
- g11xw .json .md Glasgow
- ab37-9ex .json .md Tomintoul
Request
curl https://openpostcodes.uk/EX11%201RE.json
import requests
postcode = "EX11 1RE"
response = requests.get("https://openpostcodes.uk/" + postcode + ".json")
data = response.json()
print(data)
const postcode = "EX11 1RE";
fetch("https://openpostcodes.uk/" + encodeURIComponent(postcode) + ".json")
.then((response) => response.json())
.then((data) => console.log(data));
OkHttpClient client = new OkHttpClient();
String postcode = "EX11 1RE";
Request request = new Request.Builder()
.url("https://openpostcodes.uk/" + URLEncoder.encode(postcode, StandardCharsets.UTF_8).replace("+", "%20") + ".json")
.build();
try (Response response = client.newCall(request).execute()) {
System.out.println(response.body().string());
}
const axios = require("axios");
const postcode = "EX11 1RE";
const response = await axios.get("https://openpostcodes.uk/" + encodeURIComponent(postcode) + ".json");
console.log(response.data);
<?php
require "vendor/autoload.php";
use GuzzleHttp\Client;
$client = new Client();
$postcode = "EX11 1RE";
$response = $client->get("https://openpostcodes.uk/" . rawurlencode($postcode) . ".json");
$data = json_decode($response->getBody(), true);
print_r($data);
require "httparty"
require "erb"
postcode = "EX11 1RE"
response = HTTParty.get("https://openpostcodes.uk/" + ERB::Util.url_encode(postcode) + ".json")
puts response.parsed_response
postcode := "EX11 1RE"
resp, err := http.Get("https://openpostcodes.uk/" + url.PathEscape(postcode) + ".json")
if err != nil {
log.Fatal(err)
}
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
var postcode = "EX11 1RE";
using var client = new HttpClient();
var response = await client.GetStringAsync("https://openpostcodes.uk/" + Uri.EscapeDataString(postcode) + ".json");
Console.WriteLine(response);
Response
| Field | Type | Nullable | Description |
|---|---|---|---|
postcode | string | Postcode in canonical format, with the space | |
part | object | Postcode components | |
part.outcode | string | Outward code - before the space, e.g. EC1A | |
part.incode | string | Inward code - after the space, e.g. 1BB | |
part.area | string | Postcode area - the leading letters, e.g. EC | |
part.district | string | Outward code without any trailing sub-district letter, e.g. EC1 (of EC1A) | |
part.subdistrict | string | ✓ | Outward code including the trailing letter, when present, e.g. EC1A; else null |
part.sector | string | Outward code, a space, and the first inward character, e.g. EC1A 1 | |
part.unit | string | The last two letters of the postcode, e.g. BB | |
latitude | number | ✓ | Latitude of the postcode centroid (WGS84) |
longitude | number | ✓ | Longitude of the postcode centroid (WGS84) |
open_location_code | string | ✓ | Open Location Code (plus code) for the centroid |
maidenhead_locator | string | ✓ | Maidenhead Locator (amateur radio grid square) for the centroid |
qibla | number | ✓ | Bearing to Mecca, in degrees clockwise from true north |
magnetic_declination | number | ✓ | Angle between true and magnetic north, in degrees east (World Magnetic Model 2025) |
eastings | number | ✓ | OS National Grid easting, in metres |
northings | number | ✓ | OS National Grid northing, in metres |
grid_reference | string | ✓ | OS grid reference - British National Grid, or Irish Grid for Northern Ireland |
utm | string | ✓ | Universal Transverse Mercator coordinate for the centroid - zone, MGRS latitude band, easting and northing, e.g. "30U 479645 5621910" |
antipode | object | ✓ | The point diametrically opposite on the earth's surface |
antipode.latitude | number | Latitude of the antipode (WGS84) | |
antipode.longitude | number | Longitude of the antipode (WGS84) | |
elevation | number | ✓ | Ground elevation at the centroid, in metres (GB mainland; OS Terrain 50) |
timezone | string | IANA timezone (Europe/London, or the Crown Dependency zone) | |
sun | object | ✓ | Today's solar times at the centroid, as local ISO 8601 timestamps to the minute |
sun.rise | string | ✓ | Sunrise - the sun's upper limb at the horizon, allowing for refraction |
sun.noon | string | Solar noon - the sun crossing the meridian, at its highest point of the day | |
sun.set | string | ✓ | Sunset |
country | object | Country as { name, code }. name ∈ England, Scotland, Wales, Northern Ireland, Channel Islands, Isle of Man; code is the GSS code | |
region | object | Region as { name, code } (GSS). England only; both null elsewhere | |
admin_district | object | Local authority district as { name, code } (GSS) | |
ward | object | Electoral ward as { name, code } (GSS) | |
constituency | object | Westminster parliamentary constituency as { name, code } (GSS) | |
county | object | County as { name, code } (GSS); both null where the postcode is not in a county | |
parish_code | string | ✓ | Civil parish (or community) GSS code |
census | object | 2011 & 2021 census statistical geographies (GSS codes) | |
census.oa21 | string | ✓ | 2021 Census Output Area code |
census.lsoa21 | string | ✓ | 2021 Lower Layer Super Output Area code |
census.msoa21 | string | ✓ | 2021 Middle Layer Super Output Area code |
census.msoa_name | string | ✓ | MSOA friendly name (House of Commons Library; England & Wales) |
census.oa11 | string | ✓ | 2011 Census Output Area code |
census.lsoa11 | string | ✓ | 2011 Lower Layer Super Output Area code |
census.msoa11 | string | ✓ | 2011 Middle Layer Super Output Area code |
census.workplace_zone_code | string | ✓ | 2011 Workplace Zone code |
classification | object | Area classifications and indices | |
classification.rural_urban | string | ✓ | Rural/urban classification, decoded to text |
classification.rural_urban_code | string | ✓ | Rural/urban classification code (e.g. RLN1, or 1-6 in Scotland) |
classification.output_area_classification | object | 2011 Output Area Classification as { name, code } (UK-wide) - supergroup name and code, e.g. 1B1 | |
classification.imd | number | ✓ | Deprivation rank on the relevant country's own index and scale - England's IMD, Scotland's SIMD, Wales's WIMD or Northern Ireland's NIMDM (not comparable across countries); 1 = most deprived; null for the Channel Islands and Isle of Man, which have none |
classification.user_type | string | ✓ | Postcode user type - “Small” (mostly residential) or “Large” |
health | object | NHS geographies (England; GSS codes) | |
health.nhs_region_code | string | ✓ | NHS England region code |
health.icb_location_code | string | ✓ | Integrated Care Board sub-location code |
health.integrated_care_board_code | string | ✓ | Integrated Care Board code |
health.cancer_alliance_code | string | ✓ | Cancer Alliance code |
travel_to_work_area_code | string | ✓ | Travel to Work Area GSS code |
police_force_area_code | string | ✓ | Police Force Area GSS code |
national_park_code | string | ✓ | National Park GSS code; null when not in a park |
built_up_area_code | string | ✓ | Built-Up Area (2024) GSS code |
county_electoral_division_code | string | ✓ | County Electoral Division code (two-tier county areas) |
european_electoral_region | object | European Electoral Region as { name, code } (legacy geography) | |
date_introduced | string | ✓ | Month the postcode was introduced, as YYYY-MM |
nearest | object | ||
nearest.railway_station | object | ✓ | Nearest railway station (National Rail, or Translink in Northern Ireland; excludes London Underground and light rail/trams); code is the CRS code where available |
nearest.hospital | object | ✓ | Nearest hospital (CQC-registered in England, or from a hand-compiled HSC Trust list in Northern Ireland) |
nearest.gp | object | ✓ | Nearest GP surgery (CQC-registered in England, or BSO-registered in Northern Ireland) |
nearest.school | object | ✓ | Nearest school (Get Information About Schools in England, or the Scottish Government's school roll in Scotland); no source in scope for Wales or Northern Ireland, which are null |
nearest.airport | object | ✓ | Nearest airport; code is the IATA code |
nearest.bus_stop | object | ✓ | Nearest bus stop (NaPTAN, or Translink in Northern Ireland) |
nearest.foodbank | object | ✓ | Nearest food bank (Give Food) |
nearest.defibrillator | object | ✓ | Nearest public-access defibrillator (The Circuit / BHF) |
nearest.pharmacy | object | ✓ | Nearest pharmacy (OpenStreetMap) |
nearest.post_office | object | ✓ | Nearest post office (OpenStreetMap) |
nearest.library | object | ✓ | Nearest library (OpenStreetMap) |
nearest.coast | object | ✓ | Nearest point on the coast - { distance, latitude, longitude } or null |
nearest.london | object | ✓ | Straight-line distance to central London (Trafalgar Square) - { distance, latitude, longitude } or null |
utilities | object | ||
utilities.electricity | object | ✓ | Electricity DNO; null outside GB and Northern Ireland (e.g. Channel Islands, Isle of Man) |
utilities.electricity.name | string | Distribution Network Operator name | |
utilities.electricity.region_code | string | ✓ | MPAN distributor id, letter form (A-P); null for Northern Ireland, which doesn't use GB's MPAN numbering |
utilities.electricity.mpan_id | number | ✓ | MPAN distributor id, number form (10-23) - the same distributor as region_code; null for Northern Ireland |
utilities.water | string | ✓ | Water supply undertaker |
utilities.sewerage | string | ✓ | Sewerage services undertaker (often, but not always, the same company as utilities.water) |
utilities.broadband | object | ✓ | Fixed broadband coverage (Ofcom Connected Nations, postcode level); null where Ofcom has no matching record for this postcode |
utilities.broadband.gigabit | number | % of premises with a gigabit-capable service available | |
utilities.broadband.superfast | number | % of premises with superfast broadband (SFBB, >=30Mbit/s) available | |
utilities.broadband.ultrafast | number | % of premises with ultrafast broadband (UFBB, >=300Mbit/s) available | |
utilities.broadband.below_uso | number | % of premises below the Universal Service Obligation (<10Mbit/s download or <1Mbit/s upload, from fixed broadband, a WISP or mobile FWA) | |
adjacent | string[] | Bordering postcodes | |
boundary | object | ✓ | Approximate postcode boundary as a GeoJSON geometry ({ type, coordinates }, WGS84); Great Britain only - null for Northern Ireland, the Channel Islands and Isle of Man |
MCP server
OpenPostcodes is also available as a Model Context Protocol (MCP) server, so AI assistants such as Claude, ChatGPT, Cursor and VS Code can look up postcodes, compare them and browse areas, districts and sectors directly. It is read-only, needs no key or sign-in, and serves the same data as these pages. Add this URL to your assistant as a connector:
https://openpostcodes.uk/mcp
Opened in a browser, the same URL is the MCP page: how to connect, every tool it offers and its limits.