bookdown/_book/25-Address_Matching_API.md

Postcode Verifying API

What this API does

Looking at the company in Figure \@ref(fig:chapi), we wouldn't know if the supplied postcode existed or not, given the base information supplied in the API. So we wrap the Companies House API within another API, which examines the supplied postcode and returns an assessment, as seen in Figure \@ref(fig:chapi2) below:

Postcode Verifying API

(\#fig:chapi2)Result of Postcode Verifying API

Resources Used

The resource we use to determine whether or not the postcode exists is:

https://postcodes.io/

This is a free, open source postcode and geolocation API based on Open Data from the Office for National Statistics and Ordnance Survey. The endpoints and methods are listed on their site, but the one we use is Validate a postcode, and can be found here:

https://api.postcodes.io/postcodes/:postcode/validate

...where :postcode is replaced by the postcode we're looking to validate. For example in the company being assessed in example \@ref(fig:chapi), we used the following URL:

https://api.postcodes.io/postcodes/SE258BB/validate

...and the returned result is:

{status:200, result:false}

This is confirmed using Royal Mail's postcode address finder:

Royal Mail address finder output

(\#fig:rm1)Royal Mail address finder output

Now all we have to do is extract the company's postcode in Python, supply that to postcodes.io API and return the result, as seen in example \@ref(fig:chapi).

Our API for doing this can be found here:

https://darlabs.herokuapp.com/v1/11659363/quality

You can substitute any company number in the above URL to find out if that company's postcode exists.

Caveats

As with any third party API, we don't know exactly where they get their data from. It's probably not coming from the Royal Mail Postcode Address File (PAF), but it seems to be very accurate. I've not yet found an address that is reported incorrectly using this API, but that's not to say it's 100% accurate. Use with caution.



companieshouse/DARr documentation built on Oct. 22, 2022, 8:26 p.m.