Skip to content

rokala/optimoroute-client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

69 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OptimoRoute logo

OptimoRoute API client

A quick way to start consuming the OptimoRoute API with JavaScript or TypeScript.

About

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.

About

A lightweight TypeScript WS API client/wrapper for OptimoRoute, a online route optimizing service.

Resources

License

Stars

Watchers

Forks

Packages

No packages published