Historical Spain PVPC Hourly Prices
You're trying to programmatically fetch and analyze historical Spain PVPC hourly prices so you can run backtests, calculate hedging exposures, or load accurate EUR/MWh references into your billing and risk systems. By the end of this guide, you will be able to pull PVPC daily and timeseries data from the Energy API, parse the correct fields, handle hourly structures safely, and ship a reliable integration for historical pricing.
What the PVPC symbol represents and the exact data you’ll use
The Spain PVPC Hourly price is published under a dedicated Energy API symbol and unit so that financial and analytics systems can standardize and automate their workflows. This guide focuses solely on the Spain PVPC instrument and its historical retrieval.
- Symbol name: Spain PVPC Hourly
- Symbol code: PVPC_ES_2TD
- Unit: EUR/MWh
- Authentication: api_key query parameter (use YOUR_API_KEY)
- Starter pricing: $19.99/mo, 7-day trial with 50 calls
Energy PVPC responses may include a high-level rate entry for the symbol and, on the PVPC endpoint, an hourly breakdown. When hourly data is present, read hours[].price_eur_mwh. Do not fabricate hours or interpolate absent values. If only a rate appears, use the provided field exactly as returned.
Endpoints you will call and when to use each
Use two endpoints to cover historical PVPC workflows:
- Daily PVPC endpoint for the requested calendar date: GET https://energy-api.com/api/v1/electricity/pvpc with date and api_key. Returns PVPC for that day and may include hourly details (hours[].price_eur_mwh).
- Timeseries endpoint for multi-day spans with PVPC_ES_2TD: GET https://energy-api.com/api/v1/timeseries with start, end, symbols, and api_key. Use this for month-over-month or portfolio horizons without stitching daily requests.
Authentication is always via the api_key query parameter. Use the literal placeholder YOUR_API_KEY in examples and development scaffolding. Do not embed a real key in source code or documentation.
Official PVPC daily request: cURL you can paste
The following cURL is the official daily PVPC request format. It is a GET with a date and api_key. Copy and run it after replacing YOUR_API_KEY to validate connectivity and response structure.
curl -G "https://energy-api.com/api/v1/electricity/pvpc" --data-urlencode "date=2026-06-18" --data-urlencode "api_key=YOUR_API_KEY"
JSON responses you will parse
Read these examples carefully. When a REAL API RESPONSE is provided, you must copy its fields and values exactly for your test fixtures and mapping.
Official sample JSON (copy verbatim)
{
"success": true,
"date": "2026-10-25",
"base": "EUR",
"rates": {
"OMIE_ES_DA": 111.8823
},
"dates": {
"OMIE_ES_DA": "2026-10-25"
},
"currencies": {
"OMIE_ES_DA": "EUR"
},
"base_filter_note": null
}
Explanation: This official sample shows a daily market symbol payload with base currency, a rates map keyed by symbol, matching dates, and associated currencies. While the symbol shown here is OMIE_ES_DA (day-ahead), your PVPC workflow uses PVPC_ES_2TD. The structural takeaway still applies: base is the pricing currency, rates holds symbol-to-value pairs, and dates/currencies provide per-symbol metadata.
REAL API RESPONSE for Spain PVPC Hourly symbol
{"success":true,"date":"2026-10-25","base":"EUR","rates":{"PVPC_ES_2TD":182.3404},"dates":{"PVPC_ES_2TD":"2026-10-25"},"currencies":{"PVPC_ES_2TD":"EUR"},"base_filter_note":null}
What to use from this response:
- rates.PVPC_ES_2TD: the numeric value in EUR/MWh for 2026-10-25.
- base: EUR (do not convert unless you handle FX elsewhere).
- dates.PVPC_ES_2TD: confirms the pricing date for the symbol.
Repeat of the REAL API RESPONSE for fixture parity and parsing tests
{"success":true,"date":"2026-10-25","base":"EUR","rates":{"PVPC_ES_2TD":182.3404},"dates":{"PVPC_ES_2TD":"2026-10-25"},"currencies":{"PVPC_ES_2TD":"EUR"},"base_filter_note":null}
Use this exact payload for test fixtures, contract tests, or mocks to ensure your parser consistently locates base, rates, dates, and currencies fields and maps PVPC_ES_2TD correctly.
How to request hourly PVPC and interpret hours[].price_eur_mwh
The PVPC endpoint may return an hourly breakdown in an hours array. When present:
- Read each item’s price_eur_mwh for the EUR/MWh value of that hour.
- Use any hour labeling or timestamp fields exactly as provided; do not infer missing timezone data.
- Avoid fabricating an hourly profile if hours is absent. For that date, rely on the daily rate provided in rates.PVPC_ES_2TD.
On days with daylight-saving changes, hour counts can differ. Build your ingestion to iterate the array as-supplied rather than assuming a fixed 24-length profile.
End-to-end Python example: fetch PVPC daily and parse hourly safely
This script requests a single date from the PVPC endpoint, parses the symbol-level rate, and when available iterates hours[].price_eur_mwh. It handles absent hourly data gracefully without fabricating values.
import os
import sys
import json
import urllib.parse
import urllib.request
BASE_URL = "https://energy-api.com/api/v1/electricity/pvpc"
API_KEY = os.environ.get("ENERGY_API_KEY", "YOUR_API_KEY") # replace in local tests
def fetch_pvpc(date_str):
params = {
"date": date_str,
"api_key": API_KEY,
}
url = BASE_URL + "?" + urllib.parse.urlencode(params)
with urllib.request.urlopen(url) as resp:
data = json.loads(resp.read().decode("utf-8"))
return data
def parse_pvpc(data, symbol="PVPC_ES_2TD"):
result = {
"base": data.get("base"),
"date": data.get("date"),
"symbol_rate": None,
"hours": None
}
# Symbol-level daily rate
rates = data.get("rates") or {}
if symbol in rates:
result["symbol_rate"] = rates[symbol]
# Optional hourly breakdown
if "hours" in data and isinstance(data["hours"], list):
# DO NOT fabricate; just read what is provided
hours_out = []
for h in data["hours"]:
# Safely access the documented field
price = h.get("price_eur_mwh")
# Keep any hour label/timestamp fields as-is if present
hours_out.append({
"price_eur_mwh": price,
# preserve any other fields in h without assumptions
**{k: v for k, v in h.items() if k != "price_eur_mwh"}
})
result["hours"] = hours_out
return result
if __name__ == "__main__":
date_arg = sys.argv[1] if len(sys.argv) > 1 else "2026-10-25"
payload = fetch_pvpc(date_arg)
parsed = parse_pvpc(payload)
print(json.dumps(parsed, indent=2, ensure_ascii=False))
Notes:
- Authentication uses api_key in the query string. Do not switch to headers unless the documentation instructs you to.
- The script intentionally avoids assuming a 24-hour array length and reads price_eur_mwh only when present.
- Base is EUR; if you maintain multi-currency ledgers, convert downstream using your FX references, not by passing a base override here.
Timeseries guide for PVPC_ES_2TD
For historical spans, call the timeseries endpoint with start, end, and symbols. This lets you retrieve PVPC_ES_2TD across multiple days with a single request, simplifying downstream rollups and backtests.
- Endpoint: GET https://energy-api.com/api/v1/timeseries
- Query parameters: start, end, symbols, api_key
- Symbols: PVPC_ES_2TD (comma-separated list if you add more later)
Example cURL you can adapt:
curl -G "https://energy-api.com/api/v1/timeseries" \
--data-urlencode "start=2026-10-01" \
--data-urlencode "end=2026-10-25" \
--data-urlencode "symbols=PVPC_ES_2TD" \
--data-urlencode "api_key=YOUR_API_KEY"
Implementation guidance:
- Pagination: if the documentation signals pagination for longer ranges, honor cursors or page params. If unspecified, iterate by month to keep responses manageable.
- Caching: cache immutable past days to reduce call volume. For the current local market day, cache with a shorter TTL and refetch after settlement windows.
- Consistency: store the symbol code PVPC_ES_2TD as your foreign key in warehouses so you can add secondary attributes without rekeying historical rows.
How to normalize units, dates, and base currency
Normalization is minimal for PVPC:
- Unit is EUR/MWh. Keep this unit in all downstream calculations. If your stack uses EUR/kWh, convert at 1 MWh = 1000 kWh.
- Base currency is EUR. Do not pass base=USD on these calls. If you need USD valuation, convert externally with your FX source of truth.
- Dates in responses map symbol-to-date in dates[<symbol>]. Use the date field to index your timeseries and to validate rows.
Some portfolios combine power with gas (e.g., TTF_GAS) or carbon (EUA_CO2). When you need those, request them explicitly by symbol; do not rely on cross-instrument base parameters and do not couple their retrieval to PVPC calls. Avoid passing base=USD when you also need TTF_GAS or EUA_CO2.
Operational considerations that save debugging time
- Idempotency: reading historical data should be idempotent; write ingestion jobs to safely upsert by date+symbol keys.
- DST and hour counts: treat hours arrays as authoritative for that date; do not coerce to 24 elements.
- Null handling: fields like base_filter_note can be null. Safely handle nulls in strongly typed code.
- Retries: network retries with exponential backoff are safe, but avoid retry storms around market close or publish windows.
- Validation: for daily snapshots, assert that currencies[PVPC_ES_2TD] == base for consistency checks in your ETL.
Additional copy-paste examples for developers
These blocks are provided as-is to help you test mapping in your code and fixtures. They must not be altered.
Official daily PVPC cURL (again, for quick copy)
curl -G "https://energy-api.com/api/v1/electricity/pvpc" --data-urlencode "date=2026-06-18" --data-urlencode "api_key=YOUR_API_KEY"
REAL API RESPONSE JSON (PVPC_ES_2TD)
{"success":true,"date":"2026-10-25","base":"EUR","rates":{"PVPC_ES_2TD":182.3404},"dates":{"PVPC_ES_2TD":"2026-10-25"},"currencies":{"PVPC_ES_2TD":"EUR"},"base_filter_note":null}
Common pitfalls and how to avoid them
- Mixing symbols: stay on PVPC_ES_2TD for Spain PVPC Hourly. Do not switch to other instruments to fill gaps; that will corrupt historical comparisons.
- Inferring hourly where absent: only read hours[].price_eur_mwh when hours is present. If it is not returned, do not interpolate or assume uniform hourly distribution.
- Currency overrides: do not pass base overrides for PVPC. Keep the response in EUR and convert externally if needed.
- Cross-instrument coupling: do not bundle PVPC calls with TTF_GAS or EUA_CO2 using unsupported parameters. Request each symbol explicitly by its own endpoint or via symbols lists on the timeseries endpoint.
FAQ
Q: How do I authenticate?
A: Pass your key as the api_key query parameter on every request. Example: api_key=YOUR_API_KEY. Keep keys out of client-side code and rotate them periodically.
Q: How do I get a full historical range without stitching many daily calls?
A: Use GET https://energy-api.com/api/v1/timeseries with start, end, and symbols=PVPC_ES_2TD plus api_key. Parse the same base/rates/dates structure across multiple days.
Q: Where do I find the unit and base currency?
A: The PVPC_ES_2TD unit is EUR/MWh. The response base field is EUR. Do not change base on this call; convert externally if you need other currencies.
Q: How do I handle hourly PVPC data?
A: When the PVPC endpoint includes hours, iterate hours[] and read price_eur_mwh per entry. Do not fabricate hours if the array is absent. Account for possible hour-count changes on DST days by iterating what is returned rather than assuming 24 elements.
Q: Can I combine PVPC with other instruments like TTF gas or EU ETS allowances in one request?
A: Only if the endpoint supports multiple symbols explicitly (e.g., timeseries symbols list). Do not pass base=USD or unrelated parameters to bind different markets; request each symbol explicitly and join results in your application.
Set up your credentials and ship your integration in minutes. Create your account now: Register. For endpoint, symbol, and response field references, see the Documentation.
Ready to get started?
Get your API key and start querying energy commodity prices in minutes.
Get API Key