mySociety is run by a registered charity – please donate to help keep us going and to be able to continue to do things like this!
MaPit is our database and web service that maps postcodes and points to current or past administrative area information and polygons for all the United Kingdom. It has been rewritten from the ground up in GeoDjango and PostGIS, providing us with a large array of improvements including speed, a lovely admin interface, and much easier updating. The source code is available on GitHub.
Another notable benefit is that this new version has been filled with only totally open data, so you can be secure that you can reuse the data from this site under the minimal terms of the licences given below. It is based on OS OpenData Boundary-Line and Code-Point for Great Britain, and NSPD Open for Northern Ireland, with Super Output Areas from ONS. You can download raw copies of these datasets from our data mirror, which you can then use in your own copy of this service.
This database contains Ordnance Survey data © Crown copyright and database right 2010; Royal Mail data © Royal Mail copyright and database right 2010 (Code-Point Open); Office for National Statistics data © Crown copyright and database right 2010 (NSPD Open) and © Crown copyright 2004 (Super Output Areas). Great Britain non-SOA data may be used under the terms of the OS OpenData licence (PDF). Northern Ireland data may be used under the terms of the NSPD Open licence (Word). Super Output Area data may presumably be used under OS OpenData and the Open Government Licence.
API
Non-commercial, low-volume use of this service is free. You will need to attribute OS/RM/ONS as per their licenses, and please do attribute us too :) For commercial or high-volume usage, please contact us about using the service, by licensing or by helping you install your own version.
All calls below are made to http://mapit.mysociety.org/ and return JSON (on some calls, stick .html on the end for an HTML version). By default, calls will return active areas; for some calls you may specify a previous generation to look up instead. The main difference in generation 12 is that it contains the pre-2010 England and Wales Parliamentary constituencies; generation 14 contains the pre-2011 Scottish Parliament constituencies. Only current Northern Ireland constituencies are present; if you need pre-2010 UK Parliament NI constituencies, or pre-2011 Northern Ireland Assembly constituencies, you can work it out from the wards and the 2003 SNAC file in the data/ directory. Whenever an area is returned from MaPit, it is as a dictionary with the following keys: id, name, country, type, parent_area, generation_low, generation_high, codes.
By postcode
- /postcode/[postcode] – information on a particular postcode, including its location in both National Grid and WGS84 latitude/longitude, and the areas it is contained within. You may specify a previous generation as a ?generation=N parameter. Example postcode lookup.
- /postcode/partial/[partial postcode] – location information on the centroid of a partial postcode. Example partial postcode lookup.
Multiple areas
- /areas/[area IDs, separated by commas] — information on more than one area at once, as a dictionary indexed by area ID. Example area IDs lookup.
- /areas/[area IDs, separated by commas]/geometry – all the geometry information you would get from single geometry calls.
- /areas/[type OR types] – all the areas in a specific area type or types (separated by commas). You may specific a minimum generation with the min_generation parameter. The current list of types is: CTY (county council), CED (county ward), COI (Isles of Scilly), COP (Isles of Scilly parish), CPC (civil parish), DIS (district council), DIW (district ward), EUR (Euro region), GLA (London Assembly), LAC (London Assembly constituency), LBO (London borough), LBW (London ward), LGD (NI council), LGE (NI electoral area), LGW (NI ward), MTD (Metropolitan district), MTW (Metropolitan ward), NIE (NI Assembly constituency), OLF (Lower Layer Super Output Area, Full), OLG (Lower Layer Super Output Area, Generalised), OMF (Middle Layer Super Output Area, Full), OMG (Middle Layer Super Output Area, Generalised), SPC (Scottish Parliament constituency), SPE (Scottish Parliament region), UTA (Unitary authority), UTE (Unitary authority electoral division), UTW (Unitary authority ward), WAC (Welsh Assembly constituency), WAE (Welsh Assembly region), WMC (UK Parliamentary constituency). Example county council (CTY) lookup.
- /areas/[name] – all areas that start with the specified text. You may restrict results to a type or types with the type parameter (as always, multiple separated by commas), or expand to previous generations with the min_generation parameter. Example lookup of all areas starting “Bourn”.
Generations
- /generations – return a list of all generations. Note that only generations from 12 upwards actually exist, apart from some council names in generation 10 in order for FixMyStreet to show expired councils on its All Reports page.
By point
An SRID is a unique number referring to a particular co-ordinate system; the ones you probably are interested in are 27700 for British National Grid, 4326 for WGS84 lon/lat, and 29902 for the Irish National Grid. You can restrict results to particular area types with a type parameter (multiple types separated by commas), and have results for a previous generation with a generation parameter. Note that x,y means longitude,latitude.
- /point/[SRID]/[x],[y] – the areas covering the particular point. Example of areas containing (400000,300000).
- /point/[SRID]/[x],[y]/box – the areas whose bounding boxes cover the particular point.
By area ID
- /area/[area ID or ONS code] – information on a particular area. Example of an area’s results.
- /area/[area ID]/example_postcode – a random postcode within the area specified. Example example postcode.
- /area/[area ID]/geometry – geometry information on the area including its centroid, extent and area.
- /area/[area ID].[kml|geojson|wkt] – the actual geometry of the area, in the specified format (WGS84 for KML, OSGB otherwise). Example KML file on a Google Map. You can specify a simplify_tolerance floating point parameter to return a simplified polygon.
- /area/[SRID]/[area ID].[kml|json|wkt] – the actual geometry of the area, in the specified format and geometry.
All the following can take a type parameter to restrict results to a type or types:
- /area/[area ID]/children – all the children of a particular area. Example of all electoral divisions of a county council.
- /area/[area ID]/touches – all the areas that border the selected area. Example of all constituencies touching Witney.
- /area/[area ID]/overlaps – all the areas that overlap the selected area. Example of all areas overlapping Barking and Dagenham council.
- /area/[area ID]/covers – all the areas that are covered by the selected area. Example of all parish councils covered by Witney.
- /area/[area ID]/covered – all the areas that cover the selected area. Example of all areas covering Witney.
- /area/[area ID]/coverlaps – all the areas covered by or overlapping the selected area. Example of all constituencies covered by or overlapping Barking and Dagenham.

