Why generic autocomplete isn't enough
Address autocomplete libraries designed for western markets start from assumptions that don't hold in Romania:
- They assume addresses follow the "street, number, city, postal code" order
- They don't know Romanian nomenclature (Str., Bd., Calea, Șos., Aleea, B-dul)
- They don't handle Romanian diacritics: "ș", "ț", "ă", "â", "î"
- They don't know that "Sector 3" is a subdivision of Bucharest, not a county
The result: irrelevant suggestions, checkout friction and deliveries to incomplete addresses.
The autocomplete endpoint
GET /v1/addresses/autocomplete?q={query}&limit={n} accepts a partial query and returns up to n suggestions (default 10, max 25):
curl "https://api.posty.ro/v1/addresses/autocomplete?q=mihai+vite&limit=5" \
-H "Authorization: Bearer psk_live_xxx"
{
"suggestions": [
{
"display": "Strada Mihai Viteazu, Cluj-Napoca, Cluj, 400151",
"components": {
"street": "Strada Mihai Viteazu",
"locality": "Cluj-Napoca",
"county": "Cluj",
"county_code": "CJ",
"postal_code": "400151"
},
"highlight": "Strada <em>Mihai</em> <em>Vite</em>azu, Cluj-Napoca, Cluj, 400151",
"score": 0.98,
"place_id": "psl_Y2x1ai1zdHJlZXQ"
}
],
"query": { "q": "mihai vite", "normalized": "mihai vite" }
}
Target latency is sub-150 ms at the 95th percentile, suitable for a live dropdown.
Implementation patterns
1. Debounce, not throttle
Users type fast. A 200–300 ms debounce reduces the number of requests without degrading the perceived experience:
import { ref, watch } from 'vue'
const query = ref('')
const suggestions = ref([])
let timer: ReturnType<typeof setTimeout>
watch(query, (val) => {
clearTimeout(timer)
if (val.length < 3) { suggestions.value = []; return }
timer = setTimeout(async () => {
const q = encodeURIComponent(val)
const url = `https://api.posty.ro/v1/addresses/autocomplete?q=${q}`
const res = await fetch(url, {
headers: { Authorization: `Bearer ${apiKey}` },
})
suggestions.value = (await res.json()).suggestions
}, 250)
})
2. Start at 3 characters
Below 3 characters, suggestions are too broad to be useful and consume quota unnecessarily. You can display a "keep typing…" hint for UX.
3. Always provide a manual exit
Autocomplete won't cover 100% of addresses. There are new constructions, temporary addresses or gaps in the source data. Make sure the user can ignore the suggestions and continue with what they typed.
4. Pre-fill fields on selection
When the user picks a suggestion, show display in the input and auto-populate the county, locality and postal code fields from the components object in the response. This removes a major source of errors.
function selectSuggestion(s) {
form.street = s.components.street
form.locality = s.components.locality
form.county = s.components.county
form.postalCode = s.components.postal_code
}
5. Validate at submit
Autocomplete reduces errors, it doesn't eliminate them. At submit, send the address to POST /v1/addresses/verify to catch any manual edits the user made after selecting a suggestion.
Diacritics and typo tolerance
The API normalises both the query and the data internally. "mihai vitezu" (no diacritics), "MIHAI VITEAZU" (uppercase) and "Mihai Viteazu" all return the same suggestions. No need to pre-process client input.
Try it yourself with our postal code lookup by address: type a street without diacritics or with a typo.
Accessibility
role="combobox"on the input, with correctaria-expandedandaria-controlsrole="listbox"on the container androle="option"on each suggestion- Arrow-key navigation,
Enterto select,Escapeto dismiss
NuxtUI's USelectMenu and UCommandPalette implement this pattern correctly, so you can use them as a base.