Building requests for the Trip API
Before you can start using the API, you will need to obtain the authentication token.
The following headers will be required, where the word token must be replaced by the token obtained in the authentication process:
--header 'Content-Type: application/json' \ --header 'Authorization: Bearer token'
In body all the parameters will be sent to solve the route calculation.
The Trip API can work in two ways, synchronously or asynchronously.
Synchronous Trip
With Synchronous Trip it is possible to obtain the routing result in a single request. Synchronous Trip has the following endpoints, where the term {{tripId}}
must be replaced by the ID of the route to be queried:
- https://api.maplink.global/trip/v2/calculations – POST
Used to send the logistics problem. The complete routing result is returned. - https://api.maplink.global/trip/v1/solutions/{{tripId}} – GET
Returns the routing result according to the ID entered. So that you don’t have to send the request again, you can use the route ID you previously used for the query.
The route coordinates in Synchronous Trip will be returned in the format polyline format for better performance.
Asynchronous Trip
Unlike Synchronous Trip, when sending a request to Asynchronous Trip only the route ID will be returned for future reference. It also has two extra endpoints that make it possible to check the status of request processing.
Asynchronous Trip has the following endpoints, where the term {{tripId}}
must be replaced by the ID of the route to be consulted:
- https://api.maplink.global/trip/v1/problems – POST
Used to send the route to be routed. An ID will be returned for the query. - https://api.maplink.global/trip/v1/events?jobId={{tripId}} – GET
Returns all the states from the time the request was received until its completion. - https://api.maplink.global/trip/v1/jobs/{{tripId}} – GET
Returns the current processing status of the request. - https://api.maplink.global/trip/v1/solutions/{{tripId}} – GET
Returns the result of the routing.
The route coordinates in Asynchronous Trip will be returned in object.
Note: Route IDs are available for consultation for a period of 7 days. If you need your route to be stored for longer, check out Route Storage to find out more.