API to Get the Germany Carbon Intensity Price

API to Get the Germany Carbon Intensity Price

You need a reliable way to programmatically fetch Germany’s electricity carbon intensity so your service can track grid CO2 per kWh in near real time. By the end of this guide, you will be able to call the Energy API for the Germany Carbon Intensity symbol, interpret the response fields, handle error states, and wire the result into your application with a production-safe workflow.

What you will implement

This is a first-request walkthrough for the Energy API symbol “Germany Carbon Intensity” (code: CARBON_INT_DE). You will:

Illustration: API to Get the Germany Carbon Intensity Price
  • Call GET /api/v1/latest with the symbols query parameter and your API key.
  • Inspect rates, dates, and currencies fields relevant to CARBON_INT_DE.
  • Parse the response in a short Python snippet.
  • Handle an official error envelope when the symbol is unavailable.
  • Adopt practical safeguards: units, time, mixed base handling, and caching.

Prerequisites and access

You’ll need an Energy API account. Authentication is via api_key in the query string. Use the placeholder YOUR_API_KEY in examples below. Starter pricing is $19.99/mo with a 7-day trial and 50 calls as noted in the catalog facts. Register here:

Register

Keep a browser tab open to the official docs for reference:

Documentation

Endpoint, symbol, and fields you will use

Germany’s electricity carbon intensity is published by the Energy API as:

  • Symbol name: Germany Carbon Intensity
  • Symbol code: CARBON_INT_DE
  • Unit: gCO2/kWh

Endpoint and parameters:

  • HTTP method: GET
  • URL: https://energy-api.com/api/v1/latest
  • Query parameters:
    • symbols=CARBON_INT_DE
    • api_key=YOUR_API_KEY

Response fields to read when the symbol is available:

  • rates.CARBON_INT_DE: numeric value in gCO2/kWh.
  • dates.CARBON_INT_DE: ISO date string of the quote (e.g., YYYY-MM-DD).
  • currencies.CARBON_INT_DE: base currency context if applicable; for intensity, you’ll reference units in gCO2/kWh rather than currency.
  • base: may be MIXED when combining heterogeneous symbols.

Note: Do not pass base=USD if you also need symbols like TTF_GAS or EUA_CO2. For this single-symbol guide, you do not need any base parameter; the endpoint above is sufficient.

Make your first request (cURL)

Run this as-is in your terminal after substituting your API key. The request is a GET with URL-encoded query parameters.

Code: curl

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

Official error envelope you may encounter

The live call for CARBON_INT_DE may return an error if the symbol is temporarily not in the catalog. The following is the exact error envelope the live system returned at the time of writing. Use it to implement robust error handling and fallback behavior in your client:

JSON: error envelope

{"success":false,"error":"Symbol CARBON_INT_DE is not currently available. See \/api\/v1\/symbols for the current catalog."}

How to handle this:

  • Check the success flag. If false, read the error string for context.
  • When unavailable, do not assume stale values. Consider:
    • Alerting or logging with a clear message referencing /api/v1/symbols.
    • Falling back to cached values if your product requirements allow and labeling them clearly as cached.
    • Retrying on your next scheduled poll rather than aggressively looping.

Understanding a success envelope

When the symbol is available and success is true, you’ll receive a data envelope with base metadata and per-symbol fields in rates, dates, and currencies. The official sample below comes from the live docs and shows a typical structure; in your code you will look for CARBON_INT_DE in those containers:

JSON: official sample structure

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

Field mapping you will rely on for CARBON_INT_DE specifically:

  • rates.CARBON_INT_DE → numeric intensity value in gCO2/kWh.
  • dates.CARBON_INT_DE → date for that intensity value (ISO date).
  • currencies.CARBON_INT_DE → may exist in the envelope; however, the operational unit to display is gCO2/kWh.
  • base → may be MIXED when combining multiple heterogeneous symbols; safe to ignore for single-symbol intensity reads.

Python example: request and parse

The following Python snippet calls the same endpoint, checks success, and extracts CARBON_INT_DE if present. It also logs a clear message if the symbol is unavailable, aligning with the error envelope above.

Code: Python

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

API_BASE = "https://energy-api.com/api/v1/latest"
API_KEY = os.environ.get("ENERGY_API_KEY", "YOUR_API_KEY") # keep placeholder if you don't use env vars
SYMBOL = "CARBON_INT_DE"

def fetch_latest(symbol: str) -> dict:
params = {
"symbols": symbol,
"api_key": API_KEY
}
url = API_BASE + "?" + urllib.parse.urlencode(params)
req = urllib.request.Request(url, method="GET")
with urllib.request.urlopen(req, timeout=10) as resp:
data = resp.read()
return json.loads(data.decode("utf-8"))

def main():
try:
payload = fetch_latest(SYMBOL)
except Exception as e:
print(f"Request failed: {e}", file=sys.stderr)
sys.exit(2)

# Check success flag
if not isinstance(payload, dict) or not payload.get("success", False):
# Mirror the error envelope if present
err = payload.get("error") if isinstance(payload, dict) else None
if err:
print(f"API error: {err}", file=sys.stderr)
else:
print(f"API returned non-success without error detail: {payload}", file=sys.stderr)
sys.exit(1)

# Parse the data block for CARBON_INT_DE
rates = payload.get("rates", {})
dates = payload.get("dates", {})
currencies = payload.get("currencies", {})

if SYMBOL in rates:
value_gco2_kwh = rates[SYMBOL]
asof_date = dates.get(SYMBOL)
currency_ctx = currencies.get(SYMBOL)
print(json.dumps({
"symbol": SYMBOL,
"value_gco2_per_kwh": value_gco2_kwh,
"as_of_date": asof_date,
"currency_context": currency_ctx
}, ensure_ascii=False))
sys.exit(0)
else:
# Symbol missing in a success envelope; log and exit non-zero so callers can decide on fallback
print(f"Symbol {SYMBOL} not found in 'rates'. Response keys: {list(rates.keys())}", file=sys.stderr)
sys.exit(1)

if __name__ == "__main__":
main()

Notes for production use:

  • Always verify payload["success"] before reading data fields.
  • Guard for missing symbols even on success: check that CARBON_INT_DE is present in rates and dates.
  • Use environment variables or a secure secret store for your API key; keep YOUR_API_KEY only in docs or local tests.
  • Set reasonable timeouts and handle network failures gracefully.

Field usage and units you will display

Display the intensity value exactly as provided by rates.CARBON_INT_DE and label it with the unit gCO2/kWh. Example rendering in your UI:

  • Title: Germany Carbon Intensity
  • Value: [rates.CARBON_INT_DE] gCO2/kWh
  • Date: [dates.CARBON_INT_DE] (as local date for your users if needed)

Because carbon intensity is not a currency price, treat currencies.CARBON_INT_DE as metadata. The operative unit you show to users is gCO2/kWh.

Another success envelope for parsing practice

Use the official sample again here to validate your parsing logic against a known-good structure. While the symbol in this sample is OMIE_ES_DA, your code should be robust enough to check for CARBON_INT_DE and handle the absence cleanly (for example, by logging available keys or returning a 204 from your service layer).

JSON: sample success envelope

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

For CARBON_INT_DE specifically, expect the same envelope shape, with keys replaced accordingly (rates.CARBON_INT_DE, dates.CARBON_INT_DE, currencies.CARBON_INT_DE) when the symbol is available.

Operational guidance: timing, caching, and mixed bases

Time and dates:

  • dates.CARBON_INT_DE is the quote date in ISO format (YYYY-MM-DD). Store this alongside the value for audit and UI display.
  • Some systems snapshot once per day. If you poll more frequently, cache identical dates to reduce compute and calls.

Caching and retries:

  • Implement a small cache keyed by the symbol and date. If the latest call does not advance the quote date, you can serve the cached value.
  • On failures where success=false, honor backoff. Do not hammer the API; retry on your next scheduled interval.

Mixed base considerations:

  • When combining multiple heterogeneous symbols, the base field may be MIXED, signaling mixed units or currencies in the envelope.
  • For a single intensity symbol like CARBON_INT_DE, you can ignore base and display the gCO2/kWh value.
  • Avoid adding base=USD when requesting intensity or when you also need symbols like TTF_GAS or EUA_CO2 in the same call.

Debugging unavailable symbols safely

If the symbol is unavailable, you will receive the error envelope below (copied exactly from the live system). Make sure your client surfaces this clearly to logs and user-facing status pages as appropriate:

JSON: live unavailability example

{"success":false,"error":"Symbol CARBON_INT_DE is not currently available. See \/api\/v1\/symbols for the current catalog."}

Developer workflow tips:

  • Log the error string alongside a timestamp and request correlation ID if you have one.
  • Optionally trigger a light-weight health check job to reevaluate the symbol set later instead of blocking your main processing pipeline.
  • If your product allows, display the last cached intensity with a “stale” badge and the cached date; otherwise, hide the value until success resumes.

End-to-end test checklist

  • Connectivity: Ensure your environment can reach https://energy-api.com over HTTPS.
  • Auth: Confirm the api_key parameter is included and correct (use YOUR_API_KEY in examples only).
  • Parsing: Verify your code paths for both success=true and success=false.
  • Symbol presence: Check that CARBON_INT_DE exists in rates, dates, currencies; handle its absence cleanly.
  • Units: Always label the UI with gCO2/kWh.
  • Storage: Persist the value and the dates.CARBON_INT_DE alongside an ingestion timestamp.
  • Monitoring: Alert when the symbol is missing for N consecutive polls.

Frequently asked questions

Q: What unit should I display for Germany Carbon Intensity?
A: Use gCO2/kWh exactly as stated. Read the numeric value from rates.CARBON_INT_DE and label it gCO2/kWh in your UI.

Q: Which fields do I need to persist?
A: Store rates.CARBON_INT_DE and dates.CARBON_INT_DE. Optionally keep currencies.CARBON_INT_DE for completeness and the envelope’s base for debugging, but your primary display unit is gCO2/kWh.

Q: How do I handle the symbol if it is not available?
A: Check success. If false, read the error string. Do not assume stale values unless your product explicitly permits a cached fallback. Schedule a retry on your next polling cycle.

Q: Can I request CARBON_INT_DE with other market symbols in one call?
A: Yes, you can pass multiple symbols in the symbols parameter. However, do not pass base=USD when you also need TTF_GAS or EUA_CO2. Expect base to be MIXED when combining heterogeneous symbols; treat each symbol’s units independently.

Q: Where do I find the current catalog of symbols?
A: The error message references /api/v1/symbols for catalog lookup. Use the official Documentation for details.

Ship your integration

You now have the exact GET call, a working curl, a Python example, the expected success envelope shape, and the live unavailability error to implement reliable handling. Register for API access, grab your key, and wire up CARBON_INT_DE to your data pipeline:

Register

Ready to get started?

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

Get API Key