No results? When the response is an empty list

Work through a checklist when the API answers 200 with an empty list, from side and street names to status, srid, autocomplete type and datavask.

5 min Level: Beginner ✓ Code tested

An empty list ([]) with status 200 means the call was valid, but nothing matched all the filters. The API does not tell you which filter was too narrow. Remove the filters one at a time, and use the checklist below. Most cases come down to the format of a code or a filter that works differently than expected.

Run the same call with fewer filters

The quickest diagnosis is to remove one filter at a time until results appear. The last filter you removed is the culprit. This example shows a common one: an abbreviated street name.

Python#compare-filters
import os
import requests

API = "https://api.danadresse.dk"
headers = {"X-Api-Key": os.environ["DANADRESSE_API_KEY"]}

for name in ("Gl. Kongevej", "Gammel Kongevej"):
    r = requests.get(f"{API}/adgangsadresser",
                     params={"vejnavn": name, "postnr": "1610", "per_side": 1},
                     headers=headers, timeout=10)
    r.raise_for_status()
    print(f"vejnavn={name}: {len(r.json())} result(s)")
Text#compare-output
vejnavn=Gl. Kongevej: 0 result(s)
vejnavn=Gammel Kongevej: 1 result(s)

The checklist

Pagination

  • Symptom: Page 1 has data, a later page is empty.
  • Cause: side is past the last page. There is no header with the total count.
  • Fix: Stop the loop when a page has fewer rows than per_side. See Pagination.

Codes

  • Symptom: Your own code finds no match for municipality 101 or postcode 800 in the response.
  • Cause: Codes in responses always have leading zeros: "kommunekode": "0101", "nr": "0800". As input the API accepts both kommunekode=101 and 0101.
  • Fix: Compare zero-padded strings: str(code).zfill(4) in Python, String(code).padStart(4, "0") in JavaScript.
  • Symptom: A postcode gives [] even though the address exists.
  • Cause: The address is in another postcode than you think. Streets in Copenhagen and Frederiksberg change postcode along the way, and large-recipient postcodes (companies' own postcodes) have no addresses.
  • Fix: Remove postnr and see which postcode the address has.

Status: retired and provisional addresses

  • Symptom: A new or an old address is missing.
  • Cause: Without status or medtagnedlagte, lists return current and provisional addresses (status 1 and 3, so new builds are included). Retired addresses (status 2 and 4) are left out. /autocomplete and search only find addresses that are in use: a closed address leaves the search.
  • Fix: Use medtagnedlagte or status=2 / status=4 on /adresser and /adgangsadresser. medtagnedlagte also works together with cirkel and polygon. See status, darstatus and retired addresses.

Filters on street name, house number, floor and door

  • Symptom: vejnavn=Gl. Kongevej or vejnavn=Soendergade gives [].
  • Cause: vejnavn matches the start of the official name. Abbreviations (Gl. for Gammel, Skt. for Sankt) do not match, and you cannot count on a spelling without æøå to match either.
  • Fix: Use /autocomplete or /datavask/adresser for text users have typed. Only use vejnavn= with names you got from the API.
  • Symptom: husnr=12 A gives [].
  • Cause: The house number is one string without a space: 12A.
  • Fix: Remove the space between the number and the letter.
  • Symptom: etage=1. sal or dør=t.h. gives [].
  • Cause: Floor and door have fixed codes: floor st, kl, 1, 2 …, door th, tv, mf or a number.
  • Fix: Use the codes without dots and without "sal".

Ids

  • Symptom: /adresser?id=… gives [] even though the id is valid.
  • Cause: The id belongs to an access address. Addresses and access addresses have different ids.
  • Fix: Use /adresser?adgangsadresseid=… to get the units behind a door, or /adgangsadresser/{id}. See Adresse or adgangsadresse?

Coordinates

  • Symptom: cirkel= gives [], or reverse gives 404 No address within range.
  • Cause: Longitude and latitude are swapped, UTM coordinates were sent without srid=25832, or the radius is too small. The order is always longitude, latitude: cirkel=12.5683,55.6761,100.
  • Fix: See Coordinates and srid.

Autocomplete

Symptom: /autocomplete gives []. Go through these:

  • q is empty. An empty search always gives an empty list.
  • kommunekode=, postnr= or adgangsadresseid= excludes the address. These filters narrow the suggestions. Remove them and try again.
  • type=vejnavn only returns street names, and type=adgangsadresse stops at the house number. Without type the step follows what the user has typed. See Adresse or adgangsadresse?
  • A floor and door that do not exist at the address (for example 3. th in a house without a 3rd floor) give no suggestions.
  • Typo tolerance is a flag, as in DAWA: send fuzzy (or fuzzy=) to turn it on. Without it, or with fuzzy=false, a misspelled word gives no suggestions.

Datavask

  • Symptom: /datavask/adresser?betegnelse=… gives "kategori": "C" and "resultater": [].
  • Cause: No street matched. The parser reads floor and door (2. tv, st. th, 1.mf), house letters in lower case (12a), a postcode anywhere in the text and spellings without æøå (Aabenraa, Kobenhavn). Words it cannot place, such as a c/o line, a company name or "Att.", end up in vaskeresultat.ukendtetokens of a match. When resultater is empty, the street is usually missing from that postcode, or the text is too far from the official name.
  • Fix: Send only the address lines, without names and c/o lines, or send the fields separately. That works with both GET and POST:
Shell#datavask-fields
curl -s -G "https://api.danadresse.dk/datavask/adresser" \
  --data-urlencode "vejnavn=Rådhuspladsen" \
  --data-urlencode "husnr=1" \
  --data-urlencode "etage=st" \
  --data-urlencode "dør=th" \
  --data-urlencode "postnr=4200" \
  -H "X-Api-Key: $DANADRESSE_API_KEY"

The opposite: too many results

A parameter name the API does not know is ignored without an error, as in DAWA. Known filters do filter. ?postnummer=8000 filters on nothing, and you get the first addresses in the whole country. If you get results that do not match the filter, check the spelling. See Error 400 and 404 for a function that catches unknown parameters.

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 →