API to Get the Spain PVPC Hourly Price
You need a reliable way to fetch Spain’s PVPC hourly electricity price and turn it into finance-grade inputs—hedging references, pass-through billing, or mark-to-market for indexed supply contracts. By the end of this guide, you will be able to authenticate, request both the hourly PVPC day-ahead schedule and the latest PVPC symbol snapshot, parse the numeric fields you actually need, and integrate the data into a pricing or risk workflow.
What you will get from the API
The Energy API exposes the Spain PVPC Hourly series with a dedicated symbol and an hourly endpoint:
- Symbol name: Spain PVPC Hourly
- Symbol code: PVPC_ES_2TD
- Unit: EUR/MWh
- Authentication: api_key as a query parameter (use YOUR_API_KEY while developing)
Two patterns matter for finance use-cases:
- Snapshot/Latest: request a current rate for PVPC_ES_2TD using the
/api/v1/latest?symbols=route. This is useful for dashboards, day-level pricing, and quick sanity checks. - Hourly schedule: request a specific date’s PVPC schedule via the electricity PVPC endpoint and read
hours[].price_eur_mwhfor the intraday breakdown you need for pass-through invoices and optimization models.
Endpoints you will call
Based on the catalog and official samples, you will typically use:
- Hourly PVPC schedule (by date):
GET https://energy-api.com/api/v1/electricity/pvpc?date=YYYY-MM-DD&api_key=YOUR_API_KEY - Latest symbol snapshot:
GET https://energy-api.com/api/v1/latest?symbols=PVPC_ES_2TD&api_key=YOUR_API_KEY
Use the first for hour-by-hour costs in EUR/MWh; use the second for an at-a-glance PVPC value suitable for daily markups, budget updates, or alerts.
Authentication and pricing plan
Pass your key as a query parameter: api_key=YOUR_API_KEY. Do not add header or body auth unless your stack enforces it; the API reads the query parameter. You can start on the Starter plan ($19.99/mo) with a 7-day trial that includes 50 calls. Get an API key here:
Your first PVPC request (cURL)
The following official call fetches the PVPC schedule for a given date. You will parse hours[].price_eur_mwh to read each hour’s value in EUR/MWh.
cURL
curl -G "https://energy-api.com/api/v1/electricity/pvpc" --data-urlencode "date=2026-06-18" --data-urlencode "api_key=YOUR_API_KEY"
Notes for finance teams:
- The schedule gives you 24 hourly points (or 23/25 on DST changeovers). Multiply by consumption (MWh) to compute cost for each hour.
- All amounts are in EUR/MWh. Convert units before combining with portfolio or site-level quantities.
- If you also fetch other symbols like TTF or EUA for composite indices, do not pass
base=USDalongside those requests. Keep the default base unless your downstream logic explicitly requires FX normalization.
Latest symbol snapshot via /api/v1/latest
When you need a consolidated PVPC value for the current date—useful for quick reports, risk checks, or guardrails—call the latest endpoint for PVPC_ES_2TD. This won’t replace the hourly schedule but is convenient for at-a-glance financial dashboards.
Python example: fetch the latest PVPC symbol and interpret fields
The snippet below calls /api/v1/latest for the PVPC symbol, extracts the numeric value in EUR/MWh, and prints the date attached to that symbol.
Python
import requests
API_KEY = "YOUR_API_KEY"
SYMBOL = "PVPC_ES_2TD"
url = "https://energy-api.com/api/v1/latest"
params = {
"symbols": SYMBOL,
"api_key": API_KEY
}
resp = requests.get(url, params=params, timeout=15)
resp.raise_for_status()
data = resp.json()
# Rates are keyed by symbol code
pvpc_value_eur_mwh = data["rates"][SYMBOL]
pvpc_date = data["dates"][SYMBOL]
pvpc_unit = data["currencies"][SYMBOL] # will be "EUR" for this symbol
print(f"PVPC latest: {pvpc_value_eur_mwh} {pvpc_unit}/MWh on {pvpc_date}")
# In finance workflows you might:
# - Push pvpc_value_eur_mwh into a dashboard
# - Compare against a budget curve
# - Trigger alerts if out-of-band relative to recent history
Official JSON sample (as provided)
The documentation includes a representative JSON payload structure you will see across latest-style responses. Field names are consistent with what you will parse for PVPC as well.
JSON
{
"success": true,
"date": "2026-11-10",
"base": "EUR",
"rates": {
"OMIE_ES_DA": 171.3841
},
"dates": {
"OMIE_ES_DA": "2026-11-10"
},
"currencies": {
"OMIE_ES_DA": "EUR"
},
"base_filter_note": null,
"missing_symbols": null
}
How to read these fields for finance tasks:
rates: numeric values keyed by symbol code. For PVPC snapshots you will readrates["PVPC_ES_2TD"]as a EUR/MWh value.dates: the effective date for each symbol you requested.currencies: the currency for each symbol’s unit. PVPC is in EUR.base: the base currency context for rates. If you combine symbols, keep them on the same base to avoid mixing units in financial aggregates.
Real API response for PVPC_ES_2TD
Here is a real response structure and values for the PVPC symbol using the latest-style route. You will copy the same parsing pattern from the Python snippet above.
JSON
Practical usage:
- Take
rates.PVPC_ES_2TDas the EUR/MWh numeric input for position checks or budget updates. - Use
dates.PVPC_ES_2TDto align the snapshot with your reporting date. - Confirm
currencies.PVPC_ES_2TDisEURbefore combining with any non-EUR figures.
Parsing the hourly PVPC schedule for billing and hedging
Most finance-grade usage of PVPC needs the hour-by-hour schedule for a specific date. Use the electricity PVPC endpoint shown in the cURL section. In that response, read hours[].price_eur_mwh to obtain the intraday price series in EUR/MWh.
Practical tips:
- Multiply each hour’s price (EUR/MWh) by site or portfolio volume (MWh) to compute cost per hour. Sum to a daily total.
- The hourly array is ordered by hour. Store the entire series with its date key for auditability and reconciliation.
- On daylight saving transitions, you may observe 23 or 25 hourly entries. Ensure your billing logic accommodates this.
- Cache the schedule per date to avoid re-fetching with each invoice line item.
Validation and reconciliation workflow
Finance teams commonly mix the two request patterns:
- Use the hourly endpoint by date for the contractual bill: apply
hours[].price_eur_mwhto hourly volumes. - Use the latest PVPC symbol snapshot as a guardrail or as a quick reference on a dashboard. It helps contextualize the day’s price level without reconstructing 24 hourly points.
When producing a statement or settlement file, serialize both the hourly series and computed totals, and attach the API date so downstream reviews can re-query identical data later.
Error handling, retries, and caching
For production reliability:
- Rate and availability: the trial includes 50 calls over 7 days; plan your batch size and caching accordingly. For daily operations, cache the PVPC schedule once per date and reuse it through your billing job.
- Timeouts: use sane HTTP timeouts (10–20s) and a single retry with jitter if your scheduler allows it.
- Idempotency: reading endpoints are side-effect free. You can reattempt on transient network issues safely.
- Validation: assert the presence of
rates[SYMBOL]orhours[]before computations. If missing, raise an actionable error.
Units, dates, and currency considerations
- Units: PVPC is provided in EUR/MWh. If your internal ledger tracks EUR/MWh, you can store directly. If you use EUR/kWh, divide by 1000.
- Currency base: keep PVPC and any comparator symbols on the same base. Do not pass
base=USDin multi-commodity pulls that also need TTF_GAS or EUA_CO2. - Dates: the latest endpoint returns a date per symbol via the
datesmap. Use that for alignment in your reports. For the hourly endpoint, you pass an explicit date. - Time boundaries: the hourly schedule is a per-date array. If your financial day boundary differs from the market day, document your convention (e.g., market day vs. local calendar day) in your internal procedure.
Embedding PVPC in finance workflows
Here are common finance-led integrations where the PVPC API fits cleanly:
- Pass-through billing: fetch the specific date’s PVPC hourly series, multiply by measured consumption per hour, apply contractual fees, and render invoice line-items with totals.
- Hedging P&L: use the latest PVPC symbol as a quick daily checkpoint, then reconcile against the hourly curve for precise valuation.
- Budgeting and variance analysis: roll the hourly PVPC into daily or monthly averages and compare against your budget curve to flag overspend.
- Alerting: schedule a task to pull the latest PVPC snapshot and alert finance if it breaches a threshold relative to recent realized values.
Observability and audit tips
- Persist each API response (raw JSON) alongside computed outputs. This enables audit and re-computation without re-querying during investigations.
- Log the endpoint, query parameters, and symbol codes used for every job run.
- Version your pricing logic so that future code changes don’t alter historical replays.
FAQ
Q: Which symbol code should I request for PVPC?
A: Use PVPC_ES_2TD. For snapshots via /api/v1/latest, pass ?symbols=PVPC_ES_2TD&api_key=YOUR_API_KEY. For the hourly schedule use the electricity PVPC endpoint with the date parameter.
Q: How do I get the hourly series I need for invoicing?
A: Call /api/v1/electricity/pvpc?date=YYYY-MM-DD&api_key=YOUR_API_KEY and read hours[].price_eur_mwh. Multiply each hour by your MWh consumption for that hour to compute costs.
Q: What is the unit for PVPC values?
A: EUR/MWh. If you need EUR/kWh, divide by 1000 before multiplying by kWh volumes.
Q: Can I combine PVPC with other commodities in one request?
A: You can request multiple symbols on /api/v1/latest. If you also need TTF_GAS or EUA_CO2, do not pass base=USD; keep the default base to avoid mixing units.
Q: How should I cache or store responses?
A: Cache the hourly PVPC result per date and persist raw JSON with computed outputs. For the latest PVPC symbol, cache briefly for dashboards, but always pull the hourly endpoint for invoicing-grade calculations.
Next steps
Get your API key and ship your first PVPC integration. Start with the latest PVPC symbol for dashboard checks, then add the hourly PVPC endpoint for billing and reconciliation. You can register here and consult the docs:
Ready to get started?
Get your API key and start querying energy commodity prices in minutes.
Get API Key