Global

Methods

(static) getAddresses(options, queryopt, callback)

Returns a list of addresses, it is possible to filter on postcode (P6-formatted) and number. Instance of GET /addresses.

Parameters:
Name Type Attributes Description
options Object

Options for performing the API call and influencing the callback.

Properties
Name Type Attributes Description
apiKey String

The API-token to access the API.

returnRateLimit Boolean <optional>

If set to true, the callback will be invoked with an extra result containing an object with the limit and the remaining amount of API calls.

followNext Boolean <optional>

If set to true, the pagination links will be followed an a single response will be returned.

query Object <optional>

Containing the query for calling the API. Must be an empty object if no filtering is needed.

Properties
Name Type Attributes Description
postcode String <optional>

Must contain the keys postcode (P6-formatted).

number Number <optional>

The streetnumber of the address that must be queried. It is ignored when no postcode is given.

latitude Number <optional>

The latitude from which the distance to the addresses is calculated. It is ignored when no longitude is given.

longitude Number <optional>

The longitude from which the distance to the addresses is calculated. It is ignored when no latitude is given.

sort String <optional>

At this moment the only possible value is 'distance' and it is required when using the distance functionalities. The results will be sorted on distance, when latitude and longitude are given.

callback function

A callback which is called when the API-request is finished.

Properties
Name Type Attributes Description
error Error

May contain an instance of Error, if no error occured null is responded.

result Object

Contains the response as a json in exactly the same format as provided by the API. If no results are found, null is responded.

rateLimit Object <optional>

If requested in options, an object with information about the API limits is returned. Otherwise, it will return undefined.

Since:
  • 1.2.0
Source:
Example
const postcodeApi = require('postcode-nl');

let options = {
  apiKey : 'abcdefghijklmnopQRSTUVWXYZ123',
  returnRateLimit : true
};
let query = {
  postcode: '1234AB'
};

postcodeApi.getAddresses(options, query, (error, result, rateLimit) => {
  if (!error) {
    console.log(result); // Shows the output of the API directy in the console
    console.log(rateLimit); // Shows the rateLimit information in the console
  }
});

(static) getAddressesByPostcodeAndNumber(options, query, callback)

Returns a list of addresses filtered on postcode (P6-formatted) and number. The difference with getAddresses is that filtering is required, otherwise an error is thrown. Instance of GET /addresses.

Parameters:
Name Type Description
options Object

Options for performing the API call and influencing the callback.

Properties
Name Type Attributes Description
apiKey String

The API-token to access the API.

returnRateLimit Boolean <optional>

If set to true, the callback will be invoked with an extra result containing an object with the limit and the remaining amount of API calls.

query Object

Containing the query for calling the API.

Properties
Name Type Description
postcode String

Must contain the keys postcode (P6-formatted).

number Number

The streetnumber of the address that must be queried.

callback function

A callback which is called when the API-request is finished.

Properties
Name Type Attributes Description
error Error

May contain an instance of Error, if no error occured null is responded.

result Object

Contains the response as a json in exactly the same format as provided by the API. If no results are found, null is responded.

rateLimit Object <optional>

If requested in options, an object with information about the API limits is returned. Otherwise, it will return undefined.

Since:
  • 1.2.0
Source:
Example
const postcodeApi = require('postcode-nl');

let options = {
  apiKey : 'abcdefghijklmnopQRSTUVWXYZ123',
  returnRateLimit : true
};
let query = {
  postcode: '1234AB',
  number: 10
};

postcodeApi.getAddressesByPostcodeAndNumber(options, query, (error, result, rateLimit) => {
  if (!error) {
    console.log(result); // Shows the output of the API directy in the console
    console.log(rateLimit); // Shows the rateLimit information in the console
  }
});

(static) getPostcodes(options, queryopt, callback)

Returns a list of postcodes (P6), optionally filtered on postcode area. Instance of GET /postcodes.

Parameters:
Name Type Attributes Description
options Object

Options for performing the API call and influencing the callback.

Properties
Name Type Attributes Description
apiKey String

The API-token to access the API.

returnRateLimit Boolean <optional>

If set to true, the callback will be invoked with an extra result containing an object with the limit and the remaining amount of API calls.

followNext Boolean <optional>

If set to true, the pagination links will be followed an a single response will be returned.

query Object <optional>

Containing the query for calling the API. Must be an empty object if no filtering is needed.

Properties
Name Type Attributes Description
postcodeArea String <optional>

The postcode area to be queried, formatted as P4.

latitude Number <optional>

The latitude from which the distance to the addresses is calculated. It is ignored when no longitude is given.

longitude Number <optional>

The longitude from which the distance to the addresses is calculated. It is ignored when no latitude is given.

sort String <optional>

At this moment the only possible value is 'distance' and it is required when using the distance functionalities. The results will be sorted on distance, when latitude and longitude are given.

callback function

A callback which is called when the API-request is finished.

Properties
Name Type Attributes Description
error Error

May contain an instance of Error, if no error occured null is responded.

result Object

Contains the response as a json in exactly the same format as provided by the API. If no results are found, null is responded.

rateLimit Object <optional>

If requested in options, an object with information about the API limits is returned. Otherwise, it will return undefined.

Since:
  • 1.2.0
Source:
Example
const postcodeApi = require('postcode-nl');

let options = {
  apiKey : 'abcdefghijklmnopQRSTUVWXYZ123',
  returnRateLimit : true
};
let postcodeArea = '1234';

postcodeApi.getPostcodeArea(options, id, (error, result, rateLimit) => {
  if (!error) {
    console.log(result); // Shows the output of the API directy in the console
    console.log(rateLimit); // Shows the rateLimit information in the console
  }
});

(static) getSingleAddress(options, id, callback)

To search for an address based on the BAG identifier of the object. Instance of GET /addresses.

Parameters:
Name Type Description
options Object

Options for performing the API call and influencing the callback.

Properties
Name Type Attributes Description
apiKey String

The API-token to access the API.

returnRateLimit Boolean <optional>

If set to true, the callback will be invoked with an extra result containing an object with the limit and the remaining amount of API calls.

id String

The BAG identifier of the object.

callback function

A callback which is called when the API-request is finished.

Properties
Name Type Attributes Description
error Error

May contain an instance of Error, if no error occured null is responded.

result Object

Contains the response as a json in exactly the same format as provided by the API. If no results are found, null is responded.

rateLimit Object <optional>

If requested in options, an object with information about the API limits is returned. Otherwise, it will return undefined.

Since:
  • 1.1.0
Source:
Example
const postcodeApi = require('postcode-nl');

let options = {
  apiKey : 'abcdefghijklmnopQRSTUVWXYZ123',
  returnRateLimit : true
};
let id = '0268200000075156';

postcodeApi.getSingleAddress(options, id, (error, result, rateLimit) => {
  if (!error) {
    console.log(result); // Shows the output of the API directy in the console
    console.log(rateLimit); // Shows the rateLimit information in the console
  }
});

(static) getSinglePostcode(options, postcode, callback)

Returns the details of one P6 postcode. Instance of GET /postcodes.

Parameters:
Name Type Description
options Object

Options for performing the API call and influencing the callback.

Properties
Name Type Attributes Description
apiKey String

The API-token to access the API.

returnRateLimit Boolean <optional>

If set to true, the callback will be invoked with an extra result containing an object with the limit and the remaining amount of API calls.

postcode String

The postcode to query, formatted in P6.

callback function

A callback which is called when the API-request is finished.

Properties
Name Type Attributes Description
error Error

May contain an instance of Error, if no error occured null is responded.

result Object

Contains the response as a json in exactly the same format as provided by the API. If no results are found, null is responded.

rateLimit Object <optional>

If requested in options, an object with information about the API limits is returned. Otherwise, it will return undefined.

Since:
  • 1.0.0
Source:
Example
const postcodeApi = require('postcode-nl');

let options = {
   apiKey : 'abcdefghijklmnopQRSTUVWXYZ123'
};
let postcode = '1234AB';

postcodeApi.getSinglePostcode(options, postcode, (error, result) => {
 if (!error) {
  console.log(result); // Shows the json-output of the API directy in the console
 }
});