1.0.1 • Published 8 years ago

what3words v1.0.1

Weekly downloads
5
License
ISC
Repository
github
Last release
8 years ago

#what3words what3words

Node.js library for what3words API

###Getting started

$ npm install --save what3words

###Usage ###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, es or tr.
  • format (optional) - return data format type. Can be json (the default), geojson or xml
  • display (optional) - return display type. Can be full (the default) or terse

####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 string
  • lang (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 longitude
  • lang (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 string
  • lang (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 to clip=none.

#####standardblend(options, callback) ######options

  • addr (required) - a 3 word address as a string
  • lang (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 returned
  • format (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 test