Copy-paste-klar kode til de tre mest brugte operationer: autocomplete-søgning, adresse-validering og reverse geocoding. Alt fungerer mod produktionen — gratis op til 1 000 kald/dag uden nøgle.
Returnerer en liste af forslag der matcher delvis input. Typo-tolerant (fuzzy=true).
curl 'https://api.danadresse.dk/autocomplete?q=R%C3%A5dhuspladsen&fuzzy=true&per_side=5' \
-H 'X-Api-Key: dawa_live_…'
async function autocomplete(q) {
const res = await fetch(
`https://api.danadresse.dk/autocomplete?q=${encodeURIComponent(q)}&fuzzy=true&per_side=5`,
{ headers: { 'X-Api-Key': 'dawa_live_…' } }
);
return res.json();
}
console.log(await autocomplete('Rådhuspladsen'));
interface Suggestion { tekst: string; data: Record<string, any>; }
async function autocomplete(q: string): Promise<Suggestion[]> {
const url = new URL('https://api.danadresse.dk/autocomplete');
url.searchParams.set('q', q);
url.searchParams.set('fuzzy', 'true');
url.searchParams.set('per_side', '5');
const res = await fetch(url, { headers: { 'X-Api-Key': 'dawa_live_…' } });
if (!res.ok) throw new Error(`HTTP ${res.status}`);
return res.json();
}
import httpx
def autocomplete(q: str) -> list[dict]:
r = httpx.get(
'https://api.danadresse.dk/autocomplete',
params={'q': q, 'fuzzy': 'true', 'per_side': 5},
headers={'X-Api-Key': 'dawa_live_…'},
timeout=5.0,
)
r.raise_for_status()
return r.json()
for hit in autocomplete('Rådhuspladsen'):
print(hit['tekst'])
package main
import (
"encoding/json"
"fmt"
"net/http"
"net/url"
)
type Suggestion struct {
Tekst string `json:"tekst"`
Data map[string]interface{} `json:"data"`
}
func autocomplete(q string) ([]Suggestion, error) {
u, _ := url.Parse("https://api.danadresse.dk/autocomplete")
qs := u.Query()
qs.Set("q", q); qs.Set("fuzzy", "true"); qs.Set("per_side", "5")
u.RawQuery = qs.Encode()
req, _ := http.NewRequest("GET", u.String(), nil)
req.Header.Set("X-Api-Key", "dawa_live_…")
res, err := http.DefaultClient.Do(req)
if err != nil { return nil, err }
defer res.Body.Close()
var hits []Suggestion
return hits, json.NewDecoder(res.Body).Decode(&hits)
}
func main() {
hits, _ := autocomplete("Rådhuspladsen")
for _, h := range hits { fmt.Println(h.Tekst) }
}
<?php
function autocomplete(string $q): array {
$url = 'https://api.danadresse.dk/autocomplete?' . http_build_query([
'q' => $q, 'fuzzy' => 'true', 'per_side' => 5,
]);
$ch = curl_init($url);
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['X-Api-Key: dawa_live_…'],
]);
$body = curl_exec($ch);
curl_close($ch);
return json_decode($body, true);
}
foreach (autocomplete('Rådhuspladsen') as $hit) echo $hit['tekst'] . "\n";
require 'net/http'
require 'json'
require 'uri'
def autocomplete(q)
uri = URI('https://api.danadresse.dk/autocomplete')
uri.query = URI.encode_www_form(q: q, fuzzy: 'true', per_side: 5)
req = Net::HTTP::Get.new(uri)
req['X-Api-Key'] = 'dawa_live_…'
res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) { |h| h.request(req) }
JSON.parse(res.body)
end
autocomplete('Rådhuspladsen').each { |h| puts h['tekst'] }
using System.Net.Http;
using System.Text.Json;
using System.Web;
public record Suggestion(string Tekst, Dictionary<string, object> Data);
var http = new HttpClient();
http.DefaultRequestHeaders.Add("X-Api-Key", "dawa_live_…");
var q = HttpUtility.UrlEncode("Rådhuspladsen");
var url = $"https://api.danadresse.dk/autocomplete?q={q}&fuzzy=true&per_side=5";
var body = await http.GetStringAsync(url);
var hits = JsonSerializer.Deserialize<List<Suggestion>>(body)!;
foreach (var hit in hits) Console.WriteLine(hit.Tekst);
import java.net.URI;
import java.net.http.*;
import com.fasterxml.jackson.databind.*;
HttpClient client = HttpClient.newHttpClient();
String url = "https://api.danadresse.dk/autocomplete?q=R%C3%A5dhuspladsen&fuzzy=true&per_side=5";
HttpRequest req = HttpRequest.newBuilder()
.uri(URI.create(url))
.header("X-Api-Key", "dawa_live_…")
.build();
HttpResponse<String> res = client.send(req, HttpResponse.BodyHandlers.ofString());
JsonNode hits = new ObjectMapper().readTree(res.body());
hits.forEach(h -> System.out.println(h.get("tekst").asText()));
use serde_json::Value;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = reqwest::Client::new();
let hits: Vec<Value> = client
.get("https://api.danadresse.dk/autocomplete")
.query(&[("q", "Rådhuspladsen"), ("fuzzy", "true"), ("per_side", "5")])
.header("X-Api-Key", "dawa_live_…")
.send().await?
.json().await?;
for hit in hits {
println!("{}", hit["tekst"].as_str().unwrap_or(""));
}
Ok(())
}
Returnerer kategori A (præcis), B (sandsynlig) eller C (usikker) med top-matchet adresse.
curl -X POST 'https://api.danadresse.dk/datavask/adresser' \
-H 'X-Api-Key: dawa_live_…' \
-H 'Content-Type: application/json' \
-d '{"vejnavn":"Raadhuspladsn","husnr":"1","postnr":"1550"}'
const res = await fetch('https://api.danadresse.dk/datavask/adresser', {
method: 'POST',
headers: {
'X-Api-Key': 'dawa_live_…',
'Content-Type': 'application/json',
},
body: JSON.stringify({
vejnavn: 'Raadhuspladsn', // typo
husnr: '1',
postnr: '1550',
}),
});
const { kategori, resultater } = await res.json();
console.log(`Match-kategori: ${kategori}`);
import httpx
r = httpx.post(
'https://api.danadresse.dk/datavask/adresser',
headers={'X-Api-Key': 'dawa_live_…'},
json={'vejnavn': 'Raadhuspladsn', 'husnr': '1', 'postnr': '1550'},
)
data = r.json()
print(f"Match-kategori: {data['kategori']}")
for hit in data['resultater'][:3]:
print(' ', hit['adresse']['vejnavn'], hit['adresse']['husnr'])
<?php
$ch = curl_init('https://api.danadresse.dk/datavask/adresser');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => [
'X-Api-Key: dawa_live_…',
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode([
'vejnavn' => 'Raadhuspladsn',
'husnr' => '1',
'postnr' => '1550',
]),
]);
$body = curl_exec($ch);
$data = json_decode($body, true);
echo "Match-kategori: {$data['kategori']}\n";
Find nærmeste adresse fra en GPS-position. Under 50 ms.
# Rådhuspladsen i København: lat=55.6761, lon=12.5683
curl 'https://api.danadresse.dk/adgangsadresser/reverse?x=12.5683&y=55.6761&srid=4326'
navigator.geolocation.getCurrentPosition(async (pos) => {
const { latitude: y, longitude: x } = pos.coords;
const res = await fetch(
`https://api.danadresse.dk/adgangsadresser/reverse?x=${x}&y=${y}&srid=4326`
);
const address = await res.json();
console.log(`Du er ved: ${address.vejnavn} ${address.husnr}`);
});
import httpx
def reverse_geocode(lat: float, lon: float) -> dict:
r = httpx.get(
'https://api.danadresse.dk/adgangsadresser/reverse',
params={'x': lon, 'y': lat, 'srid': 4326},
)
return r.json()
addr = reverse_geocode(55.6761, 12.5683)
print(f"{addr['vejnavn']} {addr['husnr']}, {addr['postnr']}")
resp, _ := http.Get(fmt.Sprintf(
"https://api.danadresse.dk/adgangsadresser/reverse?x=%f&y=%f&srid=4326",
12.5683, 55.6761,
))
var addr struct {
Vejnavn string `json:"vejnavn"`
Husnr string `json:"husnr"`
Postnr string `json:"postnr"`
}
json.NewDecoder(resp.Body).Decode(&addr)
fmt.Printf("%s %s, %s\n", addr.Vejnavn, addr.Husnr, addr.Postnr)
npm-pakke for Node + browser. TypeScript-typer indbygget. Drop-in DAWA-SDK.
npm install @danadresse/js
PyPI-pakke. Sync + async clients (httpx). Drop-in DAWA Python-API.
pip install danadresse
CLI der scanner din kode efter DAWA-referencer + foreslår fixes.
npx @danadresse/migrate-cli scan
Hent gratis nøgle — 1 000 kald/dag — uden kreditkort.
Start gratis → Læs API-docs →