@checkify-api/autocomplete
v1.1.0
Published
Drop-in Australian and New Zealand address and suburb autocomplete widget powered by Checkify. Covers 15.4M+ AU and NZ addresses with full unit-level resolution.
Downloads
89
Maintainers
Readme
@checkify-api/autocomplete
Drop-in JavaScript library for Australian address and suburb autocomplete, powered by the Checkify API. Covers 15.4 million addresses including full unit number resolution.
Requires an API key — sign up at checkify.com.au.
Usage
Add the script tag to your page with your API key:
<script src="https://cdn.jsdelivr.net/npm/@checkify-api/autocomplete@latest/checkify-autocomplete.js?key=YOUR_API_KEY"></script>Then initialise on your address input:
<input type="text" id="street" placeholder="Start typing an address..." />
<script>
CheckifyAutocomplete.init("#street");
</script>Field mapping
Automatically populate separate form fields when an address is selected:
<input type="text" id="street" />
<input type="text" id="unit" />
<input type="text" id="suburb" />
<input type="text" id="state" />
<input type="text" id="postcode" />
<script>
CheckifyAutocomplete.init("#street", {
unit: "#unit",
street: "#street-display",
city: "#suburb",
state: "#state",
postcode: "#postcode",
});
</script>Available field mapping keys: unit, level, unitLevel, streetNumber, streetName, streetType, street, city, state, stateFull, postcode, country, countryFull, latitude, longitude, buildingName, meshBlockCode
Suburb autocomplete
Use initSuburb() instead of init() to search suburbs and postcodes:
<input type="text" id="suburb" />
<input type="text" id="state" />
<input type="text" id="postcode" />
<script>
CheckifyAutocomplete.initSuburb("#suburb", {
city: "#suburb",
state: "#state",
postcode: "#postcode",
});
</script>Available field mapping keys: city, state, stateFull, postcode, country, countryFull
Events
Listen for checkify:selected on the input to get the full address or suburb object:
// Address widget
document.querySelector("#street").addEventListener("checkify:selected", (e) => {
console.log(e.detail);
// { unit, street, city, state, postcode, latitude, longitude, ... }
});
// Suburb widget
document.querySelector("#suburb").addEventListener("checkify:selected", (e) => {
console.log(e.detail);
// { city, state, stateFull, postcode, country, countryFull }
});Destroy
Both init() and initSuburb() return a widget instance with a destroy() method:
const widget = CheckifyAutocomplete.init("#street");
widget.destroy(); // removes listeners and dropdownOther Checkify API endpoints
The same API key gives you access to the full Checkify REST API:
| Endpoint | Description |
| ----------------------------------------- | ------------------------------------------- |
| GET /api/v1/autocomplete | Address autocomplete suggestions |
| GET /api/v1/autocomplete-details | Full details for a selected address |
| GET /api/v1/autocomplete-suburb | Suburb autocomplete suggestions |
| GET /api/v1/autocomplete-suburb-details | Full details for a selected suburb |
| GET /api/v1/reverse | Reverse geocode lat/lng to nearest address |
| GET /api/v1/postcode | Look up all suburbs for a postcode |
| GET /api/v1/abn | Look up an Australian Business Number (ABN) |
| GET /api/v1/acn | Look up an Australian Company Number (ACN) |
See the full API documentation for request/response details.
