Skip to content

Grid Intensity restructures raw API responses into a clearer, easier-to-use format, improving readability and overall usability for developers without changing the underlying result data.

License

Notifications You must be signed in to change notification settings

LewisRandles/Grid-Intensity

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Grid Intensity API Repacker

Explore electricity generation mix trends and forecasts using UK power grid data.

Badge Badge Badge Badge Badge

Introduction

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.


Table of Contents


Downloading

Different Versions

Each release provides two configuations of the project.

  • The bundled, minified format known as "production".
  • The unbundled, unminified format known as "development".

Download Page

https://github.com/LewisRandles/Grid-Intensity/releases


Installing

In your JavaScript file

	// 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';

Usage

No Parameters

Providing no parameters will result in the default information being set.

await gridIntensity();

Processing

Normalisation

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.

Sanitization

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.


Customisation

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.

Parent Names

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
	},

	...

}

Child Names

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"
	},

	...

}

Demo

Live Demo

Try the hosted demo via GitHub Pages Demo


Authors


Credit


License

MIT License

About

Grid Intensity restructures raw API responses into a clearer, easier-to-use format, improving readability and overall usability for developers without changing the underlying result data.

Resources

License

Stars

Watchers

Forks

Packages

No packages published