From dawa-autocomplete2 to Danadresse

Keep DAWA's autocomplete widget, change the script address and add a domain-locked browser key so the address field works again.

4 min Level: Beginner ✓ Code tested

Many sites loaded DAWA's widget dawa-autocomplete2 straight from dawa.aws.dk or cdn.dataforsyningen.dk. Those files disappeared when DAWA closed on 1 October 2026, and the address field stopped suggesting addresses.

We serve the same widget (version 1.1.0, MIT licence) on the same paths under api.danadresse.dk. Your initialisation code and your CSS can stay as they are. You change the domain in <script src> and give the widget a key.

1. Create a browser key

The key sits in the page's HTML, so every visitor can see it. Use a key that is locked to your domains:

  1. Open Keys and create a live key for the website.
  2. Expand Tilladte domæner (allowed domains) on the key and enter your domains, e.g. firma.dk, www.firma.dk. *.firma.dk covers subdomains only, not firma.dk itself. localhost is allowed for development.
  3. Save. A key can have up to 40 domains.

A locked key only answers when the browser's Origin (or Referer) matches one of the domains. Each visitor can make 120 calls per minute, so one visitor cannot use up your quota. The details are in Browser keys and allowed domains.

If you put an unlocked key in a public page, it is seen from many IP addresses. That looks like a leaked key, and it can be blocked (403 key_blocked).

2. Change the script address

Replace the domain and add the key as ?key=:

HTML#script-tag
<!-- Before -->
<script src="https://dawa.aws.dk/js/autocomplete/dawa-autocomplete2.min.js"></script>

<!-- After -->
<script src="https://api.danadresse.dk/js/autocomplete/dawa-autocomplete2.min.js?key=dawa_live_your_browser_key"></script>

These paths work:

DAWA pathDanadresse
dawa.aws.dk/js/autocomplete/dawa-autocomplete2.min.jsapi.danadresse.dk/js/autocomplete/dawa-autocomplete2.min.js
dawa.aws.dk/js/autocomplete/dawa-autocomplete2.jsapi.danadresse.dk/js/autocomplete/dawa-autocomplete2.js
cdn.dataforsyningen.dk/dawa/assets/dawa-autocomplete2/<version>/…api.danadresse.dk/dawa/assets/dawa-autocomplete2/<version>/…
CSSapi.danadresse.dk/css/dawa-autocomplete2.css

Every version number on the CDN path returns the same 1.1.0 build. The widget's options have not changed since 1.0.

The widget looks for the key in these places, in this order: params.api_key, the apiKey option, data-api-key on the script tag, or ?key= (or ?api_key=) on the script address. It sends it as api_key on every call. ?key= needs a classic <script> tag; loaded as an ES module the widget cannot read its own tag, so use apiKey instead.

3. Keep your initialisation

The code that attaches the widget to your field does not need to change:

HTML#widget-init
<link rel="stylesheet" href="https://api.danadresse.dk/css/dawa-autocomplete2.css">

<div class="autocomplete-container">
  <input type="search" id="adresse" autocomplete="off">
</div>

<script src="https://api.danadresse.dk/js/autocomplete/dawa-autocomplete2.min.js?key=dawa_live_your_browser_key"></script>
<script>
  dawaAutocomplete.dawaAutocomplete(document.getElementById("adresse"), {
    debounce: 200,
    select: function (selected) {
      // selected.data.id is the address UUID – store it together with the text
      document.getElementById("adresse-id").value = selected.data.id;
    }
  });
</script>
<input type="hidden" id="adresse-id" name="adresse_id">

Options the widget supports: select, type (adresse, adgangsadresse or vejnavn), adgangsadresserOnly, params (e.g. { kommunekode: "0101" } or { postnr: "8000" }), fuzzy, minLength, debounce, id (pre-fill the field with a stored address), multiline and baseUrl. The filters in params (postnr, kommunekode) narrow the suggestions.

Typo tolerance works as in DAWA: the widget sends fuzzy= by default, which turns it on, and fuzzy: false leaves the parameter out, which turns it off.

Set debounce. Without it the widget makes one call per keystroke. With debounce: 200 it waits until the user pauses briefly.

Pre-filling with id works with a key too: our build sends the key on the call that the original widget made without parameters.

4. Test it

Open the page, type a few letters and look at the browser's developer tools under Network. You should see calls to https://api.danadresse.dk/autocomplete?…&api_key=… with status 200.

This is the same call the widget makes. You can try it from the terminal:

Shell#widget-request
curl -s "https://api.danadresse.dk/autocomplete?q=R%C3%A5dhuspladsen%201&type=adresse&caretpos=15&supplerendebynavn=true&stormodtagerpostnumre=true&multilinje=true&fuzzy=" \
  -H "X-Api-Key: $DANADRESSE_API_KEY"

To test a domain-locked key from the terminal, add -H "Origin: https://firma.dk" with one of the key's domains. Otherwise you get 403 origin_not_allowed.

Errors you may see:

Status and codeMeaningFix
401 missing_api_keyThe widget found no keyCheck ?key= on the script address, or use apiKey
401 invalid_api_keyThe key does not exist or was revokedCopy the key again from Keys
403 origin_not_allowedThe page's domain is not on the key's listAdd the domain under Tilladte domæner (remember both firma.dk and www.firma.dk)
429 rate_limit_per_visitorOne visitor made too many calls in a minuteSet debounce

When a call fails, the widget writes DAWA request failed to the console and tries again after half a second. If you see that line repeat, check the status code in Network.

Next steps

Related guides

Markdown source Spotted an error? Tell us API-reference (Swagger)

Try it with a free key

2,000 calls/month on the free plan. No credit card.

Create account →