Uk.Parliament 10.0.41

dotnet add package Uk.Parliament --version 10.0.41
                    
NuGet\Install-Package Uk.Parliament -Version 10.0.41
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Uk.Parliament" Version="10.0.41" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Uk.Parliament" Version="10.0.41" />
                    
Directory.Packages.props
<PackageReference Include="Uk.Parliament" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Uk.Parliament --version 10.0.41
                    
#r "nuget: Uk.Parliament, 10.0.41"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Uk.Parliament@10.0.41
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Uk.Parliament&version=10.0.41
                    
Install as a Cake Addin
#tool nuget:?package=Uk.Parliament&version=10.0.41
                    
Install as a Cake Tool

Uk.Parliament

UK Parliament .NET Library

The most comprehensive .NET library for UK Parliament APIs
100% API coverage - All 12 public Parliament APIs supported

NuGet License: MIT .NET 10 Codacy Badge


This .NET library provides complete coverage of all 12 UK Parliament public APIs:

Petitions API - Public petitions to Parliament
Members API - MPs, Lords, constituencies, parties
Bills API - Parliamentary legislation
⚠️ Committees API - Committee inquiries and submissions
🔴 Commons Divisions API - House of Commons voting records
🔴 Lords Divisions API - House of Lords voting records
Member Interests API - Register of Members' Financial Interests
Written Questions & Statements API - Parliamentary questions and statements
Oral Questions & Motions API - Oral questions and motions
Treaties API - International treaties laid before Parliament
Erskine May API - Parliamentary procedure reference
NOW (Annunciator) API - Real-time chamber status

Status: 9/12 APIs fully functional, 3/12 affected by Parliament infrastructure issues


Overview

Version 10.0.9 - Complete Refit-based implementation with type-safe REST API access.

Features

  • 🎯 100% API Coverage - All 12 public Parliament APIs supported
  • 🚀 Type-Safe - Refit interfaces with full IntelliSense
  • Async/Await - Modern async patterns throughout
  • 📄 Pagination - Extension methods for easy data streaming
  • 🧪 Well-Tested - 104 comprehensive tests (86 passing)
  • 📖 Documented - Complete XML documentation
  • 🔧 DI-Ready - Works with dependency injection
  • 🔍 Logging - Built-in HTTP request/response logging
  • Production Ready - 9 fully functional APIs

Installation

Install via NuGet:

dotnet add package Uk.Parliament

Or via Package Manager Console:

Install-Package Uk.Parliament

Quick Start

Basic Usage

using Uk.Parliament;
using Uk.Parliament.Extensions;

// Create unified client for all Parliament APIs
var client = new ParliamentClient();

// Petitions API
var petitions = await client.Petitions.GetAsync(state: "open", pageSize: 10);
foreach (var petition in petitions.Data)
{
    Console.WriteLine($"{petition.Attributes.Action}: {petition.Attributes.SignatureCount:N0} signatures");
}

// Members API
var members = await client.Members.SearchAsync(name: "Smith", isCurrentMember: true, take: 10);
foreach (var member in members.Items)
{
    Console.WriteLine($"{member.Value.NameFullTitle} - {member.Value.LatestParty?.Name}");
}

// Bills API
var bills = await client.Bills.GetBillsAsync(take: 10);
foreach (var bill in bills.Items)
{
    Console.WriteLine($"{bill.ShortTitle} ({bill.BillTypeId})");
}

// Treaties API
var treaties = await client.Treaties.GetTreatiesAsync(status: "In Force", take: 10);
foreach (var treaty in treaties.Items)
{
    Console.WriteLine($"{treaty.Value.CommandPaperNumber}: {treaty.Value.Title}");
}

// NOW API - Real-time chamber status
var status = await client.Now.GetCommonsStatusAsync();
Console.WriteLine($"Commons sitting: {status.IsSitting}");
if (status.IsSitting)
{
    Console.WriteLine($"Current business: {status.CurrentBusiness}");
}

Pagination with Extension Methods

// Memory-efficient streaming (recommended for large datasets)
await foreach (var petition in client.Petitions.GetAllAsync(state: "open", pageSize: 50))
{
    Console.WriteLine($"{petition.Attributes.Action}");
    // Process one at a time - no memory overhead
}

// Or get all as a materialized list
var allPetitions = await client.Petitions.GetAllListAsync(state: "closed");
Console.WriteLine($"Total: {allPetitions.Count}");

Dependency Injection

// In Program.cs
services.AddSingleton<ParliamentClient>();

// Or with custom options
services.AddSingleton(sp => new ParliamentClient(new ParliamentClientOptions
{
    UserAgent = "MyApp/1.0",
    Timeout = TimeSpan.FromSeconds(30)
}));

// Inject into your services
public class MyService
{
    private readonly ParliamentClient _parliament;

    public MyService(ParliamentClient parliament)
    {
        _parliament = parliament;
    }
}

📚 Complete API Coverage

✅ Petitions API

Access public petitions to UK Parliament.

// Search petitions
var petitions = await client.Petitions.GetAsync(
    search: "climate",
    state: "open",
    page: 1,
    pageSize: 20);

// Get specific petition with full details
var petition = await client.Petitions.GetByIdAsync(700143);
Console.WriteLine($"Signatures: {petition.Data.Attributes.SignatureCount:N0}");
Console.WriteLine($"State: {petition.Data.Attributes.State}");

// Signatures by country
foreach (var country in petition.Data.Attributes.SignaturesByCountry)
{
    Console.WriteLine($"{country.Name}: {country.SignatureCount:N0}");
}

Status: 27/27 tests passing ✅

✅ Members API

Information about MPs, Lords, constituencies, and political parties.

// Search members
var members = await client.Members.SearchAsync(
    name: "Johnson",
    house: 1, // 1=Commons, 2=Lords
    isCurrentMember: true);

// Get member details
var member = await client.Members.GetByIdAsync(172);

// Search constituencies
var constituencies = await client.Members.SearchConstituenciesAsync("London", take: 10);

Status: 17/17 tests passing ✅

✅ Bills API

Parliamentary legislation information.

// List bills
var bills = await client.Bills.GetBillsAsync(
    searchTerm: "Budget",
    currentHouse: "Commons",
    take: 10);

// Get bill details
var bill = await client.Bills.GetBillByIdAsync(123);

// Get bill types
var billTypes = await client.Bills.GetBillTypesAsync();

Status: 12/12 tests passing ✅

⚠️ Committees API

Parliamentary committee information (API occasionally returns 500 errors from Parliament servers).

// List committees
var committees = await client.Committees.GetCommitteesAsync(take: 10);

// Get committee details
var committee = await client.Committees.GetCommitteeByIdAsync(1);

Status: 7/13 tests passing ⚠️ (Parliament API unstable)

🔴 Divisions APIs

Voting records (blocked by Parliament API 500 errors).

// When Parliament fixes API:
// var divisions = await client.CommonsDivisions.GetDivisionsAsync();
// var lordsDivisions = await client.LordsDivisions.GetDivisionsAsync();

Status: Interface complete, blocked by 100% API failure rate 🔴

✅ Member Interests API

Register of Members' Financial Interests.

// Get member's interests
var interests = await client.Interests.GetMemberInterestsAsync(172);
foreach (var category in interests.Categories)
{
    Console.WriteLine($"{category.Category.Name}:");
    foreach (var interest in category.Interests)
    {
        Console.WriteLine($"  - {interest.InterestDetails}");
    }
}

// Search interests
var results = await client.Interests.SearchInterestsAsync("employment", take: 10);

Status: 4/4 tests passing ✅

✅ Written Questions & Statements API

Parliamentary questions and ministerial statements.

// Get written questions
var questions = await client.QuestionsStatements.GetWrittenQuestionsAsync(
    tabledWhenFrom: DateTime.Now.AddMonths(-1),
    isAnswered: true,
    take: 20);

// Get written statements
var statements = await client.QuestionsStatements.GetWrittenStatementsAsync(
    madeWhenFrom: DateTime.Now.AddDays(-7),
    take: 20);

// Get daily reports
var reports = await client.QuestionsStatements.GetDailyReportsAsync(
    dateFrom: DateTime.Now.AddDays(-7));

Status: 4/4 tests passing ✅

✅ Oral Questions & Motions API

Oral questions and parliamentary motions.

// Get oral questions
var questions = await client.OralQuestionsMotions.GetOralQuestionsAsync(
    house: "Commons",
    dateFrom: DateTime.Now.AddMonths(-1));

// Get motions (including Early Day Motions)
var motions = await client.OralQuestionsMotions.GetMotionsAsync(
    motionType: "Early Day Motion",
    isActive: true);

Status: 3/3 tests passing ✅

✅ Treaties API

International treaties laid before Parliament.

// Get treaties
var treaties = await client.Treaties.GetTreatiesAsync(
    status: "In Force",
    dateLaidFrom: DateTime.Now.AddYears(-1));

// Get treaty details
var treaty = await client.Treaties.GetTreatyByIdAsync(123);

// Get treaty business items
var businessItems = await client.Treaties.GetTreatyBusinessItemsAsync(123);

// Get government organizations
var orgs = await client.Treaties.GetGovernmentOrganisationsAsync();

Status: 4/4 tests passing ✅

✅ Erskine May API

The authoritative guide to parliamentary procedure.

// Search parliamentary procedure
var results = await client.ErskineMay.SearchAsync("voting procedure", take: 10);

// Get all parts
var parts = await client.ErskineMay.GetPartsAsync();

// Get chapters in a part
var chapters = await client.ErskineMay.GetChaptersAsync(partNumber: 1);

// Get sections in a chapter
var sections = await client.ErskineMay.GetSectionsAsync(chapterNumber: 1, take: 20);

Status: 3/3 tests passing ✅

✅ NOW (Annunciator) API

Real-time chamber status and business information.

// Get current Commons status
var status = await client.Now.GetCommonsStatusAsync();
Console.WriteLine($"Sitting: {status.IsSitting}");
Console.WriteLine($"Current: {status.CurrentBusiness}");

// Get upcoming business
var upcoming = await client.Now.GetUpcomingBusinessAsync("Commons");

// Get current business
var current = await client.Now.GetCurrentBusinessAsync("Lords");

Status: 4/4 tests passing ✅


Configuration

var options = new ParliamentClientOptions
{
    UserAgent = "MyApp/1.0",
    Timeout = TimeSpan.FromSeconds(60),
    EnableDebugValidation = false, // Strict JSON validation
    EnableVerboseLogging = true,   // Full HTTP logs
    Logger = loggerFactory.CreateLogger("ParliamentClient")
};

var client = new ParliamentClient(options);

Test Coverage

API Unit Tests Integration Tests Total Status
Petitions 17 10 27 ✅ 100%
Members 6 11 17 ✅ 100%
Bills 3 9 12 ✅ 100%
Committees 1 6 7 ⚠️ 54%
Divisions 4 0 4 🔴 Unit only
Interests 4 8 12 ✅ 100% unit
Questions/Statements 4 15 19 ✅ 100% unit
Oral Questions 3 8 11 ✅ 100% unit
Treaties 4 6 10 ✅ 100% unit
Erskine May 3 6 9 ✅ 100% unit
NOW 4 4 8 ✅ 100% unit
TOTAL 53 83 136 86 passing

Documentation


Known Issues

  • Committees API: Intermittent 500 errors from Parliament servers
  • Divisions APIs: 100% API failure rate (Parliament infrastructure issue)
  • These are server-side problems being tracked with UK Parliament Digital Service

Development

git clone https://github.com/panoramicdata/Uk.Parliament.git
cd Uk.Parliament
dotnet build
dotnet test

Migration from v1.x

v1.x:

var client = new PetitionsClient();
var result = await client.GetPetitionAsync(123, CancellationToken.None);
if (result.Ok) { /* use result.Data */ }

v2.0+:

var client = new ParliamentClient();
var petition = await client.Petitions.GetByIdAsync(123);
// Direct access, throws ApiException on error

Contributing

Contributions welcome! Priority areas:

  1. Fix Divisions APIs when Parliament resolves 500 errors
  2. Add more integration tests
  3. Improve documentation
  4. Report issues

License

MIT License - see LICENSE file


Copyright © 2025 Panoramic Data Limited



Acknowledgments

Thanks to the UK Parliament Digital Service for providing these public APIs.

For API issues, contact: softwareengineering@parliament.uk

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
10.0.41 363 12/18/2025
10.0.40 272 12/18/2025
10.0.38 277 12/18/2025
10.0.34 227 11/26/2025
10.0.33 201 11/26/2025
10.0.19 410 11/18/2025
10.0.16 405 11/18/2025
10.0.2 407 11/18/2025
1.0.5 3,198 2/10/2019
1.0.4 2,329 2/1/2017
1.0.3 1,249 2/1/2017
1.0.2 1,581 2/1/2017
1.0.1 1,610 2/1/2017
1.0.0 1,648 1/31/2017

v10.0.9 - 100% API COVERAGE! All 12 UK Parliament APIs now supported. New: Interests, Written Questions, Oral Questions, Treaties, Erskine May, and NOW APIs. See https://github.com/panoramicdata/Uk.Parliament/releases