optimoroute-client
v1.18.1
Published
A lightweight universal TypeScript WS API client for OptimoRoute. OptimoRoute plans and optimizes routes and schedules for deliveries and mobile workforce.
Downloads
6
Maintainers
Readme
About
- Up to date with OptimoRoute API
v1.18
(the MAJOR and MINOR versions of this repository reflect the API version it supports). - See project at npmjs.com/optimoroute-client.
- See API official specifications.
Installation
Install via NPM
npm install optimoroute-client
or build it yourself
git clone https://github.com/rokala/optimoroute-client.git
cd ./optimoroute-client
npm install
npm run build
Credentials
API authentication key provided by OptimoRoute is required to use the API.
Usage
// Import the module
import OptimoRoute from 'optimoroute-client';
// Initialize the client, never expose your API key to the public
const optimoRoute = new OptimoRoute({
authKey: process.env.OPTIMO_ROUTE_API_KEY
});
// Example requests
optimoRoute.getOrders('Order_1')
.then((response) => {
// do stuff...
});
optimoRoute.getOrders([
{ orderNo: 'Order_1' },
{ orderNo: 'Order_2' },
{ orderNo: 'Order_3' }
])
.then((response) => {
// do stuff...
});
optimoRoute.getSchedulingInfo({orderNo = 'Order_1'})
.then((response) => {
// do stuff...
});
optimoRoute.getRoutes({ date: '2021-10-01' })
.then((response) => {
// do stuff...
});
optimoRoute.updateDriverParameters({ externalId: 'Driver_1', date: '2020-10-01', enabled: false })
.then((response) => {
// do stuff...
});
optimoRoute.searchOrders({dateRange: {'from': '2022-10-17', 'to': '2022-10-19'}, 'includeOrderData': true})
.then((response) => {
// do stuff ...
});
Common response properties
All responses include the following properties:
success
[boolean]code
[string] (conditional)message
[string] (conditional*)
If success === false
then code
and message
will give you a clue of what went wrong.