Mapping UK Politicians and their Financial Interests

When I set up Know Your Sanctions I wanted users to both identify political actors in the UK and their financial interests.

By combining the UK Parliament’s list of MPs with the Register of Members Financial Interest dataset, I was able to enrich the data on politicians.

Collect PEP data

When gathering data on politically exposed persons, a good place to start is always the country’s legislative assembly.

Fortunately, the British Parliament has an API that makes gathering basic data on members of the House of Commons and the House of Lords easier.

I know from the documentation that there are 1400 entries and set up my parameters:

base_url = 'https://members-api.parliament.uk/api/Members/Search'
skip = 0
take = 20
total_entries = 1400
all_members = []

We gather our data in a a while statement that sends an API request until all 1400 entries have been collected.

If we recieve a valid response, we save the data from each json response to my members varaible that is then appended to my all_members list.

while skip < total_entries:    
    url = f'{base_url}?skip={skip}&take={take}'
    response = requests.get(url)    
    if response.status_code == 200:        
        try:
            data = response.json()
            members = data['items']
            all_members.extend(members)
            skip += take        
        except (json.JSONDecodeError, KeyError) as e:            
            print("Error parsing JSON:", str(e))
            break    
    else:        
        print("Error:",response.status_code)        
    break

Our data is now stored in our all_members list. This list is a list of dictionaries that we can write to a csv.

Enrich PEP data

Details about the financial interests of Members of the House of Commons and the House of Lords is available as a csv on Members Interest. What’s great about Members Interest is that they have indexed the Register of Members Financial Interests.

The main purpose of the Register is to provide information about any financial interest which a Member has, or any benefit which he or she receives, which others might reasonably consider to influence his or her actions or words as a Member of Parliament.

The Register of Members Financial Interest is really useful as it contains:

  1. Who donors are and how much they donated
  2. The Employment and earnings of peers
  3. Visits outside the UK made by peers, to whom they travelled, where they stayed, costs and the purpose of their visit
  4. Miscellaneous data on gifts and hospitality

With these data points, we can work out the habits and connections of our politically exposed person. It tells us about their employment, salary, who they worked for, where they’ve been, who donates to whom and why and why our MPs go abroad.

What’s great is that the register is updated every 28 days and it goes back many years, meaning we have a good understanding of the different interests that our peers have.

How to enrich our PEP data?

Since the financial interest data comes as a csv, all we need to do is download the csv and merge the data with our file on MPs and Lords in order to enrich our PEP profiles.