Using the Legislation API

The legislation API provides a simple means by which developers can query the legislation data to retrieve results in a format of their choice, without the need to formulate a SPARQL query. The API provides single item endpoints and list endpoints, for retrieving multiple items.

Single Item Endpoints

To retrieve details of a single item of legislation, use the pattern:

For example:

List Endpoints

List endpoints provide a means to retreive multiple items. The items are divided into pages with a fixed number of items on each page.

To get a list of all legislation:

To get a specific page w.r.t. a specific number of items per page:

To retrieve a list of legislation by created within a range of dates, use the pattern:

For example:

Viewers

The level of detail in the retrieved results depends on a pre-configured default viewer. To control the level of detail which is reported, an alternative viewer can be selected by appending an _view parameter, e.g.:

http://gov.tso.co.uk/legislation/api/legislation/uksi/2010/2580?_view=medium

There are currently three viewers:

The default view is medium.

Formats

Results can be obtained in a variety of formats: XML, RDF+XML, Turtle and JSON. The format of the returned results can be selected by adding a path extension to any API request, e.g.:

To retrieve results in XML:

To retrieve results in XML+RDF:

To retrieve results in Turtle:

To retrieve results in JSON:

Legislation API Reference

For a complete list of the available endpoints, properties and viewers, please see the Legislation API reference.