Responsive They Work For You hack

Heard of TheyWorkForYou? It’s a political web site that lets you look up MPs and learn about their voting record, interests, expenses and more.

When I asked this at Rewired State’s National Hack The Government day, most of the room raised their hands. It’s hugely popular and has remarkable history. Built in 2004 at a NTK conference, it’s won a New Statesman New Media Award, had development supported by the Department for Constitutional Affairs, been referenced in the House of Commons and House of Lords, appeared on Channel 4, been replicated around the world and was called “the most amazing, subversive piece of political webware I’ve ever seen” by Cory Doctorow.


Wow. All this and remaining relevant for ten years on the internet is very impressive, but unfortunately it doesn’t look so good on a mobile in 2013.

TheyWorkForYou in Mobile Safari

Much as I love diving it and making quick, fun hacks on hackdays, for Rewired State I set myself the challenge of making something that would have lasting value and remain useful after the event. A responsive front end for TheyWorkForYou seemed a great project. My first idea was to build one and make a pull request to the Github repo.

Heritage PHP

Ah. Turns out TheyWorkForYou is written in what we might kindly describe as heritage PHP, which makes it very hard to adjust the front end.

But TheyWorkForYou has an API. If the data’s there, I can read it and build a new front end on top, right? Ah. Turns out the API also has a lot of… heritage.

Heritage JSON

I realised I couldn’t work through much of this data and code in a day, so I looked for the single most interesting feature of the site to convert to mobile. I think it’s the voting record, it’s intriguing to look up how MPs vote and see the issues they actually support. Did you know Nick Clegg was very strongly for tuition fees? Ok… maybe not the best example.

Nick Clegg's votes

Well, having worked out a clear and achievable goal, I dived in and started hacking. The result’s live at It looks like this:

They Work For You Mobile

There’s also a spin off hack. I had to parse the TheyWorkForYou API data for my own use, so I made a public endpoint to my data /mp_api/<member_id>/

There’s only one call, it returns information about an MP and their voting records. Here’s how my JSON response for Nick Clegg looks:


My source code’s on Github at I’m pleased to have turned it around so quickly, but it’s very rough. There are some especially hacky things in there with the images and MP lookup, we might kindly describe it as stream-of-consciousness Python. If I’m lucky, perhaps it’ll get upgraded to heritage status one day.

Everyone presented their hacks at the end of the day, and I was delighted to win a prize from MySociety. It was an honour to give something back and have Tom Steinberg recognise my contribution. MySociety’s projects were a huge influence and inspiration to me when I first saw them, back in the early 2000s when I was reading NTK and writing Perl scripts for a living.


Thanks to everyone I met at the event, Amy Whitney for giving me a hand with the design, and the teams from Rewired State, MySociety, the Taxpayers’ Alliance and Government Digital Service a great day.

Update Alex Pestell has built a Chrome extension that uses some of my code.

Nice one Alex!