Who Should Use This Guide
For: Business owners and developers integrating address autocomplete without complex setup. You’ll need: A Loqate API key and basic HTML knowledge. Not covered: Tag-based integrations (see Tag Setup) or pre-built platform integrations (see Integrations).What You’ll Build
An address autocomplete form that:- Shows address suggestions as users type
- Fills in complete address details when selected
- Works with addresses in over 250 countries
- Provides formatted address lines for easy form population
Quick Start
To set up Address Capture, you’ll need an API key. Find out how to get yours here.Choose Your Approach
- Standalone Form
- Integrate with Existing Form
Use case: Testing the API or adding to a static pageA self-contained HTML file you can copy and use immediately.Jump to standalone HTML example
Add Your Key
ReplaceYOUR_API_KEY in the code with your actual Loqate API key.
Test
- Open your page
- Start typing an address like “10 Downing”
- Select from the suggestions
- Complete address populates automatically
Address Capture supports over 250 countries and territories. Use the Countries parameter to restrict results to specific countries.
Sample Project: Checkout Form Integration
This walkthrough shows how to add address autocomplete to a checkout form. Follow along to see a basic form transform into an intelligent address capture form.This is a detailed walkthrough. If you just want working code, skip to Integration Example or Standalone HTML Example.
Before: Manual Address Entry
A checkout form with manual address entry: This form works, but users must type complete addresses manually. Let’s add autocomplete.How Address Capture Works
Address Capture uses a two-step process:1. Find Step
What it does: Searches for addresses as users type. When to use: On every keystroke or with debouncing (recommended). What you get: A list of matching addresses and containers (groups of addresses). API endpoint:https://api.addressy.com/Capture/Interactive/Find/v1.10/json6.ws
Key parameters:
Text- The search term (what the user typed)Container- Optional ID for drilling down into resultsCountries- Optional filter (e.g., “GBR” for UK only)
2. Retrieve Step
What it does: Gets the complete address details. When to use: When a user selects an address from the suggestions. What you get: Full address in multiple formats (lines, elements, label). API endpoint:https://api.addressy.com/Capture/Interactive/Retrieve/v1.00/json6.ws
Key parameter:
Id- The unique address identifier from Find results
How They Work Together
Standalone HTML Example
A minimal address autocomplete form for quick testing: Perfect for:- Quick API testing
- Learning how address autocomplete works
- Simple integrations without checkout flows
- Copy the code
- Replace
YOUR_API_KEY - Save and test with different addresses
This example searches all countries by default. Add a Countries parameter to restrict results.
Code on GitHub
If you’d like to browse the code snippets in this implementation guide or clone them, visit the repository on GitHub.Integration Example
Here’s the checkout form with full address autocomplete integrated: To use this code:- Copy the code
- Replace
YOUR_API_KEYwith your actual Loqate API key - Save as an HTML file
- Open in a browser to test
- Customize styling to match your brand
- Real-time address suggestions as users type
- Debounced API calls to reduce requests
- Automatic form population on selection
- Support for multiple countries
- Clean, production-ready code structure
This example uses debouncing (300ms delay) to reduce API calls while users type. Adjust the delay based on your needs.
Integration Tips
Adding to Your Existing Forms
To add address autocomplete to your current forms:-
Add the autocomplete functions from the integration example to your page’s
<script>sectionfindAddress()for searchingretrieveAddress()for getting full details
-
Add the dropdown styles from the integration example to your page’s
<style>section- Positions suggestions below the input
- Provides hover and selection states
-
Add the suggestion dropdown element next to your address input field
<div id="suggestions" class="suggestions"></div>
-
Add the event listeners to trigger search and handle selection
- Input event with debouncing for Find
- Click event on suggestions for Retrieve
Debouncing API Calls
Debouncing delays API calls until the user stops typing, reducing unnecessary requests:Restricting to Specific Countries
Limit results to one or more countries using ISO codes:GBR- United KingdomUSA- United StatesCAN- CanadaAUS- AustraliaFRA- France
Handling Container Results
Some Find results are “containers” (groups of addresses) that need another Find call:Populating Form Fields
Map the Retrieve response to your form fields using the Lines format (recommended):- Lines (recommended) -
Line1,Line2,City,PostalCode - Elements -
BuildingNumber,Street,District - Label - Single formatted string with
\nline breaks
Adding Custom Data
Get additional fields like latitude/longitude using Field parameters:Styling the Dropdown
Customize the suggestions dropdown to match your design:Troubleshooting
Invalid API Key
Verify you’ve replacedYOUR_API_KEY with your actual key from your Loqate account.
No Suggestions Appearing
Check:- Search term is at least 3 characters (recommended minimum)
- You have available credits in your account
- API key hasn’t been restricted by domain, IP, or rate limits (check account settings)
- Browser console for errors
- Network tab shows successful API calls
Suggestions Not Closing
Ensure you handle clicks outside the dropdown:Address Not Populating Form
Check:- You’re calling
retrieveAddress()with the correctIdfrom Find results - Result type is “Address” (not “Container”)
- Form field IDs match the JavaScript selectors
- Response contains expected fields (check browser console)
Dropdown Positioning Issues
Ensure the parent container hasposition: relative:
CORS Errors
The examples must be hosted on a web server, not opened as localfile:// URLs. Upload to your website or use a development server like Python’s http.server or Node’s http-server.
Data Privacy
- Addresses searched through Loqate’s API
- Stored in infrastructure logs for 30 days for operational purposes
- Results returned immediately
- See Privacy Policy for complete details

