Are there any APIs where I can look up a UK Member of Parliament and/or Parliamentary constituency using a postcode or address?

asked 11 Dec '10, 15:52

psychemedia's gravatar image

psychemedia ♦♦
1.1k323961
accept rate: 11%

edited 11 Dec '10, 15:52


It looks like @pezholio's http://www.uk-postcodes.com/ returns the constituency from a postcode in a variety of formats, although the service is labelled as 'experimental'. The fields returned for a postcode are:

<result> 
    <postcode>B46  3LD</postcode> 
    <geo> 
        <lat>52.496788</lat> 
        <lng>-1.70681</lng> 
        <easting>420001</easting> 
        <northing>288805</northing> 
        <geohash>http://geohash.org/gcqf9htpuqw4</geohash> 
    </geo> 
    <administrative> 
        <constituency> 
            <title>North Warwickshire</title> 
            <uri>http://statistics.data.gov.uk/id/parliamentary-constituency/323</uri> 
            <code>323</code> 
        </constituency> 
        <county> 
            <title>Warwickshire</title> 
            <uri>http://statistics.data.gov.uk/id/local-authority/44</uri> 
            <snac>44</snac> 
        </county> 
        <electoral-district> 
            <title>Coleshill</title> 
            <uri>http://data.ordnancesurvey.co.uk/doc/7000000000010112</uri> 
            <code>7000000000010112</code> 
        </electoral-district> 
        <district> 
            <title>North Warwickshire Borough Council</title> 
            <uri>http://statistics.data.gov.uk/id/local-authority/44UB</uri> 
            <snac>44UB</snac> 
        </district> 
        <ward> 
            <title>Coleshill South</title> 
            <uri>http://statistics.data.gov.uk/id/electoral-ward/44UBGC</uri> 
            <snac>44UBGC</snac> 
        </ward> 
    </administrative> 
</result>

The data can be returned in the fomats XML, CSV, JSON or RDF by adding .xml, .csv, .json or .rdf as the suffix to a root URL such as http://www.uk-postcodes.com/postcode/MK76AA

link

answered 11 Dec '10, 16:09

psychemedia's gravatar image

psychemedia ♦♦
1.1k323961
accept rate: 11%

TheyWorkForYou has an API that returns JSON data including an MP's name and and the name of the constituency: http://www.theyworkforyou.com/api/docs/getMP (a key is required to use the API).

The returned data takes the form:

{ "member_id" : "40404", "house" : "1", "first_name" : "Iain", "last_name" : "Stewart", "constituency" : "Milton Keynes South", "party" : "Conservative", "entered_house" : "2010-05-06", "left_house" : "9999-12-31", "entered_reason" : "general_election", "left_reason" : "still_in_office", "person_id" : "24947", "title" : "", "lastupdate" : "2010-05-07 07:23:48", "full_name" : "Iain Stewart", "url" : "/mp/iain_stewart/milton_keynes_south", "image" : "/images/mpsL/24947.jpeg", "image_height" : 118, "image_width" : 78 }

I think the "member_id" is a local id within the TheyWorkForYou context?

link

answered 11 Dec '10, 15:55

psychemedia's gravatar image

psychemedia ♦♦
1.1k323961
accept rate: 11%

Maybe off topic, but you can get a list of MPs voted in at any general election that includes the name of their constituency using the Guardian politics API. There's no API key but I don't know how open the data it - the results come with a copyright notice and link to Ts & Cs for example...

Queries for the JSON response take the form: http://www.guardian.co.uk/politics/api/general-election/2010/results/json and the data includes the name of the MP and the name of constituency, as well as what are presumably Guardian internal identifiers for each referered to as their aristotle-id

link

answered 11 Dec '10, 18:01

psychemedia's gravatar image

psychemedia ♦♦
1.1k323961
accept rate: 11%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×4
×2

Asked: 11 Dec '10, 15:52

Seen: 893 times

Last updated: 11 Dec '10, 18:01

powered by OSQA