/v1/addressesCosts 1 per requestSuggest addresses as someone types
G-NAF only. Unlike `/v1/typeahead`, which also returns suburbs and places, every result here is a resolved address, so nothing has to be filtered out.
Matching is a prefix of the street line, so type it as it is written: number first, then the street. A unit in front is understood and resolves to the unit's own record, not the building's: `3/90 Bay Road` returns the pid of unit 3, and `90 Bay Road` returns the pid of the parcel. `unit 3`, `u3`, `apt 3` and `3 90` are read the same way. A trailing postcode narrows.
Each result carries its `id`. Store that, not the text: the text is however your user typed it that day, the id is the address. An Australian result carries the same value under `address_detail_pid`, which is G-NAF's own column name.
Parameters
| Name | Type | Description |
|---|---|---|
| q | stringrequired | For example 145 sydney road |
| limit | integer | Defaults to 10 |
| country | string | Which country's addresses to search, as a two letter ISO 3166-1 code. Defaults to `AU`. Only a secret key may send it. A public key is scoped to the country the request came from, which Cloudflare resolves from the browser's address, and this parameter is ignored on one: a key that sits in a page cannot choose what it may see. A country no address data is loaded for answers 200 with an empty `data`, a `country_code` and a `note` saying so. That is not an error: it is the right answer for somebody typing from a country you do not hold. Defaults to AU. For example AU |
The answer application/json
| Name | Type | Description |
|---|---|---|
| data | array | |
| country_code | string | The country these results were searched in. `AU` today. Distinct from an address's own `country`, which is the country's name. |
| note | string | Why the answer is empty when empty is correct: no address data is loaded for this country, or the country could not be determined. Absent on an ordinary answer. |
| Status | Meaning |
|---|---|
| 200 | Matching addresses, best first. |
| 400 | `q` is missing. |
| 401 | No key, or a key we do not recognise. Send it as `Authorization: Bearer pf_live_...`. |
| 402 | The quota for this billing period is spent. `X-Quota-Reset` says when it returns; the billing portal is how to raise it sooner. |
| 429 | Too many requests a second for this plan. `RateLimit-Limit` says the rate and `Retry-After` says how long to wait; this is a rate, not a quota, so it clears in a second. |
curl -sS "https://api.locio.com.au/v1/addresses?q=145%20sydney%20road&country=AU" \ -H "Authorization: Bearer lc_live_..."
const url = new URL("https://api.locio.com.au/v1/addresses"); url.searchParams.set("q", "145 sydney road"); url.searchParams.set("country", "AU"); const res = await fetch(url, { headers: { "Authorization": "Bearer lc_live_..." }, }); const { data } = await res.json();
import requests res = requests.get( "https://api.locio.com.au/v1/addresses", params={"q": "145 sydney road", "country": "AU"}, headers={"Authorization": "Bearer lc_live_..."}, ) data = res.json()["data"]
require "net/http" require "json" uri = URI("https://api.locio.com.au/v1/addresses") uri.query = URI.encode_www_form(q: "145 sydney road", country: "AU") req = Net::HTTP::Get.new(uri) req["Authorization"] = "Bearer lc_live_..." res = Net::HTTP.start(uri.host, uri.port, use_ssl: true) { |http| http.request(req) } data = JSON.parse(res.body)["data"]
package main import ( "encoding/json" "fmt" "net/http" "net/url" ) func main() { q := url.Values{} q.Set("q", "145 sydney road") q.Set("country", "AU") req, _ := http.NewRequest("GET", "https://api.locio.com.au/v1/addresses?"+q.Encode(), nil) req.Header.Set("Authorization", "Bearer lc_live_...") res, err := http.DefaultClient.Do(req) if err != nil { panic(err) } defer res.Body.Close() var out struct { Data json.RawMessage `json:"data"` } json.NewDecoder(res.Body).Decode(&out) fmt.Println(string(out.Data)) }
<?php $query = http_build_query(["q" => "145 sydney road", "country" => "AU"]); $ch = curl_init("https://api.locio.com.au/v1/addresses?" . $query); curl_setopt_array($ch, [ CURLOPT_RETURNTRANSFER => true, CURLOPT_HTTPHEADER => ["Authorization: Bearer lc_live_..."], ]); $res = curl_exec($ch); curl_close($ch); $data = json_decode($res, true)['data'];
Example response, 28 lines
{
"data": [
{
"id": "GATAS717990791",
"address_detail_pid": "GATAS717990791",
"gnaf_pid": "GATAS717990791",
"formatted": "Piermont Resort, Unit 9, 12990 Tasman Highway, Swansea TAS 7190",
"components": {
"building_name": "Piermont Resort",
"flat_type": "Unit",
"flat_number": "9",
"number_first": "12990",
"street_name": "Tasman",
"street_type": "Highway",
"locality_name": "Swansea",
"state": "TAS",
"postcode": "7190"
},
"lat": -42.1557993,
"lng": 148.07629134,
"mesh_block": "60049060000",
"country": "Australia",
"region": "Tasmania",
"locality": "Swansea"
}
],
"country_code": "AU"
}