# Hansard UK Parliament Debates Scraper (`parseforge/hansard-uk-debates-scraper`) Actor

Export the official transcripts of UK Parliament debates and speeches from Hansard. Filter by House (Commons or Lords), search term, member, and date range. Each record includes the full speech text, speaker, debate section, and a permalink to the official Hansard transcript.

- **URL**: https://apify.com/parseforge/hansard-uk-debates-scraper.md
- **Developed by:** [ParseForge](https://apify.com/parseforge) (community)
- **Categories:** Business, Automation, Other
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, NaN bookmarks
- **User rating**: No ratings yet

## Pricing

from $23.63 / 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/platform/actors/running/actors-in-store#pay-per-event

## What's an Apify Actor?

Actors are a software tools running on the Apify platform, for all kinds of web data extraction and automation use cases.
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.
Actors are written with capital "A".

## 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.
The best way to integrate Actors is as follows.

In JavaScript/TypeScript projects, use official [JavaScript/TypeScript client](https://docs.apify.com/api/client/js.md):

```bash
npm install apify-client
```

In Python projects, use official [Python client library](https://docs.apify.com/api/client/python.md):

```bash
pip install apify-client
```

In shell scripts, use [Apify CLI](https://docs.apify.com/cli/docs.md):

````bash
# MacOS / Linux
curl -fsSL https://apify.com/install-cli.sh | bash
# Windows
irm https://apify.com/install-cli.ps1 | iex
```bash

In AI frameworks, you might use the [Apify MCP server](https://docs.apify.com/platform/integrations/mcp.md).

If your project is in a different language, use the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).


# README

![ParseForge Banner](https://github.com/ParseForge/apify-assets/blob/main/banners/banner-default.jpg?raw=true)

## 🗣️ Hansard UK Parliament Debates Scraper

> 🚀 **Export UK Parliament debate transcripts in seconds.** Pull every spoken contribution from the **House of Commons and House of Lords**, filtered by topic, member, date, or department. Each record is a clean structured speech with full text, speaker, debate section, and a permalink to the official Hansard transcript. No sign-up, no manual paging, no parser to maintain.

> 🕒 **Last updated:** 2026-05-15 · **📊 17 fields** per record · **🗣️ Millions of contributions** · **📜 250+ years of debates** · **🇬🇧 Both Houses**

The **Hansard UK Parliament Debates Scraper** queries the official Hansard transcript catalogue and returns up to **17 structured fields per record**, including the contribution ID, speaker name and member ID, House, debate section, sitting date, full speech text, word count, ordering metadata, and a deep permalink back to the official Hansard page.

The catalogue covers **the official record of every spoken contribution in the UK Parliament**, including ministerial statements, backbench speeches, oral questions, urgent questions, statements, and full debates. Hansard has tracked the proceedings of the UK Parliament since 1803 and is the canonical record cited by historians, journalists, and political researchers.

| 🎯 Target Audience | 💡 Primary Use Cases |
|---|---|
| Political analysts and researchers, journalists, NLP and machine-learning teams, public-affairs and lobbying firms, civic-tech projects, academic political scientists, content creators | Speech and rhetoric analysis, member voting-context research, topic mining, NLP training corpora, ministerial statement monitoring, lobbyist due diligence, civic-tech transparency tools |

---

### 📋 What the Hansard UK Debates Scraper does

Six filtering workflows in a single run:

- 🔎 **Free-text search.** Match a keyword or phrase across every spoken contribution (e.g. "climate change", "NHS funding", "AUKUS").
- 🏛️ **House filter.** Restrict to House of Commons, House of Lords, or both.
- 👤 **Member filter.** Substring match on the speaker name (e.g. "Keir Starmer", "Lord Hannan").
- 📅 **Date range.** Scope to any sitting-date window with `startDate` and `endDate`.
- 🏛️ **Department filter.** Substring match on the responsible government department (e.g. "Treasury", "Department for Education").
- 🔢 **Page-driven sample.** Pull the latest contributions across all topics when no query is set.

Each record includes the contribution ID, the member's name and (when available) their member ID, the House, the section ("Commons Chamber", "Westminster Hall", etc.), the debate section title, the Hansard internal section code, the sitting date, the timecode of the contribution, the full speech text (HTML preserved), a word count, the order in the debate, the paragraph tag, and a deep permalink back to the official Hansard transcript page.

> 💡 **Why it matters:** Hansard transcripts power policy analysis, NLP corpora, civic transparency, and political journalism. Building your own pipeline means writing a paginated client, mapping debate identifiers to permalinks, normalising HTML across sittings, and refreshing daily. This Actor skips all of that and gives you a clean refreshed snapshot on every run.

---

### 🎬 Full Demo

_🚧 Coming soon: a 3-minute walkthrough showing how to go from sign-up to a downloaded Hansard dataset._

---

### ⚙️ Input

<table>
<thead>
<tr><th>Input</th><th>Type</th><th>Default</th><th>Behavior</th></tr>
</thead>
<tbody>
<tr><td><code>searchTerm</code></td><td>string</td><td><code>""</code></td><td>Keyword or phrase to search across UK Parliament transcripts. Empty = most recent contributions across all topics.</td></tr>
<tr><td><code>house</code></td><td>string</td><td><code>"Both"</code></td><td>One of <code>Both</code>, <code>Commons</code>, or <code>Lords</code>.</td></tr>
<tr><td><code>memberName</code></td><td>string</td><td><code>""</code></td><td>Substring match on the speaker name.</td></tr>
<tr><td><code>startDate</code></td><td>string</td><td><code>""</code></td><td>Earliest sitting date (YYYY-MM-DD).</td></tr>
<tr><td><code>endDate</code></td><td>string</td><td><code>""</code></td><td>Latest sitting date (YYYY-MM-DD).</td></tr>
<tr><td><code>department</code></td><td>string</td><td><code>""</code></td><td>Substring match on the responsible department.</td></tr>
<tr><td><code>maxItems</code></td><td>integer</td><td><code>10</code></td><td>Records to return. Free plan caps at 10, paid plan at 1,000,000.</td></tr>
</tbody>
</table>

**Example: every Commons contribution mentioning "Heathrow" since 2026-01-01.**

```json
{
    "maxItems": 200,
    "searchTerm": "Heathrow",
    "house": "Commons",
    "startDate": "2026-01-01"
}
````

**Example: latest 50 contributions by Keir Starmer in either House.**

```json
{
    "maxItems": 50,
    "memberName": "Keir Starmer"
}
```

> ⚠️ **Good to Know:** the `text` field preserves the original Hansard markup, including column-number `<span>` tags and inline subscripts. That keeps the record faithful to the official transcript. If you need plain-text, strip HTML downstream once.

***

### 📊 Output

Each contribution record carries up to **17 fields**. Download the dataset as CSV, Excel, JSON, or XML.

#### 🧾 Schema

| Field | Type | Example |
|---|---|---|
| 🆔 `contributionId` | string | `"0D8CEA45-19F1-4BF6-83D3-6688C26C01B9"` |
| 👤 `memberName` | string | `"Sarah Olney"` |
| 👤 `attributedTo` | string | `"Sarah Olney"` |
| 🆔 `memberId` | number | `4591` |
| 🏛️ `house` | string | `"Commons"` |
| 📂 `section` | string | `"Commons Chamber"` |
| 📂 `debateSection` | string | `" Heathrow Airport: Third Runway"` |
| 🆔 `debateSectionId` | string | `"15106B6A-3101-426D-89E3-0544452BD096"` |
| 📂 `hansardSection` | string | `"CP-CR1"` |
| 📅 `sittingDate` | YYYY-MM-DD | `"2026-05-14"` |
| 🕒 `timecode` | string | `"2026-05-14T15:03:57"` |
| 📝 `text` | string | `"The hon. Gentleman is absolutely right that we need to see the economic case..."` |
| 🔢 `wordCount` | number | `806` |
| 🔢 `orderInDebate` | number | `6` |
| 🏷️ `paragraphTag` | string | `"hs_Para"` |
| 🔗 `url` | string | `"https://hansard.parliament.uk/Commons/2026-05-14/debates/.../HeathrowAirport%3AThirdRunway#contribution-..."` |
| 🕒 `scrapedAt` | ISO 8601 | `"2026-05-15T20:10:51.113Z"` |

#### 📦 Sample record

<details>
<summary><strong>🗣️ Commons speech: Sarah Olney on the Heathrow third runway debate</strong></summary>

```json
{
    "contributionId": "0D8CEA45-19F1-4BF6-83D3-6688C26C01B9",
    "memberName": "Sarah Olney",
    "attributedTo": "Sarah Olney",
    "memberId": 4591,
    "house": "Commons",
    "section": "Commons Chamber",
    "debateSection": " Heathrow Airport: Third Runway",
    "debateSectionId": "15106B6A-3101-426D-89E3-0544452BD096",
    "hansardSection": "CP-CR1",
    "sittingDate": "2026-05-14",
    "timecode": "2026-05-14T15:03:57",
    "text": "The hon. Gentleman is absolutely right that we need to see the economic case and to look at it in the round - not just the specific costs associated with building the runway, but all the additional costs associated with operating it at capacity ...",
    "wordCount": 806,
    "orderInDebate": 6,
    "paragraphTag": "hs_Para",
    "url": "https://hansard.parliament.uk/Commons/2026-05-14/debates/15106B6A-3101-426D-89E3-0544452BD096/HeathrowAirport%3AThirdRunway#contribution-0D8CEA45-19F1-4BF6-83D3-6688C26C01B9",
    "scrapedAt": "2026-05-15T20:10:51.113Z"
}
```

</details>

***

### ✨ Why choose this Actor

| | Capability |
|---|---|
| 🗣️ | **Both Houses, full text.** Spoken contributions from Commons and Lords with the complete speech body. |
| 🎯 | **Multi-dimensional filters.** Search term, House, member, date range, and department combine freely. |
| 🔗 | **Permalinks per row.** Every record links back to the canonical Hansard page anchor for citation. |
| 📜 | **Historic depth.** Indexed transcripts spanning decades of UK parliamentary debate. |
| ⚡ | **Fast.** 100 contributions in seconds, 10,000 records in a few minutes. |
| 🔁 | **Always fresh.** Every run hits the live transcript catalogue, so the dataset reflects the latest sittings. |
| 🚫 | **No authentication.** Public open-government data. No login needed. |

> 📊 Searchable Hansard transcripts are the foundation of every political-journalism dashboard, NLP corpus on UK politics, and lobbyist briefing pack.

***

### 📈 How it compares to alternatives

| Approach | Cost | Coverage | Refresh | Filters | Setup |
|---|---|---|---|---|---|
| **⭐ Hansard UK Debates Scraper** *(this Actor)* | $5 free credit, then pay-per-use | **Both Houses, full text** | **Live per run** | search term, House, member, date, department | ⚡ 2 min |
| Commercial parliamentary monitoring | $10k - $80k/year | Comparable + voting records | Daily | Many | 🐢 Weeks (procurement) |
| TheyWorkForYou scraping | Free | Commons-leaning, derived | Daily | Few | 🕒 Days |
| Manual hansard.parliament.uk browsing | Free | Whole catalogue | Live | Site-side | ⏳ Forever |

Pick this Actor when you want structured speech-level records with permalinks and zero pipeline maintenance.

***

### 🚀 How to use

1. 📝 **Sign up.** [Create a free account w/ $5 credit](https://console.apify.com/sign-up?fpr=vmoqkp) (takes 2 minutes).
2. 🌐 **Open the Actor.** Go to the Hansard UK Parliament Debates Scraper page on the Apify Store.
3. 🎯 **Set input.** Type a search term or member name, optionally pick a House and date range, and set `maxItems`.
4. 🚀 **Run it.** Click **Start** and let the Actor collect your contributions.
5. 📥 **Download.** Grab your dataset in the **Dataset** tab as CSV, Excel, JSON, or XML.

> ⏱️ Total time from signup to a downloaded Hansard dataset: **3-5 minutes.** No coding required.

***

### 💼 Business use cases

<table>
<tr>
<td width="50%" valign="top">

#### 🏛️ Public Affairs & Lobbying

- Monitor every mention of your client's industry across Parliament
- Build briefing packs from a member's recent contributions
- Track ministerial statements by department
- Surface debate momentum on niche policy areas

</td>
<td width="50%" valign="top">

#### 📰 Political Journalism

- Search every Commons speech for a specific quote
- Trace how a policy has been debated over years
- Build interactive dashboards of speech topics
- Cross-reference Hansard with member directory data

</td>
</tr>
<tr>
<td width="50%" valign="top">

#### 🤖 NLP & Machine Learning

- Train domain-specific UK political language models
- Build topic-classification corpora with member metadata
- Sentiment analysis on individual MPs over time
- Question-answering systems that cite primary sources

</td>
<td width="50%" valign="top">

#### 📊 Civic Analytics & Research

- Quantitative speech-pattern studies for academic papers
- Word-frequency tracking on policy themes per session
- Comparative analysis of Commons vs Lords language
- Public dashboards showing debate volume by topic

</td>
</tr>
</table>

***

### 🔌 Automating Hansard Scraper

Control the scraper programmatically for scheduled runs and pipeline integrations:

- 🟢 **Node.js.** Install the `apify-client` NPM package.
- 🐍 **Python.** Use the `apify-client` PyPI package.
- 📚 See the [Apify API documentation](https://docs.apify.com/api/v2) for full details.

The [Apify Schedules feature](https://docs.apify.com/platform/schedules) lets you trigger this Actor on any cron interval. Hourly or daily refreshes keep your political monitoring dashboards in sync with each new sitting.

***

### 🌟 Beyond business use cases

Open parliamentary transcripts power more than commercial workflows. The same structured records support research, education, civic projects, and personal initiatives.

<table>
<tr>
<td width="50%">

#### 🎓 Research and academia

- Quantitative discourse analysis for political-science theses
- Coursework on parliamentary procedure and rhetoric
- Reproducible debate corpora for NLP research papers
- Historical archives of policy framing over decades

</td>
<td width="50%">

#### 🎨 Personal and creative

- Side projects that visualise speech patterns by party
- Newsletters that summarise yesterday's notable contributions
- Word clouds of a session's most-debated topics
- Hobbyist explorations of parliamentary humour

</td>
</tr>
<tr>
<td width="50%">

#### 🤝 Non-profit and civic

- Civic-tech tools that surface debates on a topic to citizens
- Watchdog dashboards tracking member contribution rates
- Investigative journalism on lobbying-aligned speeches
- Accessibility projects that simplify parliamentary language

</td>
<td width="50%">

#### 🧪 Experimentation

- Train summarisation models on parliamentary debates
- Build agent pipelines that brief journalists on yesterday's speeches
- Prototype semantic-search tools across decades of debate
- Stress-test NLP infrastructure with real, long-form text

</td>
</tr>
</table>

***

### 🤖 Ask an AI assistant about this scraper

Open a ready-to-send prompt about this ParseForge actor in the AI of your choice:

- 💬 [**ChatGPT**](https://chat.openai.com/?q=How%20do%20I%20use%20the%20Hansard%20UK%20Debates%20Scraper%20by%20ParseForge%20on%20Apify%3F%20Show%20me%20input%20examples%2C%20output%20fields%2C%20common%20use%20cases%2C%20and%20how%20to%20integrate%20it%20into%20a%20workflow.)
- 🧠 [**Claude**](https://claude.ai/new?q=How%20do%20I%20use%20the%20Hansard%20UK%20Debates%20Scraper%20by%20ParseForge%20on%20Apify%3F%20Show%20me%20input%20examples%2C%20output%20fields%2C%20common%20use%20cases%2C%20and%20how%20to%20integrate%20it%20into%20a%20workflow.)
- 🔍 [**Perplexity**](https://perplexity.ai/search?q=How%20do%20I%20use%20the%20Hansard%20UK%20Debates%20Scraper%20by%20ParseForge%20on%20Apify%3F%20Show%20me%20input%20examples%2C%20output%20fields%2C%20common%20use%20cases%2C%20and%20how%20to%20integrate%20it%20into%20a%20workflow.)
- 🅒 [**Copilot**](https://copilot.microsoft.com/?q=How%20do%20I%20use%20the%20Hansard%20UK%20Debates%20Scraper%20by%20ParseForge%20on%20Apify%3F%20Show%20me%20input%20examples%2C%20output%20fields%2C%20common%20use%20cases%2C%20and%20how%20to%20integrate%20it%20into%20a%20workflow.)

***

### ❓ Frequently Asked Questions

#### 🧩 How does it work?

Type a search term, optionally pick a member or date window, click Start, and the Actor pages through the official Hansard transcript catalogue, applies your filters, and emits a clean structured row per spoken contribution. No browser automation, no captchas, no setup.

#### 📏 How accurate is the data?

Every record comes from the official Hansard catalogue used by hansard.parliament.uk itself, so the speech text, member, and debate references match the canonical record line for line.

#### 🔁 How often is the dataset refreshed?

Hansard is updated as sittings are transcribed and published, typically within hours of a debate. Every run hits the live catalogue.

#### 🏛️ Does it cover both Houses?

Yes. Set `house` to `Both` (default), `Commons`, or `Lords`.

#### 👤 Can I get every speech by a single MP or peer?

Yes. Set the `memberName` filter to a substring of their name (e.g. "Starmer", "Lord Hannan"). Combine with `startDate` and `endDate` for a session-bounded view.

#### 📅 How far back does the catalogue go?

The official Hansard archive runs back to the early 19th century, with full digital coverage of recent sessions and increasingly complete coverage going back decades.

#### 📝 Why does the speech text contain HTML tags?

The `text` field preserves Hansard's original markup (column-number `<span>`s, inline subscripts, paragraph anchors) so the record stays faithful to the official transcript. Strip HTML downstream if you need plain text.

#### ⏰ Can I schedule regular runs?

Yes. Use Apify Schedules to run this Actor on any cron interval (hourly during sittings, daily otherwise) and keep your political monitoring dashboards in sync.

#### ⚖️ Is this data legal to use?

Hansard transcripts are published under the Open Parliament Licence, which permits commercial reuse with attribution. Review the licence terms for your specific application.

#### 💼 Can I use this data commercially?

Yes. The Open Parliament Licence explicitly allows commercial reuse with attribution. You remain responsible for following the licence in your product.

#### 💳 Do I need a paid Apify plan to use this Actor?

No. The free Apify plan is enough for testing and small runs (10 records per run). A paid plan lifts the limit and gives you scheduling, higher concurrency, and larger datasets.

#### 🆘 What if I need help?

Our support team is here to help. Contact us through the Apify platform or use the Tally form linked below.

***

### 🔌 Integrate with any app

Hansard UK Debates Scraper connects to any cloud service via [Apify integrations](https://apify.com/integrations):

- [**Make**](https://docs.apify.com/platform/integrations/make) - Automate multi-step monitoring workflows
- [**Zapier**](https://docs.apify.com/platform/integrations/zapier) - Connect with 5,000+ apps
- [**Slack**](https://docs.apify.com/platform/integrations/slack) - Get debate-mention alerts in your channels
- [**Airbyte**](https://docs.apify.com/platform/integrations/airbyte) - Pipe transcripts into your warehouse
- [**GitHub**](https://docs.apify.com/platform/integrations/github) - Trigger runs from commits and releases
- [**Google Drive**](https://docs.apify.com/platform/integrations/drive) - Export datasets straight to Sheets

You can also use webhooks to trigger downstream actions when a run finishes. Push fresh transcripts into your NLP pipeline, or alert your political-research team in Slack.

***

### 🔗 Recommended Actors

- [**🏛️ UK Parliament Members Scraper**](https://apify.com/parseforge/members-uk-parliament-scraper) - MPs and Lords with biographies, committees, and contact details
- [**🇬🇧 GOV.UK Content Search Scraper**](https://apify.com/parseforge/govuk-content-search-scraper) - Search the entire UK government publications catalogue
- [**🛡️ OpenSanctions Sanctions & PEP Scraper**](https://apify.com/parseforge/opensanctions-entities-scraper) - Sanctioned entities and politically exposed persons
- [**⚡ Carbon Intensity UK Scraper**](https://apify.com/parseforge/carbon-intensity-uk-scraper) - National Grid carbon intensity feed
- [**📰 GovTrack U.S. Congress Scraper**](https://apify.com/parseforge/govtrack-scraper) - U.S. legislative bills and votes

> 💡 **Pro Tip:** browse the complete [ParseForge collection](https://apify.com/parseforge) for more reference-data scrapers.

***

**🆘 Need Help?** [**Open our contact form**](https://tally.so/r/BzdKgA) to request a new scraper, propose a custom data project, or report an issue.

***

> **⚠️ Disclaimer:** this Actor is an independent tool and is not affiliated with, endorsed by, or sponsored by the UK Parliament, the House of Commons, the House of Lords, or the Hansard Society. All trademarks mentioned are the property of their respective owners. Only publicly available open Hansard transcript data is collected, under the Open Parliament Licence.

# Actor input Schema

## `searchTerm` (type: `string`):

Keyword or phrase to search across UK Parliament transcripts (e.g. 'climate change', 'NHS funding'). Leave empty to fetch the most recent contributions across all topics.

## `house` (type: `string`):

Filter to a single chamber. Both = Commons + Lords combined.

## `memberName` (type: `string`):

Filter contributions to a specific MP or Lord by name (case-insensitive substring match, e.g. 'Keir Starmer').

## `department` (type: `string`):

Filter by department name (e.g. 'Treasury', 'Department for Education'). Case-insensitive substring match.

## `debateType` (type: `string`):

Restrict to a specific Hansard debate type (e.g. 'Debate', 'Question', 'Statement', 'WrittenStatement').

## `partyId` (type: `integer`):

Restrict to contributions from members of a single party. Use the numeric Party ID from the UK Parliament Members directory (e.g. 4 = Labour, 8 = Independent, 15 = Conservative).

## `includeFormer` (type: `boolean`):

When enabled, include contributions from members who no longer sit in either House.

## `startDate` (type: `string`):

Only include contributions on or after this sitting date.

## `endDate` (type: `string`):

Only include contributions on or before this sitting date.

## `orderBy` (type: `string`):

Order in which contributions are returned.

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

Free users: Limited to 10 items (preview). Paid users: Optional, max 1,000,000

## Actor input object example

```json
{
  "searchTerm": "",
  "house": "Both",
  "memberName": "",
  "department": "",
  "debateType": "",
  "includeFormer": false,
  "orderBy": "",
  "maxItems": 10
}
```

# Actor output Schema

## `overview` (type: `string`):

Overview of scraped data

## `fullData` (type: `string`):

Complete dataset

# 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 = {
    "searchTerm": "",
    "memberName": "",
    "department": "",
    "maxItems": 10
};

// Run the Actor and wait for it to finish
const run = await client.actor("parseforge/hansard-uk-debates-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 = {
    "searchTerm": "",
    "memberName": "",
    "department": "",
    "maxItems": 10,
}

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

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

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

```

## CLI example

```bash
echo '{
  "searchTerm": "",
  "memberName": "",
  "department": "",
  "maxItems": 10
}' |
apify call parseforge/hansard-uk-debates-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=parseforge/hansard-uk-debates-scraper",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "Hansard UK Parliament Debates Scraper",
        "description": "Export the official transcripts of UK Parliament debates and speeches from Hansard. Filter by House (Commons or Lords), search term, member, and date range. Each record includes the full speech text, speaker, debate section, and a permalink to the official Hansard transcript.",
        "version": "0.0",
        "x-build-id": "2aIdPCZg8KhmyfdgH"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/parseforge~hansard-uk-debates-scraper/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-parseforge-hansard-uk-debates-scraper",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        },
        "/acts/parseforge~hansard-uk-debates-scraper/runs": {
            "post": {
                "operationId": "runs-sync-parseforge-hansard-uk-debates-scraper",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor and returns information about the initiated run in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/runsResponseSchema"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/acts/parseforge~hansard-uk-debates-scraper/run-sync": {
            "post": {
                "operationId": "run-sync-parseforge-hansard-uk-debates-scraper",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "inputSchema": {
                "type": "object",
                "properties": {
                    "searchTerm": {
                        "title": "Search Term",
                        "type": "string",
                        "description": "Keyword or phrase to search across UK Parliament transcripts (e.g. 'climate change', 'NHS funding'). Leave empty to fetch the most recent contributions across all topics.",
                        "default": ""
                    },
                    "house": {
                        "title": "House",
                        "enum": [
                            "Both",
                            "Commons",
                            "Lords"
                        ],
                        "type": "string",
                        "description": "Filter to a single chamber. Both = Commons + Lords combined.",
                        "default": "Both"
                    },
                    "memberName": {
                        "title": "Member Name",
                        "type": "string",
                        "description": "Filter contributions to a specific MP or Lord by name (case-insensitive substring match, e.g. 'Keir Starmer').",
                        "default": ""
                    },
                    "department": {
                        "title": "Department",
                        "type": "string",
                        "description": "Filter by department name (e.g. 'Treasury', 'Department for Education'). Case-insensitive substring match.",
                        "default": ""
                    },
                    "debateType": {
                        "title": "Debate Type",
                        "enum": [
                            "",
                            "Debate",
                            "Question",
                            "Statement",
                            "WrittenStatement",
                            "Motion",
                            "PetitionDebate",
                            "UrgentQuestion",
                            "BackbenchDebate",
                            "Committee"
                        ],
                        "type": "string",
                        "description": "Restrict to a specific Hansard debate type (e.g. 'Debate', 'Question', 'Statement', 'WrittenStatement').",
                        "default": ""
                    },
                    "partyId": {
                        "title": "Party ID",
                        "minimum": 1,
                        "type": "integer",
                        "description": "Restrict to contributions from members of a single party. Use the numeric Party ID from the UK Parliament Members directory (e.g. 4 = Labour, 8 = Independent, 15 = Conservative)."
                    },
                    "includeFormer": {
                        "title": "Include Former Members",
                        "type": "boolean",
                        "description": "When enabled, include contributions from members who no longer sit in either House.",
                        "default": false
                    },
                    "startDate": {
                        "title": "Start Date",
                        "type": "string",
                        "description": "Only include contributions on or after this sitting date."
                    },
                    "endDate": {
                        "title": "End Date",
                        "type": "string",
                        "description": "Only include contributions on or before this sitting date."
                    },
                    "orderBy": {
                        "title": "Order By",
                        "enum": [
                            "",
                            "SittingDateAsc",
                            "SittingDateDesc"
                        ],
                        "type": "string",
                        "description": "Order in which contributions are returned.",
                        "default": ""
                    },
                    "maxItems": {
                        "title": "Max Items",
                        "minimum": 1,
                        "maximum": 1000000,
                        "type": "integer",
                        "description": "Free users: Limited to 10 items (preview). Paid users: Optional, max 1,000,000"
                    }
                }
            },
            "runsResponseSchema": {
                "type": "object",
                "properties": {
                    "data": {
                        "type": "object",
                        "properties": {
                            "id": {
                                "type": "string"
                            },
                            "actId": {
                                "type": "string"
                            },
                            "userId": {
                                "type": "string"
                            },
                            "startedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "finishedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "status": {
                                "type": "string",
                                "example": "READY"
                            },
                            "meta": {
                                "type": "object",
                                "properties": {
                                    "origin": {
                                        "type": "string",
                                        "example": "API"
                                    },
                                    "userAgent": {
                                        "type": "string"
                                    }
                                }
                            },
                            "stats": {
                                "type": "object",
                                "properties": {
                                    "inputBodyLen": {
                                        "type": "integer",
                                        "example": 2000
                                    },
                                    "rebootCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "restartCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "resurrectCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "computeUnits": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "options": {
                                "type": "object",
                                "properties": {
                                    "build": {
                                        "type": "string",
                                        "example": "latest"
                                    },
                                    "timeoutSecs": {
                                        "type": "integer",
                                        "example": 300
                                    },
                                    "memoryMbytes": {
                                        "type": "integer",
                                        "example": 1024
                                    },
                                    "diskMbytes": {
                                        "type": "integer",
                                        "example": 2048
                                    }
                                }
                            },
                            "buildId": {
                                "type": "string"
                            },
                            "defaultKeyValueStoreId": {
                                "type": "string"
                            },
                            "defaultDatasetId": {
                                "type": "string"
                            },
                            "defaultRequestQueueId": {
                                "type": "string"
                            },
                            "buildNumber": {
                                "type": "string",
                                "example": "1.0.0"
                            },
                            "containerUrl": {
                                "type": "string"
                            },
                            "usage": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "integer",
                                        "example": 1
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "usageTotalUsd": {
                                "type": "number",
                                "example": 0.00005
                            },
                            "usageUsd": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "number",
                                        "example": 0.00005
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
