Skip to content
No description, website, or topics provided.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
dist
src
.gitignore
.travis.yml
package-lock.json
package.json
readme.md
tsconfig.json

readme.md

Build Status GitHub issues npm GitHub stars

swiss-zipcodes

Purpose

Search and validate swiss zip codes

Usage

npm i --save swiss-zipcodes
# or
npm install https://github.com/creadi/swiss-zipcodes

and

import { search, validate, cityFromZip } from 'swiss-zipcodes'

search()

Search by any combination of:

  • zip (number)
  • canton (string)
  • commune (string)
search({ zip: 4054 })

returns

[
  {
    zip: 4054,
    canton: 'BS',
    commune: 'Basel'
  }
]

validate()

Validate zip code as number or string

validate(4054)

// or

validate('4054')

returns true

cityFromZip()

Get an array of commune names from a zip code ( number or string)

cityFromZip(4052)

// or

cityFromZip('4052')

returns

[
  'Basel',
  'Münchenstein'
]

Data

Data from Federal Statistics.

Direct link to excel sheet.

Update 1.0.6

Add data from geonames extraction

You can’t perform that action at this time.