Sign inTry it

Search UK legislation on legislation.gov.uk.

Searches legislation.gov.uk like its full-text search: title, year and number, legislation type and link, in the site's order. First page of results (about 10 items). Returns an empty list when nothing matches.

No reports yetRead-only, no login
Site
legislation.gov.uk, United Kingdom
Version
v1
Runs, last 7 days
No reports yet
sha256
07d58f8cda73…

Run it with your agent

after installing Wield

Ask in plain words. Your agent finds this recipe and calls it:

“Search UK legislation on legislation.gov.uk.”

Read-only: it changes nothing on the site. No login needed.

{
  "tool": "run",
  "arguments": {
    "recipe_id": "legislation.gov.uk/search-government",
    "params": {
      "query": "data protection"
    }
  }
}

Requests

sent from your browser, in order
  1. 1GET/all?textServer-rendered full-text search results (read-only GET). /search?text=… redirects to /all?text=…; the result rows are tr.oddRow / tr.evenRow with the title link in the first cell.

Parameters

from your agent
querystringrequiredWords that appear in the title or text of UK legislation, e.g. 'data protection', 'equality act', 'housing act'

Returns

to your agent
itemsobject[]reference, title, type, url
querystring

Where it can send

  • www.legislation.gov.uk

Anything else is blocked by the extension.

Reads from your session

Nothing. Your browser attaches the site's cookies by itself.

Used only in requests to the addresses on the left. Never sent to wield.run or your agent.

Checks

a run passes when
  • length(output.items) > `0`
  • length(output.items[?title != `null`]) == length(output.items)
  • length(output.items[?starts_with(url, 'https://www.legislation.gov.uk/')]) == length(output.items)

Raw recipe

Served as canonical JSON from /api/v1/recipes/legislation.gov.uk/search-government, so its sha256 matches the ETag and the index.

Check it yourself
curl -s https://wield.run/api/v1/recipes/legislation.gov.uk/search-government | shasum -a 256
# 07d58f8cda736d8a925b709087a45720dd830aff3633c9e77cb60d09e85a5b16
legislation.gov.uk/search-government.json, v1
{
  "description": "Searches legislation.gov.uk like its full-text search: title, year and number, legislation type and link, in the site's order. First page of results (about 10 items). Returns an empty list when nothing matches.",
  "effect": "read",
  "id": "legislation.gov.uk/search-government",
  "keywords": [
    "legislation",
    "legislation.gov.uk",
    "law",
    "laws",
    "act",
    "acts",
    "statute",
    "regulation",
    "gesetz",
    "gesetze",
    "recht",
    "uk law",
    "statutory instrument"
  ],
  "output": {
    "schema": {
      "properties": {
        "items": {
          "items": {
            "properties": {
              "reference": {
                "description": "Year and number as shown, e.g. '2016 No. 679'",
                "type": [
                  "string",
                  "null"
                ]
              },
              "title": {
                "type": "string"
              },
              "type": {
                "description": "Legislation type, e.g. 'Regulations originating from the EU'",
                "type": [
                  "string",
                  "null"
                ]
              },
              "url": {
                "type": "string"
              }
            },
            "required": [
              "title",
              "url"
            ],
            "type": "object"
          },
          "type": "array"
        },
        "query": {
          "type": "string"
        }
      },
      "required": [
        "query",
        "items"
      ],
      "type": "object"
    },
    "value": "{query: params.query, items: steps.search.items[?title != `null` && href != `null`].{title: title, reference: reference || `null`, type: type || `null`, url: join('', ['https://www.legislation.gov.uk', href])}}"
  },
  "params": {
    "additionalProperties": false,
    "properties": {
      "query": {
        "description": "Words that appear in the title or text of UK legislation, e.g. 'data protection', 'equality act', 'housing act'",
        "maxLength": 100,
        "minLength": 2,
        "type": "string"
      }
    },
    "required": [
      "query"
    ],
    "type": "object"
  },
  "provenance": {
    "method": "har",
    "notes": "GET /search?text=… (redirects to /all?text=…) returns server-rendered result rows (tr.oddRow, tr.evenRow) with the title link in the first cell, the year and number in the second, and the legislation type in the third. The q parameter used by the search_url gives only the search form, so the text parameter is used. Fetched once with the same page a visitor loads. Only the first page of results is read.",
    "recorded_at": "2026-11-08T16:50:00.000Z",
    "recorded_by": "wield-forge (claude-haiku agent)"
  },
  "requires_login": false,
  "schema": "https://wield.run/schema/recipe/v1.json",
  "site": {
    "country": "GB",
    "id": "legislation.gov.uk",
    "language": "en",
    "name": "legislation.gov.uk",
    "origin": "https://www.legislation.gov.uk",
    "origins": [
      "https://www.legislation.gov.uk"
    ]
  },
  "steps": [
    {
      "description": "Server-rendered full-text search results (read-only GET). /search?text=… redirects to /all?text=…; the result rows are tr.oddRow / tr.evenRow with the title link in the first cell.",
      "expect": {
        "content_type": "html",
        "status": [
          200
        ]
      },
      "extract": {
        "html_items": {
          "items": {
            "fields": {
              "href": {
                "attr": "href",
                "selector": "td:nth-child(1) a"
              },
              "reference": {
                "selector": "td:nth-child(2)"
              },
              "title": {
                "selector": "td:nth-child(1) a"
              },
              "type": {
                "selector": "td:nth-child(3)"
              }
            },
            "max": 50,
            "selector": "tr.oddRow, tr.evenRow"
          }
        }
      },
      "id": "search",
      "request": {
        "headers": {
          "Accept": "text/html"
        },
        "method": "GET",
        "query": {
          "text": "{{params.query}}"
        },
        "url": "/all"
      }
    }
  ],
  "task": "Search UK legislation on legislation.gov.uk",
  "tos": {
    "notes": "Not reviewed. One search page per call, the same page a visitor loads. The site's terms on automated access were not checked.",
    "reviewed": false
  },
  "verify": {
    "checks": [
      "length(output.items) > `0`",
      "length(output.items[?title != `null`]) == length(output.items)",
      "length(output.items[?starts_with(url, 'https://www.legislation.gov.uk/')]) == length(output.items)"
    ],
    "example_params": {
      "query": "data protection"
    },
    "max_ms": 5000
  },
  "version": 1
}