Distance / Route API
Compute optimal driving, trucking, and walking routes with turn-by-turn guidance, live traffic awareness, and multi-stop sequencing.
Overview & Solution
Transportation and field travel costs constitute a major expense in logistics, supply chains, and mobile operations. The Distance / Route API calculates accurate driving distances, realistic transit durations, and turn-by-turn navigation paths based on rich topological road networks and real-time traffic conditions.
Industry Use Cases
1. Supply Chain & Long-Haul Trucking
- Toll & Fuel Optimization: Compare toll vs. non-toll highway alternatives to optimize transport budgets.
2. Quick-Commerce & Food Delivery
- Accurate ETAs: Provide customers with realistic arrival predictions updated continuously according to traffic congestion.
- Rider Navigation: Turn-by-turn polylines and voice-guidance data for mobile navigation apps.
3. Field Service Dispatch
- Multi-Stop Journey Planning: Sequence maintenance service tickets in the most efficient order to minimize daily fuel consumption and windshield time.
The Sovereign Routing Advantage
- Turn-by-Turn Maneuvers: Delivers detailed instructions (turn left, merge, exit roundabout) with lane guidance.
- Custom Costing Models: Supports car, heavy truck, two-wheeler, and pedestrian profiles.
API reference
This page covers two related endpoints. Route returns the travelable path, instructions and geometry; Distance returns distance and duration only.
Route API
Master list reference: #3aRoute and Journey Intelligence APIs · API key only
Returns the travelable path between two or more stops, in the order given: geometry, turn-by-turn instructions, and time and length per leg.
Endpoints
All requests need only your API key, as the api-key query parameter - no bearer token:
?api-key=<apiKey>
Get the drivable path between waypoints
POST /routing/adapter/route
Base URL: https://api-gw.sovereignsolutions.com/gateway
Request Parameters
| Parameter | In | Type | Required | Description | Example |
|---|---|---|---|---|---|
locations | body | array | No | Stops, visited in the order given. At least two. | |
locations[] | body | object | No | ||
locations[].lat | body | number | No | Latitude of the point, decimal degrees. | |
locations[].lon | body | number | No | Longitude of the point, decimal degrees. | |
costing | body | string | No | Travel mode used for costing. The examples use auto (driving) and pedestrian (walking). | |
units | body | string | No | Distance unit: km. |
Request body
{
"locations": [
{
"lat": 21.4943067,
"lon": 86.8692782
},
{
"lat": 21.4335349694959,
"lon": 86.8405786566617
}
],
"costing": "auto",
"units": "km"
}
Response Schema
200 OK
{
"trip": {
"locations": [
{
"type": "break",
"lat": 21.494306,
"lon": 86.869278,
"side_of_street": "left",
"original_index": 0
},
{
"type": "break",
"lat": 21.433534,
"lon": 86.840578,
"side_of_street": "left",
"original_index": 1
}
],
"legs": [
{
"maneuvers": [
{
"type": 3,
"instruction": "Drive east.",
"verbal_succinct_transition_instruction": "Drive east.",
"verbal_pre_transition_instruction": "Drive east.",
"verbal_post_transition_instruction": "Continue for 2 kilometers.",
"time": 158.239,
"length": 2.197,
"cost": 151.988,
"begin_shape_index": 0,
"end_shape_index": 28,
"travel_mode": "drive",
"travel_type": "car"
},
{
"type": 10,
"instruction": "Turn right onto NH16/AH45/Balasore Bypass. Continue on NH16/AH45.",
"verbal_transition_alert_instruction": "Turn right onto NH16.",
"verbal_succinct_transition_instruction": "Turn right.",
"verbal_pre_transition_instruction": "Turn right onto NH16, AH45.",
"verbal_post_transition_instruction": "Continue on NH16, AH45 for 9 kilometers.",
"street_names": [
"NH16",
"AH45"
],
"begin_street_names": [
"NH16",
"AH45",
"Balasore Bypass"
],
"time": 365.522,
"length": 8.966,
"cost": 340.377,
"begin_shape_index": 28,
"end_shape_index": 76,
"travel_mode": "drive",
"travel_type": "car"
}
],
"summary": {
"has_time_restrictions": false,
"has_toll": false,
"has_highway": false,
"has_ferry": false,
"min_lat": 21.431431,
"min_lon": 86.838567,
"max_lat": 21.49335,
"max_lon": 86.889226,
"time": 547.566,
"length": 11.486,
"cost": 521.159
},
"shape": "}wu~g@si`udD|AkPhBgm@aDoYo@eLc@sfFp@oJpHc_@lFiYxHm`A~@aMsAkPuWax@{DwQoBmSUkSdAoeFsAaUyFk[aNal@_FeO}DeWkFaU{x@guBwGiYaSgjB]_IY_H]kG`WhCx_ArJr~Dd`@tt@hHvcArLjkAtNfMrAr`AnKpmAfObgBfSzaCnXbg@lJje@jPftCfmArmDl{Avf@hTbe@`QxUxInkAhf@jkE`lB`VlKxP`ItUvNzTtSl[b]hgFr_HnyApiBf}E|gGtpA||AtsAdfBn{@`gA`UpZpo@tx@p{@`kAvm@zw@zgC`dDveIp|JrfEdiFpv@x`A|rArbBrnAz{ArCjDhxAvjBli@nq@pK`Oz\\~a@ftAdcB~AxByHzGunBefC"
}
],
"summary": {
"has_time_restrictions": false,
"has_toll": false,
"has_highway": false,
"has_ferry": false,
"min_lat": 21.431431,
"min_lon": 86.838567,
"max_lat": 21.49335,
"max_lon": 86.889226,
"time": 547.566,
"length": 11.486,
"cost": 521.159
},
"status_message": "Found route between points",
"status": 0,
"units": "kilometers",
"language": "en-US"
}
}
| Field | Type | Description |
|---|---|---|
trip | object | |
trip.locations | array | The input stops as snapped to the road network. |
trip.locations[] | object | |
trip.locations[].type | string | |
trip.locations[].lat | number | |
trip.locations[].lon | number | |
trip.locations[].side_of_street | string | Side of the street the stop is on. |
trip.locations[].original_index | integer | Position of this stop in your request. |
trip.legs | array | One leg between each pair of consecutive stops. |
trip.legs[] | object | |
trip.legs[].maneuvers | array | Turn-by-turn instructions for the leg. |
trip.legs[].maneuvers[] | object | |
trip.legs[].maneuvers[].type | integer | |
trip.legs[].maneuvers[].instruction | string | Human-readable instruction. |
trip.legs[].maneuvers[].verbal_succinct_transition_instruction | string | |
trip.legs[].maneuvers[].verbal_pre_transition_instruction | string | |
trip.legs[].maneuvers[].verbal_post_transition_instruction | string | |
trip.legs[].maneuvers[].time | number | Time for this maneuver, seconds. |
trip.legs[].maneuvers[].length | number | Length of this maneuver, in units. |
trip.legs[].maneuvers[].cost | number | |
trip.legs[].maneuvers[].begin_shape_index | integer | |
trip.legs[].maneuvers[].end_shape_index | integer | |
trip.legs[].maneuvers[].travel_mode | string | |
trip.legs[].maneuvers[].travel_type | string | |
trip.legs[].summary | object | |
trip.legs[].summary.has_time_restrictions | boolean | |
trip.legs[].summary.has_toll | boolean | |
trip.legs[].summary.has_highway | boolean | |
trip.legs[].summary.has_ferry | boolean | |
trip.legs[].summary.min_lat | number | |
trip.legs[].summary.min_lon | number | |
trip.legs[].summary.max_lat | number | |
trip.legs[].summary.max_lon | number | |
trip.legs[].summary.time | number | Leg travel time, seconds. |
trip.legs[].summary.length | number | Leg length, in units. |
trip.legs[].summary.cost | number | |
trip.legs[].shape | string | Leg geometry as an encoded polyline. |
trip.summary | object | |
trip.summary.has_time_restrictions | boolean | |
trip.summary.has_toll | boolean | true when the route uses a toll road. |
trip.summary.has_highway | boolean | true when the route uses a highway. |
trip.summary.has_ferry | boolean | true when the route uses a ferry. |
trip.summary.min_lat | number | |
trip.summary.min_lon | number | |
trip.summary.max_lat | number | |
trip.summary.max_lon | number | |
trip.summary.time | number | Total travel time, seconds. |
trip.summary.length | number | Total length, in units. |
trip.summary.cost | number | |
trip.status_message | string | Result message. |
trip.status | integer | 0 when a route was found. |
trip.units | string | Distance unit used in the response. |
trip.language | string | Language of the instructions. |
Example
curl -X POST 'https://api-gw.sovereignsolutions.com/gateway/routing/adapter/route?api-key=$API_KEY' \
-H 'Content-Type: application/json' \
-d '{"locations": [{"lat": 21.4943067, "lon": 86.8692782}, {"lat": 21.4335349694959, "lon": 86.8405786566617}], "costing": "auto", "units": "km"}'
See also
Distance API
Master list reference: #3bRoute and Journey Intelligence APIs · API key only
Returns distance (metres) and estimated duration (seconds) between waypoints. Lighter than the Route API when you only need the numbers.
Endpoints
| Method | Path | Purpose |
|---|---|---|
GET | /routing/in-shortest/route/v1/{profile}/{coordinates} | Distance API - two points |
GET | /routing/in-shortest/route/v1/{profile}/{coordinates} | Distance API - multiple points |
All requests need only your API key, as the api-key query parameter - no bearer token:
?api-key=<apiKey>
Distance API - two points
GET /routing/in-shortest/route/v1/{profile}/{coordinates}
Base URL: https://api-gw.sovereignsolutions.com/gateway
Request Parameters
| Parameter | In | Type | Required | Description | Example |
|---|---|---|---|---|---|
profile | path | string | Yes | Routing profile. The examples use car and foot. | car |
coordinates | path | string | Yes | Semicolon-separated lon,lat pairs. Two pairs = point-to-point; more than two = one leg per consecutive pair. | 86.8692782,21.4943067;86.8405786566617,21.4335349694959 |
Response Schema
200 OK
{
"routes": [
{
"weight_name": "taxi",
"weight": 11486.098,
"duration": 547.567,
"distance": 11486.098,
"legs": [
{
"weight": 11486.098,
"duration": 547.567,
"steps": [],
"distance": 11486.098,
"summary": ""
}
],
"geometry": "indbCapeqOHw@HsCOsACi@CeVBc@^gBVsA\\oEFm@Iw@mAuDS{@IaAA_ADaVGgAWyAq@oCUs@QmAWeAyDyJ[sA_AwIA_@C[A[jALnEd@dRhBjD\\zEj@rFp@l@FpEf@xFr@lI~@`LpA`Cb@xBv@|MxFlPfH~BbAxBx@fAb@tF|BlSzIhAf@v@^fAp@dA`AzA`BfVx[~GtIfUnYdGjHlGhI`EdFdAxAzCvD`ErFtCtDtLnOt_@be@|RlVpDpEjG~H|FfHNP|GvIfC`Df@r@~AnBnG~HHJ_@ZeJoL"
}
],
"waypoints": [
{
"distance": 364.278,
"name": "",
"location": [
86.86865,
21.491087
]
},
{
"distance": 23.635,
"name": "NH16",
"location": [
86.84073,
21.433376
]
}
],
"code": "Ok"
}
| Field | Type | Description |
|---|---|---|
routes | array | The route found. |
routes[] | object | |
routes[].weight_name | string | Name of the cost model used. |
routes[].weight | number | Internal routing cost. Ignore it. |
routes[].duration | number | Total duration, seconds. |
routes[].distance | number | Total distance, metres. |
routes[].legs | array | One leg between each pair of consecutive points. |
routes[].legs[] | object | |
routes[].legs[].weight | number | |
routes[].legs[].duration | number | Leg duration, seconds. |
routes[].legs[].steps | array | |
routes[].legs[].distance | number | Leg distance, metres. |
routes[].legs[].summary | string | |
routes[].geometry | string | Route geometry as an encoded polyline. |
waypoints | array | Input points snapped to the road network, in input order. |
waypoints[] | object | |
waypoints[].distance | number | Distance from the input point to the snapped position, metres. |
waypoints[].name | string | Road name at the snapped position. |
waypoints[].location | array | Snapped position, [longitude, latitude]. |
waypoints[].location[] | number | |
code | string | Ok on success. |
Distance API - multiple points
GET /routing/in-shortest/route/v1/{profile}/{coordinates}
Base URL: https://api-gw.sovereignsolutions.com/gateway
Request Parameters
| Parameter | In | Type | Required | Description | Example |
|---|---|---|---|---|---|
profile | path | string | Yes | Routing profile. The examples use car and foot. | foot |
coordinates | path | string | Yes | Semicolon-separated lon,lat pairs. Two pairs = point-to-point; more than two = one leg per consecutive pair. | 80.267284,13.0363036;80.267779,13.034928;80.267437,13.03525;80.267291,13.036289;80.251724,13.032119 |
Response Schema
200 OK
{
"routes": [
{
"weight_name": "pedestrian",
"weight": 2360.007,
"duration": 1668.887,
"distance": 2360.007,
"legs": [
{
"weight": 152.966,
"duration": 107.976,
"steps": [],
"distance": 152.966,
"summary": ""
},
{
"weight": 107.549,
"duration": 75.917,
"steps": [],
"distance": 107.549,
"summary": ""
}
],
"geometry": "qaqnA}f|hNCEISIURCx@Ib@ChBOiBNHHt@n@u@o@IIc@By@HSBHTHRBDBFHJx@f@`Al@vAfANXp@tAZdBT|@x@jBPT`AtALLz@lA?pHDjADjDApA?RCDEHSl@GJBRGv@Ef@ABEdA@XAdAFvAB~@?\\?lAAvAAHElBI|AMjEChCIbDNJbB`AnA|@B@LHMpDtA@"
}
],
"waypoints": [
{
"distance": 48.114,
"name": "Subbarayan Salai",
"location": [
80.267512,
13.035933
]
},
{
"distance": 15.645,
"name": "RK Mutt Road",
"location": [
80.267922,
13.034948
]
}
],
"code": "Ok"
}
| Field | Type | Description |
|---|---|---|
routes | array | The route found. |
routes[] | object | |
routes[].weight_name | string | Name of the cost model used. |
routes[].weight | number | Internal routing cost. Ignore it. |
routes[].duration | number | Total duration, seconds. |
routes[].distance | number | Total distance, metres. |
routes[].legs | array | One leg between each pair of consecutive points. |
routes[].legs[] | object | |
routes[].legs[].weight | number | |
routes[].legs[].duration | number | Leg duration, seconds. |
routes[].legs[].steps | array | |
routes[].legs[].distance | number | Leg distance, metres. |
routes[].legs[].summary | string | |
routes[].geometry | string | Route geometry as an encoded polyline. |
waypoints | array | Input points snapped to the road network, in input order. |
waypoints[] | object | |
waypoints[].distance | number | Distance from the input point to the snapped position, metres. |
waypoints[].name | string | Road name at the snapped position. |
waypoints[].location | array | Snapped position, [longitude, latitude]. |
waypoints[].location[] | number | |
code | string | Ok on success. |
Returns one leg per consecutive pair of points. The example response is shortened to the first two legs and waypoints.
Example
curl -X GET 'https://api-gw.sovereignsolutions.com/gateway/routing/in-shortest/route/v1/car/86.8692782,21.4943067;86.8405786566617,21.4335349694959?api-key=$API_KEY'