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

node-postcode

v1.0.1

Published

API wrapper for the Postcode.nl APIs

Downloads

176

Readme

node-postcode Build Status

API wrapper for the Postcode.nl API.

Features:

  • gathering addresses using postcode, house number and house number addition
  • verifying address data

Example

var Postcode = require("node-postcode").Postcode;
var client = new Postcode({
  key: /* your API key */,
  secret: /* your API secret */
});

client.address("1111AA", 1)
.then(function (addressDetails) {
  /* addressDetails contains information about the address (if valid) */
});

Installation

$ npm i node-postcode

You can retrieve your own API credentials over here (only available in Dutch at time of writing).

API Reference

PostcodeClient (Class)

The client exposing the address and signal functions

new PostcodeClient(options)

  • Arguments

    • options - An object containing key and secret (required)
  • Example

    new PostcodeClient({
      key: "YOUR_KEY",
      secret: "YOUR_SECRET"
    });
  • Returns

    An instance of the PostcodeClient class

PostcodeClient.address(postcode, number[, numberAddition])

  • Arguments

    • postcode - required A postcode in the format 1111AA (4 digits, 2 letters). Can not start with a 0. Letters do not have to be in uppercase as these will be forced to uppercase when making the API call. 1111 AA is also accepted, as spaces in the string are removed
    • number - required An integer in the range of 0 - 99999
    • numberAddition - An addition to the number. Can indicate which apartment, room, office
  • Example

    client.address("1111AA", 1)
    .then(function (addressDetails) {
      /* 
        addressDetails = { street: 'Diemerkade',
          houseNumber: 1,
          houseNumberAddition: '',
          postcode: '1111AA',
          city: 'Diemen',
          municipality: 'Diemen',
          province: 'Noord-Holland',
          rdX: 125497,
          rdY: 483727,
          latitude: 52.34067657,
          longitude: 4.95429501,
          bagNumberDesignationId: '0384200000016667',
          bagAddressableObjectId: '0384010000016511',
          addressType: 'building',
          purposes: [ 'residency' ],
          surfaceArea: 64,
          houseNumberAdditions: [ '' ] }
      */
    })
    .catch(function (err) {
      /* Err will contain the error returned by either the API or the HTTP request */
    });
  • Returns

    Returns a Promise. When successful, .then(function (addressDetails) {}) is returned. The format and explanation of the returned data can be found at the official documentation of the API. When an error occurs, .catch(function (err) {}) contains the error given. When err.code == "PostcodeNl_Service_PostcodeAddress_AddressNotFoundException", the postcode and number supplied do not resolve to an address.

    When numberAddition is supplied, but houseNumberAddition is an empty string, the numberAddition can not be verified, but this does not mean that mail sent to this address will not be accepted.

Tests

To run the tests created for this plugin, run the following command:

$ npm test

To make sure all tests succeed, make sure that you set the environment variables API_KEY and API_SECRET to their correct values. Errors will be thrown if the credentials are not valid