Skip to content

Bench Tracker 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/Bench-Tracker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Bench Tracker API Repacker

Retrieve, organize, and analyze detailed parliamentary member data.

Badge Badge Badge Badge Badge

Introduction

Bench Tracker is a free, no-auth, user-friendly API library that provides access to UK parliamentary member data. This project makes it easy to explore current membership, party affiliations, tenure details, and related information. It’s designed for everyone from researchers and students to journalists, educators, and civic enthusiasts who want to analyze parliamentary data 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/Bench-Tracker/releases


Installing

In your JavaScript file

	// Using the unbundled version needs to be kept with the internal files.
	import benchTracker from './scripts/benchTracker_unbundled.js';

	// Using the bundled version is standalone and has no internal files.
	import benchTracker from './benchTracker_bundled.js';

Usage

No Parameters

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

await benchTracker();

First Parameter

The first parameter is providing the desired mode. The format is case-insensitive.

First Parameter Type Description
mode string Supported mode formats include person and place.
Usage Type Description
person string person enables to search using member names.
place string place enables to search using place names.
// Argument object.
await benchTracker({"mode": "person"});
// External object.
const apiConfig = {
	"mode": "person"
}

await benchTracker(apiConfig);

Second Parameter

The second parameter is providing the desired name. The format is case-insensitive.

Second Parameter Type Description
name string Supported name values depend on current mode. Any current Commons or Lords name. Any valid constituency name
Usage Type Description
name string name is where you input the desired lookup target.
// Argument object.
await benchTracker({"mode": "person", "name": "Nigel Farage"});
// External object.
const apiConfig = {
	"mode": "person",
	"name": "Nigel Farage"
}

await benchTracker(apiConfig);

Processing

Normalisation

During normalization, raw API fields such as "gender": "M", "latestParty": { "name": "Reform UK", "isIndependentParty": false }, and "latestHouseMembership": { "membershipFrom": "Clacton", "membershipEndDate": null } are converted into a processed object such as "gender": "Male", "party": { "partyName": "Reform UK", "isIndependentParty": "false" }, and "membership": { "location": "Clacton", "endDate": "No Value" };. 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 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": "checkBench"
	},

	...

}

Demo

Live Demo

Try the hosted demo via GitHub Pages Demo


Authors


Credit


License

MIT License

About

Bench Tracker 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

Languages