Member query engine API

Contents

Overview
Back to top

This API can be used to query the data platform for an XML list of Members who meet the set of criteria supplied. The query criteria available to run searches against are fairly comprehensive, but they are simple to understand and this engine is the by far fastest and easiest way to access results when only basic Member information is required.

For the times when more detailed data is needed but whilst the query to run remains simple enough not to require the complexity and development skill needed to utilise the open data platform, the API supports a wide variety of additional data ranging from one subset of information through to a full biographical overview of a Member.

Please bear in mind that the more data that is requested by the consumer, the slower the response from the service.

URL structure
Back to top

To access the service in this environment, the following URL is required: http://data.parliament.uk/membersdataplatform/services/mnis/members/query/{search criteria}/{outputs}

The parameter {search criteria} is mandatory, the data passed to it is used by the engine to return a list of Members meeting the criteria specified. The parameter {outputs} is optional, it is used to control the amount of data returned for each Member. If this parameter is not set, then the basic schema will be used. For a full list of values supported by the {outputs} parameter see here.

Search criteria options
Back to top

The following table lists all of the criteria available to pass to the API in the {search criteria} parameter. To build up a list of criteria, which the query engine will aggregate with the boolean AND operator, simply create a pipe delimited string of the criteria you wish to use.

Two operators are available to most types of search criteria, the equals (=) symbol performs an exact match on the query specified, whereas the asterisk (*) symbol instructs the query engine to perform a more flexible query, the exact function of the asterix operator varies from critierion to criterion and is explained in the table.

The correct syntax to pass to the API for a criterion is in the form parameter, operator, value (e.g. house=lords or name*smith). Parameters and values are case-insensitive. Some other example calls to the service are given here. It is also possible to pass integer identity values to certain parameters. If this is the case then it will be indicated in the table. To access the information needed to use an identifier please use the reference data service.

By default, all queries executed will only return current Members of either House. If, for example, a request is made with the criterion house*Commons, the response will include all current Members of the House of Commons, plus all current Members of the House of Lords who previously sat in the Commons. In order to receive all Members ever of the House of Commons, it is necessary to add the criterion membership=all. This will tell the query engine to include prior Members in the query results. This will be done automatically in a small number of cases (e.g. when using Member Id field). However in most cases it is necessary to include in the search criteria like any other item. Including the parameter when it is automatically added has no detrimental effect.

Search criteria has been grouped for easy reference into the following categories

Criteria to search on personal information

In addition to the below, it is also possible to add criteria to search on a Members' age. The parameter is age and the engine will recognise the standard comparison operatiors, <=, <, >=, > and =.

Parameter Id? Equals operator behaviour Asterisk operator behaviour Example usage Example explanation
id N Members' Name system unique identifier. Not supported. id=12345 Returns A Member whose unique identifier in the system is 12345.
refDods N Lookup on a Members Dods reference number. Not supported. refDods=12345 Returns A Member whose reference in the Dods system is 12345.
gender N A Members' gender (M or F). Not supported. gender=M Male Members.
namesw N Members' name (by default Commons Members) starts with the characters supplied. Not supported. namesw=A Members whose surname starts with the letter A (Commons Members only will be returned unless a House parameter is also included in the query).
titlesw N Members' title (i.e. Members of the House of Lords) starts with the characters supplied. Not supported. titlesw=A Members whose title starts with the letter A.
name N A Members' full preferred name. Searches for preferred names (Commons Members) containing the value specified. name=David Smith
name*Smith
Members whose preferred name is David Smith, or in the asterisk example, contains the word Smith (e.g. Smithson - Commons Members only will be returned unless a House parameter is also included in the query).
title N A Members' title (how a member is addressed, used instead of name in the House of Lords). Searches for titles containing the value specified. title=Lord Black of London
title*Black
Members whose title is Lord Black of London, or in the asterisk example, contains the word Black (e.g. Blackburn).
nametitle N A Members' salutatory title (Mr/Mrs etc... Commons Members only). Not supported. nametitle=Mrs Members with the salutatory title Mrs.
forename N A Members' current forename. Includes all forenames A Member has been known by historically. forename=David
forename*David
Members whose current forename is David, or in the asterisk example, has ever been called David.
surname N A Members' current surname. Includes all surnames A Member has been known by historically. surname=Smith
surname*Smith
Members whose current surname is Smith, or in the asterisk example, has ever been called Smith.
rank Y A Members' current rank (e.g Lord, Viscount). Includes all ranks A Member has held. rank=Lord
rank*Lord
Members whose current rank is Lord, or in the asterisk example, has ever held the rank Lord.
honprefix Y A Members' current honourary prefixes. Includes all honourary prefixes A Member has held historically. honprefix=Right Honourable
honprefix*Right Honourable
Members who are currently Right Honourable, or in the asterisk example, have ever been Right Honourable.
biographycategory Y Members having one or more biographical interests in the specified category. Not supported. biographycategory=Foreign Affairs Members with one or more interests in the biography category Foreign Affairs.
biographyinterest N Members with the specified interest. Not supported. biographyinterest=Africa Members with an interest in Africa.
experiencetype Y Members having experience one in the specified area. Not supported. experiencetype=Non Political Life Members with experience in one or more areas of Non Political areas.
experience N Members with the specified experience. Not supported. experience=company director Members who have been a company director.
honour Y Members holding the specified honour. Members who have held the honour now or in the past. honour=KBE
honour*KBE
Members with a KBE, or current and previous holders of the honour.
living N Whether a Member is alive or not. Not supported. living=false Members who are now deceased.
interestcategory Y Members having one or more registered interests in the specified category. Not supported. interestcategoryid=1 Members with one or more interests in the interest category with the id of 1.
Back to criteria overview

Criteria to search on house membership information

Parameter Id? Equals operator behaviour Asterisk operator behaviour Example usage Example explanation
house Y The House a Member currently sits in. Includes previous House Memberships. house=Commons
house*Commons
Members who currently sit in the Commons, or in the asterisk example, have ever sat in the Commons.
fymp N Postcode lookup for a Members' constituency. Not supported. fymp=AA1 1AB Members with a constituency in the postcode AA1 1AB
party Y The party a Member currently has allegiance with. Includes previous party allegiances. party=Conservative
party*Conservative
Members who are currently aligned to the Conservative party, or in the asterisk example, have had allegience to the party in the past.
partysubtype Y The party sub-type a Member currently has allegiance to. Includes previous party sub-type allegiances. partysubtype=Coop
partysubtype*Coop
Members who are currently aligned to the Coop party sub type, or in the asterisk example, have had allegience to the party sub type in the past.
constituency Y The constituency a Member represents. Includes Members who previously represented a constituency. constituency=Eltham
constituency*Eltham
Member who currently represents Eltham, or in the asterisk example, have represented Eltham in the past.
constituencyinarea Y Members representing constituencies in a given area. Includes Members who represented the area in the past. constituencyinarea=England
partysubtype*Coop
Members who are currently represent an English constituency, or in the asterisk example, have done so in the past.
returnedatelection Y Members returned at the specified election. Not supported. returnedatelection=2010 General Election Members returned at the 2010 General Election.
lordsmembershiptype Y Lords Members of the specified type (e.g. Elected). Includes Members who have sat by that type of membership in the past. lordsmembershiptype=Elected
lordsmembershiptype*Elected
Members who currently sit as elected members of the House of Lords, or in the asterisk example, have done so in the past.
iseligible N Whether a Member is currently eligible to sit in either House. Not supported. iseligible=true Members eligible to sit
currentstatus Y Members with the specified current status. Not supported. currentstatus=Suspended Members currently suspended for any reason.
standingdown N Whether a Member is standing down at the next election. Not supported. standingdown=true Members standing down at the next election.
Back to criteria overview

Criteria to search on roles and posts held

Parameter Id? Equals operator behaviour Asterisk operator behaviour Example usage Example explanation
layingministername N Members with a laying minister name matching the criteria specifed. Members with a laying minister name containing the criteria specifed. layingministername=Prime Minister Current Prime Minister.
holdsgovernmentpost N Members holding a Government post. Members who have held a Government post now or in the past. holdsgovernmentpost=true Current Government post holders.
holdsoppositionpost N Members holding an Opposition post. Members who have held an Opposition post now or in the past. holdsoppositionpost=true Current Opposition post holders.
holdsparliamentarypost N Members holding a Parliamentary/Party post. Members who have held a Parliamentary/Party post now or in the past. holdsparliamentarypost=true Current Parliamentary/Party post holders.
governmentpost Y Members holding the specified Government post. Members who have held the specified Government post now or in the past. governmentpost=Chancellor of the Exchequer
governmentpost*Chancellor of the Exchequer
Current Chancellor of the Exchequer, or in the asterisk example, the current and previous holders of the post. NB. It is advised to use the id option for this criterion so as to avoid typographical errors.
oppositionpost Y Members holding the specified Opposition post. Members who have held the specified Opposition post now or in the past. oppositionpost=Shadow Chancellor of the Exchequer
oppositionpost*Shadow Chancellor of the Exchequer
Current Shadow Chancellor of the Exchequer, or in the asterisk example, the current and previous holders of the post. NB. It is advised to use the id option for this criterion so as to avoid typographical errors.
parliamentarypost Y Members holding the specified Parliamentary post. Members who have held the specified Parliamentary post now or in the past. parliamentarypost=Speaker
parliamentarypost*Speaker
Current Speaker, or in the asterisk example, the current and previous holders of the post. NB. It is advised to use the id option for this criterion so as to avoid typographical errors.
holdscabinetpost N Members holding a cabinet post. Members who have held a cabinet post now or in the past. holdscabinetpost=true Current cabinet post holders.
holdsshadowcabinetpost N Members holding a shadow cabinet post. Members who have held a shadow cabinet post now or in the past. holdsshadowcabinetpost=true Current shadow cabinet post holders.
committee Y Members sitting on the specified Committee. Members who have sat on the Committee now or in the past. committee=Administration
committee*Administration
Current members of the Administration Committee, or, current and previous members of the committee.
Back to criteria overview

Criteria to search on events and data based on dates

Parameter Id? Equals operator behaviour Asterisk operator behaviour Example usage Example explanation
deceaseddays N Members who have died in the number of days specified. Not supported. deceaseddays=90 Current or former Members who have died in the past 90 days. The membership=all parameter here will include former Members who have died, otherwise only Members who held a membership at time of death will be returned.
retireddays N Members who have retired in the number of days specified. Not supported. retireddays=90 Members who have died in the past 90 days.
leftdays N Members who have left the house for the (optional) reason given in the number of days specified. Not supported. leftdays=90
leftdays=90forResigned
Members who left the house in the last 90 days (optional for Resigned end reason).
joineddays N Members who have joined a house in the number of days specified. Not supported. joineddays=90 Members who have joined either house in the past 90 days.
oath N Members who have taken an oath in the number of days specified. Not supported. oathdays=90 Members who have taken an oath in the past 90 days.
maidenspeechdays N Members who have made their maiden speech in the number of days specified. Not supported. maidenspeechdays=90 Members who have made their maiden speech in the past 90 days.
deceasedsince N Members who have died since the date specified (YYYY-MM-DD format). Not supported. deceasedsince=2012-01-01 Current or former Members who have died since 1st January 2012. The membership=all parameter here will include former Members who have died, otherwise only Members who held a membership at time of death will be returned.
retiredsince N Members who have retired since the date specified (YYYY-MM-DD format). Not supported. retiredsince=2012-01-01 Members who have died since 1st January 2012.
leftsince N Members who have left the house for the (optional) reason since the date specified (YYYY-MM-DD format). Not supported. leftsince=2012-01-01
leftsince=2012-01-01forResigned
Members who left the house since 1st Jan 2012 (optional for Resigned end reason).
joinedsince N Members who have joined a house since the date specified (YYYY-MM-DD format). Not supported. joinedsince=2012-01-01 Members who have joined either house since 1st January 2012.
oath N Members who have taken an oath since the date specified (YYYY-MM-DD format). Not supported. oathsince=2012-01-01 Members who have taken an oath since 1st January 2012.
maidenspeechsince N Members who have made their maiden speech since the date specified (YYYY-MM-DD format) Not supported maidenspeechsince=2012-01-01 Members who have made their maiden speech since 1st January 2012
deceasedbetween N Members who have died between the dates specifed (pass in the format YYYY-MM-DDandYYYY-MM-DD). Not supported. deceasedbetween=2012-01-01and2012-03-31 Current or former Members who have died between 1st January 2012 and 31st March 2012. The membership=all parameter here will include former Members who have died, otherwise only Members who held a membership at time of death will be returned.
retiredbetween N Members who have retired between the dates specifed (pass in the format YYYY-MM-DDandYYYY-MM-DD). Not supported. retiredbetween=2012-01-01and2012-03-31 Members who have died between 1st January 2012 and 31st March 2012.
leftbetween N Members who have left the house for the (optional) reason between the dates specified (pass in the format YYYY-MM-DDandYYYY-MM-DD). Not supported. leftbetween=2012-01-01and2012-03-31
leftbetween=2012-01-01and2012-03-31forResigned
Members who left the house between 1st Jan 2012 and 31st March 2012 (optional for Resigned end reason).
joinedbetween N Members who have joined a house between the dates specifed (pass in the format YYYY-MM-DDandYYYY-MM-DD). Not supported. joinedbetween=2012-01-01and2012-03-31 Members who have joined either house between 1st January 2012 and 31st March 2012.
oath N Members who have taken an oath between the dates specifed (pass in the format YYYY-MM-DDandYYYY-MM-DD). Not supported. oathbetween=2012-01-01and2012-03-31 Members who have taken an oath between 1st January 2012 and 31st March 2012.
maidenspeechbetween N Members who have made their maiden speech between the dates specifed (pass in the format YYYY-MM-DDandYYYY-MM-DD). Not supported. maidenspeechbetween=2012-01-01and2012-03-31 Members who have made their maiden speech between 1st January 2012 and 31st March 2012.
lordsmemberbetween N Members who held a membership in the House of Lords between the dates specifed (pass in the format YYYY-MM-DDandYYYY-MM-DD). Not supported. lordsmemberbetween=2012-01-01and2012-03-31 Members who were Lords members between 1st January 2012 and 31st March 2012.
commonsmemberbetween N Members who held a membership in the House of Commons between the dates specifed (pass in the format YYYY-MM-DDandYYYY-MM-DD). Not supported. commonsmemberbetween=2012-01-01and2012-03-31 Members who were Commons members between 1st January 2012 and 31st March 2012.
heldcabinetpostbetween N Members who held a cabinet post between the dates specifed (pass in the format YYYY-MM-DDandYYYY-MM-DD). Not supported. heldcabinetpostbetween=2012-01-01and2012-03-31 Members who were in the cabinet between 1st January 2012 and 31st March 2012.
heldshadowcabinetpostbetween N Members who held a shadow cabinet post between the dates specifed (pass in the format YYYY-MM-DDandYYYY-MM-DD). Not supported. heldshadowcabinetpostbetween=2012-01-01and2012-03-31 Members who were in the shadow cabinet between 1st January 2012 and 31st March 2012.
Back to criteria overview

Data outputs
Back to top

Core schema

The API supports returning a variety of content for the search being performed. By default, a basic schema is used to return data and this core data will be returned regardless of what optional parameters are additionally requested. XML is returned in a parent node - Members with each record being contained in a Member node. An example output can be found here.

It is also possible to request a JSON output. To do this, simply add "application/json" in either the accept or content-type request header.

Additional data

It is possible to request additional data about the Members returned by a query. This additional data is requested in the {outputs} part of the URL must be supplied as a pipe delimited string made up of the options below. A maximum of 3 additional sets of data may be requested for any given call to the API.

For example, to get a list of committees for a member, the {outputs} section should be Committees (.../Committees). To get a list of committees and experiences, it would read Committees|Experiences (.../Committees|Experiences), and to get house memberships as well, Committees|Experiences|HouseMemberships (.../Committees|Experiences|HouseMemberships).

Where the additional data sets return data with start and end dates, it is possible to detect current/active pieces of data by querying for content where the EndDate element has a value of null (i.e. xml will be <EndDate xsi:nil="true"/>)

Please note the output type strings are case sensitive.

Output type Dataset supported Example XML
FullBiog Returns all data held about a Member. This will only be permitted on queries that return five records or fewer. All other output types return subsets of this data. Output
Addresses Member address information (e.g. website, twitter, consituency address etc...) Output
BasicDetails Basic information about the Member (e.g. given name, HoL membership type, oaths etc...). Output
BiographyEntries Member biographical information (e.g. countries of interest, policy expertise etc...). Output
Committees Committees a Member sits or has sat on as well details on committee chairing. Output
Constituencies Constituencies a Member has represented. Output
ElectionsContested Elections a Member has contested but not won. Output
Experiences Non-parliamentary experience of a Member. Output
GovernmentPosts Government posts a Member has held. Output
Honours Honours (e.g. MBE, OBE etc...) held by a Member. Output
HouseMemberships House membership list of a Member. Output
Interests Registered interests (financial) of a Member. Output
KnownAs Details of names a Member has chosen to be known as instead of their full title (HoL members only). Output
MaidenSpeeches Maiden speech dates for a Member. Output
OppositionPosts Opposition posts a Member has held. Output
OtherParliaments Other Parliaments that a Member has held a membership of. Output
ParliamentaryPosts Parliamentary posts a Member has held. Output
Parties Party affiliations of a Member. Output
PreferredNames Full set of data about a Members' name (e.g. surname, forename, Honorary prefixes, full details of HoL title and rank etc...) Output
Staff Staff employed by a Member. Output
Statuses Status history (e.g. suspensions and disqualifications) for a Member. Output

Sample queries
Back to top

Some example query urls are listed below along with an explanation of the dataset they will return. Simply click on the link to view the result of the query. These queries will return real data so are an excellent way to become familiar with the API and the XML it produces.

Query URL
Current Members of the House of Commons who are eligible to sit. http://data.parliament.uk/membersdataplatform/services/mnis/members/query/house=Commons|IsEligible=true
Current Members of the House of Lords who are eligible to sit, including full details on how to correctly write their title and rank http://data.parliament.uk/membersdataplatform/services/mnis/members/query/House=Lords|IsEligible=true/PreferredNames
Current Members of the House of Lords aged over 65. http://data.parliament.uk/membersdataplatform/services/mnis/members/query/House=Lords|Age>65
Current female Members of the House of Commons who are eligible to sit. http://data.parliament.uk/membersdataplatform/services/mnis/members/query/House=Commons|Gender=F|IsEligible=true
All Members of the House of Commons, current and historical. http://data.parliament.uk/membersdataplatform/services/mnis/members/query/House=Commons|Membership=all
Members of the House of Lords who have died in the past 90 days. http://data.parliament.uk/membersdataplatform/services/mnis/members/query/House=Lords|DeceasedDays=90
All Members currently representing constituencies in Kent. http://data.parliament.uk/membersdataplatform/services/mnis/members/query/House=Commons|ConstituencyInArea=Kent
All Members with a surname like Smith. http://data.parliament.uk/membersdataplatform/services/mnis/members/query/name*Smith
Male members of the Labour party under the age of 40, sitting in the Commons and the government or opposition posts they have held. http://data.parliament.uk/membersdataplatform/services/mnis/members/query/House=Commons|Party=Labour|Age<40/GovernmentPosts|OppositionPosts