# AddressZen Go SDK

[`go.addresszen.com/sdk`](https://github.com/addresszen/go-sdk) calls the AddressZen API from Go 1.26 or later, with a typed method for each operation and no dependencies beyond the standard library.

```bash
go get go.addresszen.com/sdk
```

main.gogo

```go
package main

import (
	"context"
	"fmt"
	"log"

	addresszen "go.addresszen.com/sdk"
)

func main() {
	client := addresszen.NewClient("ak_test")
	res, err := client.AddressVerify(context.Background(), addresszen.AddressVerifyBody{
		Query: "1010 Cauthen Ln, Alamogordo, NM 88310",
	}, nil)
	if err != nil {
		log.Fatal(err)
	}
	if m := res.Result.AsUsaVerifyMatch(); m != nil {
		fmt.Printf("%s, %s, %s %s\n", m.AddressLineOne, m.City, m.State, m.ZipCode)
	}
}
```

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

## Features

Every operation in the API has a method. The ones most integrations need have a guide:

* [Address verification](/docs/sdks/go/address-verify.md): correct and standardize a US address against USPS data
* [Autocomplete](/docs/sdks/go/autocomplete.md): suggest addresses as the user types, in the US and other countries
* [Email validation](/docs/sdks/go/email-validation.md): check that an address can receive mail
* [Phone validation](/docs/sdks/go/phone-validation.md): check a number from any country and format it
* [API keys](/docs/sdks/go/keys.md) and [licensees](/docs/sdks/go/licensees.md): balances, limits, usage and sub-licensing

Place search and saved configs are on the [endpoint pages](/docs/sdks/go/endpoints.md), one per method.

## 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 `UspsAddress` to `MoisAddress`.
* **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](/docs/sdks/go/responses.md).
* **No hidden retries.** A billable lookup repeats only when your code repeats it.

## Coding agents

* **Agent skill.** `npx skills add addresszen/skills` installs the `azn-go-sdk` skill, built from these pages.
* **[Endpoints](/docs/sdks/go/endpoints.md).** 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`](/docs/sdks/go/errors.md).
* **[llms.txt](https://docs.addresszen.com/llms.txt).** An index of every page on this site.
* **[OpenAPI spec](https://openapi.addresszen.com/openapi.json).** The API contract the SDK is generated from.

## Authenticate

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](/docs/sdks/go/setup.md).

## Errors

An HTTP error returns `*addresszen.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](/docs/sdks/go/errors.md).
