Ideal Postcodes Go SDK

go.ideal-postcodes.co.uk/sdk calls the Ideal Postcodes UK address API from Go 1.26 or later, with a typed method for each operation and no dependencies beyond the standard library.

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.

go get go.ideal-postcodes.co.uk/sdk
main.gogo
package main

import (
	"context"
	"fmt"
	"log"

	idealpostcodes "go.ideal-postcodes.co.uk/sdk"
)

func main() {
	client := idealpostcodes.NewClient("ak_test")
	res, err := client.FindAddress(context.Background(), &idealpostcodes.FindAddressParams{
		Query: "9 Malyons Road",
	})
	if err != nil {
		log.Fatal(err)
	}
	for _, hit := range res.Result.Hits {
		if s := hit.AsUkAddressSuggestion(); s != nil {
			fmt.Println(s.Suggestion)
		}
	}
}

The package name is idealpostcodes; import it under that name, as above. Each API operation is one method on the client, named from its operation ID, such as Postcodes() or FindAddress(). Every method takes a context.Context first and returns a typed response and an error.

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 field naming its source, such as paf or abp. Its Native record holds the raw fields from that source.

Why the SDK​

  • Standard library only. Requests go through net/http. Pass your own *http.Client for timeouts, proxies or tracing. There is nothing else to install or keep patched.
  • Generated from the OpenAPI spec. Every response is a struct. Every dataset's native record has its own type, from PafAddress to UspsAddress.
  • Responses never fail on shape. A field the API adds, a value outside a known set or a dataset the SDK has not seen yet decodes without error. See responses.
  • 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.

Coding agents​

  • Agent skill. npx skills add ideal-postcodes/skills installs the ideal-postcodes-go-sdk skill, built from these pages.
  • Endpoints. Every operation, grouped by API area, with its signature, parameters, response type and a tested example.
  • Markdown pages. Add .md to any page URL for plain markdown, such as /docs/sdks/go/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 NewClient(). Key, licensee and configuration operations also need a Management Key, passed with WithManagementKey(). Keep the Management Key on your server. See setup.

Errors​

An HTTP error returns *idealpostcodes.APIError with the HTTP status and the API error code and message. Match it with errors.AsType. A failed connection returns the net/http error, wrapped. See error handling.