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​

public function retrieveAddress(string $address, array $params = []): UsaResolveAddressResponse

Arguments​

NameTypeRequiredDescription
$addressstringyesID of address suggestion
$paramsarraynoQuery parameters. Keys under Query Parameters.

Query Parameters​

Pass these as keys of $params.

NameTypeRequiredDescription
licenseestringnoLicensee Key
filterstring|list<string>noRestrict Result Fields
tagsstring|list<string>noTags

Response​

AddressZen\Responses\UsaResolveAddressResponse. Read fields as properties, such as $response->result, or as an array with the API's field names. toArray() returns the decoded body.

Errors​

An HTTP error throws ApiException with the HTTP status, the API error code from getCode() and the decoded body. A transport failure throws TransporterException. See error handling.

Example​

retrieve-address.phpphp
<?php

declare(strict_types=1);

use AddressZen\AddressZen;

require 'vendor/autoload.php';

$client = AddressZen::client('ak_test');

$response = $client->retrieveAddress('usps_Z108703633|123||1119');

$address = $response->result;

echo $address->line1, PHP_EOL;
echo $address->lastLine, PHP_EOL;