Skip to Content
dk-address

Client

A typed, English wrapper around the KDS Adressevælger endpoints.

@dk-address/client calls KDS Adressevælger for you and returns English, typed results. Use it to search or look up addresses outside the field, or pass your own fetch to it in tests.

import { createClient } from "@dk-address/client";

const kds = createClient(); // token defaults to KDS's shared "adressevaelger123"
const suggestions = await kds.search("Vesterbrogade 28 1620", { kind: "address", limit: 20 });
const address = await kds.getAddress("0a3f50a1-919f-32b8-e044-0003ba298018");

Methods

MethodKDS endpoint
search(text, { kind, limit, municipalityCodes, includeProvisional, signal })/adresser/soeg, or /husnumre/soeg for kind: "accessAddress"
getAddress(id) / getAddresses(ids)/adresser/{id}, /adresser?id_lokalids=
getAccessAddress(id) / getAccessAddresses(ids)/husnumre/{id}, /husnumre?id_lokalids=
getAccessAddressUnits(id)/husnumre/{id}/adresser
getStreet(id) / getStreetAccessAddresses(id)/navngivenvejpostnumre/{id}, …/husnumre

Lookups return null for an unknown id, and multi-id lookups return results in the order you asked for. Every result carries raw, the untouched KDS object.

KDS doesn't document the two street endpoints. Its own component uses the first, and the field uses the second for house-number prefix matching, falling back to KDS's own matches if it fails.

Suggestions

typeKDS typeFields
streetNamevejnavnlabel, streetName (no id)
streetNameNumbervejnavnhusnummerlabel, streetName, houseNumber (no id)
streetnavngivenvejpostnummerid, label, streetName, postalCode, postalDistrict, accessAddressCount
accessAddresshusnummerid, label, streetName, houseNumber
addressadresseid, label, accessAddressId

Use suggestionKey(suggestion) as a React key; two types have no id.

Text and errors

  • search cleans the text first: characters other than letters, digits, spaces and .,'- become spaces (KDS returns nothing for & or HTML), and it's capped at KDS's 73 characters. Empty text sends no request.
  • Failed requests throw AdressevaelgerError with status, KDS's Danish message and the url with the token redacted.
  • Coordinates are ETRS89 / UTM 32N (EPSG:25832), the only system KDS returns.