CiviCRM MaPit integration

2010-11-11 05:37
Written by

At the recent CiviCRM code sprint in Bristol I worked on developing integration between MaPit (a web service that maps postcodes and points to administrative area information for the UK) and CiviCRM.

Here's the background: Recently, the UK government has started making more and more public data freely available online. Earlier this year, they released a lot of geographical (Ordnance Survey) data which includes a mapping from postcodes to all available adminisrative and political areas in the UK. Soon after this, mySociety, who run 'most of the best-known democracy and transparency websites in the UK' released the MaPit API making all this data available and easy to interegate. Here's an example for E5 0DR (also available as JSON).  As soon as I saw this, I thought it would be great to add the last link to the chain and integrate it with CivICRM, so any non profit can look up and store this data alongside their contacts.  The code sprint in Bristol provided the time and space to do this.

I think this is pretty exiting - it is great to be able to put this power into the hands of all these UK orgs free of charge.  Nearly all of our clients have asked for functionality based around area information, and previously these kinds of services had an annual subscription around the £3,000 mark, which made it way out of reach of a lot of our smaller clients.

The finished code is on github and I've put up a demo so you can try it out. This initial version is pretty simple - each time a contact is created or edited, CiviCRM gives Mapit the contact's postcode and asks Mapit for some basic area information. There is also a batch function which can look up data for multiple contacts (useful when you initially install the module).

There are loads of ways that this data could be used, limited by the imaginations of the non profits using it.  Targeting campaigns, reporting on constitients, mapping membership charters to name a few simple examples.  We are really interested in further developing this module to meet your needs - if you would like us to do that, contact

Special thanks to Matthew Somerville at MySociety for developing the MaPit API and for being very helpful and answering my questions while developing this integration.  Note that this module directly calls the Mapit API.  Non-commercial, low-volume use of this service is free but you should read the full terms of use if you plan on using it.

Filed under


Good work Michael - no wonder you have been so quiet of late ;-)