# UK Legislation Point-in-Time History (`yummy_persimmon_er1/uk-legislation-history`) Actor

Fetch the full amendment history of any UK Act or Statutory Instrument: every point-in-time version, with computed diffs between amendments.

- **URL**: https://apify.com/yummy\_persimmon\_er1/uk-legislation-history.md
- **Developed by:** [Mitchel Davis](https://apify.com/yummy_persimmon_er1) (community)
- **Categories:** Developer tools, MCP servers
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $20.00 / 1,000 section processeds

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

### What does UK Legislation Point-in-Time History do?

This Actor fetches the **full amendment history** of any UK Act of Parliament or
Statutory Instrument directly from [legislation.gov.uk](https://www.legislation.gov.uk),
the National Archives' official legal database. Give it an act URL — e.g.
`https://www.legislation.gov.uk/ukpga/2015/15` (Consumer Rights Act 2015) — and it
automatically discovers every section inside the act, then returns, for each section:

- the current legal text
- **every historical point-in-time version**, exactly as the law read on each amendment date
- a computed diff summary between consecutive versions (what changed, when, by how much)

No API key, no login, no proxy needed — this runs against a fully open government
data source. Use it via the Apify Console, the API, or directly from an MCP client
(Claude, Cursor, Windsurf) since this Actor supports Apify's MCP integration.

### Why use UK Legislation Point-in-Time History?

- **Legal tech & compliance tooling** — build a "what does the law say as of this
  date" feature without maintaining your own scraper against a government XML API.
- **AI agents & RAG pipelines** — ingest clean, structured UK statute text (not
  raw XML) for retrieval-augmented generation over legal questions.
- **Legislative research** — track how a specific provision has evolved since
  enactment, with exact boundary dates and character-level change summaries.
- **Data journalism** — quantify how much a law has been amended, and when the
  amendments happened, without manually diffing PDFs.

### How to use UK Legislation Point-in-Time History

1. Find the act you want on [legislation.gov.uk](https://www.legislation.gov.uk) and
   copy its base URL (type/year/number), e.g. `https://www.legislation.gov.uk/ukpga/2015/15`.
2. Paste it into the **Act or Statutory Instrument URL** input field.
3. (Optional) Restrict to specific sections, e.g. `["9", "62"]`, or leave empty to
   process the whole act (subject to the **Max sections** safety cap).
4. Run the Actor. Results stream into the dataset as each section finishes.
5. Export the dataset as JSON, CSV, or Excel, or pull it via the API.

### Input

| Field | Type | Description |
|---|---|---|
| `actUrl` | string | **Required.** The act/SI's legislation.gov.uk URL. |
| `sections` | array of strings | Specific section numbers to fetch. Leave empty to auto-discover every section in the act. |
| `maxSections` | integer | Cap on auto-discovered sections (default 5, 0 = no cap). |
| `includeFullHistory` | boolean | Fetch every point-in-time version (default) vs. just the current text and change dates. |
| `maxRequestsPerSecond` | number | Politeness rate limit against the source. Default and maximum 0.2 (one request every 5 s), matching legislation.gov.uk's robots.txt `Crawl-delay: 5`. |

See the **Input** tab for the full JSON schema.

### Output

Each dataset item is one section of the act:

```json
{
  "act_title": "Consumer Rights Act 2015",
  "section": "9",
  "title": "Consumer Rights Act 2015 s.9 — Goods to be of satisfactory quality",
  "version_count": 4,
  "current_text": "Every contract to supply goods is to be treated as including a term that the quality of the goods is satisfactory...",
  "versions": [
    { "valid_from": "2015-10-01", "text": "..." },
    { "valid_from": "2024-01-01", "text": "..." }
  ],
  "changes": [
    { "date": "2015-10-01", "type": "INITIAL", "summary": "First recorded version, in force from 2015-10-01." },
    { "date": "2024-01-01", "type": "REENACTED", "summary": "New version boundary with no change to visible text." }
  ],
  "license": "OGL-3.0",
  "attribution": "Contains public sector information licensed under the Open Government Licence v3.0. Source: legislation.gov.uk (The National Archives)."
}
```

You can download the dataset in various formats such as JSON, HTML, CSV, or Excel.

#### Data table

| Field | Description |
|---|---|
| `act_title` | The full title of the Act or SI |
| `section` | Section number |
| `title` | Act + section number + section heading |
| `current_text` | The current in-force text of the section |
| `versions` | Every point-in-time version, each with its `valid_from` boundary date |
| `changes` | One entry per version boundary: type (`INITIAL`/`AMENDED`/`REENACTED`) and a plain-language summary |
| `license` / `attribution` | Required Open Government Licence attribution — include this if you redistribute the data |

### Pricing / Cost estimation

This Actor uses Apify pay-per-event pricing: **$0.005 per run** plus **$0.02 per section**
processed (current text + every point-in-time version + computed diffs). The default
input (5 sections) costs $0.105. A 100-section act costs about $2.01. legislation.gov.uk
itself is free and keyless.

Speed: requests are capped at one every 5 seconds to respect the site's robots.txt, so
expect roughly 25 seconds per section (about 40 minutes for a 100-section act).

### Tips

- For a **quick single-section check**, pass an explicit `sections` array — this
  skips the contents-document discovery step entirely and is the fastest path.
- For **large acts** (500+ sections), raise `maxSections` deliberately rather than
  processing the whole act by default, since some Acts (tax codes, the Companies
  Act) run into the thousands of sections.
- Set `includeFullHistory` to `false` if you only need the current text plus the
  list of amendment dates — this roughly halves the number of requests made.

### FAQ, disclaimers & support

- **Is this legal advice?** No. This Actor returns the text of the law as published
  by the National Archives. It performs no interpretation, summarization, or
  "what should you do" analysis. Always verify against the primary source
  (linked in every record) before relying on it for a legal decision.
- **Data licence.** All output is UK Crown/Parliamentary copyright material
  reused under the [Open Government Licence v3.0](https://www.nationalarchives.gov.uk/doc/open-government-licence/version/3/),
  which permits commercial and non-commercial reuse provided the required
  attribution (included in every record) is preserved.
- **Known limitations.** Very large acts (1000+ sections) may hit the `maxSections`
  cap by default — raise it explicitly if you need the whole act. Schedules and
  explanatory notes are not currently included, only numbered sections.
- **Found a bug or need a feature?** Open an issue on the Actor's Issues tab.

***

**Built this actor and want to ship your own Apify pay-per-event actor without the silent-$0-charge gotchas?** I packaged the working PPE billing pattern (Actor.charge() done right, a pricing calculator, and the 5-minute-health-test fix) into a small starter kit: https://busybusiness.gumroad.com/l/lnvqhh — $19, one-time.

# Actor input Schema

## `actUrl` (type: `string`):

A legislation.gov.uk act/SI URL, e.g. https://www.legislation.gov.uk/ukpga/2015/15 (Consumer Rights Act 2015). The tool auto-discovers every section inside it.

## `sections` (type: `array`):

Limit to specific section numbers, e.g. \["1", "9", "62"]. Leave empty to fetch every section in the act (can be large for big acts).

## `maxSections` (type: `integer`):

Safety cap on how many sections to fetch when no explicit list is given. Default 5 (about 2 minutes). Set a higher number, or 0 for no cap, to process a whole act (about 25 seconds per section at the polite rate limit).

## `includeFullHistory` (type: `boolean`):

If true, fetch and return every historical version boundary for each section (point-in-time text at each amendment date). If false, only return the current text plus the list of change dates (faster, cheaper).

## `maxRequestsPerSecond` (type: `number`):

Politeness rate limit against legislation.gov.uk. The site's robots.txt declares Crawl-delay: 5 (one request every 5 seconds), so 0.2 is both the default and the maximum. Expect roughly 5 seconds per request: a section with 4 historical versions takes about 25 seconds.

## Actor input object example

```json
{
  "actUrl": "https://www.legislation.gov.uk/ukpga/2015/15",
  "sections": [],
  "maxSections": 3,
  "includeFullHistory": true,
  "maxRequestsPerSecond": 0.2
}
```

# Actor output Schema

## `results` (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 = {
    "actUrl": "https://www.legislation.gov.uk/ukpga/2015/15",
    "maxSections": 3
};

// Run the Actor and wait for it to finish
const run = await client.actor("yummy_persimmon_er1/uk-legislation-history").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 = {
    "actUrl": "https://www.legislation.gov.uk/ukpga/2015/15",
    "maxSections": 3,
}

# Run the Actor and wait for it to finish
run = client.actor("yummy_persimmon_er1/uk-legislation-history").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 '{
  "actUrl": "https://www.legislation.gov.uk/ukpga/2015/15",
  "maxSections": 3
}' |
apify call yummy_persimmon_er1/uk-legislation-history --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,yummy_persimmon_er1/uk-legislation-history"
        }
    }
}
```

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/Mcu4XgfD6jTMtjxim/builds/uNgvsbf43dcnmIJTK/openapi.json
