Ideal Postcodes .NET SDK
IdealPostcodes calls the Ideal Postcodes UK address API from C#, with a typed …Async method for each operation. It runs on .NET 8 or later, and on .NET Framework 4.6.2 or later through netstandard2.0.
Use the ak_test key for limited testing. It is capped at 5 requests per day. A new account comes with a free test balance for fuller testing.
dotnet add package IdealPostcodes
using IdealPostcodes;
using var client = new IdealPostcodesClient("ak_test");
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 method on the client, named from its operation ID, such as PostcodesAsync() or FindAddressAsync(). Every method returns a class built from the API response, with PascalCase properties.
Address data
UK addresses come from Royal Mail's Postcode Address File (PAF) and Ordnance Survey AddressBase, depending on the datasets on your key. Each address carries a Dataset property naming its source, such as paf or abp. Its Native record holds the raw fields from that source.
Features
- Typed requests and responses. Query parameters and request bodies are classes, with required fields as constructor arguments. Every dataset's native record has its own class, from
PafAddresstoUspsAddress. - Generated from the OpenAPI spec. Methods, parameters and response classes come from the contract the API reference is built from.
- Every current API operation. Address search, postcode lookup, UPRN lookup, autocomplete, address cleanse, places, email and phone validation, plus key, licensee and configuration management. Each one has its own reference page.
- Fits your app. Pass your own
HttpClient, register the client withIHttpClientFactoryand mockIIdealPostcodesClientin tests. Every method takes aCancellationToken. The source-generated JSON context needs no reflection, so the SDK works with trimming and Native AOT.
Coding agents
- Agent skill.
npx skills add ideal-postcodes/skillsinstalls theideal-postcodes-dotnet-sdkskill, built from these pages. - Endpoints. Every operation, grouped by API area, with its parameters, response class and a tested example.
- Markdown pages. Add
.mdto any page URL for plain markdown, such as/docs/sdks/dotnet/errors.md. - llms.txt. An index of every page on this site.
- OpenAPI spec. The API contract the SDK is generated from.
- Build with AI. Every asset for AI agents.
Authentication
Pass your API key to the IdealPostcodesClient constructor. Key, licensee and configuration operations also need a Management Key, passed as the second argument. Keep the Management Key on your server. See setup.
Errors
An HTTP error throws ApiException with the HTTP status and the API error code and message. Every exception the SDK defines derives from IdealPostcodesException. A failed connection throws HttpRequestException, as any HttpClient call does. See error handling.