Skip to main content

client.FindAddress()

Find Address

Returns address suggestions for a partial address, ordered by relevance. Use it to power real-time address autofill.

Consider our address autocomplete JavaScript libraries, which add address lookup to a form without calling this API directly.

API Usage​

Implementing our Address Autocomplete API involves:

  1. Fetch address suggestions with /autocomplete/addresses
  2. Acquire the complete address using the ID from the suggestion

Step 2 decrements your lookup balance.

Step 1 is not a free standalone resource. We rate limit and then suspend integrations that repeatedly make autocomplete requests without a paid Step 2 request.

Context​

context limits the search, usually to a single country. It defaults to GBR, and an unrecognised context falls back to that default. If your key is not licensed for the datasets covering the context, the request is rejected.

Querying a full postcode within a supported context returns the entire address list for that postcode.

Query Filters​

Refine results by appending filters to your querystring, e.g. postcode=sw1a2aa for postcode SW1A 2AA. Invalid filters return an empty set without affecting your lookup count.

To apply multiple filter terms, use a comma-separated list, e.g. postcode_outward=e1,e2,e3 combines result sets for E1, E2 and E3. Unless otherwise specified, all filters support multiple terms.

Filters combine with AND logic, for instance su_organisation_indicator=Y&postcode_area=n. The maximum is 8 filter terms.

Address Bias​

Preface bias searches with bias_ to boost certain address results. Unlike filters, biasing allows unmatched addresses to appear with lower priority.

For example, use bias_postcode_area=SW,SE to favour addresses in the SW and SE postcode areas. Invalid bias terms have no effect.

Multiple bias terms are allowed unless stated otherwise, with a combined maximum of 5.

Suggestion Format​

The suggestion format is subject to change. We recommend using the suggestion as-is to avoid integration issues.

Rate Limiting and Cost​

The default rate limit is 3,000 requests per 5 minutes, counted per key and IP address. The X-RateLimit-Limit, X-RateLimit-Remaining and X-RateLimit-Reset headers report where you stand.

Autocomplete API usage does not impact your balance, but resolving a suggestion to a full address requires a paid request. Autocomplete requests without subsequent paid requests may lead to rate limiting or suspension.

Endpoint​

GET /autocomplete/addresses

See the API reference for this endpoint.

Signature​

func (c *Client) FindAddress(ctx context.Context, params *FindAddressParams) (*AutocompleteResponse, error)

Arguments​

NameTypeRequiredDescription
ctxcontext.ContextyesCancels the request and sets its deadline.
params*FindAddressParamsnoOptional 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
querystringnoAddress Query
dataset[]stringnoFilter by Dataset
contextstringnoContext
limitintnoLimit
bias_lonlatstringnoBias by Geolocation
bias_ipstringnoBias by Geolocation of IP
boxstringnoFilter by Bounding Box
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
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
postal_codestringnoFilter by postal code
postal_code_2stringnoFilter by postal code prefix
postal_code_3stringnoFilter by short postal code
citystringnoFilter by city
statestringnoFilter by state
state_codestringnoFilter by state code
bias_postal_codestringnoBias by postal code
bias_postal_code_2stringnoBias by postal code prefix
bias_postal_code_3stringnoBias by short postal code
bias_citystringnoBias by city
bias_statestringnoBias by state
bias_state_codestringnoBias by state code
is_poboxstringnoFilter by PO Box
is_businessstringnoFilter by business address

Response​

*idealpostcodes.AutocompleteResponse. 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 *idealpostcodes.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​

find-address/main.gogo
package main

import (
"context"
"fmt"
"log"

idealpostcodes "go.ideal-postcodes.co.uk/sdk"
)

func main() {
client := idealpostcodes.NewClient("ak_test")
res, err := client.FindAddress(context.Background(), &idealpostcodes.FindAddressParams{
Query: "9 Malyons Road",
Limit: 5,
})
if err != nil {
log.Fatal(err)
}
for _, hit := range res.Result.Hits {
switch s := hit.Variant().(type) {
case *idealpostcodes.UkAddressSuggestion:
fmt.Printf("%s: %s (UDPRN %d)\n", s.ID, s.Suggestion, s.UDPRN)
case *idealpostcodes.AddressSuggestion:
fmt.Printf("%s: %s\n", s.ID, s.Suggestion)
}
}
}