Putting APIs first: legislation.gov.uk
Mention the word “API” to the wrong audience and blank looks shortly follow. For the uninitiated, an API, or “Application Programming Interface”, is a way for one computer to use information or services held on another computer, often across the internet. The strategists say that developing high quality APIs has the potential to transform public services. One example where this is proving to be the case is legislation.gov.uk, the official UK legislation website, operated by The National Archives.
With legislation.gov.uk we aimed to open-up access to the government’s legislation database, by creating an API first. The legislation.gov.uk API allows anyone to access the data we hold in the database, or to use the services we have built, such as the search or to dynamically create PDF documents from the data. We wanted to show that government could create a high-quality, technically sophisticated API, following the principles of both REST and Linked Data. We also wanted our API to be fully open, with no restrictions on use, and no need to register before using it.
We developed the API and then built the legislation.gov.uk website on top of it. The API isn’t a bolt-on or additional feature, it is the beating heart of the service. Thanks to this approach it is very easy to access legislation data – just add /data.xml or /data.rdf to any web page containing legislation, or /data.feed, to any list or search results. One benefit of this approach is that the website, in a way, also documents the API for developers, helping them understand this complex data. Since launching the API we’ve seen several third party applications be developed, including two different iPhone / iPad apps, as well as innovative new products, such as a service for law lecturers to create and self-publish relevant extracts of legislation for their courses.
Many users assume, when they look at a page of legislation on the web, that it is current, in force and applies to where they live. Unfortunately legislation is a lot more complicated than that (this clip from Yes Minister may be an exaggeration, but you’ll get the idea). One Act may amend others, often in complicated ways. A major challenge with operating legislation.gov.uk is keeping pace with all the changes, so we can provide the current view of legislation the public expects. We have an editorial team at The National Archives, who identify all the changes and update the database. We create new versions of the legislation to show how it has changed over time. The difficulty is we can only manage to apply changes to primary legislation (Acts) and the number of changes to apply has been growing every year. It is a mammoth task and we needed to think how we could bring more expertise to bear on this growing challenge.
The API is enabling us to develop an entirely new approach to updating legislation, inspired by the open source software movement – our Expert Participation Programme. We are inviting people from outside The National Archives to work with us, to apply changes to the legislation in the database. Quality is maintained through our editorial practice and a stringent process of review. It is an exciting time as private sector companies are now investing, employing people to work with us to bring the database up to date and to maintain it. The API gives them ready and easy access to the data, which they can include in their own products and services. To help people use the data we have also published the code we use to present the content in HTML and PDF on github: https://github.com/legislation/legislation. Importantly, everything remains public, open and free, under the Open Government Licence. It is a win-win situation.
The legislation.gov.uk API has changed everything for us. It powers our website. It has enabled us to move to an open data business model, securing the editorial effort we need from the private sector for this important source of public data. It allows us to deliver information and services across channels and platforms through third party applications. We are developing other tools that use the API, using Linked Data – from recording the provenance of new legislation as it is converted from one format to another, to a suite of web based editorial tools for legislation, including a natural language processing capability that automatically identifies the legislative effects. Everything we do is underpinned by the API and Linked Data. With the foundations in place, the possibilities of what can be done with legislation data are now almost limitless.
About the author: John Sheridan is Head of Legislation Services at The National Archives