Skip to main content

$client->addresses()

Extract Addresses

Returns a list of UK addresses matching the query, ordered by relevance score. limit defaults to 10 and caps at 100. page defaults to 0.

You may only extract a single address from each request. To extract multiple addresses, you must perform an individual request for each address.

If the query is a valid postcode, the API returns the whole address list for that postcode and raises the limit to 100. Use page to reach the rest of a postcode holding more than 100 premises. You cannot page beyond 10,000 results.

Your key needs at least one of PAF, Multiple Residence, Not Yet Built, PAF Alias, PAF Welsh, AddressBase or AddressBase Premium. Without one the request is rejected.

A request that returns at least one address costs a lookup. Empty result sets are free.

Reverse Geocoding​

Return the addresses around a point with the lon= and lat= querystring arguments. The search radius is 100m and the API sorts addresses by distance from the point.

Filters​

Narrow your results by adding filters to your query string that correspond with an address attribute.

For instance, you can restrict to postcode SW1A 2AA by appending postcode=sw1a2aa.

If a filter term is invalid, e.g. postcode=SW1A2AAA, the API returns an empty result set and charges no lookup.

You can also scope using multiple terms for the same filter with a comma separated list of terms. E.g. Restrict results to E1, E2 and E3 outward codes: postcode_outward=e1,e2,e3. Multiple terms are OR'ed, i.e. the matching result sets are combined.

All filters can accept multiple terms unless stated otherwise below.

Multiple filters can also be combined. E.g. Restrict results to small user organisations in the N postcode area: su_organisation_indicator=Y&postcode_area=n. Multiple filters are AND'ed, i.e. each additional filter narrows the result set.

A combined maximum of 8 terms is allowed across all filters.

Biases​

You can boost address results that correspond with a given address attribute. All bias searches are prefixed with bias_.

Biased searches, unlike filtered searches, still allow unmatched addresses to appear. They rank lower.

For instance, you can boost addresses with postcode areas SW and SE by appending bias_postcode_area=SW,SE.

If a bias term is invalid, e.g. bias_postcode=SW1A2AAA, no bias is applied.

You may scope using multiple terms for the same bias with a comma separated list of terms. E.g. Prefer results in the E1, E2 and E3 outward codes: bias_postcode_outward=e1,e2,e3.

All biases can accept multiple terms unless stated otherwise below.

A combined maximum of 5 terms is allowed across all biases.

Search by Postcode and Building Name or Number​

Search by postcode and building attribute with the postcode filter and query argument. E.g. For "SW1A 2AA Prime Minister" /v1/addresses?postcode=sw1a2aa&q=prime minister.

Using a filter means a postcode mismatch returns no results and costs no lookup.

Search by UPRN​

Search by UPRN using the uprn filter and excluding the query argument. E.g. /v1/addresses?uprn=100.

Endpoint​

GET /addresses

Signature​

public function addresses(array $params = []): AddressResponse

Arguments​

NameTypeRequiredDescription
$paramsarraynoQuery parameters. Keys under Query Parameters.

Query Parameters​

Pass these as keys of $params.

NameTypeRequiredDescription
querystringnoSpecifies the address to query.
limitintnoLimit
pageintnoPage
filterstring|list<string>noRestrict Result Fields
lonfloat|intnoLongitude
latfloat|intnoLatitude
postcode_outwardstringnoFilter by Outward Code
postcodestringnoFilter by postcode Restrict result set to matching postcodes only. Can be combined with query to perform a postcode and building number or name search.
postcode_areastringnoFilter by Postcode Area
postcode_sectorstringnoFilter by Postcode Sector
post_townstringnoFilter by Town or City
uprnintnoFilter by UPRN
countrystringnoFilter by country
postcode_typestringnoFilter by Postcode Type
su_organisation_indicatorstringnoFilter by Organisation Indicator
boxstring|list<string>noFilter by Bounding Box
bias_postcode_outwardstringnoBias by Outward Code Boosts addresses with a matching outward code. The outward code is the first half of a postcode. For instance, the outward code of SW1A 2AA is SW1A.
bias_postcodestringnoBias by postcode Boost addresses which match postcode. Can be combined with query to perform a postcode and building number or name search.
bias_postcode_areastringnoBias by Postcode Area
bias_postcode_sectorstringnoBias by Postcode Sector
bias_post_townstringnoBias by Town or City
bias_thoroughfarestringnoBias by Street
bias_countrystringnoBias by Country
bias_lonlatstringnoBias by Geolocation
tagsstring|list<string>noTags
remove_organisation'true'noRemove Organisation
datasetstring|list<string>noFilter by Dataset

Response​

IdealPostcodes\Responses\AddressResponse. 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​

addresses.phpphp
<?php

declare(strict_types=1);

use IdealPostcodes\IdealPostcodes;

require 'vendor/autoload.php';

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

$response = $client->addresses(['query' => '9 Malyons Road, Swanley', 'limit' => 5]);

foreach ($response->result->hits as $address) {
echo $address->line1, ', ', $address->postTown, ', ', $address->postcode, PHP_EOL;
}

echo $response->result->total, ' addresses matched', PHP_EOL;