API Requests
Requirements
API Key
- See with your Axioroute Account Manager
Configuration
Before making any request to the Axioroute API, you'll need to config your application with some information.
- The Axioroute API Base URL, currently
https://api.axioroute.com/v1/
- Your Auth Server URL (see Auth Server section)
- Your API Key (see API Key section)
Here is an example of configuration:
import { ARRequestClient } from "@axioroute-sinari/axioroute-sdk";
ARRequestClient.setApiBaseUrl("https://api.axioroute.com/v1/");
ARRequestClient.setAuthUrl("https://myapp.example.com/auth");
ARRequestClient.setApiKey("azerty1234-a1234-4qsdf-5wxcv-0123456789f");
Making Requests
Axioroute SDK enables you to make requests to the multiple Axioroute APIs.
MPT
API for Route Scheduling and Optimisation.
- Guides: TODO
- Full API Reference
MCI
API For Itinerary Calculation.
- Guides: TODO
- Full API Reference
Carto
Provides cartographic elements (positionning, reverse geocoding, ...).
- Guides: TODO
- Full API Reference
Some API endpoints are not yet available within the SDK. You should refer to the Axioroute API Reference if you need an exhaustive list of Axioroute APIs and endpoints
Listening to Request Events
Most of complex API calls will be queued for resolution, resolution time can take just a few milliseconds to some minutes.
Hence, you'll have to subscribe API Events to know when the solution is available.
Here is an example to subscribe any MPT or MCI problem you have submitted:
ARRequestClient.instance().subscribe("RECEIVED", (request) => {
const { id, problem, solution, error } = request.job;
console.log("API used", request.api); // MPT / MCI
console.log("MY Job ID", id); // your job id, to match it with the proper request in case you have multiple jobs in parallel
console.log("Original Problem", problem); // the problem (MPT /MCI) you had submitted
if (error) {
console.log("Error", error); // the potential error encountered during problem solving
} else {
console.log("Solution", solution); // the solution to the given problem, only avialble for RECEIVED status
}
});
You can also track progression of your problem with:
ARRequestClient.instance().subscribe("LOADING", (request) => {
const { id, error, percent } = request.job;
console.log("API used", request.api); // MPT / MCI
console.log("MY Job ID", id); // your job id, to match it with the proper request in case you have multiple jobs in parallel
if (error) {
console.log("Error", error); // the potential error encountered during problem solving
} else {
console.log("Progress", `${percent}/100`); // the current progression in percent
}
});
Environments
The default environment on which request are made is preprod
, but you can switch to staging
(and later on prod
) with:
ARRequestClient.setApiEnv("staging");
If you have an active access token, it won't be usable on the new environment. Hence, you'll have to authenticate again.