Office of Public Sector Information

Office of Public Sector Information

Main menu and contents

Supplementary menus and contents

Searching

This page describes how to search for items of legislation held within Legislation API.

The Legislation API offers two types of searches:

The identifier search page is there to help you to find the correct identifier URI for a piece of legislation, particularly if you are trying to create links from other documents. For example, Hansard contains records of speeches which often quote legislation, such as:

There is nothing new in the concept that auditors shall, in appropriate circumstances, be approved by the Audit Commission. The Transport Act 1985 provides that a public transport company shall appoint only auditors who, in addition to being qualified under the Companies Act, shall be, "approved for appointment as auditors of that company by the Audit Commission"."

To mark up this information, it's useful to be able to search based on the title of the legislation, with supporting information narrowing down the search. You can complete the form manually, or use it to create URIs of the form:

http://www.legislation.gov.uk/id?title={title}&type={type}&year={year}&number={number}

Any of the fields may be missing from the search, but the more you specify, the greater the likelihood of uniquely identifying the legislation. If a single item of legislation is identified by the query, the response will be a 301 Moved Permanently that redirects you to the correct URI for the legislation. If multiple items are identified by the query, you will get a 300 Multiple Choices response that lists the possibilities in a simple XHTML document.

Within the form, the title field should hold the short title of the legislation, which includes a year. For example:

http://www.legislation.gov.uk/id?title=Transport+Act+1985

Even if other items of legislation include this phrase in their own title (such as "The Transport Act 1985 (Modifications in Schedule 4 to the Transport Act 1968) (Further Modification) Order 1993"), if the title exactly matches a single piece of legislation, you will be redirected to that piece of legislation.

On the other hand, if multiple items of legislation include, but do not exactly match, the title you have specified (which may be the case if the short title is incomplete, such as missing a year), a list of possibilities will be returned with a 300 Multiple Choices response. For example:

http://www.legislation.gov.uk/id?title=Companies+Act

will result in a 300 Multiple Choices response containing


  
    
    300 Multiple Choices
  
  
    

300 Multiple Choices

]]>

The type and year parameters can help narrow down the search for legislation. For example, you might know that you are searching for a UK Public General Act, in which case type=ukpga will help narrow down the search. The type parameter can take the same values as in the non-query URIs. Or you might know that the legislation is from 1947, in which case year=1947 will also help.

If you know the type, year and number of the legislation, perhaps through a more formal reference such as in:

Ss. 6-9: power to modify conferred (E.W.) (1.8.2001 for W. and 26.10.2001 for E.) by 2000 c. 38, s. 134(2)(a); S.I. 2001/2788, art. 2, Sch. 1 para. 2; S.I. 2001/3342, art. 2, Sch.

then you can use the form to construct the URI for the item of legislation without having to be familiar with the template for URIs. For example:

http://www.legislation.gov.uk/id?type=uksi&year=2001&number=2788

This will redirect you directly to the correct URI for the item of legislation.

Listings

The main search page enables you to create listings of legislation as a feed. This is useful if you want to display lists of legislation with a particular keyword or phrase in the title, or all legislation of a particular type in a particular year to aid browsing, for example.

The URI template for the listing is similar to the one for the identifier search:

http://www.legislation.gov.uk/search?title={title}&type={type}&start-year={year}&end-year={year}

You can also use URIs like the following:

http://www.legislation.gov.uk/{type}/{year}
http://www.legislation.gov.uk/{type}/{start-year}-{end-year}
http://www.legislation.gov.uk/title/{title}

A search that sets just the title, or sets just the type, start-year and end-year, will automatically redirect to one of these URIs.

The response will list all the matching legislation. This may run into several pages, in which case links specific to the feed format will take you from page to page.