Gov APIlegislation.gov.uk ↗
Search and retrieve UK Acts of Parliament, Statutory Instruments, and other legislation. Access titles, tables of contents, and full section text via 3 endpoints.
What is the Gov API?
The legislation.gov.uk API provides 3 endpoints for searching and reading official UK legislation, covering Acts of Parliament, Statutory Instruments, and more. Use search_legislation to find laws by title, year, number, or type, get_legislation_contents to retrieve a structured table of contents, and get_legislation_section to read the full text of any individual section, complete with amendment annotations.
curl -X GET 'https://api.parse.bot/scraper/47dc5438-5519-4ae0-bec1-bb2697e07c18/search_legislation?type=all&year=2018&title=data+protection&page=1&number=12' \ -H 'X-API-Key: $PARSE_API_KEY'
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.
| Param | Type | Description |
|---|---|---|
| page | integer | Page number for pagination. |
| type | string | 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 | Year of legislation to search within (e.g. '2018'). Used as a relevance signal, not a strict filter. |
| title | string | Search term to match against legislation titles (e.g. 'data protection', 'employment'). |
| number | string | Legislation number to search for. |
{
"type": "object",
"fields": {
"page": "current page number",
"results": "array of legislation items, each with id, title, uri, legislation_type, year, number, and updated timestamp",
"total_pages": "total number of pages available",
"total_results": "number of results on this page",
"items_per_page": "number of results per page"
},
"sample": {
"data": {
"page": 1,
"results": [
{
"id": "http://www.legislation.gov.uk/id/ukpga/2018/12",
"uri": "http://www.legislation.gov.uk/id/ukpga/2018/12",
"year": "2018",
"title": "Data Protection Act 2018",
"number": "12",
"updated": "2026-07-09T10:58:22+01:00",
"legislation_type": "UnitedKingdomPublicGeneralAct"
}
],
"total_pages": 5,
"total_results": 20,
"items_per_page": 20
},
"status": "success"
}
}About the Gov API
Searching UK Legislation
search_legislation accepts any combination of title, year, number, and type parameters — at least one must be provided. The type parameter accepts standard abbreviations: ukpga for UK Public General Acts, uksi for UK Statutory Instruments, and asp for Acts of the Scottish Parliament, among others. Results are paginated (controlled by the page parameter) and each item in the results array includes id, title, uri, legislation_type, year, number, and an updated timestamp. Note that year acts as a relevance signal rather than a strict filter, so results may include legislation from adjacent years.
Navigating Legislation Structure
get_legislation_contents takes a legislation_id in the format type/year/number — for example, ukpga/2018/12 for the Data Protection Act 2018 — and returns the title, description, and a flat contents array. Each entry in contents carries a type field (values include part, chapter, item, schedule, pblock, division, and crossheading), a number, a title, a uri, and a depth indicating its position in the hierarchy. This structure lets you enumerate all navigable sections before fetching their text.
Reading Section Text
get_legislation_section retrieves the readable text of a specific section. The section parameter follows the legislation's URL path structure: section/1, part/2/chapter/1, or schedule/1. The response includes text (paragraphs separated by newlines), section_title, section_number, legislation_title, and echoes back the legislation_id and section path. Where sections carry amendment annotations in the official XML source, those annotations appear inline in the returned text.
The Gov API is a managed, monitored endpoint for legislation.gov.uk — not a raw scraper you maintain. Every endpoint is automatically health-checked on a schedule, and when legislation.gov.uk changes and a check fails, the API is automatically queued for repair and re-verified. It is built to keep working as the site underneath it changes.
This isn't an official legislation.gov.uk API — it's an independent, maintained REST wrapper over public data. Where the source has no official API (or only a limited one), Parse gives you a stable contract over a source that never promised one, and keeps it current. Need a new endpoint or field? You can revise it yourself in plain English and the agent rebuilds it against the live site in minutes — contributing the change back to the shared API is free.
Will this API break when the source site changes?+
Is this an official API from the source site?+
Can I fix or extend this API myself if I need a new endpoint or field?+
What happens if I call an endpoint that has an issue?+
- Checking whether a specific section of the Data Protection Act 2018 is still in force by reading its text and amendment annotations.
- Building a legal research tool that lets users search Acts by title keyword and browse their full table of contents.
- Extracting all sections from a Statutory Instrument (uksi) to feed into a document summarisation pipeline.
- Comparing the structure of multiple pieces of employment legislation by enumerating their contents arrays.
- Monitoring updates to specific legislation by storing the
updatedtimestamp from search results and checking for changes. - Indexing UK legislation titles and identifiers by year for an offline reference dataset.
- Pulling the full text of individual schedules from Acts of the Scottish Parliament (asp) for compliance analysis.
| Tier | Price | Credits/month | Rate limit |
|---|---|---|---|
| Free | $0/mo | 200 | 5 req/min |
| Hobby | $30/mo | 1,000 | 20 req/min |
| Developer | $100/mo | 5,000 | 100 req/min |
| Team | $300/mo | 20,000 | 300 req/min |
| Company | $1,000/mo | 100,000 | 500 req/min |
Each endpoint has a fixed posted price per successful call — most fall between 1 and 10 credits — shown on this API's page before you run it. Exceeding the rate limit returns a 429 response. Authenticate with the X-API-Key header.
Does legislation.gov.uk have an official developer API?+
What does search_legislation return, and can I filter strictly by year?+
results array includes id, title, uri, legislation_type, year, number, and an updated timestamp. The year parameter is used as a relevance signal, not a hard filter, so results may occasionally include items from years close to the one specified. To narrow by type, supply the type parameter alongside year.Does the API return the full text of an entire Act in a single call?+
get_legislation_section. To get full Act text, you would call that endpoint once per entry in the table of contents returned by get_legislation_contents. You can fork this API on Parse and revise it to add a bulk-text endpoint that aggregates all sections automatically.Are historical (revised) versions of legislation accessible?+
What legislation types are covered, and is Welsh or Northern Irish legislation included?+
type parameter supports ukpga (UK Public General Acts), uksi (UK Statutory Instruments), and asp (Acts of the Scottish Parliament), along with other types present on legislation.gov.uk such as Welsh statutory instruments (wsi) and Northern Ireland Orders in Council. Coverage depends on what legislation.gov.uk has published; not all historical legislation is available in a machine-readable form on the source site.