GET /locations/autocomplete?q={prefix}
For a search box’s typeahead. Case-insensitive prefix match against unique cities in your tenant’s feed.
Query parameters
| Name | Required | Description |
|---|---|---|
q | yes | Prefix to match. Minimum 2 characters; shorter is rejected with 400. |
limit | no | Max suggestions. Default 10, max 25. |
Response — 200 OK
{
"suggestions": [
{ "type": "city", "value": "Windsor", "count": 1844 },
{ "type": "city", "value": "Wheatley", "count": 23 },
{ "type": "city", "value": "Wallaceburg", "count": 31 }
],
"attribution": { /* see Concepts → Attribution */ }
}Sorted by count desc — the bigger market shows up first. type is currently
always "city"; in the future we may add "neighbourhood" and "postalCode"
prefixes too.
Use in a debounced React typeahead
const [q, setQ] = useState('');
const [suggestions, setSuggestions] = useState([]);
useEffect(() => {
if (q.length < 2) return setSuggestions([]);
const id = setTimeout(async () => {
const res = await fetch(`/api/locations?q=${encodeURIComponent(q)}`); // your proxy
setSuggestions((await res.json()).suggestions);
}, 200);
return () => clearTimeout(id);
}, [q]);200ms debounce keeps rate-limit usage sane — a fast typist won’t fire more than ~3 calls for a typical city name.