Skip to main content

UK Parliament API Client

Project description

PyPI version Build Status

A client for the UK Parliament API. Python 3 only, contributions welcome.

Currently supports:

  • Commons and Lords divisions
  • Commons and Lords membership
  • Early Day Motions


The package can be installed in the usual way with pip:

pip install ukparliament


Firstly, import and create the client:

>>> from ukparliament import Parliament
>>> parliament = Parliament()

Getting membership of houses:

>>> mps = parliament.commons.members.current()
>>> len(mps)

Lists of members can be broken down by party, but otherwise behave as normal Python lists:

>>> mps.by_party()
{<Party "Labour Party">: 257,
 <Party "Conservative Party">: 315,
 <Party "Scottish National Party">: 35,
 <Party "Sinn Féin">: 7,
 None: 1,
 <Party "Liberal Democrats">: 12,
 <Party "Democratic Unionist Party">: 10,
 <Party "Plaid Cymru">: 4,
 <Party "Independent">: 8,
 <Party "Green Party">: 1}

Fetching divisions for a house:

>>> divisions = parliament.commons.recent_divisions(limit=4)
>>> division = divisions[0]
>>> division
<Commons division: "draft Double Taxation Relief and International Tax Enforcement (Jersey) Order 2018" on 2018-11-21>

Divisions contain vote totals:

>>> division.ayes, division.noes, division.passed
(302, 238, True)

You can also get the full lists of who voted:

>>> division.votes['aye'].by_party()
{<Party "Conservative Party">: 293,
 <Party "Independent">: 3,
 <Party "Democratic Unionist Party">: 6}

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for ukparliament, version 0.6
Filename, size File type Python version Upload date Hashes
Filename, size ukparliament-0.6-py3-none-any.whl (7.8 kB) File type Wheel Python version py3 Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page