Introduction to mnis

mnis is an R package to pull data from the UK parliament through the Members' Name Information Service API, with the ability to tidy that data into object classes that are easy to work with in R. It emphasises simplicity and ease of use, so that users unfamiliar with APIs can easily retrieve large volumes of high quality data. The Members' Name Information Service API does not require registration or a token, and is very generous with the number of requests allowed (it is unclear what limits are applied to the API, but I have yet to hit the limit, aside from custom requests using mnis_base().)

mnis is for researchers, journalists and developers who follow the UK parliament for work, pleasure or some combination thereof. It has a sister package called hansard that retrieves data from a different API, and while there is some overlap in function between the two packages, mnis is focused on retrieving data on individual MPs and Peers, government departments, cabinet and shadow cabinet positions, other parliamentary and political roles, and parliamentary reference data.

All functions requests data in JSON format and parse it to a tibble, except for mnis_constituency_results() which returns a list (with constituency details) and a tibble (with constituency election results).

Functions are divided into four main types:

There is also the mnis_base() function that allows for fully flexibility in all API requests, by allowing you to fully specify the URL you want to call data from.

Installing mnis

From CRAN

install.packages("mnis")

From GitHub (Development Version)

install.packages("devtools")
devtools::install_github("EvanOdell/mnis")

Load mnis

library(mnis)

Using mnis

All mnis functions contain two parameters, tidy and tidy_style:

mnis_base function

The mnis_base() function accepts requests to the mnis API. The full list of request options is available on the mnis website: http://data.parliament.uk/membersdataplatform/memberquery.aspx

Reference Functions

A series of functions to return reference data. This data is useful for providing parameters for other function calls. These functions do not accept any arguments.

ref_address_types()

ref_answering_bodies()

ref_areas()

ref_area_types()

ref_biography_categories()

ref_cabinets()

ref_committees()

ref_committee_types()

ref_constituencies()

ref_constituency_areas()

ref_constituency_types()

ref_countries()

ref_departments()

ref_disqualification_types()

ref_elections()

ref_election_types()

ref_end_reasons()

ref_experience_types()

ref_government_post_departments()

ref_government_posts()

ref_government_ranks()

ref_honourary_prefixes()

ref_honour_lists()

ref_honours()

ref_interest_categories()

ref_lords_membership_types()

ref_lords_ranks()

ref_opposition_post_departments()

ref_opposition_posts()

ref_opposition_ranks()

ref_other_parliaments()

ref_parliamentary_posts()

ref_parliamentary_ranks()

ref_parliament_types()

ref_parties()

ref_party_sub_types()

ref_photo_outputs()

ref_statuses()

ref_titles()

library(mnis)
x <- ref_titles(tidy = FALSE)
x

With the tidy parameter

library(mnis)
x <- ref_titles(tidy = TRUE)
x

Additional Information Functions

mnis_additional()

mnis_addresses()

mnis_basic_details()

mnis_biography_entries()

mnis_committees()

mnis_constituencies()

mnis_elections_contested

mnis_experiences()

mnis_government_posts()

mnis_honours()

mnis_house_memberships()

mnis_interests()

mnis_known_as()

mnis_maiden_speeches()

mnis_mps_on_date()

mnis_opposition_posts()

mnis_other_parliaments()

mnis_parliamentary_posts()

mnis_parties()

mnis_preferred_names()

mnis_staff()

mnis_statuses()

mnis_peers_on_date()

mnis_extra()

The mnis_extra() function acts as a wrapper to the additional information functions. By default it calls all functions, which is equivalent to mnis_full_biog().

Fixed Scope Functions

There are seven fixed scope functions that return ready-made datasets. They are:

mnis_party_state()

mnis_constituency_results()

mnis_department()

mnis_general_election_results()

mnis_lords_type()

mnis_member_date()

mnis_party_state()

Fixed Scope Example

Fixed scope example, returning the state of all parties in the House of Commons, as reported on 2017-04-04.

library(mnis)
x <- mnis_party_state("2017-04-04")
x

The same fixed scope function, returning the state of all parties in the House of Lords, as reported on 2017-04-04.

 y <- mnis_party_state("Lords", "2017-04-04")
 y


Try the mnis package in your browser

Any scripts or data that you put into this service are public.

mnis documentation built on April 4, 2021, 1:06 a.m.