Loading...

.NET SDK

.NET SDK for working with security and resources.

Install

PM> Install-Package getAddress.Sdk

Dependency Injection

services.AddSingleton(s => new GetAddress.ApiKeys("API Key", "admin-key"));
services.AddHttpClient<GetAddress.Api>();

Find

Find postal addresses for a UK postcode and optional house name/number.

public async Task Find(GetAddress.Api api)
{
    var result = await api.Find("TR19 7AA");
  
    if (result.IsSuccess)
    {
        foreach(var address in result.Success.Addresses)
        {
            var line1 = address.Line1;
            var line2 = address.Line2;
            var line3 = address.Line3;
            var line4 = address.Line4;
            var buildingName = address.BuildingName;
            //....
        }
    }
    else
    {
        var errorMessage = result.Failed.Message;
    }
}

Autocomplete

Autocomplete and get address.

public async Task Autocomplete(GetAddress.Api api)
{
  var autocompleteResult = await api.Autocomplete("High St");

  if (autocompleteResult.IsSuccess)
  {
      foreach(var suggestion in autocompleteResult.Success.Suggestions)
      {
          var getResult = await api.Get(suggestion);

          if (getResult.IsSuccess)
          {
              var address = getResult.Success;
              var line1 = address.Line1;
              var line2 = address.Line2;
              var line3 = address.Line3;
              var line4 = address.Line4;
              var buildingName = address.BuildingName;
              //....
          }
      }
  }
  else
  {
      var errorMessage = autocompleteResult.Failed.Message;
  }
}
Top