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.
npm install @micromint1npm/eius-tempore-asperiores
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"
}
}
const germanMetadata = require('@micromint1npm/eius-tempore-asperiores');
// 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
Jump to function:
- cityByName
- citiesByPostalCode
- citiesByState
- citiesByPhonePrefix
- citiesByPhoneNumber
- postalCodesByCityName
- postalCodesByState
- postalCodesByPhonePrefix
- postalCodesByPhoneNumber
- stateByCityName
- stateByPostalCode
- stateByPhonePrefix
- stateByPhoneNumber
- phonePrefixByCityName
- phonePrefixesByPostalCode
- phonePrefixesByState
- phonePrefixByPhoneNumber
- isCityNameValid
- isPostalCodeValid
- isStateValid
- isPhonePrefixValid
- ALL_CITIES
- ALL_CITY_NAMES
- ALL_POSTAL_CODES
- ALL_STATES
- ALL_PHONE_PREFIXES
Returns a city object by a given city name.
const cityByName = germanMetadata.getCityByName('Düren');
// -> {"name":"Düren",postalCodes[...],...}
Returns an array of city objects by a given postal code.
const citiesByPostalCode = germanMetadata.getCitiesByPostalCode('52349');
// -> [{"name":"Düren",postalCodes[...],...},...]
Returns an array of city objects by a given state.
const citiesByState = germanMetadata.getCitiesByState('Hessen');
// -> [{"name":"Frankfurt am Main",postalCodes[...],...},...]
Returns an array of city objects by a given phone prefix.
const citiesByPhonePrefix = germanMetadata.getCitiesByPhonePrefix(641);
// -> [{"name":"Gießen",postalCodes[...],...},...]
Returns an array of city objects by a given phone number.
const citiesByPhoneNumber = germanMetadata.getCitiesByPhoneNumber('069123456');
// -> [{"name":"Frankfurt am Main",postalCodes[...],...},...]
Returns an array of postal codes by a given city name.
const postalCodesByCityName = germanMetadata.getPostalCodesByCityName('Düren');
// -> ["52349","52351","52353","52355"]
Returns an array of postal codes by a given state.
const postalCodesByState = germanMetadata.getPostalCodesByState('Hessen');
// -> ["60306","60308","60310","60311","60313",...]
Returns an array of postal codes by a given phone prefix.
const postalCodesByPhonePrefix = germanMetadata.getPostalCodesByPhonePrefix(641);
// -> ["35390","35392","35394","35396","35398"]
Returns an array of postal codes by a given phone number.
const postalCodesByPhoneNumber = germanMetadata.getPostalCodesByPhoneNumber('069123456');
// -> ["60306","60308","60310","60311","60313",...]
Returns a state by a given city name.
const stateByCityName = germanMetadata.getStateByCityName('München');
// -> "Bayern"
Returns a state by a given postal code.
const stateByPostalCode = germanMetadata.getStateByPostalCode('80331');
// -> "Bayern"
Returns a state by a given phone prefix.
const stateByPhonePrefix = germanMetadata.getStateByPhonePrefix(89);
// -> "Bayern"
Returns a state by a given phone number.
const stateByPhoneNumber = germanMetadata.getStateByPhoneNumber('069123456');
// -> "Hessen"
Returns a phone prefix by a given city name.
const phonePrefixByCityName = germanMetadata.getPhonePrefixByCityName('Düren');
// -> 2421
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]
Returns an array of phone prefixes by a given state.
const phonePrefixesByState = germanMetadata.getPhonePrefixesByState('Hessen');
// -> [69,641,...]
Returns a phone prefix by a given phone number.
const phonePrefixByPhoneNumber = germanMetadata.getPhonePrefixByPhoneNumber('069123456');
// -> 69
Returns true if a given city name is valid.
const isCityNameValid = germanMetadata.isCityNameValid('Düren');
// -> true
Returns true if a given postal code is valid.
const isPostalCodeValid = germanMetadata.isPostalCodeValid('52349');
// -> true
Returns true if a given state is valid.
const isStateValid = germanMetadata.isStateValid('Hessen');
// -> true
Returns true if a given phone prefix is valid.
const isPhonePrefixValid = germanMetadata.isPhonePrefixValid(641);
// -> true
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[...],...},...]
This constant contains an array of all city names in germany.
const ALL_CITY_NAMES = germanMetadata.ALL_CITY_NAMES;
// -> ["Düren","Aachen",...]
This constant contains an array of all postal codes in germany.
const ALL_POSTAL_CODES = germanMetadata.ALL_POSTAL_CODES;
// -> ["52349","52351","52353","52355",...]
This constant contains an array of all states in germany.
const ALL_STATES = germanMetadata.ALL_STATES;
// -> ["Baden-Württemberg","Bayern","Berlin","Brandenburg",...]
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,...]
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:
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.
This package is using data provided by OpenStreetMap based on the Open Database License (ODbL).
- OpenStreetMap: https://www.openstreetmap.org
This package is using data provided by GovData based on the German Data License (dl-de-by-2.0).
- GovData: https://www.govdata.de