Skip to content
Help center

Code example: autocomplete and address search

1 min read

curl

Bash
curl -H "Authorization: Bearer <key>" \
  "https://api.danskadresseapi.dk/v1/autocomplete?q=rådhuspladsen%201"

JavaScript (fetch)

JavaScript
const res = await fetch(
  "https://api.danskadresseapi.dk/v1/adresser?q=rådhuspladsen+1+københavn&per_side=5",
  { headers: { Authorization: "Bearer " + process.env.ADDR_KEY } }
);
if (!res.ok) {
  const { error } = await res.json();
  throw new Error(`${error.type}: ${error.message} (${error.request_id})`);
}
const data = await res.json();
console.log(data);

Python (requests)

Python
import os, requests
r = requests.get(
    "https://api.danskadresseapi.dk/v1/adresser",
    params={"q": "rådhuspladsen 1 københavn", "per_side": 5},
    headers={"Authorization": f"Bearer {os.environ['ADDR_KEY']}"},
)
r.raise_for_status()
print(r.json())
Just want DAWA-compatible responses? Switch to /dawa/adresser/autocomplete?q=… (also works without a key, up to 1,000/day/IP).
Was this helpful?