Validate Address

Endpoint for checking if an address in a specific country is valid or not.

Endpoint URL

GET https://app-api.geposit.se/v2.0/validate/address/{COUNTRY_CODE}

{COUNTRY_CODE} is se, no, dk, fi or ax. Authentication, response status and permissions are described in Valid Intro. Full reference: Validate Address.

Parameters

Send street or query. Add postcode and locality whenever you have them: the address is checked against all three, and without them more addresses match.

Query parameterDescription
streetThe street address, either in full (street=Storgatan 12B, street=Gullyckeskärsvägen 203-28) or only the street name with the number in the parameters below.
street_numberStreet number, when it is not part of street. Example: street=Storgatan&street_number=12
letterLetter of the street number, when it is not part of street. Example: street=Storgatan&street_number=12&letter=B
extra_numberSecondary street number, when it is not part of street. Example: street=Gullyckeskärsvägen&street_number=203&extra_number=28
postcodePostcode of the address. Example: postcode=11121
localityLocality (city) of the address. Example: locality=Stockholm
queryThe whole address as free text, instead of the fields above. Example: query=Drottninggatan 45, 111 21 Stockholm. If you send both, the separate fields win.
suggestionstrue (default) returns suggestions when the address is invalid. false returns only the verdict and the errors.
response_formatjson (default) or xml.
administrativetrue adds administrative divisions. Needs a permission.
coordinatetrue adds latitude and longitude. Needs a permission.
property_designationtrue adds the property designation (fastighetsbeteckning), Sweden. Needs a permission.
uuidtrue adds the address's unique id, Sweden only. Needs a permission.
desotrue adds deso_code, Sweden. Needs a permission.
regsotrue adds regso_code and regso_name, Sweden. Needs a permission.
neighborhoodtrue adds neighborhood_1_name and neighborhood_2_name. Needs a permission.

A parameter that needs a permission your key does not have is ignored. See Permissions.

Response

KeyTypeDescription
versionStringAPI version
response_timeFloatProcessing time in seconds
queryObjectThe parameters as received
interpretationObjectHow the input was parsed: street, street_number, letter, extra_number, postcode, locality
is_validBooleantrue when the address matches exactly one address with no errors
statusInteger302 valid, 300 suggestions, 404 nothing found, 200 invalid with suggestions=false, 400 bad request. See Response status
status_textStringReason for a 400
matchArrayWhen the address is valid: an array with one address object
suggestionsArrayWhen the address is invalid: zero or more address objects
errorsObjectWhat was wrong with the input, as error code → text. Needs the error-codes permission. See Glossary

Address object

Used in match and suggestions. Empty fields are left out.

KeyTypeDescription
address_typeStringSee Address types
streetStringStreet name
street_numberStringStreet number
letterStringLetter of the street number, for example B in Storgatan 12B
extra_numberStringSecondary street number, for example 28 in Gullyckeskärsvägen 203-28
postcodeStringPostcode
localityStringLocality
statusStringOK when this address has no errors
errorsArrayError codes for this suggestion, for example [302]. Needs the error-codes permission
adm1_code … adm5_code, adm1_name … adm5_nameStringAdministrative divisions, with administrative=true. See Glossary
latitude, longitudeFloatCoordinate, with coordinate=true
property_designationStringWith property_designation=true
uuidStringWith uuid=true
deso_codeStringWith deso=true
regso_code, regso_nameStringWith regso=true
neighborhood_1_name, neighborhood_2_nameStringWith neighborhood=true

Finland

Validate Address expects the Finnish names. A Swedish name such as Mannerheimvägen 1, Helsingfors is not accepted as valid; the Finnish form (Mannerheimintie 1, Helsinki) is returned as a suggestion. Suggest Address does find addresses by their Swedish names.

Examples

A valid address

curl -G https://app-api.geposit.se/v2.0/validate/address/se \
  -H "x-api-key: {API_KEY}" \
  --data-urlencode "street=Drottninggatan 45" \
  --data-urlencode "postcode=11121" \
  --data-urlencode "locality=Stockholm"
{
  "version": "2.0",
  "response_time": 0.0135,
  "query": {
    "street": "Drottninggatan 45",
    "postcode": "11121",
    "locality": "Stockholm"
  },
  "interpretation": {
    "street": "drottninggatan",
    "street_number": "45",
    "postcode": "11121",
    "locality": "stockholm"
  },
  "is_valid": true,
  "status": 302,
  "match": [
    {
      "address_type": "NB",
      "street": "Drottninggatan",
      "street_number": "45",
      "postcode": "11121",
      "locality": "Stockholm",
      "status": "OK"
    }
  ]
}

The same request with response_format=xml:

<Validate>
  <version>2.0</version>
  <response_time>0.0068</response_time>
  <query>
    <street>Drottninggatan 45</street>
    <postcode>11121</postcode>
    <locality>Stockholm</locality>
  </query>
  <interpretation>
    <street>drottninggatan</street>
    <street_number>45</street_number>
    <postcode>11121</postcode>
    <locality>stockholm</locality>
  </interpretation>
  <is_valid>true</is_valid>
  <status>302</status>
  <match>
    <address_type>NB</address_type>
    <street>Drottninggatan</street>
    <postcode>11121</postcode>
    <locality>Stockholm</locality>
    <status>OK</status>
    <street_number>45</street_number>
  </match>
</Validate>

A wrong postcode

The address exists, but in postcode 11121, not 11122:

curl -G https://app-api.geposit.se/v2.0/validate/address/se \
  -H "x-api-key: {API_KEY}" \
  --data-urlencode "street=Drottninggatan 45" \
  --data-urlencode "postcode=11122" \
  --data-urlencode "locality=Stockholm"
{
  "version": "2.0",
  "response_time": 0.0172,
  "query": {
    "street": "Drottninggatan 45",
    "postcode": "11122",
    "locality": "Stockholm"
  },
  "interpretation": {
    "street": "drottninggatan",
    "street_number": "45",
    "postcode": "11122",
    "locality": "stockholm"
  },
  "is_valid": false,
  "status": 300,
  "errors": {
    "302": "Postal code is incorrect"
  },
  "suggestions": [
    {
      "address_type": "NB",
      "street": "Drottninggatan",
      "street_number": "45",
      "postcode": "11121",
      "locality": "Stockholm",
      "status": "OK",
      "errors": [302]
    }
  ]
}

With suggestions=false the same request returns only the verdict:

{
  "version": "2.0",
  "response_time": 0.0159,
  "query": { "street": "Drottninggatan 45", "postcode": "11122", "locality": "Stockholm" },
  "interpretation": { "street": "drottninggatan", "street_number": "45", "postcode": "11122", "locality": "stockholm" },
  "is_valid": false,
  "status": 200,
  "errors": {
    "302": "Postal code is incorrect"
  }
}

In XML, the top-level errors are repeated <errors><code>302</code><message>Postal code is incorrect</message></errors> elements, and a suggestion's errors are <errors>302</errors>.

A misspelled street

curl -G https://app-api.geposit.se/v2.0/validate/address/se \
  -H "x-api-key: {API_KEY}" \
  --data-urlencode "street=Drotninggatan 45" \
  --data-urlencode "postcode=11121" \
  --data-urlencode "locality=Stockholm"
{
  "is_valid": false,
  "status": 300,
  "errors": {
    "202": "Street address had misspellings, errors or was incorrect",
    "260": "Missing letter in the street number"
  },
  "suggestions": [
    {
      "address_type": "NB",
      "street": "Drottninggatan",
      "street_number": "45",
      "postcode": "11121",
      "locality": "Stockholm",
      "status": "OK",
      "errors": [202]
    },
    {
      "address_type": "NB",
      "street": "Drottninggatan",
      "street_number": "45",
      "letter": "T",
      "postcode": "11121",
      "locality": "Stockholm",
      "errors": [202, 260]
    }
  ]
}

(version, response_time, query and interpretation left out.)

Administrative divisions and coordinate

Add administrative=true&coordinate=true to the first example (needs both permissions). The match then includes:

{
  "address_type": "NB",
  "street": "Drottninggatan",
  "street_number": "45",
  "postcode": "11121",
  "locality": "Stockholm",
  "adm1_code": "01",
  "adm2_code": "0180",
  "adm3_code": "018001",
  "adm4_code": "215020",
  "adm5_code": "018001",
  "adm1_name": "Stockholm",
  "adm2_name": "Stockholm",
  "adm3_name": "Stockholms domkyrkoförsamling",
  "adm4_name": "Stockholms domkyrkodistrikt",
  "adm5_name": "Stockholms domkyrkoförs.",
  "latitude": 59.33245,
  "longitude": 18.06225,
  "status": "OK"
}

Did this page help you?