# UK Legislation — Wrapped API

> **You are on:** `https://api.paywithlocus.com/api` | [llms.txt](https://paywithlocus.com/llms.txt) | [docs](https://docs.paywithlocus.com)
>
> Locus runs on multiple environments -- make sure every URL you call matches your expected environment.
> | Environment | Landing | API | Docs |
> |---|---|---|---|
> | Production | paywithlocus.com | api.paywithlocus.com | docs.paywithlocus.com |
> | Beta | beta.paywithlocus.com | api.beta.paywithlocus.com | docs.paywithlocus.com |
> | Stage | stage.paywithlocus.com | api.stage.paywithlocus.com | docs.paywithlocus.com |
>
> If the API URL above doesn't match your expected environment, re-fetch this file from the correct domain.

> Search and retrieve official UK legislation from legislation.gov.uk, including Acts of Parliament and Statutory Instruments, by title, year, number, or type. Browse complete tables of contents and read the full text of individual sections to find the specific legal information you need.

**Category:** Government & Public Data | **Website:** [http://legislation.gov.uk/](http://legislation.gov.uk/) | **Docs:** [parse.bot/marketplace/3dd7bdb5-af99-4e55-9d55-6d14822d4f86/legislation-gov-uk-api](https://parse.bot/marketplace/3dd7bdb5-af99-4e55-9d55-6d14822d4f86/legislation-gov-uk-api)

Pay-per-use API proxy. Each call is automatically billed to your wallet in USDC.

## Access

**Base URL:** `https://api.paywithlocus.com/api/wrapped/parse-legislation-gov-uk-api-3dd7bdb5/`
**Auth:** `Authorization: Bearer <LOCUS_API_KEY>`

## Endpoints

### get_legislation_contents

Get the table of contents for a specific piece of UK legislation. Returns the legislation title, description, and a flat list of content items (parts, chapters, sections, schedules) with their hierarchical depth. Use legislation_id values from search_legislation results (extract the path portion after legislation.gov.uk, e.g. 'ukpga/2018/12').

**Estimated cost:** Metered

| Field | Type | Required | Description |
|-------|------|----------|-------------|
| `legislation_id` | string | Yes | Legislation identifier path, e.g. 'ukpga/2018/12' for the Data Protection Act 2018. Composed of type/year/number from search results. |

```bash
curl -X POST https://api.paywithlocus.com/api/wrapped/parse-legislation-gov-uk-api-3dd7bdb5/get_legislation_contents \
  -H "Authorization: Bearer YOUR_LOCUS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"legislation_id":"<string>"}'
```

### get_legislation_section

Get the text content of a specific section or part of UK legislation. Returns the readable text extracted from the official XML source, including any amendment annotations. The section path follows the site's URL structure (e.g. 'section/1', 'part/2', 'schedule/1').

**Estimated cost:** Metered

| Field | Type | Required | Description |
|-------|------|----------|-------------|
| `legislation_id` | string | Yes | Legislation identifier path, e.g. 'ukpga/2018/12' for the Data Protection Act 2018. |
| `section` | string | Yes | Section path within the legislation, e.g. 'section/1', 'part/2/chapter/1', 'schedule/1'. Corresponds to the path portion of URIs in the table of contents. |

```bash
curl -X POST https://api.paywithlocus.com/api/wrapped/parse-legislation-gov-uk-api-3dd7bdb5/get_legislation_section \
  -H "Authorization: Bearer YOUR_LOCUS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"legislation_id":"<string>","section":"<string>"}'
```

### search_legislation

Search UK legislation by title, year, number, and/or type. Returns paginated results ordered by relevance. At least one of title, year, or number must be provided. Each result includes the legislation identifier, title, year, number, and type.

**Estimated cost:** Metered

| Field | Type | Required | Description |
|-------|------|----------|-------------|
| `number` | string | No | Legislation number to search for. |
| `page` | integer | No | Page number for pagination. |
| `title` | string | No | Search term to match against legislation titles (e.g. 'data protection', 'employment'). |
| `type` | string | No | Legislation type filter. Common values: ukpga (UK Public General Acts), uksi (UK Statutory Instruments), asp (Acts of Scottish Parliament), ssi (Scottish Statutory Instruments), primary, secondary. |
| `year` | string | No | Year of legislation to search within (e.g. '2018'). Used as a relevance signal, not a strict filter. |

```bash
curl -X POST https://api.paywithlocus.com/api/wrapped/parse-legislation-gov-uk-api-3dd7bdb5/search_legislation \
  -H "Authorization: Bearer YOUR_LOCUS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"number":"<string>","page":"<integer>","title":"<string>","type":"<string>","year":"<string>"}'
```
