# UK Legislation — Wrapped API

> **You are on:** `https://api.beta.paywithlocus.com/api` | [llms.txt](https://beta.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 for Locus Pro. Each call burns credits from your workspace balance.

## Access

**Base URL:** `https://api.beta.paywithlocus.com/api/wrapped/credits/uk-legislation/`
**Auth:** `Authorization: Bearer <LOCUS_CREDITS_SECRET_KEY>` (an `lcr_` secret key or a scoped `lcac_` agent credential)
**Required header:** `Idempotency-Key: <fresh UUID per call>`. A retry with the same key replays the stored result without a new charge.
**Response:** the provider response after any endpoint-specific normalization. `X-Locus-Credits-Charged` carries the charge and `X-Locus-Credits-Balance` the remaining balance. Insufficient credits return `402` before the provider is called.
**Pricing:** estimated costs below are USD. Locus debits the credit equivalent at your workspace rate.

Full call contract: https://docs.paywithlocus.com/api-reference/introduction

> Using a Pay With Locus wallet key (`claw_` prefix)? Wallet routes are documented separately: https://docs.paywithlocus.com/wrapped-apis/for-agents

## 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.beta.paywithlocus.com/api/wrapped/credits/uk-legislation/get-legislation-contents \
  -H "Authorization: Bearer $LOCUS_CREDITS_SECRET_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -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.beta.paywithlocus.com/api/wrapped/credits/uk-legislation/get-legislation-section \
  -H "Authorization: Bearer $LOCUS_CREDITS_SECRET_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -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.beta.paywithlocus.com/api/wrapped/credits/uk-legislation/search-legislation \
  -H "Authorization: Bearer $LOCUS_CREDITS_SECRET_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{"number":"<string>","page":"<integer>","title":"<string>","type":"<string>","year":"<string>"}'
```

## Next steps

- [All wrapped API providers](https://beta.paywithlocus.com/wapi/index.md): pick another provider.
- [Find and call tools](https://beta.paywithlocus.com/agent/tools.md): price ceilings, async results, and errors.
- [Credits and billing](https://beta.paywithlocus.com/agent/billing.md): what a call costs and how to add credits.
- [Agent docs index](https://beta.paywithlocus.com/agent/index.md): every Locus agent page.