# 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.
>
> https://danadresse.dk/en/guides/migrer-dawa-autocomplete2 · verified 2026-11-02
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](/dashboard/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](/en/guides/browser-noegler-domaener).

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 id=script-tag run=no
<!-- 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 path | Danadresse |
|---|---|
| `dawa.aws.dk/js/autocomplete/dawa-autocomplete2.min.js` | `api.danadresse.dk/js/autocomplete/dawa-autocomplete2.min.js` |
| `dawa.aws.dk/js/autocomplete/dawa-autocomplete2.js` | `api.danadresse.dk/js/autocomplete/dawa-autocomplete2.js` |
| `cdn.dataforsyningen.dk/dawa/assets/dawa-autocomplete2/<version>/…` | `api.danadresse.dk/dawa/assets/dawa-autocomplete2/<version>/…` |
| CSS | `api.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 id=widget-init run=no
<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:

```bash id=widget-request run=live expect="caretpos"
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 code | Meaning | Fix |
|---|---|---|
| `401 missing_api_key` | The widget found no key | Check `?key=` on the script address, or use `apiKey` |
| `401 invalid_api_key` | The key does not exist or was revoked | Copy the key again from [Keys](/dashboard/keys) |
| `403 origin_not_allowed` | The page's domain is not on the key's list | Add the domain under **Tilladte domæner** (remember both `firma.dk` and `www.firma.dk`) |
| `429 rate_limit_per_visitor` | One visitor made too many calls in a minute | Set `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

- Prefer our own widget? See [Autocomplete widget in plain JavaScript](/en/guides/vanilla-autocomplete-widget).
- Need to move server calls too? [Move from DAWA by changing the base URL](/en/guides/migrer-fra-dawa).
