Search Legislation

Searching

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

The Legislation API offers two types of searches:

  • identifier searches enable you to work out the correct identifier to use for an item or section of legislation
  • listings enable you to find multiple items of legislation and information about them

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 an XHTML document.

Within the form, the title field should hold the query against which the title will be searched. The query is case-insenstive and punctuation sensitive. For example, the following will all return the same results:

http://www.legislation.gov.uk/id?title=TRANSPORT
http://www.legislation.gov.uk/id?title="tRanSPort
http://www.legislation.gov.uk/id?title="transport

The title query can take the '+', '-' and ""double quote operators. When a phrase is encapsulated in double quotes then that exact phrase is matched. For example, the following will match any title that contains the words 'Transport Act 1985' in that specific order:

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

Words preceded by a '+' operator and not encapsulated in double quotes will match titles with those words though not in any given order. For example, the following two queries will return the same result:

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

Words preceded by a '-' operator and will match those titles that do not contain such a word. Multiple '-' operators will match those titles that do not contain all of the '-' operated words. For example, the folowing query will match any title that does not contain the word 'criminal' and the word 'law' but does contain the word 'act':

http://www.legislation.gov.uk/id?title=Act -criminal -law

These operators can be combined to form advanced queries. For example, the following will match any title that contains the phrase 'Greater london', the word 'Act' but does not contain the word 'criminal':

http://www.legislation.gov.uk/id?title="Greater London" + Act -criminal

If the result of the query is a single piece of legislation, you will be redirected to that piece of legislation.

On the other hand, if multiple items of legislation match the query, 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

<ul>
  <li>
    <a href="http://www.legislation.gov.uk/id/uksi/1991/145">Act of Sederunt (Applications under Part VII of the Companies Act 1989) 1991</a>
  </li>
  <li>
    <a href="http://www.legislation.gov.uk/id/ukpga/Will4and1Vict/7/73">Chartered Companies Act 1837 (repealed 5.11.1993)</a>
  </li>
  <li>
    <a href="http://www.legislation.gov.uk/id/ukpga/Vict/47-48/56">Chartered Companies Act 1884 (repealed 5.11.1993)</a>
  </li>
  <li>
    <a href="http://www.legislation.gov.uk/id/apni/1960/22">Companies Act (Northern Ireland) 1960</a>
  </li>
  <li>
    <a href="http://www.legislation.gov.uk/id/ukpga/Geo6/10-11/47">Companies Act 1947</a>
  </li>
  ...
</ul>

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. Searches over multiple types can be conducted by concatenating the type together with a '+' operator, in such a case type=ukpga+uksi will search on both UK Public General Act and UK Statutory Instruments. A wild card '*' operator type=* will search over all legislation. If the wild card and specific types are mixed type=*+uksi, the result will be as per the wild card. The type parameter can take the same values as in the non-query URIs.

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}&start-number={number}&end-number={number}&version={version}

You can also use simple 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/{type}/{year}/{start-number}-{end-number}

Searches that can be mapped to these simple URIs will automatically redirect to them.

When using a querying across all legislation, the word all can be used, for example:

http://www.legislation.gov.uk/all/2010

The keywords primary and secondary can also be used to search only primary or secondary legislation.

Start and end years can take a asterisk as a wild card, for example:

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

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.