# UK Legislation Scraper - Acts and Statutory Instruments (`jungle_synthesizer/uk-legislation-gov-uk-statute-scraper`) Actor

The UK statute book as structured records: Acts and Statutory Instruments from Westminster, Scotland, Wales and Northern Ireland, plus retained EU law. Dates, extent, subjects and the amendment trail, ready to filter by type and year.

- **URL**: https://apify.com/jungle_synthesizer/uk-legislation-gov-uk-statute-scraper.md
- **Developed by:** [BowTiedRaccoon](https://apify.com/jungle_synthesizer) (community)
- **Categories:** Other, Open source
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.80 / 1,000 record scrapeds

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 Legislation Scraper — Acts and Statutory Instruments

Collects the UK statute book from [legislation.gov.uk](https://www.legislation.gov.uk/) as structured records: Acts of Parliament, Scottish, Welsh and Northern Ireland legislation, Statutory Instruments, Church measures and retained EU law. Each record carries the reference, title, dates, territorial extent, subject headings and links to the official text, with an optional amendment trail showing which legislation changed which.

***

### UK Legislation Scraper Features

- Covers 30 legislation types in one actor, from UK Public General Acts and Statutory Instruments to Scottish Acts, Welsh Statutory Instruments, Northern Ireland Orders and EU Regulations that still sit on the UK statute book
- Filters by type, year range and title text, so you can pull "every Statutory Instrument made in 2024" or "everything with 'data protection' in the title"
- Returns the enactment or making date, the first coming-into-force date, the date laid before Parliament, territorial extent (for example `E+W+S+N.I.`) and the official subject headings
- Optional amendment trail: the legislation each item amends and the legislation that amends it, with the number and kind of changes
- Links every record to the official page, the structured full-text XML and the published PDF
- Flat, consistent records that load straight into a spreadsheet, a database or a compliance tool

***

### Who Uses UK Legislation Data?

- **Regtech and compliance teams** — keep a register of new and changed UK law against the obligations you track
- **Policy and public affairs monitors** — watch what a department, devolved parliament or subject area enacted this month
- **Legal publishers and legal AI teams** — build a clean index of the statute book to link, cite and train against
- **Law firms and in-house counsel** — find every instrument touching a subject, then follow the amendment trail
- **Researchers** — study legislative volume by year, type and nation

***

### How the UK Legislation Scraper Works

1. Choose the legislation types and an optional year range, or leave the types empty to walk the whole statute book, primary legislation first and newest first.
2. The scraper lists every matching Act, instrument or measure.
3. For each one it reads the dates, extent and subject headings, unless you turn that option off for a faster title-and-reference listing.
4. With amendments switched on, it also reads which legislation each item amends and is amended by.
5. Every item is saved as one structured record.

***

### Input

```json
{
  "legislationTypes": ["uksi"],
  "yearFrom": 2024,
  "yearTo": 2024,
  "includeDetail": true,
  "includeAmendments": false,
  "maxItems": 500
}
```

| Field               | Type    | Default | Description |
|---------------------|---------|---------|-------------|
| `legislationTypes`  | Array   | all     | Which types to collect, for example `ukpga` (UK Public General Acts), `uksi` (UK Statutory Instruments), `asp` (Acts of the Scottish Parliament), `wsi` (Welsh Statutory Instruments). Empty means every type. |
| `yearFrom`          | Integer | none    | Earliest year to include. |
| `yearTo`            | Integer | none    | Latest year to include. |
| `titleContains`     | String  | none    | Keep only items whose title contains this text, for example `"data protection"`. |
| `includeDetail`     | Boolean | true    | Add dates, extent, subjects, paragraph count and PDF link. Turn off for a faster listing. |
| `includeAmendments` | Boolean | false   | Add the `amends` and `amended_by` lists. Slower, because it adds work per record. |
| `maxAmendmentPages` | Integer | 2       | Pages of changes to read per direction (up to 50 changes per page). Records are flagged `amendments_truncated` when more exist. |
| `maxItems`          | Integer | 10      | Maximum number of items to save. |

#### Example: Acts of the Scottish Parliament passed in 2020

```json
{
  "legislationTypes": ["asp"],
  "yearFrom": 2020,
  "yearTo": 2020,
  "maxItems": 50
}
```

***

### Output

One record per Act, instrument or measure:

```json
{
  "id": "uksi/2020/1",
  "title": "The Police Appeals Tribunals Rules 2020",
  "type": "uksi",
  "type_name": "UnitedKingdomStatutoryInstrument",
  "year": 2020,
  "number": "1",
  "citation": "2020 No. 1",
  "legislation_url": "https://www.legislation.gov.uk/uksi/2020/1",
  "full_text_url": "https://www.legislation.gov.uk/uksi/2020/1/data.xml",
  "description": "These Rules set out the circumstances in which a member of a police force ... may appeal to a police appeals tribunal.",
  "made_date": "2020-01-06",
  "coming_into_force_date": "2020-02-01",
  "laid_date": "2020-01-10",
  "subjects": ["POLICE, ENGLAND AND WALES"],
  "version_status": "revised",
  "version_date": "2025-05-28",
  "repealed": false,
  "extent": "E+W",
  "territorial_application": null,
  "category": "secondary",
  "minor_type": "rule",
  "total_paragraphs": 28,
  "pdf_url": "https://www.legislation.gov.uk/uksi/2020/1/pdfs/uksi_20200001_en.pdf",
  "explanatory_document_url": "https://www.legislation.gov.uk/uksi/2020/1/pdfs/uksiem_20200001_en.pdf",
  "explanatory_document_type": "UK Explanatory Memorandum",
  "isbn": "9780111191835",
  "published": "2020-01-10T00:00:00+00:00",
  "last_updated": "2025-06-10T12:00:00+01:00",
  "amends": [
    { "id": "uksi/2012/2630", "title": "The Police Appeals Tribunals Rules 2012", "url": "https://www.legislation.gov.uk/uksi/2012/2630", "effects": 1, "effect_types": ["revoked"] }
  ],
  "amended_by": [],
  "amendments_truncated": false
}
```

| Field                     | Description                                                                           |
|---------------------------|---------------------------------------------------------------------------------------|
| `id`                      | Stable identifier in the form `type/year/number`.                                     |
| `title`                   | Short title.                                                                          |
| `title_welsh`             | Welsh-language title of bilingual Welsh legislation.                                  |
| `type`, `type_name`       | Type code and full type name.                                                         |
| `year`, `number`          | Year and number within the year (older items use regnal references).                  |
| `citation`                | Official citation as printed, such as `2020 c. 1` or `2020 No. 1`.                    |
| `legislation_url`         | Canonical page for the item.                                                          |
| `full_text_url`           | Full text as structured XML.                                                          |
| `description`             | Long title or summary.                                                                |
| `made_date`               | Date of Royal Assent, enactment or making.                                            |
| `coming_into_force_date`  | First coming-into-force date (Statutory Instruments).                                 |
| `laid_date`               | Date laid before Parliament (Statutory Instruments).                                  |
| `subjects`                | Subject headings.                                                                     |
| `version_status`          | Status of the current text: `enacted`, `made`, `final` or `revised`.                  |
| `version_date`            | Date the current version of the text is valid from.                                   |
| `repealed`                | `true` when the whole item is marked repealed.                                        |
| `extent`                  | Territorial extent codes.                                                             |
| `territorial_application` | Where an instrument applies when narrower than its extent.                            |
| `category`, `minor_type`  | `primary` or `secondary`, and the instrument kind.                                    |
| `total_paragraphs`        | Number of provisions in the text.                                                     |
| `pdf_url`                 | Official PDF as published.                                                            |
| `explanatory_document_*`  | Explanatory Notes or Memorandum PDF and its kind, when published.                     |
| `amends`, `amended_by`    | Counterpart legislation with change counts and kinds (only with `includeAmendments`). |

Some fields are empty where the publisher does not record them. Many recently made Statutory Instruments have no making date or extent yet, and `amends`/`amended_by` stay empty unless you turn amendments on.

***

### Tips

- **Whole statute book:** leave `legislationTypes` empty and raise `maxItems`. The corpus is several hundred thousand items, so long runs are normal. Narrow by type and year to refresh just the part you track.
- **Keeping up with new law:** filter to the current year and schedule a weekly run.
- **Speed:** switch `includeDetail` off for a plain reference list of titles and links.
- **Amendments:** use a small `maxItems` first. Heavily amended Acts have hundreds of changes, and `amendments_truncated` tells you when a list was cut at your page limit.

***

### FAQ

**Does it need an account or API key?**
No. It reads the public statute book.

**Is the text itself included?**
Each record links the official full text as structured XML and the published PDF. The record carries the metadata, not the whole body of the Act.

**Does it show whether an Act has been repealed?**
`version_status` reports the state of the current text, and `amended_by` shows the legislation that changed or repealed an item. It does not give a single in-force or repealed flag.

**Is the data current?**
Yes. Records reflect the publisher's statute book at the time of the run, and `last_updated` shows when each item last changed.

**Can I schedule it?**
Yes. Use Apify schedules to run weekly, filtered to the types and years you follow.

# Actor input Schema

## `sp_intended_usage` (type: `string`):

What will this data feed? E.g. lead lists, KYB checks, price tracking.

## `sp_improvement_suggestions` (type: `string`):

Provide any feedback or suggestions for improvements.

## `sp_contact` (type: `string`):

We'll personally help with your use case. No spam.

## `legislationTypes` (type: `array`):

Which kinds of legislation to collect (Acts, Statutory Instruments, retained EU law and so on). Leave empty to collect every type, primary legislation first.

## `yearFrom` (type: `integer`):

Earliest year of enactment to include, for example 2015. Leave empty for no lower bound.

## `yearTo` (type: `integer`):

Latest year of enactment to include, for example 2024. Leave empty for no upper bound.

## `titleContains` (type: `string`):

Keep only items whose title contains this text, for example "data protection". Free text, matched by the publisher. Leave empty for no title filter.

## `includeDetail` (type: `boolean`):

Add the enactment or made date, coming-into-force date, territorial extent, subject headings and PDF link to each record. Turn off for a faster title-and-reference listing.

## `includeAmendments` (type: `boolean`):

Add the lists of legislation each item amends and is amended by, with the number of changes and their kinds. Slower, because it adds requests per record.

## `maxAmendmentPages` (type: `integer`):

How many pages of changes to read per direction when amendments are included. Each page covers up to 50 changes, and records are flagged when more exist.

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

Maximum number of legislation items to save.

## Actor input object example

```json
{
  "sp_contact": "Share your email here...",
  "legislationTypes": [],
  "includeDetail": true,
  "includeAmendments": false,
  "maxAmendmentPages": 2,
  "maxItems": 10
}
```

# 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 = {
    "sp_contact": "Share your email here...",
    "legislationTypes": [],
    "includeDetail": true,
    "includeAmendments": false,
    "maxAmendmentPages": 2,
    "maxItems": 10
};

// Run the Actor and wait for it to finish
const run = await client.actor("jungle_synthesizer/uk-legislation-gov-uk-statute-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 = {
    "sp_contact": "Share your email here...",
    "legislationTypes": [],
    "includeDetail": True,
    "includeAmendments": False,
    "maxAmendmentPages": 2,
    "maxItems": 10,
}

# Run the Actor and wait for it to finish
run = client.actor("jungle_synthesizer/uk-legislation-gov-uk-statute-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 '{
  "sp_contact": "Share your email here...",
  "legislationTypes": [],
  "includeDetail": true,
  "includeAmendments": false,
  "maxAmendmentPages": 2,
  "maxItems": 10
}' |
apify call jungle_synthesizer/uk-legislation-gov-uk-statute-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,jungle_synthesizer/uk-legislation-gov-uk-statute-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/24dNtan6ev9ViqmY7/builds/DeHEUAjVz6GdNKlWM/openapi.json
