Autocomplete
Suggestions as the user types, the way DAWA made them. /autocomplete is the one both
browser widgets call: it suggests street names first, then access addresses, then
addresses, and moves on a level as the text narrows. The per-resource autocompletes below suggest one kind of thing only.
Free suggestions: add kun_tekst=true to /autocomplete,
/adresser/autocomplete or /adgangsadresser/autocomplete (ours, not DAWA's). Each suggestion
then carries only what shows it and fetches it: the texts, and of the address only id and
href. No coordinates, no other fields. Such an answer is free, and rate limited like the
other free endpoints; when the user picks one, fetch it from /adresser/{id}
(or the href) for 1 look-up. So a completed address costs one look-up however many
keystrokes it took. Without kun_tekst the answer is DAWA's own, with the address in the mini structure,
and an answer that holds addresses is 1 look-up, as below.
/autocomplete
It starts at startfra and stops at type. From street names it moves on only when exactly one street
matches and the text already begins with its whole name; from access addresses, when at most one matches. Each suggestion
has a type (vejnavn, adgangsadresse or adresse), the text to show
(forslagstekst), the text to put in the input (tekst), where the caret goes (caretpos),
and data: the street name, or the address in DAWA's mini structure.
| Parameter | Default | Description |
|---|---|---|
| q | The text typed so far. | |
| caretpos | end of q | Where the caret is in q. The last word is matched as a prefix when the caret is at its end. |
| type | adresse | Where to stop: vejnavn, adgangsadresse or adresse. |
| startfra | vejnavn | Where to start: vejnavn, adgangsadresse or adresse. |
| fuzzy | false | Fuzzy matching for misspellings, on the last level searched. fuzzy= with no value turns it on, as the widget sends it. |
| id | Suggest the one record with this id, at level type (the widget uses it to show a saved address). | |
| adgangsadresseid | Suggest the addresses at this access address. | |
| postnr | Only these postcodes, e.g. 2300 or 2300|2100. | |
| kommunekode | Only these municipalities, e.g. 0101. | |
| supplerendebynavn | true | Include the supplementary town name in the suggestion text. |
| stormodtagerpostnumre | false | Also suggest an address under its large-recipient postcode, where it has one. |
| multilinje | false | Break forslagstekst over lines. |
| per_side | 20 | Most suggestions to return, at most 100. |
| srid | 4326 | Coordinates of data.x/data.y: 4326 or 25832. |
| kun_tekst | false | Ours, not DAWA's. true: data is only the address's id and href (a street name is unchanged), and the answer is free. |
Street names
While more than one street matches, the answer is street names. It is free.
Request
GET
Response — the first 2 of 20 shown
[
{
"type": "vejnavn",
"tekst": "Amager ",
"forslagstekst": "Amager",
"caretpos": 7,
"data": {
"navn": "Amager",
"href": "https://api.getaddress.dk/vejnavne/Amager"
}
},
{
"type": "vejnavn",
"tekst": "Amager Boulevard ",
"forslagstekst": "Amager Boulevard",
"caretpos": 17,
"data": {
"navn": "Amager Boulevard",
"href": "https://api.getaddress.dk/vejnavne/Amager%20Boulevard"
}
}
]
Addresses
Once the street is known, the answer is addresses. It costs 1 look-up, however many suggestions it holds.
Request
GET https://api.getaddress.dk/autocomplete?q=Amagerbrogade%20217A&api-key={your-api-key}
Response — the first 1 of 16 shown
[
{
"data": {
"id": "415d291b-648c-4908-bfea-dc75aec543d1",
"status": 1,
"darstatus": 3,
"vejkode": "0108",
"vejnavn": "Amagerbrogade",
"adresseringsvejnavn": "Amagerbrogade",
"husnr": "217A",
"etage": null,
"dør": null,
"supplerendebynavn": null,
"postnr": "2300",
"postnrnavn": "København S",
"stormodtagerpostnr": null,
"stormodtagerpostnrnavn": null,
"kommunekode": "0101",
"adgangsadresseid": "099f3e28-4fb8-4c61-86a1-edff5df52409",
"x": 12.6135425,
"y": 55.6489036,
"href": "https://api.getaddress.dk/adresser/415d291b-648c-4908-bfea-dc75aec543d1"
},
"stormodtagerpostnr": false,
"type": "adresse",
"tekst": "Amagerbrogade 217A, 2300 København S",
"forslagstekst": "Amagerbrogade 217A, 2300 København S",
"caretpos": 36
}
]
Addresses, text only
With kun_tekst=true the same suggestions carry only the address's id and href. Free. Fetch the one picked from /adresser/{id} for 1 look-up.
Request
GET https://api.getaddress.dk/autocomplete?q=Amagerbrogade%20217A%2C%20kl.%205%2C%202300&kun_tekst=true&api-key={your-api-key}
Response
[
{
"data": {
"id": "3bba05d4-c8c4-4c90-8a64-a4dff11b9d1b",
"href": "https://api.getaddress.dk/adresser/3bba05d4-c8c4-4c90-8a64-a4dff11b9d1b"
},
"type": "adresse",
"tekst": "Amagerbrogade 217A, kl. 5, 2300 København S",
"forslagstekst": "Amagerbrogade 217A, kl. 5, 2300 København S",
"caretpos": 43
}
]
Access addresses
With type=adgangsadresse it stops at the access address (street, house number, postcode). Also 1 look-up, or free with kun_tekst=true.
Request
GET https://api.getaddress.dk/autocomplete?q=Amagerbrogade%20217A&type=adgangsadresse&api-key={your-api-key}
Response
[
{
"data": {
"id": "099f3e28-4fb8-4c61-86a1-edff5df52409",
"status": 1,
"darstatus": 3,
"vejkode": "0108",
"vejnavn": "Amagerbrogade",
"adresseringsvejnavn": "Amagerbrogade",
"husnr": "217A",
"supplerendebynavn": null,
"postnr": "2300",
"postnrnavn": "København S",
"stormodtagerpostnr": null,
"stormodtagerpostnrnavn": null,
"kommunekode": "0101",
"x": 12.6135425,
"y": 55.6489036,
"href": "https://api.getaddress.dk/adgangsadresser/099f3e28-4fb8-4c61-86a1-edff5df52409"
},
"stormodtagerpostnr": false,
"type": "adgangsadresse",
"tekst": "Amagerbrogade 217A, 2300 København S",
"forslagstekst": "Amagerbrogade 217A, 2300 København S",
"caretpos": 36
}
]
/adresser/autocomplete
Addresses only, with floor and door. Each suggestion is tekst and the address in the mini structure. 1 look-up per answer that is not empty; with kun_tekst=true, tekst and only the address's id and href, free.
| Parameter | Description |
|---|---|
| q | The text typed so far; the last word is matched as a prefix. |
| postnr, kommunekode | Only these postcodes or municipalities; several separated by |. |
| vejnavn, vejkode, husnr, etage, dør, supplerendebynavn | Only addresses with these values. etage= or dør= with no value means none. |
| id, adgangsadresseid | Only these addresses (several ids separated by |), or the addresses at this access address. |
| side, per_side | Paging. per_side defaults to 20, at most 100. |
| srid | 4326 (default) or 25832. |
| kun_tekst | Ours, not DAWA's. true: each suggestion is tekst and only the address's id and href, and the answer is free. |
Request
GET https://api.getaddress.dk/adresser/autocomplete?q=Amagerbrogade%20217A%2C%20kl.%205%2C%202300&api-key={your-api-key}
Response
[
{
"tekst": "Amagerbrogade 217A, kl. 5, 2300 København S",
"adresse": {
"id": "3bba05d4-c8c4-4c90-8a64-a4dff11b9d1b",
"status": 1,
"darstatus": 3,
"vejkode": "0108",
"vejnavn": "Amagerbrogade",
"adresseringsvejnavn": "Amagerbrogade",
"husnr": "217A",
"etage": "kl",
"dør": "5",
"supplerendebynavn": null,
"postnr": "2300",
"postnrnavn": "København S",
"stormodtagerpostnr": null,
"stormodtagerpostnrnavn": null,
"kommunekode": "0101",
"adgangsadresseid": "099f3e28-4fb8-4c61-86a1-edff5df52409",
"x": 12.6135425,
"y": 55.6489036,
"href": "https://api.getaddress.dk/adresser/3bba05d4-c8c4-4c90-8a64-a4dff11b9d1b"
}
}
]
With kun_tekst=true:
Request
GET https://api.getaddress.dk/adresser/autocomplete?q=Amagerbrogade%20217A%2C%20kl.%205%2C%202300&kun_tekst=true&api-key={your-api-key}
Response
[
{
"tekst": "Amagerbrogade 217A, kl. 5, 2300 København S",
"adresse": {
"id": "3bba05d4-c8c4-4c90-8a64-a4dff11b9d1b",
"href": "https://api.getaddress.dk/adresser/3bba05d4-c8c4-4c90-8a64-a4dff11b9d1b"
}
}
]
/adgangsadresser/autocomplete
Access addresses only. The same parameters as /adresser/autocomplete, without etage, dør and adgangsadresseid. 1 look-up per answer that is not empty, or free with kun_tekst=true.
Request
GET https://api.getaddress.dk/adgangsadresser/autocomplete?q=Amagerbrogade%20217A&api-key={your-api-key}
Response
[
{
"tekst": "Amagerbrogade 217A, 2300 København S",
"adgangsadresse": {
"id": "099f3e28-4fb8-4c61-86a1-edff5df52409",
"status": 1,
"darstatus": 3,
"vejkode": "0108",
"vejnavn": "Amagerbrogade",
"adresseringsvejnavn": "Amagerbrogade",
"husnr": "217A",
"supplerendebynavn": null,
"postnr": "2300",
"postnrnavn": "København S",
"stormodtagerpostnr": null,
"stormodtagerpostnrnavn": null,
"kommunekode": "0101",
"x": 12.6135425,
"y": 55.6489036,
"href": "https://api.getaddress.dk/adgangsadresser/099f3e28-4fb8-4c61-86a1-edff5df52409"
}
}
]
/vejnavne/autocomplete
Street names. Free. Takes q, postnr, kommunekode, side and per_side (default 20, at most 100).
Request
GET
Response — the first 2 of 3 shown
[
{
"tekst": "Biensvej",
"vejnavn": {
"navn": "Biensvej",
"href": "https://api.getaddress.dk/vejnavne/Biensvej"
}
},
{
"tekst": "Bientjevej",
"vejnavn": {
"navn": "Bientjevej",
"href": "https://api.getaddress.dk/vejnavne/Bientjevej"
}
}
]
/postnumre/autocomplete
Postcodes, by number or name. Free. Takes q, nr, navn, kommunekode, side and per_side (default 20, at most 100).
Request
GET https://api.getaddress.dk/postnumre/autocomplete?q=23&api-key={your-api-key}
Response
[
{
"tekst": "2300 København S",
"postnummer": {
"nr": "2300",
"navn": "København S",
"stormodtager": false,
"visueltcenter_x": 12.6554181,
"visueltcenter_y": 55.67362511,
"href": "https://api.getaddress.dk/postnumre/2300"
}
}
]
In the browser
Autocomplete runs in your visitor's browser, where an API key must not go. Use a
domain token: in api-key, or in the path
(/t/{your-domain-token}/…) for a widget that builds its own query strings. For an address field there
are two widgets, both supported, and both call select with the same object (valgt.tekst,
and valgt.data in DAWA's field names), so one handler works for either.
Our widget, getaddress-dk-autocomplete: getaddress.dk's
defaults, the token as an argument, styles included. It asks with kun_tekst=true, so the suggestions
are free, and fetches the address picked by id before calling select:
1 look-up per address picked. npm install getaddress-dk-autocomplete, or:
<link rel="stylesheet" href="https://cdn.getaddress.io/scripts/getaddress-dk-autocomplete-1.2.0.css">
<script src="https://cdn.getaddress.io/scripts/getaddress-dk-autocomplete-1.2.0.js"></script>
<script>
getAddressDk.autocomplete(document.getElementById('adresse'), '{your-domain-token}', {
select: function (valgt) { console.log(valgt.tekst, valgt.data.id); }
});
</script>
DAWA's open-source dawa-autocomplete2
(npm), pointed at us with baseUrl: the Danish state's own widget, with its full option set
documented upstream. If you already use it, baseUrl is the only change. As published it asks for DAWA's
full answers, so each answer that suggests addresses is 1 look-up; add params: { kun_tekst: true } and
fetch the address picked yourself for free suggestions
(how).
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/dawa-autocomplete2@1.1.0/dist/css/dawa-autocomplete2.css">
<script src="https://cdn.jsdelivr.net/npm/dawa-autocomplete2@1.1.0/dist/js/unfilled/dawa-autocomplete2.min.js"></script>
<script>
dawaAutocomplete.dawaAutocomplete(document.getElementById('adresse'), {
baseUrl: 'https://api.getaddress.dk/t/{your-domain-token}',
select: function (valgt) { console.log(valgt.tekst, valgt.data.id); }
});
</script>