Retrieve, organize, and analyze detailed parliamentary member data.
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.
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/Bench-Tracker/releases
// 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';Providing no parameters will result in the default information being set.
await benchTracker();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);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);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.
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 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": "checkBench"
},
...
}Try the hosted demo via GitHub Pages Demo
- For member API information, the Members API