# Uk Parliament Members Scraper (`b2b_lead_generation/uk-parliament-members-scraper`) Actor

Export details on UK MPs and Lords directly from official public records. Quickly search by name or house to pull membership status, parties, constituencies, and contact details. Download your complete datasets instantly in CSV, JSON, or Excel format.

- **URL**: https://apify.com/b2b_lead_generation/uk-parliament-members-scraper.md
- **Developed by:** [B2B Lead Generation](https://apify.com/b2b_lead_generation) (community)
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $2.99 / 1,000 results

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## UK Parliament Members Directory Scraper

<p align="center">
  <img src="https://imgur.com/enEMReT.png" alt="Uk Parliament Members" style="max-width:100%; border-radius:14px; width:680px;" />
</p>

Easily extract and export comprehensive directory listings of UK Members of Parliament (MPs) and Lords. This tool gathers names, political parties, constituencies, official roles, status details, and contact numbers smoothly and efficiently. You can export your clean datasets anytime into CSV, JSON, or Excel formats.

***

### What It Does

- **Directory Extraction**: Pulls comprehensive member records with customizable filters for house, name, and membership status.
- **Contact Inclusion**: Automatically fetches and attaches available contact numbers, postcodes, and office details when requested.
- **Flexible Runs**: Run quick searches or schedule regular updates to keep your records fresh and accurate.

***

### Use Cases

- **Constituency Lists**: Search by surname or filter to quickly export current House of Commons members.
- **Lords Offices**: Focus specifically on the House of Lords to gather parliamentary office details, phone numbers, and postal codes.
- **CRM Maintenance**: Set up scheduled runs to ensure your internal directories and contact lists stay current.
- **Historical Research**: Easily switch off the active filter to include former members who are no longer in office.

***

### Input Configuration

| Parameter | Type | Default | Description |
| --- | --- | --- | --- |
| `mode` | string | `members` | Choose between standard member extraction (`members`) or dedicated contact gathering (`contacts`). |
| `name` | string |  | Filter records by entering a specific name or keyword. |
| `house` | integer | `1` | Select the parliamentary house (`1` for Commons, `2` for Lords). |
| `isCurrentMember` | boolean | `true` | Restrict results to active, current members only. |
| `includeContacts` | boolean | `true` | Attach available phone and address details to member records. |
| `maxItems` | integer | `100` | Set a limit on the total number of successful rows saved (hard cap of 1000). |
| `timeoutSecs` | integer | `300` | Stop the run after this many seconds. |
| `requestTimeoutSecs` | integer | `30` | Timeout limit per individual request. |
| `proxyConfiguration` | object | `{"useApifyProxy": false}` | Optional proxy settings. |

#### Example Input

```json
{
  "mode": "members",
  "name": "smith",
  "house": 1,
  "isCurrentMember": true,
  "includeContacts": true,
  "maxItems": 100,
  "timeoutSecs": 300,
  "requestTimeoutSecs": 30,
  "proxyConfiguration": { "useApifyProxy": false }
}

```

***

### Output Structure & Fields

Every record saved in the dataset provides a structured object containing the following key details:

| Field | Type | Description |
| --- | --- | --- |
| `memberId` | integer | Unique identifier for each individual record. |
| `nameDisplayAs` | string | The official display name of the member. |
| `partyName` | string | The political party affiliation. |
| `constituency` | string | The represented constituency or membership classification. |
| `statusText` | string | Current operational status description. |
| `houseNumber` | integer | Indicates whether the member belongs to the Commons (`1`) or Lords (`2`). |
| `phone` | string | Primary contact telephone number retrieved. |
| `postcode` | string | Primary postal code associated with the office. |
| `scrapedAt` | string | Timestamp of when the record was processed. |

***

### Performance & Reliability

- **Smart Retries**: Temporary connection interruptions or rate limits are handled automatically with built-in retry logic and intelligent backoff intervals.
- **Duplicate Prevention**: Automatically filters and drops duplicate member IDs to keep your dataset clean.
- **Error Handling**: If an individual record encounters an issue, it logs a clean error row while allowing the rest of the run to proceed smoothly.

***

### Frequently Asked Questions

- **How many records can I export in one run?** The default limit is 100 items, with a maximum cap of 1,000 successful rows per execution.
- **Can I export my data to Excel or CSV?** Yes, you can easily download your final dataset in CSV, JSON, or Excel format directly from the platform.
- **What do house numbers represent?** House 1 corresponds to the House of Commons, and House 2 corresponds to the House of Lords.

***

### Is Web Scraping Legal?

Collecting publicly accessible information is generally permissible, but how you utilize the data matters:

- **Personal Data**: Depending on your jurisdiction (such as GDPR in Europe or CCPA in California), regulations may govern how you store and process personal information like names and contact details. Ensure you have a valid purpose and legal basis for collection.
- **Copyright & Content**: Respect intellectual property rights and avoid republishing protected materials without proper authorization.
- **Terms & Guidelines**: Always follow best practices, respect rate guidelines, and adhere to appropriate attribution requirements.
- **Legal Guidance**: This overview is for informational purposes and does not constitute legal counsel. Consult a qualified professional if you have specific legal questions.

# Actor input Schema

## `mode` (type: `string`):

members returns one row per person from Members Search. contacts follows each person with a contact request.

## `name` (type: `string`):

Optional name filter sent as the Search Name parameter. Leave blank to list the selected house.

## `house` (type: `integer`):

House filter on Members Search. 1 is Commons, 2 is Lords.

## `isCurrentMember` (type: `boolean`):

When true, Search keeps current members. When false, former members are included.

## `includeContacts` (type: `boolean`):

On members runs, also request each person's contact record and store it on the row. Contact mode always requests contacts.

## `maxItems` (type: `integer`):

Maximum successful rows to save. Hard cap is 1000.

## `timeoutSecs` (type: `integer`):

Stop the run after this many seconds and write an error row if work is still unfinished.

## `requestTimeoutSecs` (type: `integer`):

Seconds to wait for each Members API response before retrying.

## `proxyConfiguration` (type: `object`):

Optional proxy. Leave useApifyProxy false. The public Members API is called directly unless you opt in.

## Actor input object example

```json
{
  "mode": "members",
  "name": "smith",
  "house": 1,
  "isCurrentMember": true,
  "includeContacts": true,
  "maxItems": 100,
  "timeoutSecs": 300,
  "requestTimeoutSecs": 30,
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}
```

# Actor output Schema

## `dataset` (type: `string`):

No description

## `datasetUrl` (type: `string`):

No description

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "name": "smith"
};

// Run the Actor and wait for it to finish
const run = await client.actor("b2b_lead_generation/uk-parliament-members-scraper").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = { "name": "smith" }

# Run the Actor and wait for it to finish
run = client.actor("b2b_lead_generation/uk-parliament-members-scraper").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "name": "smith"
}' |
apify call b2b_lead_generation/uk-parliament-members-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,b2b_lead_generation/uk-parliament-members-scraper"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/e8EptMF9e4nZhZ76b/builds/gneuPNCv6xvP4dWkT/openapi.json
