Official PHP client for integrating Addresso UK address lookups into any PHP application. Zero dependencies, typed data classes, and full IDE autocomplete.
Requires PHP 8.1 or later with the curl and json extensions (enabled by default on most installs).
composer require addresso/addresso-php
Create a Client with your API key. All methods return typed readonly objects with full IDE autocomplete.
use Addresso\Client;
$client = new Client('ak_your_api_key');
// Postcode lookup
$result = $client->lookupPostcode('SW1A 1AA');
foreach ($result->addresses as $address) {
echo $address->buildingNumber . ' ' . $address->street . "\n";
}
// Address search
$search = $client->searchAddresses(['q' => '10 Downing Street']);
// Account info
$account = $client->account();
echo "Credits: " . $account->creditsBalance;apiKeystringrequiredYour Addresso API key (begins with ak_).
baseUrlstringOverride the API base URL. Defaults to https://addresso.co.uk.
Look up all addresses at a UK postcode. Returns a PostcodeLookupResult with an array of typed Address objects.
$result = $client->lookupPostcode('SW1A 1AA');
echo $result->postcode; // "SW1A 1AA"
echo count($result->addresses); // number of addresses
echo $result->creditsRemaining; // credits left
foreach ($result->addresses as $address) {
echo $address->buildingName;
echo $address->street;
echo $address->town;
}Search for addresses using free text or structured fields. Returns an AddressSearchResult.
// Free-text search
$result = $client->searchAddresses(['q' => '10 Downing Street']);
// Structured search
$result = $client->searchAddresses([
'town' => 'London',
'street' => 'Downing Street',
'building_number' => '10',
'limit' => 5,
]);
echo $result->count; // total matches
echo $result->creditsRemaining; // credits leftqstringFree-text query across all fields.
postcodestringFilter by postcode.
townstringFilter by town.
streetstringFilter by street name.
building_namestringFilter by building name.
building_numberstringFilter by building number.
organisationstringFilter by organisation.
limitintMax results to return (default 50).
Check your account status and remaining credits.
$account = $client->account(); echo $account->companyName; // your company name echo $account->creditsBalance; // credits remaining echo $account->earliestExpiry; // earliest credit expiry date (or null)
All API responses are mapped to typed readonly objects. The Address class contains these properties:
postcodestringFull postcode.
townstringPost town.
localitystringLocality name.
subLocalitystringSub-locality.
streetstringPrimary street name.
secondaryStreetstringSecondary street.
buildingNumberstringBuilding number.
buildingNamestringBuilding name.
subBuildingstringSub-building (flat, unit, etc.).
poBoxstringPO box number.
departmentstringDepartment name.
organisationstringOrganisation name.
udprnintUnique Delivery Point Reference Number.
postcodeTypestringPostcode type (S or L).
deliveryPointSuffixstringRoyal Mail delivery point suffix.
latitude?floatWGS84 latitude, or null.
longitude?floatWGS84 longitude, or null.
All API errors throw AddressoException which extends RuntimeException. Use getStatusCode() to inspect the HTTP status.
use Addresso\AddressoException;
try {
$result = $client->lookupPostcode('INVALID');
} catch (AddressoException $e) {
echo $e->getMessage(); // "Invalid postcode"
echo $e->getStatusCode(); // 400
}