The JSON API for postal codes, area codes and places. Send a postal code, an area code or a place name and get back the place, the country and all related postal codes and area codes.

Buy a developer token You need a developer token to send requests to the API. Sign in to get one.
Sign in

Every request needs a developer token. Pass the token in the X-Api-Token header, as Authorization: Bearer … or as the token parameter.

Endpoint

Country and search term go either in the path or as URL parameters. Both forms return the same JSON response.

https://www.postleitzahl.net/api/{country}/{query}
https://www.postleitzahl.net/api?country={country}&q={query}
{
    "status": "success",
    "country": "Canada",
    "countryCode": "CA",
    "place": "Conception Bay South",
    "postcode": [
        "A1W",
        "A1X"
    ],
    "areacode": "709",
    "query": "A1W",
    "type": "postcode"
}

Query types

The API detects what you are looking for: input in the postal code format of the country is searched as a postal code first, other digits as an area code, everything else as a place name. If there is no match, the other types are checked. Use the type parameter to set the type yourself.

Example Type Meaning
https://www.postleitzahl.net/api/de/32423orhttps://www.postleitzahl.net/api?country=de&q=32423postcodepostal code
https://www.postleitzahl.net/api/de/0571orhttps://www.postleitzahl.net/api?country=de&q=0571prefixtelephone area code
https://www.postleitzahl.net/api/de/Mindenorhttps://www.postleitzahl.net/api?country=de&q=Mindenplaceplace name

Parameters

Parameter Effect
countryRequired: the two-letter country code, e.g. de, nl or gb – in the path (/api/de/32423) or as a parameter (country=de)
fieldscomma separated list of the desired fields, e.g. ?fields=place,postcode
typesets the query type: postcode, prefix or place
langlanguage of the translatable fields, e.g. ?lang=en
callbackJSONP function name
qthe search term as a parameter instead of in the path: /api?country=de&q=Minden

Localization

Use the lang parameter to choose the language of the response. The country name is translated; place names stay in their original form. Without lang, the Accept-Language header of your request applies; unknown values are ignored.

de ar be bg bs ca cs da el en es et fa fi fr ga he hi hr hu hy id is it ja ka km ko lo lt lv mk mn ms mt ne nl no pl pt ro ru sk sl sq sr sv th tr uk vi zh

curl "https://www.postleitzahl.net/api/de/32423?lang=en"
{ "status": "success", "country": "Germany", "countryCode": "DE", "place": "Minden", "postcode": "32423", "query": "32423", "type": "postcode" }

Response fields

Field Content Example
statussuccess or fail"success"
querythe submitted query"10000"
typedetected query type: postcode, prefix or place"postcode"
countrycountry, translatable via lang"Germany"
countryCodecountry code per ISO 3166-1"CA"
placeplace name, a list if there are several"Minden"
postcodepostal code of the place, a list if there are several["32423","32425","32427","32429"]
areacodetelephone area code of the place, a list if there are several"0571"
messageonly with status fail: reason"not found"

Usage limit

With a developer token you can send 20 requests per minute. Every response shows in its headers how many requests are left in the current minute (X-Rl) and in how many seconds the next minute starts (X-Ttl).

{
  "status": "fail",
  "code": 1008,
  "message": "rate limit exceeded, 20 requests per minute",
  "query": "10000"
}

Error responses

HTTP Code message Cause
4011001missing api tokenno token supplied
4011002invalid api tokentoken unknown or invalid
4001003missing or unknown countryThe country code is missing or unknown.
4001004missing queryno query supplied
4001005query too longmore than 80 characters
4041006not foundno match
4291007try-out limit exceeded, 10 requests per 5 minutes without api tokenTry-out limit reached
4291008rate limit exceeded, 20 requests per minuteRequest limit reached – available again from the next minute
4291009try-out banned for 60 minutes, limit exceeded repeatedlylimit exceeded repeatedly

Examples

curl -H "X-Api-Token: plz_…" https://www.postleitzahl.net/api/ca/10000
curl -H "X-Api-Token: plz_…" "https://www.postleitzahl.net/api/gb/SW1A%201AA"
curl -H "X-Api-Token: plz_…" "https://www.postleitzahl.net/api/de/Minden?fields=place,postcode"
curl "https://www.postleitzahl.net/api?country=de&q=0571&type=prefix&token=plz_…"

Data sources

Municipality keys, NUTS codes and population figures come from the municipality register and the NUTS classification of Eurostat. The assignment of postal codes to regions follows the official TERCET table of the European Commission.