MF
mfix22/what3words
:round_pushpin: Node client package for what3words REST API
what3words 
Node.js library for what3words API
Getting started
$ npm install --save what3wordsUsage
Node.js
var w3w = require('what3words');Config
var options = {
key : '<YOUR_API_KEY_HERE>',
lang : 'en',
display : 'terse'
}
w3w.config(options);options
All config options can be overidden in function calls. Each config option will be included in every call that is not
overidden by the specific function call.
key(required) - your API key (get yours here)lang(optional) - a supported w3w address language:en(the default),de, ru, sv, pt, sw, it, fr, esortr.format(optional) - return data format type. Can bejson(the default),geojsonorxmldisplay(optional) - return display type. Can befull(the default) orterse
Functions
For each of the functions below, all options are passed in the first function parameter. If a second parameter is included, that will be the functions callback. If not, the function will return a Promise.
forward(options[, callback])
options
addr(required) - a 3 word address as a stringlang(optional) - a supported w3w address language (see Config)format(optional) - return data format type (see Config)display(optional) - return display type (see Config)
reverse(options[, callback])
options
coords(required) - coordinates as a comma separated string of latitude and longitudelang(optional) - a supported w3w address language (see Config)format(optional) - return data format type (see Config)display(optional) - return display type (see Config)
autosuggest(options[, callback])
options
addr(required) - a 3 word address as a stringlang(optional) - a supported w3w address language (see Config)format(optional) - return data format type (see Config)display(optional) - return display type (see Config)focus(optional) - a location, specified as a latitude,longitude used to refine the results.clip(optional) - Restricts results to those within a geographical area. If omitted defaults toclip=none.
standardblend(options[, callback])
options
addr(required) - a 3 word address as a stringlang(optional) - a supported w3w address language (see Config)format(optional) - return data format type (see Config)focus(optional) - a location, specified as a latitude,longitude used to refine the results.
grid(options[, callback])
options
bbox(required) - Bounding box, specified by the northeast and southwest corner coordinates, for which the grid should be returnedformat(optional) - return data format type (see Config)
languages(options[, callback])
options
format(optional) - return data format type (see Config)
Example
var w3w = require('what3words');
w3w.config({
key : '<INSERT_YOUR_API_KEY>',
lang : 'en'
});
w3w.forward({
addr : 'steep.sober.potato',
display : 'terse'
}, function (err, res){
if (err) console.log(err);
else console.log(JSON.stringify(res, null, 4));
});Test
$ npm testOn this page
Languages
JavaScript100.0%
MIT License
Created June 27, 2016
Updated March 1, 2023