Find the municipality, region, parish and police district of an address

Look up the administrative areas of an address, from municipality and region to parish, police district, court district and nomination district.

3 min Level: Beginner ✓ Code tested

Many systems need more than the address itself. A municipality wants to route cases by parish, an insurer wants the police district, an election site has to show the nomination district and polling area. All these areas come from the Danish Administrative Geographic Division (DAGI) and are already on the access address.

So you normally do not need an extra call. If you have the access-address id, you have the areas.

The areas on the access address

Shell#dagi-curl
curl -s "https://api.danadresse.dk/adgangsadresser/0a3f507a-ec01-32b8-e044-0003ba298018" \
  -H "X-Api-Key: $DANADRESSE_API_KEY"

Among other things the response contains these fields (shortened):

JSON#dagi-svar
{
  "id": "0a3f507a-ec01-32b8-e044-0003ba298018",
  "adressebetegnelse": "Rådhuspladsen 1, 1550 København V",
  "kommune": { "kode": "0101", "navn": "København" },
  "region": { "kode": "1084", "navn": "Region Hovedstaden" },
  "sogn": { "kode": "7002", "navn": "Helligånds" },
  "politikreds": { "kode": "1470", "navn": "Københavns Politi" },
  "retskreds": { "kode": "1101", "navn": "Københavns Byret" },
  "opstillingskreds": { "kode": "0003", "navn": "Indre By" },
  "afstemningsområde": { "nummer": "63", "navn": "3. Midt" },
  "storkreds": { "nummer": "1", "navn": "København" },
  "valglandsdel": { "bogstav": "A", "navn": "Hovedstaden" },
  "landsdel": { "nuts3": "DK011", "navn": "Byen København" }
}
FieldAreaKey
kommuneMunicipalitykode, 4 digits with a leading zero
regionRegionkode (1081-1085)
sognParish (Church of Denmark)kode
politikredsPolice districtkode
retskredsCourt district (district court)kode
opstillingskredsNomination district for general electionskode
afstemningsområdePolling areanummer, unique within the municipality
storkreds, valglandsdelElectoral areas above the nomination districtnummer, bogstav
landsdelProvince (EU NUTS 3)nuts3

Each block also has an href to the area's own resource, e.g. /sogne/7002.

If you have an address id (with floor and door), the same fields are under adgangsadresse in the response from GET /adresser/{id}. The areas belong to the building, so every flat on a staircase has the same ones.

In Python

Python#dagi-python
import os
import requests

r = requests.get(
    "https://api.danadresse.dk/adgangsadresser/0a3f507a-ec01-32b8-e044-0003ba298018",
    headers={"X-Api-Key": os.environ["DANADRESSE_API_KEY"]},
    timeout=10,
)
r.raise_for_status()
a = r.json()

def navn(blok):
    return f'{blok["navn"]} ({blok.get("kode") or blok.get("nummer")})' if blok else "-"

print(a["adressebetegnelse"])
for felt in ("kommune", "region", "sogn", "politikreds", "retskreds",
             "opstillingskreds", "afstemningsområde"):
    print(f"  {felt:18} {navn(a.get(felt))}")

A block can be null if the register has no area for that particular address. Write your code so it copes with that.

One combined lookup with /api/v1/enrich/…/dagi

GET /api/v1/enrich/adresser/{id}/dagi gathers the same areas in one compact structure under boundaries and adds the coordinates. It takes an access-address id or an address id with floor and door. The areas are the same for every address in the building.

Shell#dagi-enrich
curl -s "https://api.danadresse.dk/api/v1/enrich/adresser/0a3f507c-0624-32b8-e044-0003ba298018/dagi" \
  -H "X-Api-Key: $DANADRESSE_API_KEY"
JSON#dagi-enrich-svar
{
  "id": "0a3f507c-0624-32b8-e044-0003ba298018",
  "boundaries": {
    "region": { "kode": "1084", "navn": "Region Hovedstaden" },
    "kommune": { "kode": "0157", "navn": "Gentofte" },
    "postnummer": { "nr": "2900", "navn": "Hellerup" },
    "sogn": { "kode": "7117", "navn": "Hellerup" },
    "retskreds": { "kode": "1104", "navn": "Retten i Lyngby" },
    "politikreds": { "kode": "1468", "navn": "Nordsjællands Politi" },
    "opstillingskreds": { "kode": "0013", "navn": "Gentofte" },
    "afstemningsomraade": { "kode": "7", "navn": "Hellerup" }
  },
  "coordinates": { "lat": 55.7326, "lon": 12.5757, "srid": 4326 }
}

If an area is missing, kode and navn are null and the block has "_status": "needs_dagi_etl". Storkreds, valglandsdel and landsdel are only in the normal access-address response.

Endpoints under /api/v1/enrich/ need a normal live key. A test key gets 403 with the code sandbox_scope, and a browser key gets 403 with browser_key_scope. So use /adgangsadresser/{id} if your code runs in the browser.

The other direction: every address in an area

The filters work the other way round too. /adgangsadresser takes kommunekode, regionskode, sognekode, politikredskode, retskredskode and opstillingskredskode. Separate several values with |:

Shell#dagi-filter
curl -s "https://api.danadresse.dk/adgangsadresser?politikredskode=1470&struktur=mini&per_side=3" \
  -H "X-Api-Key: $DANADRESSE_API_KEY"

The lists of the areas themselves come from /sogne, /politikredse, /retskredse, /opstillingskredse, /regioner and /kommuner. See Postcodes and municipalities for dropdowns.

Edge cases

  • Municipality code with a zero. The code is a four-digit string: 0101, not 101. The API always returns four digits, and filters also accept kommunekode=101. Store the code as text so the zero does not disappear in your own data.
  • A parish is not a postcode. A postcode can span several municipalities and parishes, so you cannot look up the parish from the postcode. Always go through the address.
  • Boundaries move. Polling areas and parishes change now and then. If you store the areas on a case, store the date too, or look them up again when you need them.

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 →