deutsche-postdeprecated

German post office postal code utilities.

Usage no npm install needed!

<script type="module">
  import deutschePost from 'https://cdn.skypack.dev/deutsche-post';
</script>

README

deutsche-post

German post office postal code utilities. Inofficial, using an endpoint by Deutsche Post. Ask them for permission before using this module in production.

npm version Build Status Greenkeeper badge dependency status license chat on gitter

Installation

npm install --save deutsche-post

Usage

const post = require('deutsche-post')

municipalities(postalCode)

postalCode must be a valid german postal code String like 14050 or 04936. Returns a Promise.

post.municipalities('04936').then(…)
[
    {
        "postal-code": "04936",
        "municipality-addition": "",
        "municipality": "Hillmersdorf"
    },
    {
        "postal-code": "04936",
        "municipality-addition": "b Schlieben",
        "municipality": "Naundorf"
    },
    {
        "postal-code": "04936",
        "municipality-addition": "",
        "municipality": "Proßmarke"
    }
    // …
]

or

post.municipalities('14057').then(…)
[
    {
        "district": "Charlottenburg",
        "postal-code": "14057",
        "municipality": "Berlin"
    },
    {
        "district": "Westend",
        "postal-code": "14057",
        "municipality": "Berlin"
    }
]

postalCodeShapes(postalCode)

postalCode must be a valid german postal code, as a number like 10969 or a ECQL query string like strToLowerCase(code) like '109%'. Returns a Promise.

post.postalCodeShapes('10969')
.then(console.log, console.error)
{
    "type": "FeatureCollection",
    "totalFeatures": 1,
    "features": [
        {
            "type": "Feature",
            "id": "plz_5_2015_q1.10969",
            "geometry": {
                "type": "MultiPolygon",
                "coordinates": [
                    [
                        [
                            [
                                13.405129,
                                52.508324
                            ],
                            [
                                13.405416,
                                52.508295
                            ],
                            [
                                13.407717,
                                52.506733
                            ]
                            // …
                        ]
                    ]
                ]
            },
            "geometry_name": "geom",
            "properties": {
                "code": "10969",
                "bbox": [
                    13.385739,
                    52.49588,
                    13.415268,
                    52.509257
                ]
            }
        }
    ],
    "crs": {
        "type": "name",
        "properties": {
            "name": "urn:ogc:def:crs:EPSG::4326"
        }
    },
    "bbox": [
        52.49588,
        13.385739,
        52.509257,
        13.415268
    ]
}

Contributing

If you found a bug, want to propose a feature or feel the urge to complain about your life, feel free to visit the issues page.