Spain PVPC Hourly Price API

Spain PVPC Hourly Price API

You need a reliable way to pull Spain’s regulated PVPC hourly electricity price into a finance workflow—budgeting, tariff comparison, hedging input, or cost-of-goods sold—without reverse-engineering vendor portals. By the end of this guide, you can fetch the latest PVPC quote for Spain (EUR/MWh) via a production API, parse it in code, and know how to stitch it into billing or risk calculations with correct units, timezone, and caching rules.

What you will build and why it matters for finance

This tutorial shows how to call a real Energy API endpoint to retrieve Spain PVPC Hourly (symbol PVPC_ES_2TD), interpret the price for EUR-denominated forecasting, and optionally drill into date-based hour slices when you need tariff-accurate cost allocation. We focus on finance tasks like daily accruals, invoice reconciliation, and variable tariff modeling—where the correctness of the latest quote, the daily reference date, and the EUR/MWh unit are non-negotiable.

Illustration: Spain PVPC Hourly Price API

Symbol, units, and auth

Energy API symbol for this feed:

  • Symbol name: Spain PVPC Hourly
  • Symbol code: PVPC_ES_2TD
  • Unit: EUR/MWh

Authentication:

  • Pass your key as a query parameter: api_key=YOUR_API_KEY
  • Use the placeholder YOUR_API_KEY only in examples. Replace it with your real key in production.

Plan and trial:

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

Links to get started quickly:

Fetch the latest PVPC quote (EUR/MWh)

Use the latest endpoint to retrieve the current PVPC price consolidated for the daily reference. This is the simplest path to plug a live PVPC rate into a finance calculation (e.g., today’s exposure or a daily accrual entry).

Latest endpoint (GET)

Base URL:

  • GET https://energy-api.com/api/v1/latest?symbols=PVPC_ES_2TD&api_key=YOUR_API_KEY

Notes:

  • Do not pass base=USD for PVPC—this symbol is denominated in EUR/MWh.
  • If you later add TTF_GAS or EUA_CO2 to your symbols list: do not pass base=USD in the same request (those use MIXED base). Keep PVPC separate if you need a uniform base.

cURL example (copy-pasteable)

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

REAL API RESPONSE

Below is a live-format payload for the latest PVPC rate. Use these exact values to test your parser:

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

Field usage for finance:

  • date: API’s reference date for the quote; align this with your value date in accrual logic.
  • base: EUR; this is the quote currency domain for PVPC.
  • rates.PVPC_ES_2TD: 155.27 (EUR/MWh); the number you multiply by MWh consumption to estimate cost.
  • dates.PVPC_ES_2TD: “2026-10-10”; the instrument-specific date stamp (aligns with date above).
  • currencies.PVPC_ES_2TD: “EUR”; confirms denomination.

Hourly PVPC by date (for tariff-accurate allocation)

When you need 00:00–23:00 local-hour splits to power invoice reconstruction or product-level P&L (e.g., charging sessions, shift loads), use the dedicated PVPC endpoint with a date. You will read hours[].price_eur_mwh from the response to obtain each hour’s rate in EUR/MWh. Do not invent the series; always parse from the API payload.

Official cURL sample

Use this exact sample to validate your client setup (auth, network path). The date is supplied via query parameter.

curl -G "https://energy-api.com/api/v1/electricity/pvpc" --data-urlencode "date=2026-06-18" --data-urlencode "api_key=YOUR_API_KEY"

Parsing guidance:

  • Inspect hours[] entries in the response and read hours[].price_eur_mwh.
  • Hour boundaries apply to the Spain PVPC zone in local time. Align this with your ledger timezone policy (commonly CET/CEST with daylight saving).

OFFICIAL SAMPLE JSON (for structure handling)

Copying the official sample payload verbatim. This sample helps you validate JSON field handling in your client:

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

Explanation:

  • success/date/base: top-level status, reference date, and currency base.
  • rates / dates / currencies: instrument-level fields. For PVPC hourly resolution, parse hours[].price_eur_mwh from the PVPC endpoint response; do not synthesize hourly data.

Python example: latest PVPC for accruals + hourly PVPC for cost allocation

This end-to-end script fetches the daily latest PVPC quote and, for a given historical date, reads the hourly series to allocate energy costs by hour in EUR. Replace YOUR_API_KEY before production.

import os
import requests
from datetime import date

API_KEY = os.getenv("ENERGY_API_KEY", "YOUR_API_KEY")

def latest_pvpc():
url = "https://energy-api.com/api/v1/latest"
params = {
"symbols": "PVPC_ES_2TD",
"api_key": API_KEY
}
r = requests.get(url, params=params, timeout=20)
r.raise_for_status()
data = r.json()
# Core finance fields
ref_date = data.get("date")
rate = data.get("rates", {}).get("PVPC_ES_2TD")
quote_ccy = data.get("currencies", {}).get("PVPC_ES_2TD")
return {
"ref_date": ref_date,
"rate_eur_per_mwh": rate,
"ccy": quote_ccy
}

def hourly_pvpc_by_date(yyyymmdd):
url = "https://energy-api.com/api/v1/electricity/pvpc"
params = {
"date": yyyymmdd,
"api_key": API_KEY
}
r = requests.get(url, params=params, timeout=20)
r.raise_for_status()
data = r.json()
# Expect an array like hours = [{ "hour": "00-01", "price_eur_mwh": 120.1 }, ...]
hours = data.get("hours", [])
# Map hour to EUR/MWh so you can multiply by MWh consumption per hour
hourly_prices = [(h.get("hour"), h.get("price_eur_mwh")) for h in hours]
return hourly_prices

if __name__ == "__main__":
# 1) Latest PVPC for today's accrual entry
latest = latest_pvpc()
print("Latest PVPC reference date:", latest["ref_date"])
print("Latest PVPC rate (EUR/MWh):", latest["rate_eur_per_mwh"])
print("Currency:", latest["ccy"])

# 2) Hourly PVPC for a historical date for cost allocation
yyyymmdd = "2026-06-18"
hourly = hourly_pvpc_by_date(yyyymmdd)
# Example: compute cost given hourly consumption in MWh (placeholder values)
hourly_consumption_mwh = [0.5] * len(hourly) # replace with actual per-hour MWh
total_cost_eur = 0.0
for (slot, price), mwh in zip(hourly, hourly_consumption_mwh):
if price is None:
continue
total_cost_eur += price * mwh
print(f"Total estimated energy cost on {yyyymmdd}: EUR {total_cost_eur:.2f}")

Another copy of the REAL API RESPONSE for parser verification

Use this identical payload to unit-test your JSON parsing and caching layers without hitting the API multiple times:

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

cURL for the dated PVPC endpoint and field reading reminder

When you need hour-by-hour PVPC values on a specific date for ledger splits or billing detail, use the dated endpoint. Remember to read hours[].price_eur_mwh from the response.

curl -G "https://energy-api.com/api/v1/electricity/pvpc" --data-urlencode "date=2026-06-18" --data-urlencode "api_key=YOUR_API_KEY"

Once you receive the JSON, iterate hours[] and extract price_eur_mwh to multiply by your per-hour MWh. Preserve the hour label (e.g., “00-01”) and align with Spain’s local time for the date in question.

JSON structure recap (for QA)

Keep one more identical copy at hand while wiring dashboards or ETL, to avoid re-downloading during development:

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

Data handling details that will save time in finance integrations

Units and conversions:

  • PVPC_ES_2TD quotes are in EUR per MWh. If your metering data is in kWh, divide price by 1000 before multiplying, or convert kWh to MWh (1 MWh = 1000 kWh).
  • Avoid mixing bases in multi-symbol queries that include MIXED-base instruments (e.g., TTF_GAS or EUA_CO2). For PVPC, stick with EUR and keep calls separate if needed.

Dates and timezone:

  • The latest payload provides a single daily reference date. Use this for daily accruals and day-based finance views.
  • Hourly PVPC uses Spain local time (CET/CEST depending on DST). Daylight-saving transitions can cause 23 or 25 hour entries. Always store the hour label and the date-time mapping explicitly.

Caching and refresh:

  • For the latest PVPC, respect your firm’s cache policy to avoid intra-day overcalls. A 5–15 minute cache typically suffices for dashboarding; use event-driven refresh on settlement or tariff publication for ledger actions.
  • Record the entire response (rates/dates/currencies) with your accrual so downstream reconciliations can trace the source quote.

Non-trading/holiday behavior:

  • PVPC is a regulated retail tariff reference; expect daily coverage. If your call returns the prior day’s value or delays occur, fall back to your last good value with a data-staleness flag in your ledger.

Pagination and batching:

  • The latest endpoint supports symbols query input. For PVPC-only finance workflows, keep a single-symbol call for clarity.

Error handling:

  • Guard against null rates or unexpected structures by validating that rates.PVPC_ES_2TD is a number and currencies.PVPC_ES_2TD is “EUR”.
  • On HTTP errors, retry with exponential backoff and persist your last-good-rate snapshot to prevent downstream noise in accruals.

End-to-end accrual and billing pattern

Daily accrual:

  • At your close time T, call latest for PVPC_ES_2TD and store date, rate, and currency.
  • Compute cost = rate (EUR/MWh) × daily MWh consumption. If your meter data is in kWh, convert accordingly.

Invoice reconstruction and validation:

  • For a closed billing day D, call the dated PVPC endpoint and fetch hours[].price_eur_mwh.
  • Multiply each hourly price by matching hourly consumption to derive a line-item ledger you can reconcile to supplier invoices.

Hedge input and scenario testing:

  • Use the latest PVPC as a proxy input to stress-test energy cost components in your margin model.

How to test quickly (without wiring everything first)

Use the following cURL for sanity checks of latest PVPC (you should see EUR base and a PVPC_ES_2TD rate):

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

Then run the official dated PVPC endpoint call to validate your auth and observe the field presence of hours[].price_eur_mwh:

curl -G "https://energy-api.com/api/v1/electricity/pvpc" --data-urlencode "date=2026-06-18" --data-urlencode "api_key=YOUR_API_KEY"

One more official sample JSON (for tooling compatibility)

This block is provided to help confirm your JSON deserializer and field path logic. Copy it as-is to your unit tests.

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

Security and operational notes

Keys and secrets:

  • Store YOUR_API_KEY in a secure secret manager. Never hardcode it in version control.

Observability:

  • Log symbol, date, rate, and correlation ID (if available) for each call. Attach these logs to your finance job runs for auditability.

Idempotency:

  • When persisting daily accruals, key by symbol + reference date to avoid duplicate ledger entries on retries.

Frequently asked questions

Q1: What unit should I use when multiplying PVPC by consumption?
A1: PVPC_ES_2TD is in EUR/MWh. If your consumption is in kWh, either convert kWh to MWh (divide by 1000) or divide the EUR/MWh price by 1000 before multiplying.

Q2: How do I get hourly PVPC values for accurate billing?
A2: Call the dated PVPC endpoint with a date query param and parse hours[].price_eur_mwh. Do not invent or extrapolate the hourly series; always read it from the response.

Q3: Should I request USD base for PVPC?
A3: No. Keep PVPC in EUR. Also, if you later query symbols like TTF_GAS or EUA_CO2, do not include base=USD alongside them; they use MIXED base. Keep PVPC separate when you need a consistent base.

Q4: How often should I refresh the latest PVPC quote?
A4: For finance dashboards, cache for minutes; for accruals or ledger close, refresh at your close cut-off and store the exact response for audit.

Q5: Is there a free trial, and how do I start?
A5: Yes. Trial is 7 days / 50 calls. Starter is $19.99/mo. Use the links below to create an account and read full endpoint details.

Next steps

Spin up your key, run the cURL samples, and wire the latest PVPC quote into your accrual job—then add the hourly endpoint to power invoice-accurate allocations. Create your account at Register and keep the reference handy at Documentation.

Ready to get started?

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

Get API Key

Related posts