# Spain Electricity Prices (PVPC, REE/ESIOS) (`innovito/precios-luz-pvpc`) Actor

Official Spanish PVPC hourly electricity prices (precio PVPC API) from the ESIOS public archive (Red Eléctrica). No API token. Peninsula and Ceuta-Melilla in €/MWh and €/kWh, plus published components. Built for comparadores, alertas horarias and n8n / automations.

- **URL**: https://apify.com/innovito/precios-luz-pvpc.md
- **Developed by:** [Asier Sanchez](https://apify.com/innovito) (community)
- **Categories:** Automation
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $2.50 / 1,000 hourly pvpc prices

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

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 Electricity Prices (PVPC, REE/ESIOS)

Get the official **Spanish PVPC hourly electricity price** (Precio Voluntario para el Pequeño Consumidor) as clean JSON or CSV rows.

The Actor downloads **ESIOS archive 70**, a public JSON published by Red Eléctrica de España. **No API token is required.** This is the regulated PVPC used by comparators, hourly alerts and home or industry automations (including n8n) — not the wholesale day-ahead spot from `apidatos.ree.es`.

### What this Actor does

- Reads the official public archive for each requested day (Peninsula and Ceuta-Melilla).
- Writes **one dataset row per hour** (normally 24 rows per day).
- Keeps the official unit **€/MWh** and adds a derived **€/kWh** value (÷ 1,000).
- Includes the published tariff components and the official archive URL for that day.

### What you get

| Field | Description |
|---|---|
| `date`, `hour`, `hourStart` | Day and hour slot (`00-01` … `23-24`) |
| `pcbEurPerMwh` | Peninsula price, official unit **€/MWh** |
| `cymEurPerMwh` | Ceuta and Melilla price, **€/MWh** |
| `pcbEurPerKwh`, `cymEurPerKwh` | Same prices divided by 1,000, in **€/kWh** (derived, for convenience) |
| `coefficient2Td` | Official 2.0TD coefficient (`COF2TD`) when present |
| `componentsPcb`, `componentsCym` | Published components (market, adjustment, fees, energy term, marketing margin, hourly charge, etc.) |
| `unitOfficial` | Always `EUR/MWh` |
| `sourceUrl` | Official archive URL for that day |
| `sourceAttribution` | Required credit line |
| `scrapedAt` | UTC timestamp of the run |

### Configuration

| Input field | Type | Default | Description |
|---|---|---|---|
| `dateFrom` | date (`YYYY-MM-DD`) | (empty) | First day to include. Example: `2026-11-22`. If empty, the Actor uses `lookbackDays`. |
| `dateTo` | date (`YYYY-MM-DD`) | today (UTC) | Last day to include. The next day’s PVPC is usually published the evening before. |
| `lookbackDays` | integer | `1` | Used only when `dateFrom` is empty. How many days to request ending at `dateTo`. Maximum 31. |
| `maxItems` | integer | `0` | Stop after this many hourly rows. `0` = no limit. A full day is 24 rows. |

### Input example

```json
{
  "dateFrom": "2026-11-22",
  "dateTo": "2026-11-22",
  "maxItems": 24
}
```

### Output example

```json
{
  "date": "2026-11-22",
  "hour": "00-01",
  "hourStart": 0,
  "pcbEurPerMwh": 143.45,
  "cymEurPerMwh": 143.45,
  "pcbEurPerKwh": 0.14345,
  "cymEurPerKwh": 0.14345,
  "coefficient2Td": 0.934,
  "componentsPcb": {
    "market": 80.12,
    "adjustment": 5.0,
    "omFee": 0.5,
    "osFee": 0.3,
    "interruptibility": 0.0,
    "capacityPayment": 2.1,
    "energyTerm": 40.0,
    "marketingMargin": 3.0,
    "edsr": 0.0,
    "hourlyCharge": 12.43
  },
  "componentsCym": {
    "market": 80.12,
    "adjustment": 5.0,
    "omFee": 0.5,
    "osFee": 0.3,
    "interruptibility": 0.0,
    "capacityPayment": 2.1,
    "energyTerm": 40.0,
    "marketingMargin": 3.0,
    "edsr": 0.0,
    "hourlyCharge": 12.43
  },
  "unitOfficial": "EUR/MWh",
  "sourceUrl": "https://api.esios.ree.es/archives/70/download_json?locale=es&date=2026-11-22",
  "sourceAttribution": "Fuente: Red Eléctrica de España (ESIOS), archivo 70 PVPC. https://www.esios.ree.es",
  "scrapedAt": "2026-11-23T21:00:00+00:00"
}
```

A run summary (days requested, days with data, prices pushed) is saved in the default key-value store as `RUN_STATS`.

### Python example (`apify-client`)

```python
from apify_client import ApifyClient

client = ApifyClient("YOUR_APIFY_TOKEN")
run = client.actor("innovito/precios-luz-pvpc").call(
    run_input={
        "dateFrom": "2026-11-22",
        "dateTo": "2026-11-22",
        "maxItems": 24,
    }
)
for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(item["date"], item["hour"], item["pcbEurPerMwh"], item["pcbEurPerKwh"])
```

You can also schedule the Actor daily and send the dataset to Google Sheets, Slack, Make, Zapier or n8n.

### Pricing

Pay-per-event: $2.50 per 1,000 hourly prices written to the dataset, plus $0.00005 per Actor start. You are not charged for platform compute.

### Data source and terms

- Endpoint (no token): `https://api.esios.ree.es/archives/70/download_json?locale=es&date=YYYY-MM-DD`.
- Published by [Red Eléctrica de España / ESIOS](https://www.esios.ree.es). Reuse is subject to REE’s open-data / reuse conditions. Credit Red Eléctrica de España (ESIOS). Do not present this Actor as an official REE product.
- Official figures are in €/MWh. The €/kWh fields are a simple conversion (÷ 1,000) and are labelled as such.

***

## Precios de la luz en España (PVPC, REE/ESIOS)

Obtiene el **precio horario oficial del PVPC** (Precio Voluntario para el Pequeño Consumidor) en filas JSON o CSV listas para comparadores, alertas horarias, n8n o un agente.

Usa el **archivo 70 de ESIOS**, un JSON público de Red Eléctrica de España: **no hace falta token**. Es el PVPC regulado, no el precio mayorista de `apidatos.ree.es`.

### Qué hace este Actor

- Lee el archivo oficial de cada día solicitado (Península y Ceuta-Melilla).
- Escribe **una fila del dataset por hora** (normalmente 24 filas por día).
- Conserva la unidad oficial **€/MWh** y añade el valor derivado en **€/kWh** (÷ 1.000).
- Incluye los componentes tarifarios publicados y la URL oficial del archivo de ese día.

### Qué devuelve

| Campo | Descripción |
|---|---|
| `date`, `hour`, `hourStart` | Día y tramo horario (`00-01` … `23-24`) |
| `pcbEurPerMwh` | Precio en Península, unidad oficial **€/MWh** |
| `cymEurPerMwh` | Precio en Ceuta y Melilla, **€/MWh** |
| `pcbEurPerKwh`, `cymEurPerKwh` | Los mismos precios divididos entre 1.000, en **€/kWh** (campo derivado) |
| `coefficient2Td` | Coeficiente oficial 2.0TD (`COF2TD`), si viene |
| `componentsPcb`, `componentsCym` | Componentes publicados (mercado, ajuste, peajes, término de energía, margen de comercialización, cargo horario, etc.) |
| `unitOfficial` | Siempre `EUR/MWh` |
| `sourceUrl` | URL oficial del archivo de ese día |
| `sourceAttribution` | Línea de atribución obligatoria |
| `scrapedAt` | Marca de tiempo UTC de la ejecución |

### Configuración

| Campo de entrada | Tipo | Valor por defecto | Descripción |
|---|---|---|---|
| `dateFrom` | fecha (`YYYY-MM-DD`) | (vacío) | Primer día. Ejemplo: `2026-11-22`. Si está vacío, se usa `lookbackDays`. |
| `dateTo` | fecha (`YYYY-MM-DD`) | hoy (UTC) | Último día. El PVPC del día siguiente suele publicarse la víspera por la tarde. |
| `lookbackDays` | entero | `1` | Solo si no hay `dateFrom`. Días hacia atrás desde `dateTo`. Máximo 31. |
| `maxItems` | entero | `0` | Para tras este número de horas. `0` = sin límite. Un día completo son 24 filas. |

### Ejemplo de entrada

```json
{
  "dateFrom": "2026-11-22",
  "dateTo": "2026-11-22",
  "maxItems": 24
}
```

### Ejemplo de salida

```json
{
  "date": "2026-11-22",
  "hour": "00-01",
  "hourStart": 0,
  "pcbEurPerMwh": 143.45,
  "cymEurPerMwh": 143.45,
  "pcbEurPerKwh": 0.14345,
  "cymEurPerKwh": 0.14345,
  "coefficient2Td": 0.934,
  "componentsPcb": {
    "market": 80.12,
    "adjustment": 5.0,
    "omFee": 0.5,
    "osFee": 0.3,
    "interruptibility": 0.0,
    "capacityPayment": 2.1,
    "energyTerm": 40.0,
    "marketingMargin": 3.0,
    "edsr": 0.0,
    "hourlyCharge": 12.43
  },
  "componentsCym": {
    "market": 80.12,
    "adjustment": 5.0,
    "omFee": 0.5,
    "osFee": 0.3,
    "interruptibility": 0.0,
    "capacityPayment": 2.1,
    "energyTerm": 40.0,
    "marketingMargin": 3.0,
    "edsr": 0.0,
    "hourlyCharge": 12.43
  },
  "unitOfficial": "EUR/MWh",
  "sourceUrl": "https://api.esios.ree.es/archives/70/download_json?locale=es&date=2026-11-22",
  "sourceAttribution": "Fuente: Red Eléctrica de España (ESIOS), archivo 70 PVPC. https://www.esios.ree.es",
  "scrapedAt": "2026-11-23T21:00:00+00:00"
}
```

El resumen de la ejecución se guarda en el almacén de clave-valor como `RUN_STATS`.

### Ejemplo en Python (`apify-client`)

```python
from apify_client import ApifyClient

client = ApifyClient("YOUR_APIFY_TOKEN")
run = client.actor("innovito/precios-luz-pvpc").call(
    run_input={
        "dateFrom": "2026-11-22",
        "dateTo": "2026-11-22",
        "maxItems": 24,
    }
)
for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(item["date"], item["hour"], item["pcbEurPerMwh"], item["pcbEurPerKwh"])
```

También puedes programar el Actor cada día y enviar el dataset a Google Sheets, Slack, Make, Zapier o n8n.

### Precio

Pago por uso: 2,50 $ por cada 1.000 precios horarios escritos en el dataset, más 0,00005 $ por arranque. No se cobra el cómputo de la plataforma.

### Origen y condiciones

- Endpoint (sin token): `https://api.esios.ree.es/archives/70/download_json?locale=es&date=YYYY-MM-DD`.
- Publicado por [Red Eléctrica de España / ESIOS](https://www.esios.ree.es). La reutilización está sujeta a las condiciones de datos abiertos de REE. Hay que citar a Red Eléctrica de España (ESIOS). Este Actor no es un producto oficial de REE.
- Las cifras oficiales están en €/MWh. Los campos en €/kWh son una conversión simple (÷ 1.000) y se identifican como tal.

# Actor input Schema

## `dateFrom` (type: `string`):

First day to include (YYYY-MM-DD). If empty, the Actor looks back <code>lookbackDays</code> from the end date. Example: <code>2026-11-22</code>.

## `dateTo` (type: `string`):

Last day to include (YYYY-MM-DD). Defaults to today (UTC). The next day's PVPC is usually published the evening before. Example: <code>2026-11-22</code> for a single day (24 hourly rows).

## `lookbackDays` (type: `integer`):

When <code>dateFrom</code> is empty, how many days to request ending at <code>dateTo</code>. Default 1 (that day only). Capped at 31.

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

Stop after this many hours. 0 = no limit. A full day is 24 rows.

## Actor input object example

```json
{
  "lookbackDays": 1,
  "maxItems": 0
}
```

# Actor output Schema

## `prices` (type: `string`):

Dataset of official Spanish PVPC hourly electricity prices from ESIOS archive 70 (one row per hour).

## `runStats` (type: `string`):

RUN_STATS record: days requested, days with data, hourly prices parsed and pushed.

# 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 = {};

// Run the Actor and wait for it to finish
const run = await client.actor("innovito/precios-luz-pvpc").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 = {}

# Run the Actor and wait for it to finish
run = client.actor("innovito/precios-luz-pvpc").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 '{}' |
apify call innovito/precios-luz-pvpc --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,innovito/precios-luz-pvpc"
        }
    }
}
```

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/cFfJbhfZ7fz66eg2P/builds/bxwdfDDHuvJYpSSyZ/openapi.json
