Product
Introducing License Enforcement in Socket
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
swiss-address-js
Advanced tools
Allows to query for 🇨🇭 addresses with ease.
swiss-address-js is a JavaScript library that allows you to query for swiss addresses with ease. It uses the API of Swiss Post fetch latest building addresses. It is written in TypeScript and can be used in any JavaScript environment.
This project is not affiliated with Swiss Post. It is an unofficial API wrapper for the Address Webservices API. Use at your own risk. We are not responsible for any damage caused by the use of this library.
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.
Please make sure you have installed the following tools:
And a package manager of your choice:
Next, you need to create a new account at Swiss Post and request an API key for a technical user. You will need the username and password to use this library.
Install the package via npm:
npm install swiss-address-js --save
or via yarn:
yarn add swiss-address-js
import AddressService from 'swiss-address-js';
// Create a new instance
const {swissPostOpenData, addresses} = new AddressService('your-username', 'your-password');
// Find street names by postal code
swissPostOpenData.getStreetNamesByPostalCode('9436');
// Find street names by postal code and street name
swissPostOpenData.getStreetByPostalCodeAndStreetName('9436','Kapfstrasse');
// Find buildings by postal code and street name
swissPostOpenData.getBuildingsByPostalCodeAndStreet('9435','Gutenbergstrasse');
// Search for zip codes
const zipCodes = await addresses.findTownNameByZipCode('8000')
// Search for street names beginning with 'A'
const streetNames = await addresses.findStreetsByTown('A', '8000', 'Zürich')
// Search for house numbers beginning with 1, in towns with zip code beginning with "80" and name "Zürich" lying in a street called "Alte Landstrasse"
const buildingNumbers = await addresses.findBuildingNumbersByStreet('1', '80', 'Zürich', 'Alte Landstrasse')
In the vast realm of code, where ideas intertwine and innovation knows no bounds, I find myself continually amazed by the unwavering spirit of collaboration that defines the open source community. It's a world where developers, like you and me, share their creations, their insights, and their expertise with an unparalleled generosity. Countless times, whether through serendipitous discovery or through meticulous research, I've stumbled upon remarkable projects that have enriched my own journey as a developer.
Recognizing the profound impact that the open source community has had on my own growth, I've made a personal commitment to give back to this tapestry of ingenuity. The code is licensed under the APGL license, which means that you're free to use, remix, and build upon it for non-commercial purposes. It's my way of extending the thread of collaboration that binds us as developers.
However, I also understand the diverse needs that drive us in this community. If you're considering utilizing this project for commercial purposes, I invite you to reach out. While there isn't a fixed license model in place, I believe in the power of optimism and negotiation. Let's work together to find a solution that aligns with your goals while respecting the effort and intent behind this work.
Tests are written with jest. You can run them with the following command:
npm run test
FAQs
Allows querying for 🇨🇭 addresses using Swiss Post data
The npm package swiss-address-js receives a total of 2 weekly downloads. As such, swiss-address-js popularity was classified as not popular.
We found that swiss-address-js demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
Product
We're launching a new set of license analysis and compliance features for analyzing, managing, and complying with licenses across a range of supported languages and ecosystems.
Product
We're excited to introduce Socket Optimize, a powerful CLI command to secure open source dependencies with tested, optimized package overrides.