Government and law

legislation.gov.uk API

by legislation.gov.uk

Government and law Added on November 7th, 2026 Checked and working on November 7th, 2026
Visit legislation.gov.uk →

What it does

legislation.gov.uk publishes all UK legislation, and every page can also be fetched as data: add /data.xml to an act or section address to get it as XML, or use the Atom feeds to follow new and changed legislation, for example to show the current text of a section of the Data Protection Act. Free, no key needed.
  • API
  • HTTP-GET
  • REST
  • RSS
  • XML

At a glance

API key
Not needed · More APIs with no key
Pricing
Free, no key needed.
From the browser
Yes (CORS)
Formats
XML, RSS
Interface
REST, HTTP-GET
Provider
legislation.gov.uk
Last checked
Working on November 7th, 2026

More information: https://www.legislation.gov.uk/developer

Is this your service? Show that it is listed

Put this badge on your website or in your README; it links to this page. About the badge

Listed on Free Web Services

legislation.gov.uk
legislation.gov.uk API

Example request

curl

curl 'https://www.legislation.gov.uk/ukpga/2018/12/data.xml'

JavaScript

const response = await fetch("https://www.legislation.gov.uk/ukpga/2018/12/data.xml");
const text = await response.text();
console.log(text);

Python

import requests

response = requests.get(
    "https://www.legislation.gov.uk/ukpga/2018/12/data.xml",
    timeout=30,
)
print(response.text)

The JavaScript works in a web page as well as in Node.js 18 or newer.

Did it work for you?

Tell us what you found when you tried legislation.gov.uk API.