Route API (Single Route)

Use Route to generate a single route with total distance and travel time , detailed itinerary steps , and route points . For multi-vehicle optimization, use Dispatch .

TrackRoad Route API generating a single route with distance, travel time, and turn-by-turn directions
Single-route planning example showing distance, ETA, and route geometry returned by the Route API.

Need the full contract?

Swagger includes the full schema, models, and endpoint details for Route and related APIs.

View Swagger UI API Reference Overview

Table of Contents

  1. What Route does
  2. Endpoints and base URL (REST + SOAP)
  3. Authentication
  4. Request schema
  5. Response schema
  6. Examples
  7. Common errors
  8. Best practices
  9. Related endpoints
  10. FAQ

What Route does#

Route calculates a single route through a list of locations. It returns total distance and travel time, route legs with itinerary instructions, route points, and optional map output depending on the selected options.

LatLong is preferred. If you omit coordinates for a location, you must provide an Address . Shared models such as Location, LatLong, and Address are documented in the Dispatch API .

Endpoints and base URL (REST + SOAP)#

REST

Item Value
Base URL https://trackservice.trackroad.com
Endpoint POST /rest/Route
Full URL https://trackservice.trackroad.com/rest/Route
Content-Type application/json
Auth X-API-Key: YOUR_TRACKSERVICEKEY

SOAP

Item Value
WSDL https://trackservice.trackroad.com/TrackService.asmx?wsdl
SOAP Endpoint https://trackservice.trackroad.com/TrackService.asmx
Operation CalculateRoute
SOAPAction http://TrackService.TrackRoad.com/CalculateRoute
Namespace http://TrackService.TrackRoad.com/
Content-Type text/xml; charset=utf-8
Auth Header SessionIDHeader with SessionID

Authentication#

REST authentication (X-API-Key)

Include your TrackServiceKey in the X-API-Key header on every REST request. Generate it in API Authentication .

SOAP authentication (SessionIDHeader)

SOAP calls use a SessionIDHeader. Typical flow:

  1. Call Login (SOAP) with your username and password.
  2. Read the returned SessionIDHeader containing the SessionID.
  3. Send that SessionID in the SOAP header for CalculateRoute requests.

REST and SOAP authentication are separate. REST uses X-API-Key. SOAP uses SessionIDHeader.

Request schema#

The REST request body is RouteSpecification. . SOAP uses the same logical structure in XML. Shared models are documented in Dispatch API .

RouteSpecification

Property Type Required Description
Locations Location[] Yes* List of route stops. Provide at least 2 locations.
RouteOptions RouteOptions No Routing engine, units, route preference, and optional map settings.

RouteOptions

Property Type Required Description
RoutingService int (enum) No 0=NetRoad, 1=TrackRoad, 2=Bing.
DistanceUnit int (enum) No 0=Mile, 1=Kilometer.
RouteOptimize int (enum) No 0=MinimizeTime, 1=MinimizeDistance.
Culture string No For example, en-US.
MapSize MapSize No Optional output size with Width and Height.
RouteColor RouteColor No Optional map route color.
MapCenter LatLong No Optional map center coordinates.
HideStops bool No If true, stop markers are hidden on map output when available.
ZoomLevel int No 0=auto; otherwise a fixed zoom level.

Shared types

To avoid duplication, shared models such as Location, LatLong, and Address are described in Dispatch API .

Response schema#

A successful response returns RouteResult with Route containing distance, travel time, route legs, itinerary steps, route points, and optional map output.

RouteResult

Property Type Description
Route Route Route output including distance, travel time, legs, points, and optional map.
Errors Error[] Optional errors or warnings.
Status int (enum) 0=None, 1=Success, 2=Failed, 3=SuccessWithErrors.

Route

Property Type Description
Distance double Total distance. The unit depends on DistanceUnit.
Time int Total travel time in seconds.
RouteLegs RouteLeg[] Route legs containing itinerary steps.
Points LatLong[] Polyline points. This collection can be large.
Map string Optional map payload depending on server behavior and options.

Examples#

Example request bodies, sample responses, headers, and language-specific code samples should be inserted below.

REST request body (JSON)#

{
  "Locations": [
    { "Name": "Start", "LatLong": { "Latitude": 37.7946, "Longitude": -122.3950 }, "LocationType": 1 },
    { "Name": "Stop A", "LatLong": { "Latitude": 37.7897, "Longitude": -122.4011 }, "LocationType": 0 },
    { "Name": "Finish", "LatLong": { "Latitude": 37.7810, "Longitude": -122.4110 }, "LocationType": 2 }
  ],
  "RouteOptions": {
    "RoutingService": 2,
    "DistanceUnit": 0,
    "RouteOptimize": 0,
    "Culture": "en-US",
    "ZoomLevel": 0
  }
}

REST call examples#

curl -X POST "https://trackservice.trackroad.com/rest/Route" \
  -H "Content-Type: application/json" \
  -H "X-API-Key: YOUR_TRACKSERVICEKEY" \
  -d @route-request.json

SOAP request (CalculateRoute)#

SOAP requires SessionIDHeader. Replace YOUR_SESSION_ID with the session id returned from SOAP Login.

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Header>
    <SessionIDHeader xmlns="http://TrackService.TrackRoad.com/">
      <SessionID>YOUR_SESSION_ID</SessionID>
    </SessionIDHeader>
  </soap:Header>

  <soap:Body>
    <CalculateRoute xmlns="http://TrackService.TrackRoad.com/">
      <specification>
        <Locations>
          <Location>
            <Name>Start</Name>
            <LatLong><Latitude>37.7946</Latitude><Longitude>-122.3950</Longitude></LatLong>
            <LocationType>Start</LocationType>
          </Location>

          <Location>
            <Name>Stop A</Name>
            <LatLong><Latitude>37.7897</Latitude><Longitude>-122.4011</Longitude></LatLong>
            <LocationType>Midway</LocationType>
          </Location>

          <Location>
            <Name>Finish</Name>
            <LatLong><Latitude>37.7810</Latitude><Longitude>-122.4110</Longitude></LatLong>
            <LocationType>Finish</LocationType>
          </Location>
        </Locations>

        <RouteOptions>
          <RoutingService>Bing</RoutingService>
          <DistanceUnit>Mile</DistanceUnit>
          <RouteOptimize>MinimizeTime</RouteOptimize>
          <Culture>en-US</Culture>
          <ZoomLevel>0</ZoomLevel>
        </RouteOptions>
      </specification>
    </CalculateRoute>
  </soap:Body>
</soap:Envelope>

SOAP call examples#

curl -X POST "https://trackservice.trackroad.com/TrackService.asmx" \
  -H "Content-Type: text/xml; charset=utf-8" \
  -H "SOAPAction: http://TrackService.TrackRoad.com/CalculateRoute" \
  -d @calculate-route.xml

Response example (REST JSON)#

{
  "Route": {
    "Distance": 5.42,
    "Time": 1180,
    "RouteLegs": [
      {
        "Distance": 2.10,
        "Time": 480,
        "Itinerary": {
          "Items": [
            {
              "Distance": 0.2,
              "Time": 40,
              "Text": "Head north on ...",
              "LatLong": { "Latitude": 37.79, "Longitude": -122.39 }
            }
          ]
        }
      }
    ],
    "Points": [
      { "Latitude": 37.7946, "Longitude": -122.3950 },
      { "Latitude": 37.7897, "Longitude": -122.4011 }
    ],
    "Map": null
  },
  "Errors": [],
  "Status": 1
}

Common errors#

  • 401 / Unauthorized (REST): Missing or invalid X-API-Key.
  • SOAP auth failure: Missing or invalid SessionIDHeader, or an expired session id.
  • Validation errors: A location may be missing both LatLong and Address, coordinates may be invalid, or too few locations were provided.
  • Non-routeable locations: Some points may not be routeable depending on the routing provider or data quality.

Best practices#

  • Prefer LatLong for all locations to reduce geocoding cost and ambiguity.
  • Choose the optimization mode carefully: MinimizeTime for the fastest route, MinimizeDistance for the shortest route.
  • Polyline Points can be large, so request and store them only when geometry is required.
  • Use Dispatch for multi-vehicle or many-stop route optimization.

FAQ#

What does the Route API return?
Route returns total distance and travel time, route legs with itinerary steps, route points, and optional map output depending on your options.
How do I authenticate?
REST uses X-API-Key. SOAP uses SessionIDHeader with a SessionID obtained from the SOAP Login call.
Do I need LatLong or Address for locations?
LatLong is preferred. If LatLong is omitted for a location, Address is required so the service can geocode the stop.
When should I use Route instead of Dispatch?
Use Route when you need a single route with directions and travel details. Use Dispatch when you need multi-vehicle or many-stop route optimization.

Build routes in minutes

Generate your API key for REST, or use SOAP Login to obtain a SessionID, then start routing with TrackRoad.

Get API Key View Swagger UI