Search

Pass q to /api/v1/{country}/laws and the endpoint switches from listing to full-text search, ranked by relevance. Filters, pagination and response formats work exactly the same in both modes.

How results are ranked

Ranking is length-normalised, so the norm itself wins over the norms that amend it — searching codigo penal returns the Código Penal first, not the twenty laws whose titles quote it. A title containing your query verbatim gets an extra boost.

bash
curl -H "Authorization: Bearer $LEGALIZE_API_KEY" \ 'https://legalize.dev/api/v1/es/laws?q=constitucion' # → "Constitución Española" first, out of 49 matches

Each result carries a title_snippet with the matched terms already wrapped in <mark>, ready to render.

Searching by law number

Cite a norm the way a lawyer does — Ley 2/2026, Ley Orgánica 10/1995 — and the number is matched exactly rather than split into two loose digits. You get the norms carrying that number, not every law published in 2026.

bash
curl -H "Authorization: Bearer $LEGALIZE_API_KEY" \ 'https://legalize.dev/api/v1/es/laws?q=ley%202/2026' # → the four norms numbered 2/2026, nothing else

This works wherever the country writes the number into the title (n/YYYY). Where it doesn't — Sweden's 1979:368, France's 2016-1321 — the query falls back to fuzzy title matching, which also covers typos.

Filters and pagination

Every filter available when listing also applies to a search: law_type, jurisdiction, year, status, from_date, to_date, sort. Results paginate with page and per_page like any list, and total is the true match count.

# Andalusian housing laws, every match, paged for you. for law in client.laws.search_iter("es", q="vivienda", jurisdiction="es-an"): print(law.title)
for await (const law of client.laws.searchIter("es", "vivienda", { jurisdiction: "es-an" })) { console.log(law.title); }
it := client.Laws.SearchIter(ctx, "es", "vivienda", 100, 0, opts) for it.Next() { fmt.Println(it.Value().Title) }

Auto-paginating a search needs Python SDK 0.2.1 or newer. Earlier versions stop at the first page.

What search covers

Search runs over law titles, not the article text, and matches whole words by prefix. That last point has a consequence worth knowing: a plural does not find a singular. viviendas and vivienda return different result sets, so search the singular form when you want the widest net.