December 5, 2023
by Gary Fuller

Expanding our Email Your MP API

Postgre Query - Chiffre01, CC BY-SA 4.0 , via Wikimedia Commons

Postgres Query – Chiffre01, CC BY-SA 4.0 , via Wikimedia Commons

Since we created our first “Email Your MP” website in 2018, the service has expanded to support multiple organisations but has remained relatively focused on national campaigns. The API behind it has expanded somewhat to include additional MPs, such as those Northern Ireland, but has remained relatively static in terms of scope.

That changed recently thanks to various development requests. Firstly, the Liberal Democrats needed a new version of their postal voting page. Secondly, a new client wished to use additional data, alongside MP contact details, as part of their campaign. The result? Two new API endpoints and changes to our Fleet and WordPress platforms to make use of them.

Local Authorities

The first new endpoint allows us to query data about local authorities based upon postcodes. This data includes a name, address, email address, and phone number for the relevant authority that can be used to send in postal vote request forms. Our Fleet website system can now take your personal details, populate a postal vote request form and give you all the information you need to send it off.

At the API end this required adding a new script to pull the data from the Electoral Commission API, a new database migration to incorporate it into its own table and support querying it alongside postcode data, and creating a new endpoint and controller to return the data. At the Fleet end, this required a new extension for our Typo3 site package, including its own controller class to manage the API call and a new fluid template to generate the form and pdf. The pdf file is generated using a JavaScript library.

Because the functionality is based upon using an API, it opens up some interesting possibilities for the future. One such possibility is turning it into a mobile app. One could complete the form in app and have it submitted directly to your local authority.  As more local authorities move towards supporting online postal vote applications, and digital signatures, it should become practical to build out the functionality in this way.

Local Tourism

Data from the ONS suggests that at least 3 million people visit the UK every month, contributing more than £24bn to the economy annually. Those visitors create a lot of jobs and give a boost to the economy in various constituencies, especially in London. Data around these benefits is potentially useful to politicians, campaigners, and charitable organisations.

We were therefore delighted when supplied with data on the effects of Inbound tourism to incorporate it into our Email Your MP API. As with the local authority data, we created a new endpoint to make use of this data. We also updated our WordPress platform so that the new endpoint could be chosen when creating a campaign.

Integrating such data, anonymised where appropriate, into our API could help expand its usefulness beyond the existing campaigning functionality. We’re hoping that, having seen how the new data is being put to use, more clients will come to us with requests to integrate data relevant to their campaigns.

Sources:

https://commons.wikimedia.org/wiki/File:Postgres_Query.jpg (Chiffre01, CC BY-SA 4.0 <https://creativecommons.org/licenses/by-sa/4.0>, via Wikimedia Commons).

https://www.ons.gov.uk/peoplepopulationandcommunity/leisureandtourism/bulletins/overseastravelandtourism/octoberandnovember2022provisionalresults