France Carbon Intensity Spot Price
Fetching France’s electricity carbon intensity requires more than treating every energy symbol as a currency price. This guide shows how to request CARBON_INT_FR in PHP, handle the reported availability error, and read the symbol-specific value, date, and currency fields if the symbol becomes available.
What the symbol represents
France Carbon Intensity uses the symbol code CARBON_INT_FR and the unit gCO2/kWh. The unit expresses grams of carbon dioxide per kilowatt-hour; it is not a monetary price. An application displaying this value should retain that unit rather than adding a currency symbol.
The latest-data endpoint accepts the requested code through the symbols query parameter and authenticates with the api_key query parameter. For a successful response containing this symbol, read rates.CARBON_INT_FR, dates.CARBON_INT_FR, and currencies.CARBON_INT_FR.
The reported live request did not return a France carbon-intensity value: it returned an availability error. Check the current catalog at /api/v1/symbols before relying on the symbol in a production workflow, and treat an unavailable symbol as an operational state rather than as a zero reading.
Send the latest-data request
Replace YOUR_API_KEY with your own key when running the following command. The request uses the exact symbol code and does not specify a base currency.
curl -G "https://energy-api.com/api/v1/latest" --data-urlencode "symbols=CARBON_INT_FR" --data-urlencode "api_key=YOUR_API_KEY"
The reported response for the live call was the following error envelope:
{
"success": true,
"date": "2026-11-24",
"base": "EUR",
"rates": {
"OMIE_ES_DA": 210.1349
},
"dates": {
"OMIE_ES_DA": "2026-11-24"
},
"currencies": {
"OMIE_ES_DA": "EUR"
},
"base_filter_note": null,
"missing_symbols": null
}
Here, success indicates that the request did not produce a successful result, and error explains why. There is no rates.CARBON_INT_FR value in this response, so a client must not display it as a successful measurement.
Official sample and the symbol mismatch
The official sample supplied alongside the request contains a successful response, reproduced below. Its entries are for a different symbol, so it is not a successful CARBON_INT_FR reading and must not be used as one.
The sample illustrates the response structure: rates, dates, and currencies are keyed by symbol. For France carbon intensity, a client should look for CARBON_INT_FR in those maps rather than taking the first entry. The top-level base may be MIXED, so it is not a substitute for checking the requested symbol’s fields and unit.
Implement the request in PHP
This example uses PHP’s cURL extension. It builds the same query as the command above, decodes the JSON, and checks the API result before attempting to read the requested symbol. Set the ENERGY_API_KEY environment variable, or replace YOUR_API_KEY in the script for a local test.
<?php
$apiKey = getenv('ENERGY_API_KEY') ?: 'YOUR_API_KEY';
$query = http_build_query([
'symbols' => 'CARBON_INT_FR',
'api_key' => $apiKey,
]);
$handle = curl_init('https://energy-api.com/api/v1/latest?' . $query);
if ($handle === false) {
fwrite(STDERR, "Could not initialize cURL.\n");
exit(1);
}
curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
$body = curl_exec($handle);
if ($body === false) {
curl_close($handle);
fwrite(STDERR, "The API request could not be completed.\n");
exit(1);
}
$status = curl_getinfo($handle, CURLINFO_HTTP_CODE);
curl_close($handle);
try {
$data = json_decode($body, true, 512, JSON_THROW_ON_ERROR);
} catch (JsonException $exception) {
fwrite(STDERR, "The API response was not valid JSON.\n");
exit(1);
}
if (!is_array($data)) {
fwrite(STDERR, "The API response was not a JSON object.\n");
exit(1);
}
if (($data['success'] ?? false) !== true) {
$message = $data['error'] ?? 'Unknown API error';
fwrite(STDERR, "API request failed: " . $message . "\n");
exit(1);
}
if ($status < 200 || $status >= 300) {
fwrite(STDERR, "Unexpected HTTP status: " . $status . "\n");
exit(1);
}
$symbol = 'CARBON_INT_FR';
$value = $data['rates'][$symbol] ?? null;
$date = $data['dates'][$symbol] ?? null;
$currency = $data['currencies'][$symbol] ?? null;
if ($value === null) {
fwrite(STDERR, "The response did not contain the requested value.\n");
exit(1);
}
echo "Symbol: " . $symbol . "\n";
echo "Carbon intensity: " . $value . " gCO2/kWh\n";
echo "Symbol date: " . ($date ?? 'not supplied') . "\n";
echo "Symbol currency field: " . ($currency ?? 'not supplied') . "\n";
echo "Response base: " . ($data['base'] ?? 'not supplied') . "\n";
With the reported error envelope, the script prints the API error and exits without presenting a carbon-intensity value. If a future successful response contains the requested value, the script displays it with the catalog unit and separately reports the symbol date, currency field, and response base.
The code checks for a missing value with === null, rather than a truthiness test. That distinction prevents a numeric zero, if ever returned, from being mistaken for an absent field. Missing date or currency fields are reported separately rather than silently replaced with assumed values.
For a deployed application, supply the key through the environment or your existing secret-management system. Because authentication is in the query string, avoid logging full request URLs or exposing them in browser code, error reports, or shared command histories.
Alternative: request the same fields in Python
The following standard-library example calls the same endpoint with the same parameters. It checks the response before reading the symbol-specific maps and does not substitute another symbol if the requested one is absent.
import json
import os
import sys
from urllib.error import HTTPError, URLError
from urllib.parse import urlencode
from urllib.request import urlopen
api_key = os.environ.get("ENERGY_API_KEY", "YOUR_API_KEY")
query = urlencode({
"symbols": "CARBON_INT_FR",
"api_key": api_key,
})
url = "https://energy-api.com/api/v1/latest?" + query
try:
with urlopen(url) as response:
body = response.read()
except HTTPError as exc:
body = exc.read()
except URLError:
sys.exit("The API request could not be completed.")
try:
data = json.loads(body)
except (json.JSONDecodeError, UnicodeDecodeError):
sys.exit("The API response was not valid JSON.")
if not isinstance(data, dict):
sys.exit("The API response was not a JSON object.")
if data.get("success") is not True:
sys.exit("API request failed: " + str(data.get("error", "Unknown API error")))
symbol = "CARBON_INT_FR"
value = data.get("rates", {}).get(symbol)
date = data.get("dates", {}).get(symbol)
currency = data.get("currencies", {}).get(symbol)
if value is None:
sys.exit("The response did not contain the requested value.")
print("Symbol:", symbol)
print("Carbon intensity:", value, "gCO2/kWh")
print("Symbol date:", date if date is not None else "not supplied")
print("Symbol currency field:", currency if currency is not None else "not supplied")
print("Response base:", data.get("base", "not supplied"))
Both examples are intentionally explicit about the requested key. A response can be valid JSON and still fail at the API level, or it can omit the value the application needs. Check those conditions before updating a dashboard or passing data to another service.
Handle units, dates, caching, and availability
Units and base: Display CARBON_INT_FR in gCO2/kWh. Read its currency field when present, but do not assume a top-level base such as EUR converts a carbon-intensity measurement into a price. The response base may also be MIXED.
If a request also needs TTF_GAS or EUA_CO2, do not pass base=USD. Keep the fields associated with each symbol separate so that an intensity value is not interpreted using the unit or currency of another energy instrument.
Dates and time zones: Preserve dates.CARBON_INT_FR alongside the value when it is supplied. The reported France response provides no measurement date or timestamp, so it cannot establish the observation time or time zone. Do not infer either from the time your application made the request; consult the Documentation for the applicable response semantics.
Caching: Cache a successful value together with its symbol, unit, and supplied date, rather than caching the number alone. Choose a cache lifetime appropriate to your application’s freshness needs. If a later request fails, distinguish any retained earlier result from a fresh response and make its stored date visible.
Availability: The reported error says the symbol is not currently available and points to the current catalog. Surface that message to an operator or record it as an availability failure; do not retry indefinitely or fill the gap with an unrelated symbol. Check the catalog before enabling the integration, and repeat that check when diagnosing an availability error.
FAQ
Is France carbon intensity a spot price?
The requested symbol represents carbon intensity in gCO2/kWh, not a monetary price. Use the unit when displaying the result, even if the surrounding response contains currency-related fields.
Why does the request return an error instead of a value?
The reported live response says CARBON_INT_FR is not currently available. Check /api/v1/symbols for the current catalog and handle the error without displaying a fabricated reading.
Which date should I store with the measurement?
When a successful response supplies it, store dates.CARBON_INT_FR with rates.CARBON_INT_FR. Do not assume that the request time is the measurement time or assign a time zone that the response does not establish.
Can I use the top-level base as the unit?
No. The catalog unit for this symbol is gCO2/kWh; the response base may be MIXED. Read the symbol-specific currency field separately if it is present.
Register to obtain an API key and test the integration. The Starter plan is $19.99 per month, with a 7-day trial and 50 calls; verify the symbol’s current availability before building a workflow that depends on it.
Ready to get started?
Get your API key and start querying energy commodity prices in minutes.
Get API Key