Node package to simplify the use of the Postcoder API from Allies, which offers UK and international postcode and address lookup.
npm install postcoder-address-lookupSimple node wrapper for address lookup and postcode lookup endpoints of the
Postcoder API from Allies.
Find out more about the address lookup API
and sign up for a trial to get an API key
The API allows searching for addresses around the world, using either a
postal code or fragment of an address, along with the country you want to search.
Note: This is a paid for API
For full developer documentation
Move to ES6 syntax within module.
ally the same however the getCountries() method has been removed.
npm install postcoder-address-lookup
``javascript
const addressLookup = require('postcoder-address-lookup');
addressLookup.init('[YOUR API KEY HERE]');
addressLookup.searchAddress('NR14 7PZ', 'GB', (result, error) => {
if (error) {
console.log(error);
} else {
// returns an array of addresses
console.log(result);
}
});
`
`javascript
var addressLookup = require('postcoder-address-lookup');
addressLookup.init('[YOUR API KEY HERE]');
addressLookup.searchAddressGeo('NR14 7PZ', 'GB', (result, error) => {
if (error) {
console.log(error);
} else {
// returns an array of addresses, including latitude and longitude
console.log(result);
}
});
`
Extra parameters can be passed using an options object, which is
converted into the querystring of the API request.
A full list of these parameters can be found in the
developer documentation
`javascript
var addressLookup = require('postcoder-address-lookup');
var options = {
lines: 2,
addtags: 'udprn',
};
addressLookup.init('[YOUR API KEY HERE]', options);
addressLookup.searchAddress('NR14 7PZ', 'GB', (result, error) => {
if (error) {
console.log(error);
} else {
// returns an array of addresses
console.log(result);
}
});
`
Options can also be passed after the init using setOptions()
`javascript
var addressLookup = require('postcoder-address-lookup');
addressLookup.init('[YOUR API KEY HERE]');
var options = {
lines: 2,
addtags: 'udprn',
};
addressLookup.setOptions(options);
`
For the UK you can also search for street level data (No organisation names,
building names or numbers)
`javascript
var addressLookup = require('postcoder-address-lookup');
addressLookup.init('[YOUR API KEY HERE]');
addressLookup.searchStreet('NR14 7PZ', (result, error) => {
if (error) {
console.log(error);
} else {
// returns an array of street level information
console.log(result);
}
});
`
Returns an object with information about number of credits on your account and more
`javascript
var addressLookup = require('postcoder-address-lookup');
addressLookup.init('[YOUR API KEY HERE]');
addressLookup.checkStatus((result, error) => {
if (error) {
console.log(error);
} else {
// returns an object with information about number of credits
// on your account and more
console.log(result);
}
});
``
This is a community supported package, maintained by Stephen Keable