BOE Insights
v0.2.1Analytics over Spain's BOE open data: law version history, amendments and legislative trends.
These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.
search_legislation Search Spanish legislation
Find laws by title, text, rank, department, scope or publication date. Answers 'which laws are about X?' or 'what was published recently?'. Use resolve_reference instead when you already know a law's name or number. Returns compact records. The API gives no total count: while has_more is true, request the next page with next_offset. Only consolidated legislation is covered, not every item published in the BOE. With no filters it lists the most recently published laws.
| Parameter | Type | Description |
|---|---|---|
department_code | BOE department code, e.g. '7723' (Jefatura del Estado). Look codes up with find_codes. | |
descending | boolean | Newest first when true. |
limit | integer | Results per page. |
offset | integer | Start position; pass next_offset from the previous page. |
published_from | Earliest publication date, ISO format, e.g. 2020-01-01. | |
published_to | Latest publication date, ISO format, e.g. 2020-12-31. | |
rank | Only laws of this rank, e.g. 'ley_organica'. | |
scope | string | 'state' (national), 'regional' (autonomous communities) or 'any'. |
sort_by | string | Sort by publication, last-update or enactment date. |
subject_code | BOE subject (materia) code. Look codes up with find_codes. | |
text | Words that must all appear in the law's body text. | |
title | Words that must all appear in the title, e.g. 'protección de datos'. |
resolve_reference Resolve a law reference
Turn a law's name or number into its BOE identifier. Answers 'what is the identifier of Ley 40/2015?'. Call this before get_law_overview, which needs an identifier. Accepts a rank and number ('Ley Orgánica 3/2018', 'RDL 6/2019'), a bare number, an identifier or a title fragment. Returns status 'resolved' (one match), 'ambiguous' (candidates; follow the hint) or 'not_found'. To explore laws by topic rather than look up a known one, use search_legislation.
| Parameter | Type | Description |
|---|---|---|
reference * | string | A law as people name it: 'Ley 40/2015', 'Real Decreto-ley 6/2019', 'LO 3/2018', 'BOE-A-2015-10566' or a title fragment. Years need four digits. |
get_law_overview Get a law overview
Summarise one law: identity, legal status and how much it has been amended. Answers 'is this law still in force, and how much has it changed?'. Returns title, rank, dates, a status with a plain-English note, the BOE's initial note when it has one, and counts and samples of the norms that amend it or that it amends. The status is derived from the BOE flags (repealed, annulled, validity exhausted), from the amendment references (later norms that repeal it, giving 'partially_repealed') and from a repeal note opening the text, so it is an indication, not a legal determination: 'in_force' does not…
| Parameter | Type | Description |
|---|---|---|
law_id * | string | BOE identifier of the law, e.g. BOE-A-2015-10566. |
find_codes Find BOE codes
Look up BOE department, subject or rank codes by name. Answers 'what is the department_code of the Agencia Española de Protección de Datos?'. Use it to get the values for the department_code and subject_code filters of search_legislation. Matching ignores case and accents and needs every word; the shortest names come first. Subjects are a large flat list, so use specific words.
| Parameter | Type | Description |
|---|---|---|
kind * | string | Which BOE code table to search. |
text * | string | Words that must all appear in the name, e.g. 'protección de datos'. |
limit | integer | Maximum matches to return. |
get_amendment_history List the amendments of a law
List the later norms that amended, repealed or otherwise affected a whole law. Answers 'which laws changed Ley 40/2015, and when?'. Get law_id from resolve_reference. Newest first. Filter with group (repeals, modifies, adds, corrections, other; default all). Returns counts per group and per year, then one page of items with law_id, year, relation and text; while has_more is true, pass next_offset as offset. It names the norms, not the articles they touched: for one article use get_article_history. Derived from BOE references, so informational.
| Parameter | Type | Description |
|---|---|---|
law_id * | string | BOE identifier of the law, e.g. BOE-A-2015-10566. Get it from resolve_reference. |
group | string | Kind of amending norm: 'repeals' (also annulments), 'modifies', 'adds', 'corrections', 'other' or 'all'. |
limit | integer | Items per page. |
offset | integer | Start position; pass next_offset from the previous page. |
read_article Read an article
Read the text of one article of a law as in force on a date. Answers 'what does article 46 bis of Ley 40/2015 say, today or on 2017-01-01?'. Get law_id from resolve_reference. If several blocks match, or none, outcome is 'ambiguous' or 'not_found' and candidates lists blocks to retry with as block_id. When the whole law is repealed, state is 'repealed' although the article shows no marker. Long texts come in parts: while truncated is true, pass next_offset as offset. For changes over time use compare_article_versions or get_article_history. Consolidated text is informational, not official.
| Parameter | Type | Description |
|---|---|---|
law_id * | string | BOE identifier of the law, e.g. BOE-A-2015-10566. Get it from resolve_reference. |
article | The article or provision designation, e.g. '46 bis', 'art. 1.902', 'disposición adicional tercera'. Give this or block_id. | |
as_of | Show the text valid on this date, ISO format, e.g. 2017-01-01. Default: today. | |
block_id | Exact block_id taken from candidates. Give this or article, not both. | |
max_chars | integer | Largest part of the text to return. |
offset | integer | Start character; pass next_offset from the previous part, with the same other arguments. |
compare_article_versions Compare article versions
Show how one article's text differs between two dates. Answers 'what changed in article 48 between 2017-01-01 and today?'. Returns the added, removed and reworded paragraphs (rewordings marked [-old-] {+new+}; tables give both texts), a unified diff and the norms that amended the article in between. If the article did not exist on from_date, everything shows as added. If the whole law was repealed, note says so. Output is capped: see changes_truncated and unified_truncated, and raise max_changes or max_chars for more. To list every amendment use get_article_history. Consolidated text is infor…
| Parameter | Type | Description |
|---|---|---|
from_date * | string | Earlier date, ISO format, e.g. 2017-01-01. |
law_id * | string | BOE identifier of the law, e.g. BOE-A-2015-10566. Get it from resolve_reference. |
article | The article or provision designation, e.g. '46 bis', 'art. 1.902', 'disposición adicional tercera'. Give this or block_id. | |
block_id | Exact block_id taken from candidates. Give this or article, not both. | |
max_changes | integer | Most changed paragraphs to list. |
max_chars | integer | Largest total text of the listed changes. |
to_date | Later date, ISO format. Default: today. |
get_article_history Get an article's history
List the versions of one article: when each took effect, who amended it, what changed. Answers 'when and by which laws was article 48 amended?'. Each event is original, amended or repealed, with the paragraphs added, removed and changed against the previous version. To see what changed between two dates use compare_article_versions; for the amendments of the whole law, not one article, use get_amendment_history. At most the 60 most recent versions are returned; truncated says when older ones are left out. current_state is 'repealed' also when the whole law is repealed. Informational, not offi…
| Parameter | Type | Description |
|---|---|---|
law_id * | string | BOE identifier of the law, e.g. BOE-A-2015-10566. Get it from resolve_reference. |
article | The article or provision designation, e.g. '46 bis', 'art. 1.902', 'disposición adicional tercera'. Give this or block_id. | |
block_id | Exact block_id taken from candidates. Give this or article, not both. |
get_law_structure Get a law's table of contents
Table of contents of a law: books, titles, chapters, sections and article headings, each with the block_id to pass to the article tools. Use it to find which article deals with a matter before reading it. Large codes need paging or detail='headings'.
| Parameter | Type | Description |
|---|---|---|
law_id * | string | BOE identifier of the law, e.g. BOE-A-2015-10566. Get it from resolve_reference. |
as_of | Show the structure valid on this date, ISO format, e.g. 2017-01-01. Default: today. | |
detail | string | 'headings' leaves out the articles and provisions. |
limit | integer | Entries per page. |
offset | integer | Start position; pass next_offset from the previous page. |
legislation_over_time Count laws over time
Count laws per year, quarter or month, optionally split by rank, department or scope. Answers 'how much legislation on X over time?'. Counts consolidated legislation only.
| Parameter | Type | Description |
|---|---|---|
date_basis | string | Date to count by: 'published' (BOE publication) or 'enacted'. |
department_code | BOE department code. Look codes up with find_codes. | |
from_date | Start of the range, ISO format. Default: 1 January of the year 19 years before to_date. | |
group_by | string | Split by 'rank', 'department' or 'scope'; 'none' gives one series. |
period | string | Period size: 'year', 'quarter' or 'month'. |
rank | Only laws of this rank, e.g. 'real_decreto_ley'. | |
scope | string | 'state' (national), 'regional' (autonomous communities) or 'any'. |
subject_code | BOE subject (materia) code. Look codes up with find_codes. | |
text | Words that must all appear in the law's body text (exact words). | |
title | Words that must all appear in the title (whole words; singular and plural forms both match), e.g. 'teletrabajo'. | |
to_date | End of the range, ISO format. Default: today. | |
top_groups | integer | Groups to list; the rest is 'other'. |
top_departments Rank departments by laws
Rank the departments (ministries, Jefatura del Estado, autonomous communities) by laws. Counts laws in a period. Answers 'who legislates most on X?'.
| Parameter | Type | Description |
|---|---|---|
date_basis | string | Date to count by: 'published' (BOE publication) or 'enacted'. |
from_date | Start of the range, ISO format. Default: 1 January of the year 19 years before to_date. | |
limit | integer | Departments to list. |
rank | Only laws of this rank, e.g. 'real_decreto_ley'. | |
scope | string | 'state' (national), 'regional' (autonomous communities) or 'any'. |
subject_code | BOE subject (materia) code. Look codes up with find_codes. | |
text | Words that must all appear in the law's body text (exact words). | |
title | Words that must all appear in the title (whole words; singular and plural forms both match), e.g. 'teletrabajo'. | |
to_date | End of the range, ISO format. Default: today. |
compare_topics Compare topics over time
Compare how often several topics appear in legislation over time. Each topic is title words, body words or a subject code.
| Parameter | Type | Description |
|---|---|---|
topics * | array | 2 to 5 topics, each with a name and at least one of title, text or subject_code. |
date_basis | string | Date to count by: 'published' (BOE publication) or 'enacted'. |
department_code | BOE department code. Look codes up with find_codes. | |
from_date | Start of the range, ISO format. Default: 1 January of the year 19 years before to_date. | |
period | string | Period size: 'year', 'quarter' or 'month'. |
rank | Only laws of this rank, e.g. 'real_decreto_ley'. | |
scope | string | 'state' (national), 'regional' (autonomous communities) or 'any'. |
to_date | End of the range, ISO format. Default: today. |
explain_spike Explain a spike in legislation
Explain why a period has unusually many laws. Shows which ranks, departments and scopes grew against the preceding periods, with the laws themselves. Without period_key it picks the strongest spike in the range.
| Parameter | Type | Description |
|---|---|---|
baseline_periods | integer | Preceding periods to compare with. |
date_basis | string | Date to count by: 'published' (BOE publication) or 'enacted'. |
department_code | BOE department code. Look codes up with find_codes. | |
from_date | Start of the range, ISO format. Default: 1 January of the year 19 years before to_date. | |
max_laws | integer | Laws to list. |
period | 'year', 'quarter' or 'month'. Default: what period_key shows, else 'year'. | |
period_key | Period to explain: '2020', '2020-Q2' or '2020-03'. Default: the strongest spike in the range. | |
rank | Only laws of this rank, e.g. 'real_decreto_ley'. | |
scope | string | 'state' (national), 'regional' (autonomous communities) or 'any'. |
subject_code | BOE subject (materia) code. Look codes up with find_codes. | |
text | Words that must all appear in the law's body text (exact words). | |
title | Words that must all appear in the title (whole words; singular and plural forms both match), e.g. 'teletrabajo'. | |
to_date | End of the range, ISO format. Default: today. |
most_amended_laws Find the most amended laws
Rank laws by how many later laws amended them, within a filtered set. Examines a limited number of laws per call; when complete is false, call again to continue.
| Parameter | Type | Description |
|---|---|---|
date_basis | string | Date to count by: 'published' (BOE publication) or 'enacted'. |
department_code | BOE department code. Look codes up with find_codes. | |
from_date | Only laws published on or after this date, ISO format. | |
limit | integer | Laws to return. |
max_laws | integer | Most laws to examine in this call (one request each). |
rank | Only laws of this rank, e.g. 'real_decreto_ley'. | |
scope | string | 'state' (national), 'regional' (autonomous communities) or 'any'. |
subject_code | BOE subject (materia) code. Look codes up with find_codes. | |
text | Words that must all appear in the law's body text (exact words). | |
title | Words that must all appear in the title (whole words; singular and plural forms both match), e.g. 'teletrabajo'. | |
to_date | Only laws published on or before this date, ISO format. |
get_daily_summary Get a day's BOE summary
Everything the BOE published on one day: dispositions, appointments, grants and announcements, by section and department. Covers the whole gazette since 1960-09-01, not just consolidated laws. Without a date it gives the latest issue.
| Parameter | Type | Description |
|---|---|---|
date | Day to show, ISO format, e.g. 2020-03-14. Default: the latest issue. | |
department_code | Only this department code. Look codes up with find_codes. | |
limit | integer | Items per page. |
offset | integer | Start position; pass next_offset from the previous page. |
section | Only this section code, e.g. '1', '2A', '3', '5B'. | |
words | Words that must all appear in the title (whole words; singular and plural forms both match). |
scan_gazette Scan the BOE over several days
Find items published in the BOE over a range of up to 31 days whose title has given words, or that belong to a section or department. Matches titles only, whole words; singular and plural forms both match. When complete is false, call again to continue.
| Parameter | Type | Description |
|---|---|---|
department_code | Only this department code. Look codes up with find_codes. | |
from_date | First day, ISO format. Default: 6 days before to_date. | |
limit | integer | Items per page. |
offset | integer | Start position; pass next_offset from the previous page. |
section | Only this section code, e.g. '1', '2A', '3', '5B'. | |
to_date | Last day, ISO format. Default: today. | |
words | Words that must all appear in the title (whole words; singular and plural forms both match). |
verify_citation Verify citations of laws
Check citations of Spanish laws against the consolidated text: whether the law and article exist, their state on a date, and whether quoted words match the text, the current version or an older one. Reports facts, not legal correctness. Compares words, not meaning: a paraphrase does not match.
| Parameter | Type | Description |
|---|---|---|
citations * | array | 1 to 10 citations to check. |
explore_amendment_chain Explore an amendment chain
Follow amendments between laws for up to three levels: the laws that amended a law and the laws that amended those (amended_by), or what a law amended (amends). A law two levels away amended the intermediate law, not necessarily the parts that touch the starting law. Examines a limited number of laws per call; when complete is false, call again to continue.
| Parameter | Type | Description |
|---|---|---|
law_id * | string | BOE identifier of the law, e.g. BOE-A-2015-10566. Get it from resolve_reference. |
depth | integer | Levels to follow: 1 is only the direct amendments. |
details | string | Which edges carry the BOE's reference text: 'root' (those touching the starting law), 'all' or 'none'. |
direction | string | 'amended_by': the laws that amended it; 'amends': the laws it amended. |
include | string | 'amendments' (modifications, repeals, additions, suspensions) or 'all', which adds corrections, citations and judicial references. |
max_laws | integer | Most laws to read in this call (one request each). |
save_search Save a search
Save a search to re-check later: gazette items by title words, section or department, or one law to follow for amendments and court rulings. Nothing is sent automatically; call check_saved_searches to see what is new. A name is proposed when none is given.
| Parameter | Type | Description |
|---|---|---|
department_code | Only this department code. Look codes up with find_codes. | |
law_id | BOE identifier of a consolidated law to follow, e.g. BOE-A-2015-10566 (use resolve_reference). | |
name | Name for the search; default: one built from its filters. | |
section | Only this section code, e.g. '1', '2A', '3', '5B'. | |
words | Words that must all appear in the title (whole words; singular and plural forms both match). |
list_saved_searches List saved searches
The saved searches, with their filters and when each was last checked.
check_saved_searches Check saved searches for news
What is new for the saved searches since each was last checked; what is shown is marked as seen. Covers at most the last 31 days; shows up to 60 items per call, so call again while complete is false. since re-reads gazette searches up to 90 days back without marking anything.
| Parameter | Type | Description |
|---|---|---|
limit | integer | New items or changes shown per search per call; the rest stay new. |
name | Check only this saved search; default: all. | |
since | Re-read gazette searches from this date (at most 90 days back) without marking anything as seen. |
edit_saved_search Edit a saved search
Rename a saved search or change its gazette filters. Its last-checked point is kept.
| Parameter | Type | Description |
|---|---|---|
name * | string | Name of the saved search (see list_saved_searches). |
department_code | New value; an empty string removes this filter. | |
new_name | New name for the search. | |
section | New value; an empty string removes this filter. | |
words | New value; an empty string removes this filter. |
delete_saved_search Delete a saved search
Delete a saved search. This cannot be undone.
| Parameter | Type | Description |
|---|---|---|
name * | string | Name of the saved search (see list_saved_searches). |