OpenPostcodes

Dead simple, very quick, rich, straightforward and free UK postcode lookup API - as an HTML page, JSON or Markdown.

Sample Postcodes

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

FieldTypeNullableDescription
postcodestringPostcode in canonical format, with the space
partobjectPostcode components
part.outcodestringOutward code - before the space, e.g. EC1A
part.incodestringInward code - after the space, e.g. 1BB
part.areastringPostcode area - the leading letters, e.g. EC
part.districtstringOutward code without any trailing sub-district letter, e.g. EC1 (of EC1A)
part.subdistrictstringOutward code including the trailing letter, when present, e.g. EC1A; else null
part.sectorstringOutward code, a space, and the first inward character, e.g. EC1A 1
part.unitstringThe last two letters of the postcode, e.g. BB
latitudenumberLatitude of the postcode centroid (WGS84)
longitudenumberLongitude of the postcode centroid (WGS84)
open_location_codestringOpen Location Code (plus code) for the centroid
maidenhead_locatorstringMaidenhead Locator (amateur radio grid square) for the centroid
qiblanumberBearing to Mecca, in degrees clockwise from true north
eastingsnumberOS National Grid easting, in metres
northingsnumberOS National Grid northing, in metres
grid_referencestringOS grid reference - British National Grid, or Irish Grid for Northern Ireland
utmstringUniversal Transverse Mercator coordinate for the centroid - zone, MGRS latitude band, easting and northing, e.g. "30U 479645 5621910"
elevationnumberGround elevation at the centroid, in metres (GB mainland; OS Terrain 50)
timezonestringIANA timezone (Europe/London, or the Crown Dependency zone)
countryobjectCountry as { name, code }. name ∈ England, Scotland, Wales, Northern Ireland, Channel Islands, Isle of Man; code is the GSS code
regionobjectRegion as { name, code } (GSS). England only; both null elsewhere
admin_districtobjectLocal authority district as { name, code } (GSS)
wardobjectElectoral ward as { name, code } (GSS)
constituencyobjectWestminster parliamentary constituency as { name, code } (GSS)
countyobjectCounty as { name, code } (GSS); both null where the postcode is not in a county
parish_codestringCivil parish (or community) GSS code
censusobject2011 & 2021 census statistical geographies (GSS codes)
census.oa21string2021 Census Output Area code
census.lsoa21string2021 Lower Layer Super Output Area code
census.msoa21string2021 Middle Layer Super Output Area code
census.msoa_namestringMSOA friendly name (House of Commons Library; England & Wales)
census.oa11string2011 Census Output Area code
census.lsoa11string2011 Lower Layer Super Output Area code
census.msoa11string2011 Middle Layer Super Output Area code
census.workplace_zone_codestring2011 Workplace Zone code
classificationobjectArea classifications and indices
classification.rural_urbanstringRural/urban classification, decoded to text
classification.rural_urban_codestringRural/urban classification code (e.g. RLN1, or 1-6 in Scotland)
classification.output_area_classificationobject2011 Output Area Classification as { name, code } (UK-wide) - supergroup name and code, e.g. 1B1
classification.imdnumberDeprivation 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_typestringPostcode user type - “Small” (mostly residential) or “Large”
healthobjectNHS geographies (England; GSS codes)
health.nhs_region_codestringNHS England region code
health.icb_location_codestringIntegrated Care Board sub-location code
health.integrated_care_board_codestringIntegrated Care Board code
health.cancer_alliance_codestringCancer Alliance code
travel_to_work_area_codestringTravel to Work Area GSS code
police_force_area_codestringPolice Force Area GSS code
national_park_codestringNational Park GSS code; null when not in a park
built_up_area_codestringBuilt-Up Area (2024) GSS code
county_electoral_division_codestringCounty Electoral Division code (two-tier county areas)
european_electoral_regionobjectEuropean Electoral Region as { name, code } (legacy geography)
date_introducedstringMonth the postcode was introduced, as YYYY-MM
nearestobject
nearest.railway_stationobjectNearest railway station (National Rail, or Translink in Northern Ireland; excludes London Underground and light rail/trams); code is the CRS code where available
nearest.hospitalobjectNearest hospital (CQC-registered in England, or from a hand-compiled HSC Trust list in Northern Ireland)
nearest.gpobjectNearest GP surgery (CQC-registered in England, or BSO-registered in Northern Ireland)
nearest.schoolobjectNearest 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.airportobjectNearest airport; code is the IATA code
nearest.bus_stopobjectNearest bus stop (NaPTAN, or Translink in Northern Ireland)
nearest.foodbankobjectNearest food bank (Give Food)
nearest.defibrillatorobjectNearest public-access defibrillator (The Circuit / BHF)
nearest.pharmacyobjectNearest pharmacy (OpenStreetMap)
nearest.post_officeobjectNearest post office (OpenStreetMap)
nearest.libraryobjectNearest library (OpenStreetMap)
nearest.coastobjectNearest point on the coast - { distance, latitude, longitude } or null
nearest.londonobjectStraight-line distance to central London (Trafalgar Square) - { distance, latitude, longitude } or null
utilitiesobject
utilities.electricityobjectElectricity DNO; null outside GB and Northern Ireland (e.g. Channel Islands, Isle of Man)
utilities.electricity.namestringDistribution Network Operator name
utilities.electricity.region_codestringMPAN distributor id, letter form (A-P); null for Northern Ireland, which doesn't use GB's MPAN numbering
utilities.electricity.mpan_idnumberMPAN distributor id, number form (10-23) - the same distributor as region_code; null for Northern Ireland
utilities.waterstringWater supply undertaker
utilities.seweragestringSewerage services undertaker (often, but not always, the same company as utilities.water)
utilities.broadbandobjectFixed broadband coverage (Ofcom Connected Nations, postcode level); null where Ofcom has no matching record for this postcode
utilities.broadband.gigabitnumber% of premises with a gigabit-capable service available
utilities.broadband.superfastnumber% of premises with superfast broadband (SFBB, >=30Mbit/s) available
utilities.broadband.ultrafastnumber% of premises with ultrafast broadband (UFBB, >=300Mbit/s) available
utilities.broadband.below_usonumber% of premises below the Universal Service Obligation (<10Mbit/s download or <1Mbit/s upload, from fixed broadband, a WISP or mobile FWA)
adjacentstring[]Bordering postcode
boundaryobjectApproximate postcode boundary as a GeoJSON geometry ({ type, coordinates }, WGS84); Great Britain only - null for Northern Ireland, the Channel Islands and Isle of Man