# legislation.gov.uk API

Category: [Government and law](https://free-web-services.com/web-services/open-data/government/)  
Page: https://free-web-services.com/web-services/open-data/government/legislation-gov-uk-api.html  
Documentation: https://www.legislation.gov.uk/developer

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 key: Not needed
- 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

Example request:

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

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

