PVPC_ES_2TD Price API

PVPC_ES_2TD Price API

You need a fast, reliable way to fetch the latest Spain PVPC (Precio Voluntario para el Pequeño Consumidor) electricity price for finance workflows like mark-to-market, settlement checks, forecasting inputs, and cost alerts. By the end of this guide, you’ll be able to call the Energy API to retrieve the latest PVPC_ES_2TD price, parse the response, and wire it into production code with safe handling for base currency, units, and date fields.

What you will build

You will integrate a single GET request to the Energy API’s latest endpoint for the PVPC_ES_2TD symbol, parse the fields that matter for finance (price, currency, as-of date), and structure the response for downstream valuation or analytics. You’ll also see how to handle units, base currency, caching, and non-trading-day semantics for daily electricity pricing.

Illustration: PVPC_ES_2TD Price API

Quick facts you must know before coding

  • Symbol name: Spain PVPC
  • Symbol code: PVPC_ES_2TD
  • Unit: EUR/MWh
  • Auth: api_key query parameter (use literal YOUR_API_KEY in examples; do not put secrets in code)
  • Starter: $19.99/mo; trial is 7 days / 50 calls
  • Base currency: base may be MIXED in multi-symbol requests; for PVPC_ES_2TD alone, base is typically EUR
  • Never add base=USD when you also need TTF_GAS or EUA_CO2 (their base is MIXED)
  • No MCP host; call the endpoint below directly

Endpoint and authentication

Use a GET request to fetch the latest price. Authentication is via an api_key query parameter. Always URL-encode values you pass to the endpoint.

  • HTTP method: GET
  • URL: https://energy-api.com/api/v1/latest
  • Required query parameters:
    • symbols: set to PVPC_ES_2TD
    • api_key: set to YOUR_API_KEY

Starter plan is $19.99/month with a 7-day / 50-call trial, suitable for evaluation and low-volume jobs. For full rate card and additional endpoints, consult the Documentation.

Official cURL you can copy

This is a copy-pasteable call you can run from any shell. Use YOUR_API_KEY literally as shown while testing configurations or replace it with your secret key in CI/CD.

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

Official JSON examples and field mapping

Use these JSON examples to validate request/response handling. Copy them into unit tests or fixtures for your parser. The energy market is daily for PVPC; read the price from rates.PVPC_ES_2TD, the as-of date from dates.PVPC_ES_2TD, and the currency from currencies.PVPC_ES_2TD. Units are EUR/MWh.

Real PVPC response (use values exactly as shown)

{"success":true,"date":"2026-11-11","base":"EUR","rates":{"PVPC_ES_2TD":230.0733},"dates":{"PVPC_ES_2TD":"2026-11-11"},"currencies":{"PVPC_ES_2TD":"EUR"},"base_filter_note":null,"missing_symbols":null}

Field notes you’ll actually use:

  • rates.PVPC_ES_2TD: 230.0733 (EUR/MWh)
  • dates.PVPC_ES_2TD: 2026-11-11 (as-of date for the rate)
  • currencies.PVPC_ES_2TD: EUR (currency of the PVPC quote)
  • base: EUR (the base for this request; in multi-symbol requests, base may be MIXED)

Official sample response (from live docs)

{
"success": true,
"date": "2026-11-11",
"base": "EUR",
"rates": {
"OMIE_ES_DA": 210.9359
},
"dates": {
"OMIE_ES_DA": "2026-11-11"
},
"currencies": {
"OMIE_ES_DA": "EUR"
},
"base_filter_note": null,
"missing_symbols": null
}

This official sample demonstrates identical field structure (success, date, base, rates, dates, currencies). For PVPC, read rates.PVPC_ES_2TD and dates.PVPC_ES_2TD instead of OMIE symbols.

Same PVPC response, pretty-printed for test fixtures

{
"success": true,
"date": "2026-11-11",
"base": "EUR",
"rates": {
"PVPC_ES_2TD": 230.0733
},
"dates": {
"PVPC_ES_2TD": "2026-11-11"
},
"currencies": {
"PVPC_ES_2TD": "EUR"
},
"base_filter_note": null,
"missing_symbols": null
}

Tip: Consider storing the as-of date and currency alongside the numeric rate to avoid misinterpretation in historical backfills or currency conversions.

JavaScript example: fetch and parse PVPC_ES_2TD

The snippet below queries the live endpoint, validates the field presence, and normalizes a finance-friendly object with value, unit, currency, and as-of date. It includes simple guards for null fields and unexpected base currency states.

// Minimal Node.js example using fetch (Node 18+ or add node-fetch)
import https from "node:https";

async function getLatestPVPC() {
const url = new URL("https://energy-api.com/api/v1/latest");
url.searchParams.set("symbols", "PVPC_ES_2TD");
url.searchParams.set("api_key", "YOUR_API_KEY");

const res = await fetch(url, { agent: new https.Agent({ keepAlive: true }) });
if (!res.ok) {
throw new Error(`HTTP ${res.status}: ${await res.text()}`);
}
const data = await res.json();

// Validate structure
if (!data.success) {
throw new Error("API returned success=false");
}
const price = data?.rates?.PVPC_ES_2TD;
const asOf = data?.dates?.PVPC_ES_2TD;
const ccy = data?.currencies?.PVPC_ES_2TD;
const base = data?.base;

if (price == null || !asOf || !ccy) {
throw new Error("Missing PVPC_ES_2TD fields in response");
}

// Normalize for finance pipelines
return {
symbol: "PVPC_ES_2TD",
value: Number(price), // 230.0733
unit: "EUR/MWh", // fixed for PVPC
currency: ccy, // "EUR"
asOf, // "2026-11-11"
base, // "EUR" for this single-symbol call
sourceDate: data.date || asOf
};
}

getLatestPVPC()
.then((quote) => {
console.log("PVPC latest:", quote);
// Persist to your pricing store or trigger downstream valuation here.
})
.catch((err) => {
console.error("PVPC fetch failed:", err);
process.exitCode = 1;
});

Python example: requests + explicit parsing

This Python example matches the same endpoint and extracts the relevant fields for your finance store. It demonstrates basic error handling and field-level validation.

import requests

def get_latest_pvpc():
url = "https://energy-api.com/api/v1/latest"
params = {
"symbols": "PVPC_ES_2TD",
"api_key": "YOUR_API_KEY",
}
r = requests.get(url, params=params, timeout=10)
r.raise_for_status()
data = r.json()

if not data.get("success", False):
raise RuntimeError("API returned success=false")

rates = data.get("rates", {})
dates = data.get("dates", {})
currencies = data.get("currencies", {})

price = rates.get("PVPC_ES_2TD")
as_of = dates.get("PVPC_ES_2TD")
ccy = currencies.get("PVPC_ES_2TD")
base = data.get("base")

if price is None or not as_of or not ccy:
raise ValueError("Missing PVPC_ES_2TD fields in response")

return {
"symbol": "PVPC_ES_2TD",
"value": float(price),
"unit": "EUR/MWh",
"currency": ccy,
"as_of": as_of,
"base": base,
"source_date": data.get("date", as_of),
}

if __name__ == "__main__":
quote = get_latest_pvpc()
print(quote)

Implementation notes that will save you time

  • Units: PVPC_ES_2TD is quoted in EUR/MWh. Do not convert units implicitly; store the unit with the rate.
  • Currency vs base: The currency for PVPC is EUR. The response also includes a top-level base. When requesting multiple symbols together, base may be MIXED. For single-symbol PVPC calls, expect base to be EUR, as shown in the real response.
  • As-of date alignment: Use dates.PVPC_ES_2TD as the authoritative as-of date for your finance store. The top-level date may mirror it, but treat per-symbol dates as canonical when present.
  • Caching: For cost and risk dashboards, a 1–5 minute cache is reasonable. PVPC is a daily series; avoid overpolling during the day unless your workflow requires immediate refresh after the daily update posts.
  • Non-trading days: Electricity daily series can still have calendar effects. If the API returns the same date across weekends or holidays, do not assume a new fix has posted; check dates.PVPC_ES_2TD.
  • Timeouts and retries: Use short timeouts (5–10s) and cautious retries (e.g., 2 attempts) around network errors. Avoid retry storms that exceed trial quotas.
  • Security: Keep YOUR_API_KEY out of logs and client-side code. Inject via environment variables and CI/CD secrets.

How to store PVPC for finance workflows

When persisting quotes, store a compact record with symbol, value, currency, unit, and as-of date. This prevents ambiguity when you later join PVPC with other energy or FX series for PnL or hedging analytics.

  • Key: PVPC_ES_2TD + as-of date
  • Value: numeric (e.g., 230.0733)
  • Currency: EUR
  • Unit: EUR/MWh
  • Provenance: API name + request timestamp + top-level base

Operational checklist for production

  • Monitoring: Track success, latency, and data freshness (as-of date drift > 1 day).
  • Backfills: For historical data, consult the Documentation for additional endpoints. This article focuses on latest pricing.
  • Multi-symbol requests: If you later add TTF_GAS or EUA_CO2 to the same call, do not pass base=USD. Their base is MIXED; handle per-symbol currencies from currencies.{symbol}.
  • Idempotency: If you upsert by (symbol, as-of), your store remains consistent even if you poll multiple times a day.

Additional complete JSON examples for testing

Use these exact blocks for parser and alerting unit tests. They match the structure your code should handle.

PVPC response (exact values, compact form)

{"success":true,"date":"2026-11-11","base":"EUR","rates":{"PVPC_ES_2TD":230.0733},"dates":{"PVPC_ES_2TD":"2026-11-11"},"currencies":{"PVPC_ES_2TD":"EUR"},"base_filter_note":null,"missing_symbols":null}

Official sample structure (OMIE symbol, same schema)

{
"success": true,
"date": "2026-11-11",
"base": "EUR",
"rates": {
"OMIE_ES_DA": 210.9359
},
"dates": {
"OMIE_ES_DA": "2026-11-11"
},
"currencies": {
"OMIE_ES_DA": "EUR"
},
"base_filter_note": null,
"missing_symbols": null
}

FAQ

Q: Which field contains the numeric PVPC price I should store?
A: Read rates.PVPC_ES_2TD. The unit is EUR/MWh and the currency is provided by currencies.PVPC_ES_2TD.

Q: What date should I use for valuation cutovers?
A: Use dates.PVPC_ES_2TD as the as-of date for the symbol. Treat it as authoritative for pricing rolls and backfills.

Q: Do I need to pass a base currency parameter?
A: No. The latest endpoint returns a top-level base and per-symbol currencies. If you add TTF_GAS or EUA_CO2 to multi-symbol calls, do not pass base=USD; handle MIXED bases and read currencies.{symbol} instead.

Q: How many calls can I make on trial?
A: The trial allows 7 days and 50 calls, which is sufficient to integrate and validate your PVPC ingestion pipeline.

Q: Is there a header-based auth?
A: Authentication is via the api_key query parameter. Pass YOUR_API_KEY as shown in the examples.

Next steps

Register for an API key, run the official cURL call, and wire one of the code snippets into your pricing pipeline. You can get started now using the 7-day / 50-call trial on the Starter plan ($19.99/mo). See the full parameter reference, schemas, and additional endpoints in the Documentation, and create your account at Register.

Ready to get started?

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

Get API Key

Related posts