# Spain Electricity & Gas Tariffs Scraper (CNMC) + PVPC Prices (`rastriq/cnmc-energy-comparator`) Actor

Scrape every electricity and gas tariff in Spain from the official CNMC comparator: prices, bill estimates by postcode, hourly PVPC prices. JSON, CSV, Excel.

- **URL**: https://apify.com/rastriq/cnmc-energy-comparator.md
- **Developed by:** [Rastriq — Structured data from the world](https://apify.com/rastriq) (community)
- **Categories:** Business, E-commerce, 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.10 / 1,000 ranked offer with estimated bills

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 Electricity & Gas Tariffs Scraper (CNMC) + PVPC Prices

**Spain Electricity & Gas Tariffs Scraper** extracts every electricity, natural gas and dual-fuel tariff in Spain from the official **CNMC energy offers comparator** ([comparador.cnmc.gob.es](https://comparador.cnmc.gob.es)): prices per period, ranked **estimated bills for any postcode and consumption**, supplier contact details, **hourly PVPC prices** and the regulated PVPC bill simulator. No API key, no login, no browser — clean JSON, CSV or Excel in seconds.

### What is the Spain Electricity & Gas Tariffs Scraper?

The CNMC (Comisión Nacional de los Mercados y la Competencia) is Spain's energy regulator. Every electricity and gas supplier (*comercializadora*) must register its offers in the CNMC comparator, which makes it the only neutral, complete source of **Spanish energy prices**. The website, however, shows one form and one household at a time.

The Spain Electricity & Gas Tariffs Scraper turns the whole comparator into data you can analyse and automate:

- 📊 **Comparator rankings** — the same ranking the CNMC shows, for as many profiles as you want: postcode × electricity (2.0TD households, 3.0TD businesses) / gas (RL.1–RL.4) / dual fuel × contracted power × consumption × period.
- 📚 **Full tariff catalogue** — all ~350 active offers in Spain with power and energy prices P1–P6, discounts, flexible hours, bundled services, territory and links. Also **historical catalogues back to 2021**.
- 🔔 **Tariff change feed** — `delta` mode returns only new, changed and withdrawn offers since your last run.
- ⚡ **PVPC hourly prices** — the regulated electricity price for every hour, three zones, with or without taxes.
- 🧾 **PVPC bill simulator (Facturaluz)** — line-by-line regulated bill with the CNMC's explanation of each amount, social bonus (*bono social*) and "what if I contract another power".
- 📈 **Your real consumption** — upload the hourly CSV from your distributor and rankings use your real consumption per period.
- 📄 **Official reports** — save the CNMC PDF and Excel report of each ranking and the PDF sheet of each offer.

### What data does the Spain Electricity & Gas Tariffs Scraper extract?

Each row has a `record_type`, and the dataset has a table view for each one.

| Data | Main fields |
|---|---|
| 🏆 **Ranked offers** (`comparison`) | rank, offer, supplier, estimated bill 1st / 2nd year (VAT incl.), savings vs regulated PVPC / TUR, price type, green energy, permanence and penalty, additional services, bill breakdown (power, energy, electricity tax, meter, VAT), customer-service phone / e-mail / web, validity, conditions |
| 📚 **Catalogue offers** (`offer`) | offer, supplier, type, plan (fixed / indexed / flexible), power €/kW·year and energy €/kWh P1–P6, discounts, power and consumption limits, gas toll band, eligibility, provinces, sales channels, links, change type and changed fields |
| ⚡ **PVPC day** (`pvpc_price`) | date, zone, 24 hourly prices €/kWh, average, min, max, cheapest and most expensive hour, last-7-days average |
| 🧾 **PVPC bill** (`pvpc_bill`) | fixed and variable term, social bonus discount, electricity tax, meter rental, VAT, total, explanation of each line, daily consumption and cost (smart meter), alternative powers |
| 🧮 **Regulated parameters** (`parameter`) | tolls, charges, taxes, meter rental, social bonus discounts with validity dates |
| 🗺️ **Reference** (`province`, `consumption_profile`) | provinces and postcode prefixes, CNMC consumption profiles |

### How to use the Spain Electricity & Gas Tariffs Scraper

1. Click **Try for free** and keep the pre-filled input: the 10 cheapest electricity offers for a Madrid household (3.45 kW, 2,600 kWh/year) and today's PVPC prices.
2. Answer three questions in plain words: **what you want** (cheapest offers, all tariffs, hourly PVPC price, check a bill), **your postcode**, and **which home or business looks like yours** (small flat, average home, home with electric heating or EV, shop, medium business…). No energy knowledge needed: typical power and consumption are filled in for you.
3. Optional: type your real **contracted power** and **yearly consumption** from your bill, say **when you use most electricity** (normal, nights and weekends, daytime), or paste your distributor's **hourly consumption file** for the most accurate result.
4. Click **Start**. A typical run takes 10–60 seconds.
5. Download the results as JSON, CSV, Excel or HTML, or connect them to Google Sheets, Make, Zapier or the Apify API.
6. To be alerted of tariff changes, answer **Yes** to "Only show what changed since my last run?" and add a daily schedule.

### Input parameters

| Field | Description |
|---|---|
| `datasets` | `comparison`, `offers_catalog`, `pvpc_prices`, `pvpc_bill`, `regulated_parameters`, `reference_data` |
| `supplyTypes`, `postalCodes` | `electricity`, `gas`, `combined` × Spanish postcodes (one ranking per combination) |
| `consumerProfile`, `gasUse`, `usagePattern` | Plain-language presets: `small_home`, `average_home`, `large_home`, `all_electric_home`, `small_business`, `medium_business`; gas for hot water / flat / house / large house; normal, nights & weekends or daytime use. Any number you type overrides the preset |
| `contractedPowerKw`, `contractedPowerValleKw`, `contractedPowersKw` | Contracted power; six powers P1–P6 for 3.0TD |
| `annualElectricityKwh`, `electricityConsumptionSplitPct`, `annualGasKwh` | Consumption and optional split by period |
| `consumptionCurveUrl` / `consumptionCurveCsv` | Your hourly consumption CSV (distributor format) |
| `periodStart`, `periodEnd` | Period to simulate (default: last 365 days) |
| `household`, `excludeAdditionalServices`, `excludePermanence`, `priceTypes`, `greenEnergyOnly`, `companies` | Comparator filters |
| `includeOfferDetails`, `maxOffersPerScenario`, `saveRankingReports`, `saveOfferPdfs` | Detail level and official reports |
| `scenarios` | Custom list of profiles (any field above per scenario, up to 300) |
| `mode`, `catalogOfferTypes`, `catalogDate`, `catalogDates`, `stateKey` | Catalogue: snapshot, delta, history |
| `pvpcDateFrom`, `pvpcDateTo`, `pvpcZones`, `pvpcTaxes` | PVPC prices |
| `billPeriodStart` … `billSimulatePowersKw`, `socialBonus` | PVPC bill simulation |
| `maxItems` | Row limit and spending cap |

```json
{
  "datasets": ["comparison"],
  "scenarios": [
    { "id": "flat-madrid", "supply": "electricity", "postalCode": "28013", "contractedPowerKw": 4.6, "annualElectricityKwh": 3500 },
    { "id": "house-sevilla", "supply": "combined", "postalCode": "41001", "annualElectricityKwh": 4000, "annualGasKwh": 9000 },
    { "id": "shop-valencia", "supply": "electricity", "postalCode": "46001", "contractedPowersKw": [20, 20, 20, 20, 20, 25], "annualElectricityKwh": 45000, "household": false }
  ],
  "maxOffersPerScenario": 20
}
```

### Output example

A real `comparison` row (shortened):

```json
{
  "record_type": "comparison",
  "scenario_id": "s001-electricity-28001",
  "supply_type": "electricity", "postal_code": "28001", "province": "Madrid", "access_tariff": "2.0TD",
  "contracted_power_kw": [3.45, 3.45], "period_start": "2025-11-20", "period_end": "2026-11-20",
  "electricity_kwh_period": 2600, "electricity_kwh_by_period": [745, 639, 1216],
  "rank": 1, "results_in_scenario": 72,
  "offer_id": 7212, "offer_name": "Tarifa Fácil Plus 36 Meses", "company": "ENI PLENITUDE IBERIA, S.L.",
  "offer_kind": "market_offer", "price_type": "single_price", "is_regulated": false,
  "estimated_cost_first_year_eur": 669.71, "estimated_cost_second_year_eur": 669.71,
  "savings_vs_regulated_eur": 3.0, "green_energy": true, "has_permanence_penalty": false,
  "customer_service_phone": "900 373 763", "customer_service_email": "clientes@eniplenitude.es",
  "bill_first_year_electricity_lines": [
    { "concept": "Término de potencia", "amount_eur": 283.33 },
    { "concept": "Consumo electricidad", "amount_eur": 233.98 },
    { "concept": "Impuesto sobre electricidad 5,11269632%", "amount_eur": 26.45 },
    { "concept": "Equipo de medida", "amount_eur": 9.72 }
  ],
  "validity_period": "Oferta válida desde 01-nov-2026 hasta 15-dic-2026",
  "source": "CNMC - Comparador de Ofertas de Energía (comparador.cnmc.gob.es)",
  "license": "CC BY-SA 4.0 — información recabada y gestionada por la CNMC en el Comparador de Ofertas de Energía"
}
```

A `pvpc_price` row has `date`, `zone`, `taxes_included`, `avg_price_eur_kwh`, `cheapest_hour`, `h00` … `h23` and `hourly_prices`. A `pvpc_bill` row has the bill lines with the CNMC explanation, for example *"P1 (Punta): 3,45 kW x 27,704413 €/kW/año x 30 días / 365 días = 7,86 €"*.

### 💰 How much does it cost to scrape Spanish electricity and gas tariffs?

The Spain Electricity & Gas Tariffs Scraper uses **pay-per-event** pricing: you pay per row, and the price depends on the row type. Prices below are for the Starter plan (Bronze). Free-plan users pay 15% more, and Scale and Business plans get 15–30% off.

| Event | Price |
|---|---|
| Ranked offer with estimated bill | $0.003 |
| Catalogue offer | $0.001 |
| Catalogue change (delta mode) | $0.003 |
| PVPC prices for one day | $0.002 |
| PVPC bill simulation | $0.01 |
| Regulated parameter / reference row | $0.0005 |
| Actor start | $0.01 per run |

What typical runs cost:

- **Top 10 offers for one household**: about $0.04.
- **Full catalogue of ~350 offers**: about $0.36. In `delta` mode, later runs charge only offers that changed; unchanged offers are free.
- **One year of PVPC hourly prices**: about $0.74.
- **50 postcodes × 3 supply types, top 20 offers each**: about $9.

With the $5 free credit you can get roughly 1,400 ranked offers. Use **Max rows** as a spending cap.

### Related Actors

- [EU ETS Installations & Verified Emissions](https://apify.com/Rastriq/eu-ets-installations-emissions) — CO2 emissions of every power plant and factory in the EU Emissions Trading System.
- [EU EV Charging Graph](https://apify.com/Rastriq/eu-ev-charging-graph) — EV charge points in Germany, France and Spain.
- [Spain Public Procurement Scraper (PLACSP)](https://apify.com/Rastriq/placsp-scraper) — Spanish public tenders and awards, including energy supply contracts.
- [TED Tenders API](https://apify.com/Rastriq/ted-tenders-api) — EU public procurement search.

### FAQ

**Is it legal to scrape the CNMC comparator?**
Yes. The CNMC publishes this data openly under **CC BY-SA 4.0**. If you republish it, mention that it is "información recabada y gestionada por la CNMC en el Comparador de Ofertas de Energía"; every row carries `source` and `license` for that. The Actor makes polite requests to public endpoints only. It is not affiliated with the CNMC.

**Do I need a CNMC API key?**
No. The Spain Electricity & Gas Tariffs Scraper works without an account, key or proxy.

**Who uses it?**
Energy comparison sites and switching services, suppliers' pricing teams (competitive intelligence), energy brokers and consultants quoting SMEs, analysts and journalists tracking fixed vs indexed prices, smart-home and EV-charging apps scheduling consumption by PVPC price, and social services simulating bills with *bono social*.

**How accurate are the estimated bills?**
They are the CNMC's own calculation for the consumption and period you give, taxes included. The second-year figure also comes from the CNMC; for some offers whose price period lasts 12 months it can be incomplete.

**Can I compare offers for a business above 15 kW?**
Yes. Set `contractedPowerKw` above 15 or give six powers in `contractedPowersKw`, and the CNMC switches to the 3.0TD tariff.

**Is my consumption file safe?**
The CSV is sent only to the CNMC to calculate the ranking and the bill. The CUPS (supply point ID) never appears in the output.

**Why do some catalogue offers have no supplier?**
The public catalogue has no supplier field. The Actor fills it by matching offer names with comparator rankings and web domains (about 80% of offers). Offers the CNMC never shows in a ranking keep `company: null` and `company_domain`.

**What is not available?**
"Entiende tu factura", comparison from a bill QR code and the flexible-offers CSV need the QR token of a real bill. The gas-cap adjustment calculator and the toll-only bill have been switched off by the CNMC.

**Something is missing or broken?**
Open an issue in the Issues tab and we will reply quickly.

***

### 🇪🇸 Versión en español

> Resumen en español del README anterior.

#### ¿Qué es el Spain Electricity & Gas Tariffs Scraper?

Es un scraper del **Comparador de Ofertas de Energía de la CNMC** que te da en un solo dataset todas las **tarifas de luz y gas de España**: el ranking de ofertas con la **factura estimada** para cualquier código postal, potencia y consumo, el catálogo completo de ofertas con sus precios por periodo, los **precios PVPC hora a hora** y el simulador de factura PVPC (Facturaluz). Sin API key ni registro.

#### ¿Qué datos extrae?

| Dato | Campos |
|---|---|
| Ranking de ofertas | posición, oferta, comercializadora, factura estimada 1er y 2º año, ahorro frente a PVPC/TUR, energía verde, permanencia, desglose de la factura, teléfono y e-mail de atención al cliente |
| Catálogo de ofertas | precios de potencia y energía P1–P6, descuentos, horas flexibles, servicios, provincias, enlaces; altas, cambios y bajas en modo delta |
| PVPC | 24 precios horarios por día y zona, media, mínimo, máximo, hora más barata |
| Factura PVPC | término fijo y variable, bono social, impuesto eléctrico, contador, IVA, total y explicación de cada línea |
| Parámetros regulados | peajes, cargos, impuestos, alquiler del contador, descuentos del bono social |

#### ¿Cómo se usa?

1. Deja el input precargado (hogar en Madrid, 3,45 kW, 2.600 kWh/año) y pulsa **Start**.
2. Elige luz, gas o ambos, tu código postal y el perfil que más se parezca a ti (piso pequeño, hogar medio, casa con calefacción eléctrica o coche eléctrico, tienda, negocio mediano…). No hace falta saber de energía: potencia y consumo se rellenan solos, y si los conoces (están en tu factura) puedes escribirlos.
3. Si tienes el CSV horario de tu distribuidora, pégalo o pon su URL para comparar con tu consumo real.
4. Para seguir los cambios de tarifas, activa el modo **Delta** y prográmalo a diario.
5. Descarga los resultados en JSON, CSV o Excel.

#### ¿Cuánto cuesta?

Pago por evento: 0,003 $ por oferta del ranking, 0,001 $ por oferta del catálogo, 0,003 $ por cambio detectado, 0,002 $ por día de PVPC, 0,01 $ por simulación de factura y 0,01 $ por ejecución. Las 10 mejores ofertas para un hogar cuestan unos 0,04 $ y el catálogo completo unos 0,36 $. En modo delta solo pagas las ofertas que han cambiado.

# Changelog

This Actor's version history is a separate document: https://apify.com/rastriq/cnmc-energy-comparator/changelog.md

# Actor input Schema

## `datasets` (type: `array`):

Pick one or more. Each one is a separate table in the results.

## `postalCodes` (type: `array`):

Your 5-digit Spanish postcode, e.g. <code>28001</code>. Prices and taxes change with the place (Peninsula, Balearic Islands, Canary Islands, Ceuta, Melilla). Add several to compare places.

## `supplyTypes` (type: `array`):

What you want to compare. "Electricity + gas together" shows offers that bundle both in one contract.

## `consumerProfile` (type: `string`):

We fill in typical power and consumption for you. If you know your real numbers (they are on your bill), choose <b>I'll enter my own numbers</b> and fill in the next section.

## `gasUse` (type: `string`):

Only used when comparing gas. Sets a typical yearly gas consumption.

## `maxOffersPerScenario` (type: `integer`):

The cheapest N offers for each place and supply. The regulated tariff (PVPC for electricity, TUR for gas) is always added as a reference. 0 = all (about 70 electricity or 60 gas offers).

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

The run stops after this many rows in total, so you never pay more than expected. 0 = no limit.

## `contractedPowerKw` (type: `number`):

On your electricity bill as <i>Potencia contratada</i> (if it shows two values, use the first, <i>punta</i>). Most Spanish homes have 3.45, 4.6 or 5.75 kW. Leave empty to use the profile above. Above 15 kW the business tariff (3.0TD) applies.

## `annualElectricityKwh` (type: `integer`):

On your bill as <i>Consumo anual</i> or in your supplier's app. If you only know one month, multiply by 12. Leave empty to use the profile.

## `annualGasKwh` (type: `integer`):

On your gas bill in kWh (not m³). Leave empty to use the gas option above.

## `usagePattern` (type: `string`):

Electricity is cheaper at night and at weekends with many tariffs. This changes which offers come out cheapest.

## `consumptionCurveUrl` (type: `string`):

Most accurate option. Download the CSV of your hourly consumption from your distributor's website (i-DE, e-distribución, UFD…; <a href='https://comparador.cnmc.gob.es/ejemplo.csv' target='_blank'>example</a>) and paste a link to it. Offers are then compared with your real consumption. Your supply number (CUPS) is never written to the results.

## `consumptionCurveCsv` (type: `string`):

Alternative to the link above: open the CSV and paste its content here.

## `greenEnergyOnly` (type: `boolean`):

Show only offers with certified green electricity.

## `excludePermanence` (type: `boolean`):

Hide offers that charge you if you leave before a given date.

## `excludeAdditionalServices` (type: `boolean`):

Hide offers that include maintenance, insurance or similar extras in the price.

## `priceTypes` (type: `array`):

Empty = all. <b>Same price all day</b> is the simplest. <b>Cheaper at some hours</b> rewards using electricity at night or weekends. <b>Free / cheap hours you choose</b> lets you pick your hours. <b>Follows the market</b> changes with wholesale prices.

## `companies` (type: `array`):

Optional. Part of the supplier name, e.g. <code>iberdrola</code>, <code>endesa</code>, <code>octopus</code>.

## `includeOfferDetails` (type: `boolean`):

For each offer: how the bill is calculated (power, energy, taxes, meter, VAT), customer-service phone and e-mail, and conditions.

## `saveRankingReports` (type: `boolean`):

Saves the official CNMC comparison report of each search. Each row gets a download link.

## `saveOfferPdfs` (type: `boolean`):

Saves the CNMC sheet of each offer (estimated bill and conditions). Each row gets a download link.

## `periodStart` (type: `string`):

Leave both dates empty to compare a full year (recommended). To compare one bill, enter its start and end dates.

## `periodEnd` (type: `string`):

Empty = today.

## `mode` (type: `string`):

<b>No</b>: the full list every time. <b>Yes</b>: the first run returns everything; next runs only new, changed and withdrawn tariffs. Schedule it daily to be alerted of price changes.

## `catalogOfferTypes` (type: `array`):

Empty = all.

## `catalogDate` (type: `string`):

Empty = today.

## `catalogDates` (type: `array`):

Optional. Get the tariffs as they were on each date (YYYY-MM-DD, back to 2021), e.g. to see how prices evolved. Only with "full list every time".

## `enrichCatalogCompanies` (type: `boolean`):

The official list does not include the supplier name; we add it for about 80% of tariffs (free, takes a few seconds more).

## `stateKey` (type: `string`):

Optional. Use a different name to keep separate change alerts (e.g. one per client).

## `pvpcDateFrom` (type: `string`):

Empty = today. Prices are available from mid-2024.

## `pvpcDateTo` (type: `string`):

Empty = latest published day (tomorrow after 20:30).

## `pvpcZones` (type: `array`):

Prices differ by area because of taxes.

## `pvpcTaxes` (type: `string`):

With taxes = what you actually pay per kWh.

## `billPeriodStart` (type: `string`):

As on your bill. Empty = first day of last month.

## `billPeriodEnd` (type: `string`):

Empty = last day of last month.

## `billMeterType` (type: `string`):

Almost all homes have a smart meter, but the simple option only needs the three numbers from your bill. If you gave an hourly consumption file above, it is used automatically.

## `billPostalCode` (type: `string`):

Empty = first postcode above.

## `billPowerP1Kw` (type: `number`):

<i>Potencia punta</i> on your bill. Empty = your contracted power or profile.

## `billPowerP2Kw` (type: `number`):

<i>Potencia valle</i> on your bill. Usually the same as peak.

## `billConsumptionP1Kwh` (type: `integer`):

<i>Consumo punta</i> on your bill. Leave the three consumption fields empty to estimate them from your profile.

## `billConsumptionP2Kwh` (type: `integer`):

<i>Consumo llano</i> on your bill.

## `billConsumptionP3Kwh` (type: `integer`):

<i>Consumo valle</i> on your bill.

## `socialBonus` (type: `string`):

Discount for vulnerable households. If you don't know, leave "No".

## `socialBonusCategory` (type: `integer`):

1 = one person or no children, 2 = one child, 3 = two children, 4 = large family, 5 = pensioner with minimum pension.

## `threePhaseMeter` (type: `boolean`):

Only if your bill says <i>trifásico</i>. Most homes are single-phase.

## `billSimulatePowersKw` (type: `array`):

Optional. Powers to try, e.g. <code>\[2.3, 4.6]</code>: the bill is recalculated with each one so you can see if lowering your power saves money.

## `contractedPowerValleKw` (type: `number`):

Only if your bill shows a different <i>potencia valle</i>. Defaults to the contracted power.

## `contractedPowersKw` (type: `array`):

For businesses above 15 kW with six contracted powers, e.g. <code>\[20, 20, 20, 20, 20, 25]</code>.

## `electricityConsumptionSplitPct` (type: `array`):

Exact share of consumption in peak / flat / off-peak hours (P1–P3; P1–P6 for businesses), e.g. <code>\[30, 25, 45]</code>. Overrides "When do you use most electricity?".

## `household` (type: `boolean`):

Some offers are only for homes, others only for businesses. Set automatically from the profile.

## `selfConsumption` (type: `boolean`):

Marks offers that pay for surplus solar energy. The CNMC does not include the surplus in the bill estimate.

## `scenarios` (type: `array`):

Replaces the postcode × supply grid. Each object may set: <code>id</code>, <code>label</code>, <code>supply</code> (electricity | gas | combined), <code>postalCode</code>, <code>consumerProfile</code>, <code>gasUse</code>, <code>usagePattern</code>, <code>contractedPowerKw</code>, <code>contractedPowerValleKw</code>, <code>contractedPowersKw</code>, <code>annualElectricityKwh</code>, <code>electricityKwhPeriod</code>, <code>electricityConsumptionSplitPct</code>, <code>annualGasKwh</code>, <code>periodStart</code>, <code>periodEnd</code>, <code>household</code>, <code>excludeAdditionalServices</code>, <code>excludePermanence</code>, <code>selfConsumption</code>, <code>useConsumptionCurve</code>. Missing fields take the values above. Max 300.

## `billSimulations` (type: `array`):

List of objects with any of the bill fields above (<code>label</code>, <code>billPeriodStart</code>, <code>billPeriodEnd</code>, <code>billPostalCode</code>, <code>billPowerP1Kw</code>, <code>billConsumptionP1Kwh</code>…, <code>socialBonus</code>, <code>socialBonusCategory</code>, <code>billMeterType</code>).

## `parametersDate` (type: `string`):

For "Official regulated prices and taxes". Empty = today.

## Actor input object example

```json
{
  "datasets": [
    "comparison",
    "pvpc_prices"
  ],
  "postalCodes": [
    "28001"
  ],
  "supplyTypes": [
    "electricity"
  ],
  "consumerProfile": "average_home",
  "maxOffersPerScenario": 10,
  "maxItems": 60,
  "usagePattern": "standard",
  "greenEnergyOnly": false,
  "excludePermanence": false,
  "excludeAdditionalServices": false,
  "includeOfferDetails": true,
  "saveRankingReports": false,
  "saveOfferPdfs": false,
  "mode": "snapshot",
  "enrichCatalogCompanies": true,
  "pvpcZones": [
    "peninsula_baleares"
  ],
  "pvpcTaxes": "with_taxes",
  "billMeterType": "auto",
  "socialBonus": "none",
  "socialBonusCategory": 1,
  "threePhaseMeter": false,
  "selfConsumption": false,
  "scenarios": [
    {
      "id": "flat-madrid",
      "supply": "electricity",
      "postalCode": "28013",
      "consumerProfile": "small_home"
    },
    {
      "id": "shop-valencia",
      "supply": "electricity",
      "postalCode": "46001",
      "consumerProfile": "medium_business"
    }
  ]
}
```

# Actor output Schema

## `comparison` (type: `string`):

No description

## `offers` (type: `string`):

No description

## `pvpc` (type: `string`):

No description

## `allRows` (type: `string`):

No description

## `runSummary` (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 = {
    "datasets": [
        "comparison",
        "pvpc_prices"
    ],
    "postalCodes": [
        "28001"
    ],
    "supplyTypes": [
        "electricity"
    ],
    "consumerProfile": "average_home",
    "maxOffersPerScenario": 10,
    "maxItems": 60
};

// Run the Actor and wait for it to finish
const run = await client.actor("rastriq/cnmc-energy-comparator").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 = {
    "datasets": [
        "comparison",
        "pvpc_prices",
    ],
    "postalCodes": ["28001"],
    "supplyTypes": ["electricity"],
    "consumerProfile": "average_home",
    "maxOffersPerScenario": 10,
    "maxItems": 60,
}

# Run the Actor and wait for it to finish
run = client.actor("rastriq/cnmc-energy-comparator").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 '{
  "datasets": [
    "comparison",
    "pvpc_prices"
  ],
  "postalCodes": [
    "28001"
  ],
  "supplyTypes": [
    "electricity"
  ],
  "consumerProfile": "average_home",
  "maxOffersPerScenario": 10,
  "maxItems": 60
}' |
apify call rastriq/cnmc-energy-comparator --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,rastriq/cnmc-energy-comparator"
        }
    }
}
```

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/hoAkcJDfaWTsT9djU/builds/33N3Thluh5cqY2XTF/openapi.json
