Location
The Location API suggests places for a partly typed suburb or postcode. A place is one suburb, state and postcode, as G-NAF names them — a suburb that spans two postcodes is two places.
Step 1.Request
GET https://api.getaddress.io/location/{term}?api-key={your-api-key}
Response, for 'northb'
{
"suggestions":
[
{
"location": "NORTHBRIDGE NSW 2063",
"url": "/get-location/northbridge-nsw-2063",
"id": "northbridge-nsw-2063"
},
{
"location": "NORTHBRIDGE WA 6003",
"url": "/get-location/northbridge-wa-6003",
"id": "northbridge-wa-6003"
}
]
}
A term matches the start of any word of the place, so 'bon' finds BONDI and NORTH BONDI, and a postcode works as well as a name. Among equally good matches, the place with more addresses comes first.
Step 2.The selected 'Id' is passed to the 'Get Location' API to return the place and its centre.
Request
GET https://api.getaddress.io/get-location/{id}?api-key={your-api-key}
A place's id is built from its suburb, state and postcode, so it is the same in every G-NAF release — it is safe to store.
Authentication
Your API key goes in the api-key query parameter, as above. It is the only place the key is read from.
Filter
A filter limits results to specific criteria. Send it as the body of a POST to the same URL.
Request
{
"filter":
{
"state":"{state abbreviation, e.g. NSW}",
"postcode":"{4-digit postcode}",
"radius":{
"km":"{max distance from lat/long in kilometres}",
"longitude":{longitude},
"latitude":{latitude}
}
}
}
Example
Filtering 'state' to 'WA' will only return places in Western Australia.
{
"filter":
{
"state":"WA"
}
}
Location
Prefers places closer to a point. Nothing is excluded: places near the point come first, and the rest of the list is filled from everywhere. A request made with a domain token prefers places near the visitor automatically; on a server, pass your end user's ip_address for the same effect.
{
"location":
{
"latitude":-31.9505,
"longitude":115.8605
}
}
With that location, 'northb' returns NORTHBRIDGE WA 6003 before NORTHBRIDGE NSW 2063.
Options
| Name | Default | Description | Type |
|---|---|---|---|
| top | 6 | The number of suggestions to return, 1–20. Also accepted as a query parameter on the GET. | Number |
| filter | None | Only return places in a state, a postcode, or within a radius. POST body only. | Object |
| location | None | Prefer places near a latitude and longitude. POST body only. | Object |
| ip_address | None | Your end user's IP address, used to prefer places near them. POST body only, and read only on an API-key request. | Text |
Usage
- Location queries are rate limited but do not increase your usage.
- Resolving a location suggestion with the Get Location API counts as 1 look-up.
Domain Tokens
To avoid exposing your API key in browser code, Domain Tokens can be used in place of your API key. A Domain Token is generated for one domain and works on that domain and its sub-domains.
A Domain Token can only be used for address and place look-ups — /autocomplete,
/get, /validate, /distance, /location, /get-location, /nearest-location and
/typeahead. It cannot read your usage, so it carries none of the access your API key does.
A revoked Domain Token stops working within a minute.
Each token is throttled per visitor IP address: 60 look-ups per minute by default,
and the limit can be set per token (1–10,000 look-ups over a window of 1–60 minutes).
Requests over the limit get 429 with a Retry-After header. There is a second
ceiling on the token's total traffic across all visitors, so a token being used somewhere other than
your site is throttled even when every request arrives from a different address.
Look-ups made with a Domain Token count against your plan's allowance exactly as look-ups made with your API key do.
A Domain Token is also what carries the free Google Places fallback: with it switched on, an autocomplete that finds nothing hands the widget your own Google API key.
What a Domain Token is, and what it isn't. It keeps your API key out of your page source, and it makes a token copied out of your page close to worthless: it works only on your domain, only for look-ups, and only at the rate you set. It is not a secret — you publish it in your page — and the domain check reads request headers, which a determined caller can set to anything. The throttle is the protection; set it no higher than your address form actually needs.
Rate Limiting
Your subscription's plan will limit the number of requests per 5 minute span. Exceeding your plan's rate limit will return a HTTP 429 response.
The Retry-After HTTP header contains the number of seconds until a successful retry can be made.