Skip to content

digitalanalogue9/CompaniesHouse.NET

 
 

Repository files navigation

CompaniesHouse.NET

A simple .NET client wrapper for CompaniesHouse API.

install from nuget downloads Build status

Getting Started

CompaniesHouse.NET can be installed via the package manager console by executing the following commandlet:

PM> Install-Package CompaniesHouse

Once we have the package installed, we can then create a CompaniesHouseSettings with a ApiKey which can be created via the CompaniesHouse API website

var settings = new CompaniesHouseSettings(apiKey);

We need to now create a CompaniesHouseClient - passing in the settings that we've just created.

vusing(ar client = new CompaniesHouseClient(settings))
{
    // Do some work...
}

This is the object we'll use going forward for any interaction to the CompaniesHouse API, but don't forget to call Dispose after you've finish (or wrap in a using block).

Usage

Searching for resources

To search for a resource, we first need to create a SearchRequest with details of the search we require.

var request = new SearchRequest()
{
    Query = "Jay2Base",
    StartIndex = 10,
    ItemsPerPage = 10
};

We can then pass the SearchRequest object in to the SearchAllAsync method and await on the task, this will then return all related resources.

var result = await client.SearchAllAsync(request);

foreach (var item in _result.Data.Items)
{
    // Do something...
}

If we need to be more precise on the resources we require, we can then pass the request object in to the required search method, either SearchCompanyAsync or SearchOfficerAsync or SearchDisqualifiedOfficerAsync and await on the task.

var result1 = await client.SearchCompanyAsync(request);

var result2 = await client.SearchOfficerAsync(request);

var result3 = await client.SearchDisqualifiedOfficerAsync(request);

Getting a company profile

To get a company profile, we pass a company number in to the GetCompanyProfileAsync method and await on the task.

var result = await client.GetCompanyProfileAsync("10440441");

If there was no match for that company number then null will be returned.

Getting company officer list

To get a list of officers for a company, we pass a company number in to the GetOfficersAsync method and await on the task.

var result = await client.GetOfficersAsync("03977902");

We can also pass in some optional parameters of startIndex and pageSize which will allow us to page the results.

var result = await client.GetOfficersAsync("03977902", 10, 10);

Getting company filing history list

To get a list of the filing history for a company, we can pass a company number to the GetCompanyFilingHistoryAsync method and await on the task.

var result = await client.GetCompanyFilingHistoryAsync("10440441");

We can also pass in some optional parameters of startIndex and pageSize which will allow us to page the results.

var result = await client.GetCompanyFilingHistoryAsync("10440441", 10, 10);

Getting company insolvency information

To get the insolvency information for a company, we can pass a company number to the GetCompanyInsolvencyInformationAsync method and await on the task.

var result = await client.GetCompanyInsolvencyInformationAsync("10440441");

If there was no insolvency information for the given company number then null will be returned.

Contributing

  1. Fork
  2. Hack!
  3. Pull Request

About

A simple .NET client wrapper for CompaniesHouse API

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 99.9%
  • PowerShell 0.1%