Spain PVPC Price API

Spain PVPC Price API

You need a reliable way to pull today’s Spain PVPC (Precio Voluntario para el Pequeño Consumidor) electricity price for financial workflows like billing, hedging, and cost simulations. By the end of this guide, you’ll be able to call the Energy API’s latest endpoint, parse the PVPC price in EUR/MWh, and integrate it into production code with proper handling for units, base currency, and daily updates.

What the PVPC price represents and where it fits in finance

PVPC is the regulated retail electricity price reference for Spain. Developers in finance use it to compute daily energy costs, run scenario analyses, reconcile invoices, and build dashboards that track household and SME exposure to energy price movements. Because PVPC updates daily, you typically need a simple, robust “latest” fetch that returns one numerical rate plus a publication date and currency.

Illustration: Spain PVPC Price API

This guide stays focused on the Spain PVPC symbol only and shows how to retrieve and interpret it from Energy API’s latest endpoint. All examples use the documented parameters and fields you can copy directly into your codebase.

Quick start: endpoint, auth, and the symbol you must use

Energy API exposes a latest endpoint that returns the current value for requested symbols. For Spain PVPC, use the following symbol code:

  • Symbol code: PVPC_ES_2TD

HTTP method and URL:

  • GET https://energy-api.com/api/v1/latest

Required query parameters:

  • symbols: PVPC_ES_2TD
  • api_key: YOUR_API_KEY (query parameter)

Plan and trial details:

  • Starter: $19.99/mo
  • Trial: 7 days / 50 calls

Notes that matter in finance code:

  • Unit: EUR/MWh for PVPC_ES_2TD
  • Base currency can be EUR or sometimes MIXED across multi-symbol requests. For PVPC_ES_2TD alone, expect EUR in currencies and base = EUR in the example below.
  • Do not pass base=USD when you also need TTF_GAS or EUA_CO2. This guide stays on PVPC_ES_2TD and does not mix symbols.
  • No MCP host. Use the URL shown above.

Origin catalog facts

The following facts come directly from the origin catalog and should be copied as-is when onboarding this symbol into your systems:

  • Symbol name: Spain PVPC
  • Symbol code: PVPC_ES_2TD
  • Unit: EUR/MWh
  • Auth: api_key query parameter. Placeholder YOUR_API_KEY only.
  • Do not pass base=USD when you also need TTF_GAS or EUA_CO2.
  • No MCP host. Starter $19.99/mo, trial 7 days / 50 calls.
  • curl: curl -G "https://energy-api.com/api/v1/latest" --data-urlencode "symbols=PVPC_ES_2TD" --data-urlencode "api_key=YOUR_API_KEY"
  • Read rates.PVPC_ES_2TD, dates.PVPC_ES_2TD, currencies.PVPC_ES_2TD. base may be MIXED.

Fetch the latest PVPC price: curl

Use this copy-pasteable curl command. It queries only the PVPC_ES_2TD symbol and authenticates via the api_key query parameter.

curl -G "https://energy-api.com/api/v1/latest" --data-urlencode "symbols=PVPC_ES_2TD" --data-urlencode "api_key=YOUR_API_KEY"

If you are evaluating the API, you can start a 7-day, 50-call trial on the Starter plan ($19.99/mo) and plug the trial key into this exact command. During trial and in production, keep the symbol list focused on what you need (here, PVPC_ES_2TD) to limit bandwidth and simplify parsing.

Understand the latest response fields you will actually use

Below is a real API response for PVPC. Copy these exact values for your tests, then switch to live data by calling the endpoint with your own key.

{"success":true,"date":"2026-10-13","base":"EUR","rates":{"PVPC_ES_2TD":208.2129},"dates":{"PVPC_ES_2TD":"2026-10-13"},"currencies":{"PVPC_ES_2TD":"EUR"},"base_filter_note":null}

How to interpret the fields for finance-caliber workflows:

  • success: Boolean request status you can assert before parsing numeric values.
  • date: Top-level server date associated with this latest payload. Treat it as the canonical publication date for the batch.
  • base: The base currency for the response. For single-symbol PVPC queries, you will typically see EUR. If you mix symbols in other use cases, base may be MIXED.
  • rates.PVPC_ES_2TD: The current PVPC price expressed in the unit given in currencies and the unit catalog (EUR per MWh).
  • dates.PVPC_ES_2TD: The effective date for that specific symbol’s value. Use this when charting or reconciling time-aligned calculations.
  • currencies.PVPC_ES_2TD: The currency of the rate. For PVPC_ES_2TD, it is EUR.
  • base_filter_note: Optional note about base filtering. Often null when no filtering caveats apply.

With the above, a typical financial calculation is as simple as taking rates.PVPC_ES_2TD as a EUR/MWh price and multiplying by the metered MWh for a day. If you compute household bills in kWh, divide the price by 1000 first.

Production-grade parsing in Python

This script calls the latest endpoint for PVPC_ES_2TD, asserts the response, and extracts the price, currency, and date you need for downstream finance use (billing, risk, dashboards). Replace YOUR_API_KEY with your key before running. No other placeholders are used.

import os
import sys
import json
import urllib.parse
import urllib.request

def fetch_latest_pvpc(api_key):
base_url = "https://energy-api.com/api/v1/latest"
params = {
"symbols": "PVPC_ES_2TD",
"api_key": api_key
}
url = base_url + "?" + urllib.parse.urlencode(params)
req = urllib.request.Request(url, method="GET")

with urllib.request.urlopen(req, timeout=20) as resp:
body = resp.read().decode("utf-8")
data = json.loads(body)

if not data.get("success", False):
raise RuntimeError("API call unsuccessful")

symbol = "PVPC_ES_2TD"
try:
rate = float(data["rates"][symbol])
eff_date = data["dates"][symbol]
currency = data["currencies"][symbol]
except (KeyError, ValueError) as e:
raise KeyError(f"Missing or invalid fields for {symbol}: {e}")

base_currency = data.get("base")
# For PVPC only, base is expected to be EUR. You may verify and log if needed.
return {
"symbol": symbol,
"rate": rate,
"unit": f"{currency}/MWh", # Per origin catalog
"effective_date": eff_date,
"base": base_currency
}

if __name__ == "__main__":
api_key = "YOUR_API_KEY"
try:
latest = fetch_latest_pvpc(api_key)
except Exception as exc:
print(f"Error: {exc}", file=sys.stderr)
sys.exit(1)

# Example computation: convert EUR/MWh to EUR/kWh for billing micro-calculations
eur_per_mwh = latest["rate"]
eur_per_kwh = eur_per_mwh / 1000.0

print(json.dumps({
"symbol": latest["symbol"],
"effective_date": latest["effective_date"],
"eur_per_mwh": eur_per_mwh,
"eur_per_kwh": eur_per_kwh,
"base": latest["base"],
"unit_mwh": latest["unit"]
}, indent=2))

Consider wrapping the fetch in a retry with exponential backoff for network hiccups, and persist the final parsed values to your datastore for reproducibility in financial reporting.

Practical details that save time

  • Units and conversions: PVPC is returned as EUR/MWh. To price per kWh, divide by 1000. Always tag your datasets with units to avoid silent mismatches.
  • Base and currency: For single-symbol PVPC calls, currencies.PVPC_ES_2TD and base are EUR in the real example below. If you later query multiple symbols simultaneously and they cannot share a single base, base may be MIXED. Read the currencies map per symbol reliably.
  • Timestamps and timezone: The latest endpoint returns a date (YYYY-MM-DD) for the batch and a per-symbol dates entry. Treat these as calendar dates. If you must time-stamp ingestion events, keep your own UTC timestamps to separate “ingested_at” from “effective_date.”
  • Caching: For dashboards and billing jobs, cache results for the calendar day to minimize calls. Clear the cache when a new date appears in dates.PVPC_ES_2TD. For intraday retries, 1–5 minute cache is reasonable unless you need immediate picks after publication.
  • Non-trading days: Energy references can publish daily, but always code defensively: if today’s date isn’t available, use the last available business day and log the lag. Your finance app should surface that lag to users.
  • Trials and limits: The Starter plan is $19.99/mo, with a 7-day trial limited to 50 calls. Budget your calls by caching and avoiding unnecessary re-queries.

Official sample blocks (verbatim)

The following official sample blocks are included exactly as provided by the source. Use them as structural references. Note that the JSON shows a different symbol for illustration; your PVPC integration should use PVPC_ES_2TD as demonstrated elsewhere in this guide.

cURL:

curl -G "https://energy-api.com/api/v1/latest" --data-urlencode "symbols=PVPC_ES_2TD" --data-urlencode "api_key=YOUR_API_KEY"

JSON:

{
"success": true,
"date": "2026-10-13",
"base": "EUR",
"rates": {
"OMIE_ES_DA": 168.8263
},
"dates": {
"OMIE_ES_DA": "2026-10-13"
},
"currencies": {
"OMIE_ES_DA": "EUR"
},
"base_filter_note": null
}

Real PVPC examples you can paste into tests

Use the following real PVPC response for tests in your CI or local environment. This comes from a live response and must be copied exactly when you need a stable fixture.

{"success":true,"date":"2026-10-13","base":"EUR","rates":{"PVPC_ES_2TD":208.2129},"dates":{"PVPC_ES_2TD":"2026-10-13"},"currencies":{"PVPC_ES_2TD":"EUR"},"base_filter_note":null}

For convenience, here are two additional complete, unchanged PVPC response blocks that you may use as deterministic fixtures across different test files or microservices. Keeping fixtures consistent avoids fragile tests that fail due to day-by-day changes.

{"success":true,"date":"2026-10-13","base":"EUR","rates":{"PVPC_ES_2TD":208.2129},"dates":{"PVPC_ES_2TD":"2026-10-13"},"currencies":{"PVPC_ES_2TD":"EUR"},"base_filter_note":null}
{"success":true,"date":"2026-10-13","base":"EUR","rates":{"PVPC_ES_2TD":208.2129},"dates":{"PVPC_ES_2TD":"2026-10-13"},"currencies":{"PVPC_ES_2TD":"EUR"},"base_filter_note":null}

Error handling, validation, and data hygiene

Financial code should fail loudly on structural issues and fail softly on expected gaps (e.g., new day not yet published). Recommended checks:

  • Check success is true. If false or missing, raise and log.
  • Validate that rates.PVPC_ES_2TD, dates.PVPC_ES_2TD, and currencies.PVPC_ES_2TD are present. If any is missing, treat the payload as unusable for billing computations.
  • Confirm currencies.PVPC_ES_2TD is EUR when converting to kWh prices. If mixing symbols in other workflows, use the per-symbol currency map instead of assuming a shared base.
  • Range checks: For PVPC, guard against negative or zero values. Log if the value exceeds a sanity threshold you define for EUR/MWh in your environment.
  • Idempotency: When persisting to a database, use (symbol, effective_date) as a natural key to avoid duplicates and to support backfills.

Scheduling, freshness, and downstream dependencies

PVPC is daily, which simplifies scheduling. Typical approaches:

  • Cron-based fetch after the expected publication time in Spain. If you do not know the exact publication time, fetch hourly until dates.PVPC_ES_2TD equals today’s local date for Spain or your canonical accounting date, then cache for the day.
  • Failure mode: If you do not receive today’s value by a cutoff, move forward with the previous business day’s price and annotate the report. Ensure stakeholders can see that the date did not change.
  • Versioning: Store raw JSON as received, plus a normalized record with fields symbol, effective_date, price_eur_per_mwh, and ingestion_time_utc. This separation helps audits and reconciliations.

Common integration patterns in finance

Financial teams generally combine PVPC with metering and tariff logic. Consider:

  • Unit normalization: Keep all energy prices in EUR/MWh internally, then convert to application-facing units only at presentation time to reduce repeated conversions and rounding differences.
  • Reference data integrity: Pin the symbol code PVPC_ES_2TD in your configuration. Avoid free-text symbol entry in operational tools to prevent typos.
  • Backfills and replays: While this guide focuses on latest, design your pipeline so you can backfill historical days if you add that endpoint to your workflow later. Keep ingestion idempotent as noted above.

End-to-end example: reading and computing a daily bill line

A minimal flow for a daily bill line item could be:

  1. Fetch latest PVPC using the GET /api/v1/latest call with symbols=PVPC_ES_2TD and api_key.
  2. Parse rates.PVPC_ES_2TD and dates.PVPC_ES_2TD and persist with your metered MWh for that date.
  3. Compute line_total_eur = (metered_mwh * price_eur_per_mwh).
  4. Apply taxes and fees separately, with explicit documentation of the rate used and its published date.

This keeps your finance application deterministic and auditable.

FAQ

Q: What unit is PVPC returned in?
A: EUR/MWh. Convert to EUR/kWh by dividing by 1000 when needed for consumer billing views.

Q: How do I authenticate?
A: Pass your key via the api_key query parameter. Use YOUR_API_KEY as the placeholder during setup and testing code samples.

Q: Do I need to specify a base currency?
A: No. For PVPC alone, you will get EUR in currencies.PVPC_ES_2TD and base will be EUR in the example. If you query other symbols together and encounter mixed currencies, base may be MIXED. Do not pass base=USD when you also need TTF_GAS or EUA_CO2.

Q: What should I cache?
A: Cache the entire JSON payload per date and a normalized record with price and effective date. Refresh when dates.PVPC_ES_2TD changes to a new calendar date.

Q: Is there a trial?
A: Yes. The Starter plan is $19.99/mo with a 7-day trial capped at 50 calls.

Ready to wire PVPC into your finance stack? Create an account and start your 7-day trial, then ship your first integration with the latest endpoint. Register and explore every field and behavior in the Documentation.

Ready to get started?

Get your API key and start querying energy commodity prices in minutes.

Get API Key

Related posts