Route API (Single Route)

Use Route to generate a single route with total distance/time, itinerary steps (turn-by-turn), and route points (polyline). For multi-vehicle optimization use Dispatch.

TrackRoad Route API generating a single optimized route with distance, 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 all fields, enums, and models for Route and other endpoints.

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 (REST + SOAP)
  7. Common errors
  8. Best practices
  9. Related endpoints

What Route does#

Route calculates a single route through a list of locations. It returns total distance/time plus detailed legs and itinerary steps (instruction text), route points, and optional map output depending on options.

LatLong is preferred. If you omit LatLong on a location, you must provide Address. Shared models (Location/LatLong/Address) are documented in 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 here: API Authentication.

SOAP authentication (SessionIDHeader)#

SOAP calls use a SessionIDHeader. Typical flow:

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

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

Request schema#

REST request body is RouteSpecification. SOAP uses the same logical structure in XML. Shared models (Location/LatLong/Address) 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, fastest/shortest, 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 e.g. en-US.
MapSize MapSize No Optional output size (Width/Height).
RouteColor RouteColor No Optional map route color.
MapCenter LatLong No Optional map center.
HideStops bool No If true, hide stop markers on map output (if returned).
ZoomLevel int No 0=auto, otherwise fixed zoom.

Shared types#

To avoid duplication, shared models (Location, LatLong, Address) are described in Dispatch API → Request schema.

Response schema#

A successful response returns RouteResult with Route (distance/time, legs, itinerary items, points).

RouteResult#

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

Route#

Property Type Description
Distance double Total distance (unit depends on DistanceUnit).
Time int Total travel time in seconds.
RouteLegs RouteLeg[] Legs containing itinerary steps.
Points LatLong[] Polyline points (may be large).
Map string Optional map payload (depends on server/options).

Examples (REST + SOAP)#

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/invalid SessionIDHeader or expired session id.
  • Validation errors: Location missing both LatLong and Address, invalid coordinates, or too few locations.
  • Non-routeable locations: Some points may not be routeable depending on provider/data.

Best practices#

  • Prefer LatLong for all locations to avoid geocoding cost/ambiguity.
  • Choose optimization correctly: MinimizeTime for fastest, MinimizeDistance for shortest.
  • Polyline Points can be large—only use when you need geometry.
  • Use Dispatch for multi-vehicle or many-stop optimization.

Build routes in minutes

Generate your API Key (TrackServiceKey) for REST, or use SOAP Login to obtain a SessionID, then start routing.

Get API Key View Swagger UI