what3words API
Node.js library forGetting started
$ npm install --save what3words
Usage
Node.js
var w3w = ;
Config
var options = key : '<YOUR_API_KEY_HERE>' lang : 'en' display : 'terse' w3w;
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, es
ortr
.format
(optional) - return data format type. Can bejson
(the default),geojson
orxml
display
(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 = ; w3w; w3w;
Test
$ npm test