# UK Parliament Written Questions Search - Full Answers (`thatmike1/uk-parliament-written-questions-search`) Actor

Search Commons and Lords written questions by keyword and date. Full question and answer text, department, asking and answering members, holding and corrected answers. Official Parliament API.

- **URL**: https://apify.com/thatmike1/uk-parliament-written-questions-search.md
- **Developed by:** [Michal Pšenčík](https://apify.com/thatmike1) (community)
- **Categories:** Business, Automation
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 72.4% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.00005 / actor start

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

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 Written Questions Search - Full Answers

Search written questions in the House of Commons and the House of Lords by keyword and date, and get one row per
question with the **full question text and the full answer**, the asking and answering members, the department and
every date: tabled, due, answered, holding answer and correction. Data comes from Parliament's official Written
Questions API.

Parliament's list search cuts both texts short (the question at 255 characters, the answer after a few lines with
`...`). This actor fetches each question's own record, so every row carries the complete texts.

Useful for public-affairs and policy work: every question MPs and peers asked government about your topic last week,
with what ministers answered, in a spreadsheet or a monitoring pipeline.

### Input

| Field                       | What it does                                                                                 |
| --------------------------- | -------------------------------------------------------------------------------------------- |
| Search term                 | Keyword or phrase, 2-100 characters (default `energy`). Empty lists every question.          |
| Date to filter on           | `Tabled` (default) or `Answered`.                                                            |
| From date / To date         | `YYYY-MM-DD`, both included. Defaults: the last 60 days up to today (UTC). At most 366 days. |
| House                       | Both (default), House of Commons or House of Lords.                                          |
| Answered status             | Any (default), answered only or unanswered only.                                             |
| Include withdrawn questions | Off by default.                                                                              |
| Maximum questions           | 1 to 1000 (default 50).                                                                      |

```json
{
    "searchTerm": "battery",
    "dateField": "tabled",
    "dateFrom": "2026-10-01",
    "dateTo": "2026-10-22",
    "house": "Both",
    "answeredStatus": "Any",
    "includeWithdrawn": false,
    "maxItems": 50
}
```

The search is Parliament's own ("searches item content"); the actor sends your term as is and does not filter the
results further. Questions come in the order the API lists them, and the first `maxItems` are returned.

### Output

One row per question. Example (22 Oct 2026, answer shortened here):

```json
{
    "id": 1949544,
    "uin": "35189",
    "house": "Commons",
    "heading": "Telecommunications: Supported Housing",
    "dateTabled": "2026-10-15",
    "dateForAnswer": "2026-10-19",
    "dateAnswered": "2026-10-22",
    "dateHoldingAnswer": null,
    "dateAnswerCorrected": null,
    "questionText": "To ask the Secretary of State for Digital, Culture, Media and Sport, what assessment her department has made of the potential impact of homecare telecommunications in the event of a power cut.",
    "answerHtml": "<p>The Government is committed to ensuring that any risks ...</p>",
    "answerText": "The Government is committed to ensuring that any risks ...\n\nIn November 2024 and March 2026, ...",
    "originalAnswerHtml": null,
    "answerIsHolding": false,
    "answerIsCorrection": false,
    "isWithdrawn": false,
    "isNamedDay": false,
    "answeringBodyId": 10,
    "answeringBodyName": "Department for Digital, Culture, Media and Sport",
    "askingMember": { "id": 5265, "name": "James MacCleary", "party": "Liberal Democrat", "memberFrom": "Lewes" },
    "answeringMember": { "id": 3966, "name": "Ian Murray", "party": "Labour", "memberFrom": "Edinburgh South" },
    "groupedQuestionUins": [],
    "attachmentCount": 0,
    "sourceUrl": "https://questions-statements-api.parliament.uk/api/writtenquestions/questions/1949544",
    "fetchedAt": "2026-10-22T21:00:00.000Z"
}
```

- `answerHtml` is the answer exactly as Parliament publishes it; `answerText` is the same answer as plain text with
  paragraphs separated by a blank line. Both are `null` for an unanswered question.
- `originalAnswerHtml` holds the earlier answer when an answer was corrected. `answerIsHolding` and
  `answerIsCorrection` are `null` on unanswered questions, as the API sends them.
- Members carry id, name, party and constituency (`memberFrom`). If the API sends no member details, only the id is
  filled. `answeringMember` is `null` until a question is answered.
- Dates are calendar dates (`YYYY-MM-DD`); the API sends no time zone. `attachmentCount` counts attachments; their
  content is not downloaded.

#### Run summary

The key-value store record `SUMMARY` (free) shows the resolved query, the API's `totalResults`, how many ids were
listed, selected and stored, whether the query was exhausted or capped by `maxItems`, and every selected question that
has no row, with its reason: `detail_not_found`, `detail_error`, `invalid_record`, `not_fetched_deadline`,
`not_fetched_source_stop`, `not_stored_budget`, `not_stored_deadline`, `not_stored_max_items`, `not_stored` or
`delivery_uncertain`. `complete` is true only when every question the query matched was listed and stored; a run capped
by `maxItems` reports `complete: false` and `cappedByMaxItems: true`. `stoppedReason` says why a run stopped early.

### Pricing

Pay per event: **$0.002 per stored question** (with its full detail record) and **$0.00005 per run start**. Each row
is billed once, when it is stored; rows already stored stay billed even if the run later fails or stops. Errors, rows
not stored, invalid or filtered inputs, questions whose record could not be fetched, and the SUMMARY carry no item
fee. The `apify-actor-start` event applies to every run, including failed and empty ones. The actor keeps no state
between runs: searching the same window again bills the questions again.

Examples: the default 50 questions cost $0.10005, a weekly report of 200 questions $0.40005, 1,000 questions $2.00005.

### Limits

- Source: `https://questions-statements-api.parliament.uk`, public, no key. One request at a time, 1.5 s after each
  list page and 0.5 s between question records. A list page can take 10-30 s, so a 1,000-question run takes roughly
  15-20 minutes.
- A run does at most 30 minutes of work; questions not fetched by then are listed in SUMMARY and the run reports
  `stoppedReason: "deadline"`.
- A 403 or 429 from the API, or an HTML page instead of JSON, stops the run: rows already stored stay delivered.
- Written questions only: no written statements, oral questions or Hansard debates. No links to the human-facing
  website (it sits behind a browser check).
- Members of Parliament are public office-holders; the actor exports only name, party and constituency as Parliament
  publishes them.

# Actor input Schema

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

Keyword or phrase, 2 to 100 characters, searched in the question and answer content by the Parliament API itself (no extra filtering). Leave empty to list every question in the date window.

## `dateField` (type: `string`):

Whether the date window applies to the date a question was tabled or the date it was answered.

## `dateFrom` (type: `string`):

First day of the window, YYYY-MM-DD, inclusive. Empty means 60 days before the run date (UTC).

## `dateTo` (type: `string`):

Last day of the window, YYYY-MM-DD, inclusive. Empty means the run date (UTC). The window may span at most 366 days.

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

House of Commons, House of Lords, or both.

## `answeredStatus` (type: `string`):

Only answered questions, only unanswered ones, or any.

## `includeWithdrawn` (type: `boolean`):

Ask the API to include questions that were withdrawn.

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

The most questions to return (each stored question is billed). The first questions the API lists are selected; a run that stops here with more matches is reported as capped in SUMMARY.

## Actor input object example

```json
{
  "searchTerm": "energy",
  "dateField": "tabled",
  "house": "Both",
  "answeredStatus": "Any",
  "includeWithdrawn": false,
  "maxItems": 50
}
```

# Actor output Schema

## `rows` (type: `string`):

No description

## `summary` (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 = {
    "searchTerm": "energy"
};

// Run the Actor and wait for it to finish
const run = await client.actor("thatmike1/uk-parliament-written-questions-search").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": "energy" }

# Run the Actor and wait for it to finish
run = client.actor("thatmike1/uk-parliament-written-questions-search").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 '{
  "searchTerm": "energy"
}' |
apify call thatmike1/uk-parliament-written-questions-search --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,thatmike1/uk-parliament-written-questions-search"
        }
    }
}
```

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/U07I9wXP776y1IRMu/builds/nAOjDyPEqwKRKvfQd/openapi.json
