# Spain BOE Legislation Scraper (`spain-data/spain-boe-legislation`) Actor

Get new Spanish laws, royal decrees, orders and resolutions from the official BOE open data API. Filter by keyword, department and legal rank. Legal metadata and optional full text for AI and legal research.

- **URL**: https://apify.com/spain-data/spain-boe-legislation.md
- **Developed by:** [Roberto Valera Calatrava](https://apify.com/spain-data) (community)
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $3.50 / 1,000 provisions

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Spain BOE Legislation Scraper (Boletín Oficial del Estado)

**Get every new Spanish law, royal decree, ministerial order and resolution** published in the **BOE (Boletín Oficial del Estado)**, Spain's official gazette, as clean structured data. Everything comes from the **official BOE open data API**.

Filter by **keyword, section, issuing department and legal rank**, and optionally get **legal metadata** (entry into force, repeal status, ELI identifier, subject matters, what each provision repeals, amends or transposes) and the **full text**.

> Legislación española del BOE: leyes, reales decretos, órdenes y resoluciones, con metadatos jurídicos y texto completo.

### What does Spain BOE Legislation Scraper do?

- Reads the **daily BOE summary** from the official open data API (no fragile HTML scraping).
- Returns each provision with **title, rank, official number, issuing department, section, dates and links** (PDF, HTML, XML).
- Optionally adds **legal metadata**: approval date, entry into force, repeal and annulment status, **ELI** identifier, subject matters, alerts and **references** (repeals, amends, transposes EU directives...).
- Optionally adds the **full text** of each provision, ready for AI, RAG and search.
- Skips days without a BOE (Sundays) automatically.

### Who is it for?

| You are... | Use it to... |
| --- | --- |
| A law firm or legal department | Track **new legislation** in your practice areas every morning. |
| A compliance or regulatory affairs team | Get a **regulatory alert** for rules that affect your sector. |
| A legal tech or AI company | Build and update a **corpus of Spanish legislation** with full text. |
| A consultancy, association or lobby | Monitor **ministries, regions and topics** for your clients. |
| A journalist or researcher | Analyse regulatory activity by **ministry, rank or subject**. |

### How to use it

1. Click **Try for free** (or **Start**).
2. Optionally enter **keywords** (for example `vivienda`, `protección de datos`, `IRPF`), **departments** or **legal ranks**.
3. Choose how many of the **latest BOE issues** to process, or set a **date range**.
4. Turn on **Include full text** if you need the complete provision.
5. Click **Start** and download the results as **JSON, CSV, Excel or HTML**, or connect an integration.

#### Get a daily regulatory alert (recommended)

1. Save your filters as a **Task** with **Latest issues = 1**.
2. Add a **Schedule** to run it every weekday morning (the BOE is published early in the morning).
3. Connect an **integration** (Google Sheets, Slack, email, Zapier, Make or a webhook).

### Input examples

**Only major legislation (laws and royal decree-laws):**

```json
{
  "sections": ["1"],
  "ranks": ["Ley", "Ley Orgánica", "Real Decreto-ley"],
  "lastIssues": 5
}
```

**Everything about housing, with full text, for a legal AI corpus:**

```json
{
  "keywords": ["vivienda", "alquiler", "arrendamiento"],
  "startDate": "2026-01-01",
  "endDate": "2026-10-31",
  "includeFullText": true
}
```

**Daily alert from the Ministry of Labour (collective agreements included):**

```json
{
  "departments": ["Trabajo"],
  "lastIssues": 1
}
```

#### Input fields

| Field | Description |
| --- | --- |
| Keywords | Words to look for in the title or heading (accents ignored). |
| Exclude keywords | Skip items containing these words. |
| BOE sections | I. General provisions (laws, decrees, orders) and/or III. Other provisions (agreements, grants, collective agreements, court rulings...). |
| Issuing departments | Partial match, e.g. Hacienda, Trabajo, Tribunal Constitucional, Comunidad Autónoma de Cataluña. |
| Legal rank | e.g. Ley, Ley Orgánica, Real Decreto, Real Decreto-ley, Orden, Resolución, Circular. |
| Latest issues | Number of most recent BOE issues to process (use `1` for a daily schedule). |
| Start / end date | Optional date range (up to 1 year). |
| Include legal metadata | Rank, official number, dates, repeal status, ELI, subjects, references. |
| Include full text | Complete text of each provision. |
| Maximum results | Stop after N items. |

### Output example

```json
{
  "id": "BOE-A-2026-22081",
  "titulo": "Real Decreto 847/2026, de 21 de octubre, por el que se establecen las disposiciones mínimas de seguridad y salud aplicables a los trabajos con riesgo de exposición al amianto.",
  "fechaPublicacion": "2026-10-23",
  "numeroBoe": 263,
  "seccion": "I. Disposiciones generales",
  "departamento": "MINISTERIO DE LA PRESIDENCIA, JUSTICIA Y RELACIONES CON LAS CORTES",
  "epigrafe": "Prevención de riesgos laborales",
  "rango": "Real Decreto",
  "numeroOficial": "847/2026",
  "fechaDisposicion": "2026-10-21",
  "fechaVigencia": "2026-10-24",
  "derogada": false,
  "urlEli": "https://www.boe.es/eli/es/rd/2026/10/21/847",
  "materias": ["Seguridad e higiene en el trabajo", "Accidentes de trabajo y enfermedades profesionales"],
  "referenciasAnteriores": [
    { "id": "BOE-A-2006-6474", "relacion": "DEROGA", "texto": "Real Decreto 396/2006, de 31 de marzo" },
    { "id": "DOUE-L-2023-81725", "relacion": "TRANSPONE", "texto": "la Directiva (UE) 2023/2668, de 22 de noviembre" }
  ],
  "urlPdf": "https://www.boe.es/boe/dias/2026/10/23/pdfs/BOE-A-2026-22081.pdf",
  "urlHtml": "https://www.boe.es/diario_boe/txt.php?id=BOE-A-2026-22081"
}
```

With **Include full text** enabled, each item also has a `texto` field with the complete provision.

### How much does it cost?

You pay **only for the provisions you get**: **$5 per 1,000 results** (half a cent per provision). Platform usage is included, also with full text.

| Typical use | Approximate cost |
| --- | --- |
| Daily alert with ~10 matching provisions | about $0.05 per day (~$1 per month) |
| Full BOE (sections I and III) for one day, ~60 provisions | about $0.30 |
| One-year corpus on a topic, ~1,000 provisions with full text | about $5 |

Apify's free plan includes monthly credits, so you can try it at no cost.

### FAQ

**Where does the data come from?**
From the official open data API of the Agencia Estatal Boletín Oficial del Estado (www.boe.es).

**How fresh is the data?**
The BOE is published every day except Sundays, early in the morning. Run the Actor with *Latest issues = 1* each morning to get the new provisions.

**Does it include regional gazettes (DOGC, BOJA, BOCM...)?**
Not yet. It covers the BOE, which also publishes many regional laws and agreements in sections I and III.

**Why are appointments and civil service exams not included?**
Section II of the BOE mostly concerns specific people. To respect data protection rules, this Actor only covers sections I and III and skips items about specific individuals.

**Can I use the full text to train or feed an AI?**
Yes, the BOE open data is offered for reuse. Always cite the source (Agencia Estatal BOE).

### Data source and privacy

Data comes from the open data API of the Agencia Estatal Boletín Oficial del Estado, offered for reuse under Spanish public sector information reuse rules. Source: Agencia Estatal BOE (www.boe.es).

This Actor only covers **Section I (general provisions)** and **Section III (other provisions)**. To respect data protection rules, it **does not** include Section II (appointments and civil service exams) or court and administrative notices, and it **automatically skips** items about specific private individuals (such as grants of nationality or pardons).

This Actor is not affiliated with or endorsed by the Agencia Estatal BOE or the Spanish government.

### Related Actors

- **[Spain Public Tenders Scraper](https://apify.com/spain-data/spain-public-tenders)**: new Spanish public tenders (licitaciones) from the official procurement platform, with filters by keyword, CPV, region and budget.

### Feedback

Found a bug or need a new field or filter? Open an issue in the **Issues** tab and it will be looked at quickly.

***

**Resumen en español:** obtén cada día las nuevas leyes, reales decretos, órdenes y resoluciones del BOE desde la API oficial de datos abiertos. Filtra por palabras clave, sección, departamento y rango, con metadatos jurídicos (vigencia, derogaciones, ELI, materias) y texto completo opcional. Ideal para despachos, compliance, alertas normativas e IA jurídica.

# Actor input Schema

## `keywords` (type: `array`):

Only return items whose title or heading contains at least one of these words (Spanish, accents ignored). Example: protección de datos, vivienda, IRPF.

## `excludeKeywords` (type: `array`):

Skip items containing any of these words.

## `sections` (type: `array`):

Section I contains laws, royal decrees and ministerial orders. Section III contains other provisions: collective agreements, grants, agreements, court rulings, etc.

## `departments` (type: `array`):

Filter by issuing body (partial match, accents ignored). Example: Hacienda, Trabajo, Tribunal Constitucional, Comunidad Autónoma de Cataluña.

## `ranks` (type: `array`):

Filter by type of provision, e.g. Ley, Ley Orgánica, Real Decreto, Real Decreto-ley, Orden, Resolución, Circular.

## `lastIssues` (type: `integer`):

Number of most recent BOE issues to process (days without a BOE, such as Sundays, are skipped). Ignored if a date range is set. Use 1 for a daily schedule.

## `startDate` (type: `string`):

Optional. Process every BOE from this date (YYYY-MM-DD). Max range: 1 year.

## `endDate` (type: `string`):

Optional. Last date of the range (defaults to today).

## `includeDetails` (type: `boolean`):

Adds rank, official number, dates of approval and entry into force, repeal status, ELI identifier, subject matters and references (repeals, amends, transposes...).

## `includeFullText` (type: `boolean`):

Adds the complete text of each provision. Ideal for AI, RAG and legal analysis.

## `maxItems` (type: `integer`):

Stop after this many items.

## Actor input object example

```json
{
  "sections": [
    "1",
    "3"
  ],
  "lastIssues": 1,
  "includeDetails": true,
  "includeFullText": false,
  "maxItems": 20
}
```

# Actor output Schema

## `results` (type: `string`):

No description

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "sections": [
        "1",
        "3"
    ],
    "lastIssues": 1,
    "maxItems": 20
};

// Run the Actor and wait for it to finish
const run = await client.actor("spain-data/spain-boe-legislation").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "sections": [
        "1",
        "3",
    ],
    "lastIssues": 1,
    "maxItems": 20,
}

# Run the Actor and wait for it to finish
run = client.actor("spain-data/spain-boe-legislation").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "sections": [
    "1",
    "3"
  ],
  "lastIssues": 1,
  "maxItems": 20
}' |
apify call spain-data/spain-boe-legislation --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,spain-data/spain-boe-legislation"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/f8SibK9uM8raS9jOj/builds/3g6yZaxlcj34rHhvX/openapi.json
