Explore electricity generation mix trends and forecasts using UK power grid data.
Grid Intensity is a free, no-auth, user-friendly API library that provides access to real-time and forecasted electricity generation mix data from the Carbon Intensity API. This project makes it easy to explore energy contributions from different fuel sources. It’s designed for everyone from energy analysts and students to educators and planners who want to study generation trends and carbon intensity impacts without complex software or specialized expertise.
Each release provides two configuations of the project.
- The bundled, minified format known as "production".
- The unbundled, unminified format known as "development".
https://github.com/LewisRandles/Grid-Intensity/releases
// Using the unbundled version needs to be kept with the internal files.
import gridIntensity from './scripts/gridIntensity_unbundled.js';
// Using the bundled version is standalone and has no internal files.
import gridIntensity from './gridIntensity_bundled.js';Providing no parameters will result in the default information being set.
await gridIntensity();During normalization, raw API fields such as varied key names and value types of "Gas (Combined Cycle)" is converted to combineCycledGas and "Dutch Imports" becomes dutchImports. The conversions are intended to standardized keys. Objects provide more reliable and consistent access than arrays while enabling easier manipulation and processing of nested data structures. Nested objects are flattened, redundant metadata and overlapping identifiers are removed, empty or missing fields are normalized, boolean and encoded values are standardized, and all data is organized into a uniform, consistent key-value JSON structure to produce a clean and predictable final result.
During sanitization, instead of leaving object values as null or undefined, missing or empty fields are filled with a placeholder such as "no value" to ensure that every key in the final result has a valid string; this prevents errors in downstream processing, makes the dataset fully predictable, and allows client applications to safely read and display all values without additional null checks.
This JSON serves as a configuration layer that lets you enable or disable individual parent and child fields and rename them through the use of altName, giving you full control over which properties appear in the final output. Some values from the raw API return are intentionally omitted because they are considered unnecessary or not useful.
The parents group defines the top-level fields that can be enabled, disabled, or renamed, allowing you to control which main object properties appear in the output.
"parents": {
"item1": {
"name": {
"original": "defaultName",
"altName": "customName"
},
"used": true
},
...
}The children group manages the nested fields within those parent objects, giving similar control over which sub-properties are included and how they are labeled.
"children": {
"item1": {
"name": {
"original": "defaultName",
"altName": "customName"
},
"used": true,
"validate": "checkIntensity"
},
...
}Try the hosted demo via GitHub Pages Demo
- For intensity API information, the intensity API
