# Spain Electricity Prices – PVPC & Spot, Hourly (REE) (`shikimokami/spain-electricity-prices`) Actor

Official hourly electricity prices in Spain from Red Eléctrica: the regulated PVPC 2.0TD tariff and the day-ahead spot market. Today, tomorrow or any date since 2021, with peak/off-peak periods, daily rank and the cheapest hours. Ideal for home automation and energy analysis.

- **URL**: https://apify.com/shikimokami/spain-electricity-prices.md
- **Developed by:** [SHiki](https://apify.com/shikimokami) (community)
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.50 / 1,000 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 & Spot, Hourly (REE) ⚡

Get the **official hourly electricity prices in Spain** straight from **Red Eléctrica** (REData API):

- **PVPC 2.0TD**: the regulated tariff that millions of Spanish households pay, hour by hour (energy, network tolls and charges, before taxes).
- **Day-ahead spot market** (OMIE, Spanish zone): hourly averages and, since October 2025, the 15-minute prices.

Today, **tomorrow** (as soon as it is published) or **any date range since 2021**, with the 2.0TD tariff period of every hour (peak, mid-peak, off-peak), its rank within the day, and the cheapest hours and time windows.

No scraping, no API key, no proxies.

### What can you do with it?

- 🏠 **Home automation**: run it every evening and switch on the heat pump, EV charger, water heater or washing machine in the cheapest hours of tomorrow (Home Assistant, Node-RED, Zapier, Make, webhooks…).
- 📱 **Apps, bots and websites**: show today's and tomorrow's price by hour, with ready-made rank and price level.
- 📊 **Energy analysis**: years of hourly PVPC and spot prices for reports, forecasting models or solar and battery sizing.
- 🏭 **Businesses**: plan consumption around peak hours and check the market price you are indexed to.

### Input

All fields are optional. With no input you get **today and tomorrow, hour by hour**.

| Field | What it does |
|---|---|
| **Start date / End date** | Any range from 2021-06-01 (PVPC) or 2014-04-01 (spot only) up to tomorrow. Long ranges are fine. |
| **Include tomorrow** | With no dates, also return tomorrow. Spot is published around 13:00 and PVPC around 20:30 (Spanish time). |
| **Output** | One row per hour, or one row per day with averages, min, max, cheapest hours and the cheapest 2, 3 and 4-hour windows. |
| **Only the N cheapest hours of each day** | E.g. `4` returns only the 4 cheapest hours of each day. |
| **Tariff periods** | Keep only P1 (peak), P2 (mid-peak) or P3 (off-peak) hours. |
| **Include 15-minute spot prices** | Adds the four quarter-hour market prices of each hour. |
| **Maximum results** | Limit the number of rows. |

#### Example: the 4 cheapest hours of tomorrow

```json
{
  "startDate": "2026-10-15",
  "cheapestHoursPerDay": 4
}
```

### Output (hourly)

```json
{
  "date": "2026-10-14",
  "hour": 0,
  "startTime": "2026-10-14T00:00:00+02:00",
  "endTime": "2026-10-14T01:00:00+02:00",
  "pvpcEURPerMWh": 185.98,
  "pvpcEURPerKWh": 0.18598,
  "spotEURPerMWh": 207.49,
  "spotEURPerKWh": 0.20749,
  "tariffPeriod": "P3",
  "tariffPeriodName": "off-peak",
  "weekday": "Wednesday",
  "offPeakDay": false,
  "dayRank": 11,
  "rankedBy": "pvpc",
  "priceLevel": "medium",
  "vsDayAveragePct": -16,
  "isCheapestHour": false,
  "isMostExpensiveHour": false,
  "source": "Red Eléctrica (REData API) – PVPC and day-ahead market prices, peninsular system"
}
```

- `dayRank`: 1 = cheapest hour of the day. Ranks use PVPC, or the spot price while tomorrow's PVPC is not published yet (`rankedBy`).
- `priceLevel`: `low`, `medium` or `high` (thirds of the day).
- `tariffPeriod`: 2.0TD periods. Weekdays: P1 10–14 h and 18–22 h, P2 8–10 h, 14–18 h and 22–24 h, P3 0–8 h. Weekends and national fixed-date holidays are P3 all day.
- Times are Spanish peninsular time with the UTC offset. Daylight-saving days have 23 or 25 hours, and the repeated hour keeps its own offset.

### Output (daily)

```json
{
  "date": "2026-03-29",
  "weekday": "Sunday",
  "offPeakDay": true,
  "hours": 23,
  "pvpcPublished": true,
  "pvpcAverageEURPerKWh": 0.09436,
  "pvpcMinEURPerKWh": 0.08477,
  "pvpcMinHour": 19,
  "pvpcMaxEURPerKWh": 0.11025,
  "pvpcMaxHour": 8,
  "pvpcAverageByPeriodEURPerKWh": { "P1": null, "P2": null, "P3": 0.09436 },
  "spotAverageEURPerMWh": 0.18,
  "spotMinEURPerMWh": -9.82,
  "spotMaxEURPerMWh": 12.52,
  "cheapestHours": [19, 10, 12, 14, 20, 11],
  "cheapest2hWindow": { "startTime": "2026-03-29T19:00:00+02:00", "endTime": "2026-03-29T21:00:00+02:00", "average": 0.08737 },
  "cheapest3hWindow": { "startTime": "2026-03-29T18:00:00+02:00", "endTime": "2026-03-29T21:00:00+02:00", "average": 0.08843 },
  "cheapest4hWindow": { "startTime": "2026-03-29T18:00:00+02:00", "endTime": "2026-03-29T22:00:00+02:00", "average": 0.08938 },
  "rankedBy": "pvpc",
  "source": "Red Eléctrica (REData API) – PVPC and day-ahead market prices, peninsular system"
}
```

Every run also saves a free **SUMMARY** record in the key-value store with the average PVPC of the period, the cheapest and most expensive hour, and a short summary of each day.

### Pricing

You only pay for the rows you get (pay per result). A day is 24 hourly rows, or a single row with the daily output.

### FAQ

**Is this legal?** Yes. Red Eléctrica publishes these prices as open data through its public REData API, and every record includes the source.

**When are tomorrow's prices available?** The day-ahead market closes at noon and its prices appear around 13:00; Red Eléctrica publishes tomorrow's PVPC around 20:30 (Spanish time). Schedule a run at 21:00 to always get the full day.

**Which areas are covered?** The peninsular electricity system, as published by Red Eléctrica's REData API.

**Do the prices include taxes?** No. PVPC prices include energy, network tolls and charges, but not the electricity tax or VAT.

### Made by

The team behind [CuántoGasta](https://cuantogasta.github.io/), a free website with the price of electricity in Spain hour by hour, today and tomorrow.

# Actor input Schema

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

First day (YYYY-MM-DD). Empty = today. PVPC is available since 2021-06-01 and the spot market since 2014-04-01.

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

Last day (YYYY-MM-DD). Empty = the start date, or tomorrow when both dates are empty and 'Include tomorrow' is on.

## `includeTomorrow` (type: `boolean`):

With no dates, also return tomorrow's prices. The spot market is published around 13:00 and PVPC around 20:30 (Spanish time); until then tomorrow's PVPC fields are empty.

## `output` (type: `string`):

One row per hour, or one row per day with averages, minimum, maximum, cheapest hours and cheapest 2, 3 and 4-hour windows.

## `cheapestHoursPerDay` (type: `integer`):

Hourly output only. E.g. 4 returns the 4 cheapest hours of each day: perfect to schedule a heat pump, an EV charger or a washing machine. 0 = all hours.

## `tariffPeriods` (type: `array`):

Hourly output only. Keep only these periods.

## `includeSpotQuarterHours` (type: `boolean`):

Since October 2025 the day-ahead market has 15-minute prices. Adds the four quarter-hour prices of each hour.

## `maxResults` (type: `integer`):

0 = no limit.

## Actor input object example

```json
{
  "includeTomorrow": true,
  "output": "hourly",
  "cheapestHoursPerDay": 0,
  "tariffPeriods": [],
  "includeSpotQuarterHours": false,
  "maxResults": 0
}
```

# Actor output Schema

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

One record per hour (or per day with the daily output) with PVPC and spot prices, tariff period and rank.

## `summary` (type: `string`):

Average PVPC price of the period, cheapest and most expensive hour and a short summary of each day.

# 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("shikimokami/spain-electricity-prices").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("shikimokami/spain-electricity-prices").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 shikimokami/spain-electricity-prices --silent --output-dataset

```

## MCP server setup

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

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/8YBohUz5VgUO2JKq5/builds/KST9tEWXdW7KAdrCJ/openapi.json
