npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

german-metadata

v2.0.1

Published

A js package for easy consumption of german metadata such as city names, postcodes, phone prefixes and states.

Downloads

171

Readme

german-metadata

A js package for easy consumption of german metadata such as city names, postcodes, phone prefixes and states in german language with given special characters. This package uses data from OpenStreetMap and German GovData, please see chapter Licensing Information for more details.


Usage

npm install german-metadata

City objects

The german meta data package is based on an array that consists of single city objects and a set of functions that allows to query them. Here is a basic city object sample for Frankfurt am Main. If a functions states to return a city object, this is what you will get.

{
  "name": "Düren",
  "postalCodes": ["52349", "52351", "52353", "52355"],
  "state": "Nordrhein-Westfalen",
  "phonePrefix": 2421,
  "identifiable": {
    "name": "dueren",
    "state": "nordrhein7westfalen"
  }
}

Samples

const germanMetadata = require('german-metadata');

// sample cityByName
const cityByName = germanMetadata.getCityByName('Düren');

// sample postalCodesByState
const postalCodesByState = germanMetadata.getPostalCodesByState('Hessen');

// sample isPostalCodeValid
const isPostalCodeValid = germanMetadata.isPostalCodeValid('52349');

Samples for each function are provided in the chapter All functions with samples

All functions with samples

Jump to function:

cityByName

Returns a city object by a given city name.

const cityByName = germanMetadata.getCityByName('Düren');
// -> {"name":"Düren",postalCodes[...],...}

citiesByPostalCode

Returns an array of city objects by a given postal code.

const citiesByPostalCode = germanMetadata.getCitiesByPostalCode('52349');
// -> [{"name":"Düren",postalCodes[...],...},...]

citiesByState

Returns an array of city objects by a given state.

const citiesByState = germanMetadata.getCitiesByState('Hessen');
// -> [{"name":"Frankfurt am Main",postalCodes[...],...},...]

citiesByPhonePrefix

Returns an array of city objects by a given phone prefix.

const citiesByPhonePrefix = germanMetadata.getCitiesByPhonePrefix(641);
// -> [{"name":"Gießen",postalCodes[...],...},...]

citiesByPhoneNumber

Returns an array of city objects by a given phone number.

const citiesByPhoneNumber = germanMetadata.getCitiesByPhoneNumber('069123456');
// -> [{"name":"Frankfurt am Main",postalCodes[...],...},...]

postalCodesByCityName

Returns an array of postal codes by a given city name.

const postalCodesByCityName = germanMetadata.getPostalCodesByCityName('Düren');
// -> ["52349","52351","52353","52355"]

postalCodesByState

Returns an array of postal codes by a given state.

const postalCodesByState = germanMetadata.getPostalCodesByState('Hessen');
// -> ["60306","60308","60310","60311","60313",...]

postalCodesByPhonePrefix

Returns an array of postal codes by a given phone prefix.

const postalCodesByPhonePrefix = germanMetadata.getPostalCodesByPhonePrefix(641);
// -> ["35390","35392","35394","35396","35398"]

postalCodesByPhoneNumber

Returns an array of postal codes by a given phone number.

const postalCodesByPhoneNumber = germanMetadata.getPostalCodesByPhoneNumber('069123456');
// -> ["60306","60308","60310","60311","60313",...]

stateByCityName

Returns a state by a given city name.

const stateByCityName = germanMetadata.getStateByCityName('München');
// -> "Bayern"

stateByPostalCode

Returns a state by a given postal code.

const stateByPostalCode = germanMetadata.getStateByPostalCode('80331');
// -> "Bayern"

stateByPhonePrefix

Returns a state by a given phone prefix.

const stateByPhonePrefix = germanMetadata.getStateByPhonePrefix(89);
// -> "Bayern"

stateByPhoneNumber

Returns a state by a given phone number.

const stateByPhoneNumber = germanMetadata.getStateByPhoneNumber('069123456');
// -> "Hessen"

phonePrefixByCityName

Returns a phone prefix by a given city name.

const phonePrefixByCityName = germanMetadata.getPhonePrefixByCityName('Düren');
// -> 2421

phonePrefixesByPostalCode

Returns an array of phone prefixes by a given postal code.

const phonePrefixesByPostalCode = germanMetadata.getPhonePrefixesByPostalCode('52349');
// -> [2421,2422,2423,2424,2425,2426,2427,2428,2429]

phonePrefixesByState

Returns an array of phone prefixes by a given state.

const phonePrefixesByState = germanMetadata.getPhonePrefixesByState('Hessen');
// -> [69,641,...]

phonePrefixByPhoneNumber

Returns a phone prefix by a given phone number.

const phonePrefixByPhoneNumber = germanMetadata.getPhonePrefixByPhoneNumber('069123456');
// -> 69

isCityNameValid

Returns true if a given city name is valid.

const isCityNameValid = germanMetadata.isCityNameValid('Düren');
// -> true

isPostalCodeValid

Returns true if a given postal code is valid.

const isPostalCodeValid = germanMetadata.isPostalCodeValid('52349');
// -> true

isStateValid

Returns true if a given state is valid.

const isStateValid = germanMetadata.isStateValid('Hessen');
// -> true

isPhonePrefixValid

Returns true if a given phone prefix is valid.

const isPhonePrefixValid = germanMetadata.isPhonePrefixValid(641);
// -> true

ALL_CITIES

This constant contains an array of all cities in germany. Each city is represented by a city object.

const ALL_CITIES = germanMetadata.ALL_CITIES;
// -> [{"name":"Düren",postalCodes[...],...},...]

ALL_CITY_NAMES

This constant contains an array of all city names in germany.

const ALL_CITY_NAMES = germanMetadata.ALL_CITY_NAMES;
// -> ["Düren","Aachen",...]

ALL_POSTAL_CODES

This constant contains an array of all postal codes in germany.

const ALL_POSTAL_CODES = germanMetadata.ALL_POSTAL_CODES;
// -> ["52349","52351","52353","52355",...]

ALL_STATES

This constant contains an array of all states in germany.

const ALL_STATES = germanMetadata.ALL_STATES;
// -> ["Baden-Württemberg","Bayern","Berlin","Brandenburg",...]

ALL_PHONE_PREFIXES

This constant contains an array of all phone prefixes in germany.

const ALL_PHONE_PREFIXES = germanMetadata.ALL_PHONE_PREFIXES;
// -> [2421,2422,2423,2424,2425,2426,2427,2428,2429,...]

Licensing Information

Make sure to apply propper attribution when using this package in public facing projects. As this project is using data from OpenStreetMap and German GovData Portal, the following licensing information applies:

Project Code License

As per the terms of this project's license, the project code is released under the MIT License. You can find the full text of the MIT License in the LICENSE file within this repository.

Attribution to OpenStreetMap

This package is using data provided by OpenStreetMap based on the Open Database License (ODbL).

Attribution to GovData

This package is using data provided by GovData based on the German Data License (dl-de-by-2.0).