README
Postcoder geocoding
Simple node wrapper for geocoding endpoints of the Postcoder API from Allies.
Find out more about the geocoding API and sign up for a trial to get an API key
The API allows searching for forward and reverse UK geocoding. Note: This is a paid for API
For full developer documentation
Install
npm install postcoder-geocoding
https://www.npmjs.com/package/postcoder-geocoding
Basic usage
const geocoding = require('postcoder-geocoding');
geocoding.init('[YOUR API KEY HERE]');
geocoding.geoFromPostcode('NR14 7PZ', (result, error) => {
if (error) {
console.log(error);
} else {
// returns an array of locations containing latitude and longitude
console.log(result);
}
});
Also returns OS Eastings and Northings.
Return street level data as well as latitude and longitude
const geocoding = require('postcoder-geocoding');
geocoding.init('[YOUR API KEY HERE]');
geocoding.searchStreetGeo('NR14 7PZ', (result, error) => {
if (error) {
console.log(error);
} else {
// returns an array of locations containing street level data,
// latitude and longitude
console.log(result);
}
});
Returns street name, county name and more alongside the same fields as the geoFromPostcode method, full list of fields
Reverse geocoding (street level data)
const geocoding = require('postcoder-geocoding');
geocoding.init('[YOUR API KEY HERE]');
// Passing in latitude, longitude and radius (metres)
geocoding.streetFromGeo(
'52.5859714116',
'1.3492192897',
'50',
(result, error) => {
if (error) {
console.log(error);
} else {
// returns an array of locations containing street level data,
// latitude and longitude
console.log(result);
}
});
Check status of your API key
Returns an object with information about number of credits on your account and more
const geocoding = require('postcoder-geocoding');
geocoding.init('[YOUR API KEY HERE]');
geocoding.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);
}
});
Note about support
This is a community supported package, maintained by Stephen Keable