Great Britain Carbon Intensity Spot Price

Great Britain Carbon Intensity Spot Price

You need to programmatically retrieve Great Britain’s real-time carbon intensity and turn it into a dependable data point inside your app. By the end of this guide you’ll be able to call the Energy API for the Great Britain Carbon Intensity symbol, handle availability errors, parse the rate/unit fields you need in PHP, and ship a production-ready polling/caching loop.

What you’re integrating: Great Britain Carbon Intensity, units, and symbol

This guide focuses on the Energy API symbol for Great Britain’s grid carbon intensity. You’ll fetch the latest figure for Great Britain and read the unit, timestamp, and base metadata you need for downstream calculations.

Illustration: Great Britain Carbon Intensity Spot Price
  • Symbol name: Great Britain Carbon Intensity
  • Symbol code: CARBON_INT_GB
  • Unit: gCO2/kWh

The endpoint you’ll call returns a latest snapshot keyed by symbol. You’ll read the rate from the rates.CARBON_INT_GB field, the timestamp from dates.CARBON_INT_GB, and the unit from currencies.CARBON_INT_GB. The top-level base may be MIXED when multiple symbols are requested together.

Endpoint, authentication, and request parameters you’ll use

Use the latest endpoint via HTTP GET. Authentication is an API key sent as a query parameter. There is no request body.

  • Method: GET
  • Path: /api/v1/latest
  • Required query parameters:
    • symbols: a comma-separated list. For this guide, use CARBON_INT_GB.
    • api_key: your API key value.

Do not pass a base parameter for this integration. If you expand to include TTF_GAS or EUA_CO2 later, explicitly do not pass base=USD with those symbols.

Starter pricing is $19.99/mo with a 7-day trial and 50 calls. See the product docs for general behavior and additional endpoints as you scale.

Documentation

Official curl sample request (copy-paste)

Run this from a terminal to fetch a latest snapshot for CARBON_INT_GB. Replace the api_key value with your own API key when you implement, but keep symbols as-is for this guide.

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

Official sample JSON response format and field map

The service returns a consistent envelope across symbols. The official sample below demonstrates the structure of the latest endpoint. Your PHP code will use the same top-level keys (success, base, rates, dates, currencies) and symbol-specific entries.

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

Field usage in your code:

  • success: boolean for transport-level success.
  • base: top-level base. May be MIXED if multiple symbols are requested. Treat as metadata.
  • rates: numeric values keyed by symbol. For Great Britain Carbon Intensity you will read rates.CARBON_INT_GB.
  • dates: the timestamp or date string for each symbol at dates.CARBON_INT_GB.
  • currencies: the unit or monetary currency for each symbol at currencies.CARBON_INT_GB. For carbon intensity, treat this as the unit label (gCO2/kWh per the catalog).

Real API response for CARBON_INT_GB availability and how to handle it

The latest live call for CARBON_INT_GB returned an availability error. Your integration must detect this and degrade gracefully, e.g., display “unavailable,” fall back to cached data, or retry with an appropriate backoff.

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

When success is false, do not try to read rates, dates, or currencies. Log the error, update metrics, and optionally refresh your symbol catalog before re-queuing a job to avoid hot loops on unavailable instruments.

PHP integration: fetching and parsing Great Britain Carbon Intensity

The snippet below uses PHP with ext-curl to call the endpoint, parse the envelope, and extract the rate, date, and unit for CARBON_INT_GB. It includes defensive checks for success=false and for missing symbol keys.

PHP code

<?php
declare(strict_types=1);

/**
* Fetch latest Great Britain Carbon Intensity (CARBON_INT_GB) from Energy API.
* - Reads rates.CARBON_INT_GB as a float (gCO2/kWh).
* - Reads dates.CARBON_INT_GB as an ISO date/time string.
* - Reads currencies.CARBON_INT_GB as the unit label (expect gCO2/kWh from catalog).
* - Handles success=false error envelopes and missing symbol keys.
*/

function fetchCarbonIntensityGb(string $apiKey): array {
$endpoint = 'https://energy-api.com/api/v1/latest';
$query = http_build_query([
'symbols' => 'CARBON_INT_GB',
'api_key' => $apiKey,
]);

$ch = curl_init();
curl_setopt_array($ch, [
CURLOPT_URL => $endpoint . '?' . $query,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 10,
CURLOPT_HTTPGET => true,
]);

$raw = curl_exec($ch);
$curlErr = curl_error($ch);
$httpCode = (int) curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);

if ($raw === false) {
throw new RuntimeException('HTTP transport error: ' . $curlErr);
}

$json = json_decode($raw, true);
if (!is_array($json)) {
throw new RuntimeException('Malformed JSON from API; HTTP ' . $httpCode . ' body: ' . $raw);
}

// Handle error envelope: {"success": false, "error": "..."}
if (array_key_exists('success', $json) && $json['success'] === false) {
$apiErr = $json['error'] ?? 'Unknown API error';
return [
'available' => false,
'error' => $apiErr,
'http_code' => $httpCode,
];
}

// Defensive extraction of symbol-scoped values
$symbol = 'CARBON_INT_GB';

$rate = $json['rates'][$symbol] ?? null;
$date = $json['dates'][$symbol] ?? null;
$unit = $json['currencies'][$symbol] ?? null; // For this symbol: unit label expected (gCO2/kWh)
$base = $json['base'] ?? null; // Can be MIXED when multiple symbols requested

if ($rate === null || $date === null || $unit === null) {
// If symbol was requested but not returned, treat as unavailable for now.
return [
'available' => false,
'error' => 'Symbol data missing in response',
'http_code' => $httpCode,
'raw' => $json,
];
}

// Normalize types
$rate = (float) $rate;
$date = (string) $date;
$unit = (string) $unit;

return [
'available' => true,
'symbol' => $symbol,
'rate' => $rate, // gCO2/kWh
'date' => $date, // ISO date/time from API
'unit' => $unit, // Expect "gCO2/kWh"
'base' => $base, // Might be "MIXED" when batching symbols
'http_code' => $httpCode,
'raw' => $json, // Keep raw for audit/logging
];
}

try {
$result = fetchCarbonIntensityGb('YOUR_API_KEY');

if ($result['available'] === false) {
// Application-level handling: log, show fallback, or schedule retry
error_log('CARBON_INT_GB unavailable: ' . ($result['error'] ?? 'unknown'));
// Example display:
echo 'Carbon intensity (GB): unavailable';
} else {
// Render formatted output
$value = number_format($result['rate'], 2);
echo 'Carbon intensity (GB): ' . $value . ' ' . $result['unit'] . ' as of ' . $result['date'];
}
} catch (Throwable $e) {
// Transport or parsing issues
error_log('Integration error: ' . $e->getMessage());
echo 'Carbon intensity (GB): error';
}

Implementation notes:

  • Set a short network timeout and surface transport errors distinctly from API envelopes with success=false.
  • Do not assume the absence of a key implies zero; treat as temporarily unavailable and fall back to cached values if you maintain them.
  • The unit label for this symbol is gCO2/kWh; keep values as floats and format only at the presentation layer.

Python example: reading the same fields

If you prefer a quick cross-check in Python while building PHP, this example calls the same endpoint and extracts the same fields. Keep the symbol identical and pass YOUR_API_KEY as the query parameter.

import json
import urllib.parse
import urllib.request

def fetch_carbon_intensity_gb(api_key: str):
base_url = "https://energy-api.com/api/v1/latest"
qs = urllib.parse.urlencode({
"symbols": "CARBON_INT_GB",
"api_key": api_key,
})
url = f"{base_url}?{qs}"

with urllib.request.urlopen(url, timeout=10) as resp:
body = resp.read().decode("utf-8")
data = json.loads(body)

if data.get("success") is False:
return {"available": False, "error": data.get("error")}

symbol = "CARBON_INT_GB"
rate = (data.get("rates") or {}).get(symbol)
date = (data.get("dates") or {}).get(symbol)
unit = (data.get("currencies") or {}).get(symbol)
base = data.get("base")

if rate is None or date is None or unit is None:
return {"available": False, "error": "Symbol data missing", "raw": data}

return {
"available": True,
"symbol": symbol,
"rate": float(rate),
"date": str(date),
"unit": str(unit), # expected gCO2/kWh
"base": base,
"raw": data,
}

if __name__ == "__main__":
result = fetch_carbon_intensity_gb("YOUR_API_KEY")
if not result["available"]:
print("CARBON_INT_GB unavailable:", result.get("error"))
else:
print(f"GB Carbon Intensity: {result['rate']} {result['unit']} @ {result['date']} (base={result['base']})")

JSON examples you’ll see in practice

Use these examples to validate your parsing and error handling. The structure is identical across symbols.

Official sample envelope (structure reference)

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

Availability error for CARBON_INT_GB (handle gracefully)

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

Official sample envelope (shape re-check during testing)

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

How to think about units, base, timestamps, and batching

Units: For CARBON_INT_GB the domain unit is gCO2/kWh. The value you read from rates.CARBON_INT_GB should be treated as that unit. Do not coerce to currency or perform FX conversions.

Base: The top-level base may be MIXED when you query multiple symbols in one call. If you only request CARBON_INT_GB, treat base as metadata and rely on currencies.CARBON_INT_GB for the definitive unit label.

Timestamps: Read the symbol-specific ISO string at dates.CARBON_INT_GB for when the value is valid. If you cache, store this timestamp alongside the numeric value so you can surface staleness to users.

Batching: You can request multiple symbols with a comma-separated symbols parameter. When batching, always read values by their exact symbol keys in rates, dates, and currencies to avoid mismatches. If any requested symbol is unavailable, handle missing data per-symbol; do not fail the entire refresh if your app can render partial data.

Polling, caching, and retries (production checklist)

  • Polling interval: Use a modest cadence that fits your UX and plan. Start with a 1–5 minute refresh for dashboards and back off if the symbol is unavailable.
  • Backoff on availability errors: The example error indicates the symbol is not currently available. In that case, skip immediate retries and re-check the catalog before re-enqueuing work.
  • Caching: Store the last known good rate, date, and unit. Serve cached data with a visible “as of {date}” label if a fresh fetch fails.
  • Observability: Log success=false envelopes and missing symbol keys separately from transport errors. Track response latencies and error rates.
  • Resilience: Set tight HTTP timeouts (e.g., 10s) and distinguish between timeouts, DNS/connect errors, HTTP non-200 codes, and API-level error envelopes.
  • Trial considerations: During the 7-day / 50-call trial, throttle manual refreshes and structure your cache to minimize duplicate calls across processes.

End-to-end test procedure

Step 1: Verify shell access with curl

Confirm your network path and key handling with the official curl command. Replace the api_key value with your key in local testing.

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

Observe one of two outcomes:

  • A success envelope with the standard structure (see the official sample JSON structure for field layout).
  • The availability error for CARBON_INT_GB shown earlier. Ensure your code path treats this as a soft failure and preserves cached data.

Step 2: Exercise PHP handler

Run the PHP script and confirm that it prints either a formatted carbon intensity line with gCO2/kWh or a clear “unavailable” message. Inspect logs for exact error strings to verify you captured the envelope.

Step 3: Validate parsing and types

Assert that the rate is a float and that unit equals gCO2/kWh. If you batch symbols later, ensure you always index by exact symbol keys.

Operational safeguards specific to energy symbols

  • Do not send base=USD when expanding your requests to include TTF_GAS or EUA_CO2; leave base unspecified to avoid unintended conversions or API rejections.
  • Store symbol-level timestamps and surface when data is stale. Energy data can have reporting gaps; show “as of” to set user expectations.
  • Implement feature flags to disable display of a symbol that returns success=false repeatedly.
  • Keep your dependency on currencies.CARBON_INT_GB for labeling. For carbon intensity, that entry represents the measurement unit.

FAQ

Q: Which fields do I read for Great Britain Carbon Intensity?
A: Read rates.CARBON_INT_GB for the numeric value (gCO2/kWh), dates.CARBON_INT_GB for the timestamp string, and currencies.CARBON_INT_GB for the unit label. The top-level base is informational and may be MIXED when batching.

Q: What should I do if success is false for CARBON_INT_GB?
A: Treat the symbol as temporarily unavailable. Do not attempt to read rates/dates/currencies. Log the error message, serve cached data if available, and retry later with backoff.

Q: Can I request CARBON_INT_GB together with other symbols?
A: Yes, pass a comma-separated list in symbols. Always index into rates, dates, and currencies using the exact symbol keys and be prepared for some symbols to be missing or unavailable in a batch response.

Q: Do I need to pass a base parameter for this integration?
A: No. Leave base unset. If you add TTF_GAS or EUA_CO2 later, do not pass base=USD with those symbols.

Q: How do I authenticate?
A: Include your key via the api_key query parameter. Use the placeholder YOUR_API_KEY in samples; replace it with your real key in your environment variables or secrets manager.

Ready to implement this in your stack and iterate with a trial? Create an account and get an API key in minutes: Register. For endpoint details and symbol catalog references, keep the docs open: Documentation.

Ready to get started?

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

Get API Key