what3words-api-nodejs-client v0.3.1
what3words-api-nodejs-client
what3words-api-nodejs-client is Node.js client library for what3words API.
Work In Progress : It exposes a subset of what3words API methods.
what3words API key
This library allows to use an environment variable (W3W_API_KEY
) to send requests on what3words API. Otherwise the what3words API keyr is a parameter of each requests.
$ export W3W_API_KEY=YOUR-API-KEY
or
what3words.forward({
addr: 'index.home.raft',
key: 'YOUR-API-KEY'
});
browser ?
what3words already maintains a dedicated client side JavaScript library
Get started
- what3words api
installation
$ npm install what3words-api-nodejs-client
configure
$ export W3W_API_KEY=YOUR-API-KEY
Enjoy #3wordadresses
API
forward(options)
This function wraps what3words API method forward It returns a Promise resolved by API payload.
const what3words = require('what3words-api-nodejs-client');
what3words.forward({
addr: 'index.home.raft'
})
.then(
(data) => {
console.log(data);
}
)
.catch((err) => {
console.error(err);
});
reverse(options)
This function wraps what3words API method reverse It returns a Promise resolved by API payload.
const what3words = require('what3words-api-nodejs-client');
what3words.reverse({
coords: '51.521251,-0.203586'
})
.then(
(data) => {
console.log(data);
}
)
.catch((err) => {
console.error(err);
});
languages()
This function wraps what3words API method languages It returns a Promise resolved by what3words API payload.
const what3words = require('what3words-api-nodejs-client');
what3words.languages()
.then(
(data) => {
console.log(data);
}
)
.catch((err) => {
console.error(err);
});
standardblend(options)
This function wraps what3words API method standardblend It returns a Promise resolved by API payload.
const what3words = require('what3words-api-nodejs-client');
what3words.standardblend({
addr: 'planter.récolte.a',
lang: 'fr'
})
.then(
(data) => {
console.log(data);
}
)
.catch((err) => {
console.error(err);
});
autosuggest(options)
This function wraps what3words API method autosuggest It returns a Promise resolved by API payload.
const what3words = require('what3words-api-nodejs-client');
what3words.autosuggest({
addr: 'index.home.ra',
lang: 'en'
})
.then(
(data) => {
console.log(data);
}
)
.catch((err) => {
console.error(err);
});
autosuggestML(options)
This function wraps what3words API method autosuggest It returns a Promise resolved by API payload.
const what3words = require('what3words-api-nodejs-client');
what3words.autosuggestML({
addr: 'index.home.ra',
lang: 'en'
})
.then(
(data) => {
console.log(data);
}
)
.catch((err) => {
console.error(err);
});
grid(options)
This function wraps what3words API method grid It returns a Promise resolved by API payload.
const what3words = require('what3words-api-nodejs-client');
what3words.grid({
bbox: '45.192,5.7237,45.188,5.7180',
format: 'geojson'
})
.then(
(data) => {
console.log(data);
}
)
.catch((err) => {
console.error(err);
});
Build and test
setup
$ npm i
unit test
$ npm test
coverage
$ npm run-script coverage
report is available with :
$ open coverage/lcov-report/index.html
Contributing
Anyone and everyone is welcome to contribute.
Issues
Find a bug or want to request a new feature? Please let me know by submitting an issue.
Licensing
Licensed under the MIT License
A copy of the license is available in the repository's LICENSE file.