Skip to content

About

.NET SDK for the Ideal Postcodes API: UK postcode and address lookup, autocomplete, cleanse, email and phone validation

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Ideal Postcodes .NET SDK

Typed calls to the Ideal Postcodes API. Runs on .NET 8 or later and on .NET Framework 4.6.2 or later through netstandard2.0.

dotnet add package IdealPostcodes
using IdealPostcodes;

using var client = new IdealPostcodesClient("ak_test");

var lookup = await client.LookupAsync("BR8 7RE");
foreach (var address in lookup.Addresses)
{
    Console.WriteLine($"{address.Line1}, {address.PostTown}, {address.Postcode}");
}

var response = await client.FindAddressAsync(new FindAddressParams { Query = "9 Malyons Road" });
foreach (var hit in response.Result.Hits)
{
    Console.WriteLine(hit.Suggestion);
}

Each API operation is one …Async method on the client, named from its operation ID, such as PostcodesAsync, AddressCleanseAsync or KeyUsageAsync. Query parameters and request bodies are typed classes. Responses are classes with PascalCase properties; fields this version does not know are kept in AdditionalProperties. An HTTP error throws ApiException, with the HTTP status in StatusCode and the API error code in Code.

Key, licensee and configuration operations take your Management Key as the second constructor argument. Keep it on your server.

Use your own HttpClient

Create one client and reuse it. To manage the HttpClient yourself, pass it in; the client never disposes an HttpClient it did not create. With IHttpClientFactory:

services.AddSingleton(new IdealPostcodesOptions { ApiKey = "ak_test" });
services.AddHttpClient<IIdealPostcodesClient, IdealPostcodesClient>();

Then inject IIdealPostcodesClient, which is also what to mock in tests.

Documentation covers setup, postcode and UPRN lookup, autocomplete, address cleanse, email and phone validation, keys, licensees, responses, errors and a reference page for every operation. Coding agents can install the ideal-postcodes-dotnet-sdk skill with npx skills add ideal-postcodes/skills.

License

SEE LICENSE IN LICENSE

About

.NET SDK for the Ideal Postcodes API: UK postcode and address lookup, autocomplete, cleanse, email and phone validation

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages