Skip to main content

client.RetrieveAddress()

Retrieve Address

Returns the full address for an autocomplete suggestion id.

This is the charged step of address autocomplete. A successful retrieval decrements your lookup balance. An id which resolves to no address returns 404.

Every address comes back in one US-shaped format, whatever country or dataset it came from: up to two address lines and US field names such as zip_code, state and city.

Endpoint​

GET /autocomplete/addresses/{address}/usa

See the API reference for this endpoint.

Signature​

func (c *Client) RetrieveAddress(ctx context.Context, address string, params *RetrieveAddressParams) (*UsaResolveAddressResponse, error)

Arguments​

NameTypeRequiredDescription
ctxcontext.ContextyesCancels the request and sets its deadline.
addressstringyesID of address suggestion
params*RetrieveAddressParamsnoOptional query parameters, or nil. Fields under Query Parameters.

Query Parameters​

A required parameter is a method argument. Set the rest as fields of params, named in Studly case (post_town is PostTown); a field left at its zero value is not sent.

NameTypeRequiredDescription
licenseestringnoLicensee Key
filterstringnoRestrict Result Fields
tagsstringnoTags
remove_firmstringnoRemove Firm

Response​

*addresszen.UsaResolveAddressResponse. Fields the API may leave out or send as null are pointers. RawJSON() returns the body as received. See responses.

Errors​

An HTTP error returns *addresszen.APIError with the HTTP status, the API error code and the body; match it with errors.AsType. A transport failure returns the net/http error, wrapped. See error handling.

Example​

retrieve-address/main.gogo
package main

import (
"context"
"fmt"
"log"

addresszen "go.addresszen.com/sdk"
)

func main() {
client := addresszen.NewClient("ak_test")
res, err := client.RetrieveAddress(context.Background(), "usps_Z108703633|123||1119", nil)
if err != nil {
log.Fatal(err)
}
fmt.Println(res.Result.Line1)
fmt.Println(res.Result.LastLine)
}