Geocode API (Address → Latitude/Longitude)

Use Geocode to convert postal addresses into latitude/longitude coordinates. Geocoding is usually the first step before route planning or dispatch optimization when you do not already have reliable stop coordinates.

TrackRoad Geocode API converting an address into latitude/longitude coordinates for routing and dispatch.
Geocode API example: convert an address into latitude/longitude coordinates for accurate routing and dispatch.

Best practice: validate stops before route optimization

Bad addresses are one of the most common causes of missing stops, incorrect routes, and avoidable optimization failures. Geocode first, then call Dispatch or Route.

API Reference Overview View Swagger UI

Table of contents

  1. What geocoding is and why it matters
  2. What Geocode does
  3. Understanding MatchCode
  4. REST endpoint and base URL
  5. SOAP endpoint
  6. Authentication
  7. Request schema
  8. Response schema
  9. Examples
  10. Common errors
  11. Best practices
  12. Related endpoints
  13. FAQ

What geocoding is and why it matters#

Geocoding converts a postal address such as 350 5th Ave, New York, NY into latitude/longitude coordinates that software can use for routing, ETA calculation, and distance measurement.

Route optimization engines depend on accurate stop coordinates. When addresses are incomplete, ambiguous, or wrong, route results become less reliable.

  • Incorrect coordinates can produce wrong routes, wrong distances, and poor ETAs.
  • Missing coordinates can lead to dispatch failures, skipped stops, or unassigned work.
  • Ambiguous addresses can result in low MatchCode values and lower confidence results.

If you optimize routes without validating addresses first, you are more likely to see missing stops, infeasible plans, or poor route quality.

What Geocode does#

Geocode accepts one or more Address objects and returns one or more candidate Location results for each address. Each returned Location can include LatLong coordinates and a MatchCode value that helps you evaluate match quality.

Transactions: each address geocoded counts as a transaction, even when multiple addresses are submitted in the same request.

Understanding MatchCode#

MatchCode is a confidence indicator returned during geocoding. It shows how closely TrackRoad matched your input address to a real-world location.

  • High MatchCode usually means a more precise match and is typically safer for dispatch.
  • Low MatchCode usually means the address is incomplete, ambiguous, or less reliable.
  • No useful match may indicate an invalid address or missing city, state, postal code, or country data.

If MatchCode is low, correct the address or send latitude/longitude directly when coordinates are already known.

REST endpoint and base URL#

Item Value
Base URL https://trackservice.trackroad.com
Endpoint POST /rest/geocode
Full URL https://trackservice.trackroad.com/rest/geocode
Content-Type application/json

REST geocode requests use POST and typically return JSON. Depending on integration details, XML may also be supported.

SOAP endpoint#

Item Value
SOAP URL https://trackservice.trackroad.com/TrackService.asmx
WSDL https://trackservice.trackroad.com/TrackService.asmx?wsdl
SOAPAction http://TrackService.TrackRoad.com/Geocode
Content-Type text/xml; charset=utf-8

SOAP request envelopes and headers for Geocode are defined in the WSDL and may vary by SOAP version.

Authentication#

REST authentication (X-API-Key)

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

curl -X POST "https://trackservice.trackroad.com/rest/geocode" \
  -H "Content-Type: application/json" \
  -H "X-API-Key: YOUR_TRACKSERVICEKEY" \
  -d '{ "IsNeedMatchCode": true, "Addresses": [] }'

Keep API keys server-side whenever possible. Avoid embedding production API keys directly in browser or mobile client code.

SOAP authentication (SessionIDHeader)

SOAP requests use a SessionIDHeader. For TrackRoad SOAP services, send your TrackServiceKey as the SessionID value for each call. Legacy Login/Logout methods may still appear in older documentation but are not required for modern usage.

Recommended: prefer REST unless you must integrate with an existing SOAP-only system.

Request schema#

The request body is a single GeocodeSpecification object. Provide one or more addresses that you want to geocode.

GeocodeSpecification

Property Type Required Description
IsNeedMatchCode bool No If true, includes match quality indicators in the result. Recommended for production integrations.
Addresses Address[] Yes* One or more addresses to geocode. Each address counts as a transaction.

Address

Address is a shared model across endpoints. The full Address schema is also documented on Dispatch API (shared models) .

Property Type Required Description
Street string Recommended Street address line.
City string Recommended City or locality.
State string No State, province, or region.
PostalCode string No ZIP or postal code.
Country string Recommended Country code or country name, for example US.

Response schema#

A successful response returns a GeocodeResult containing one or more GeocodeItem objects. Each item maps to one input address.

GeocodeResult

Property Type Description
Items GeocodeItem[] One item per input address. Each item may contain zero, one, or multiple candidate locations.
Errors Error[] Errors or warnings returned by the service.
Status int (enum) Status code such as 0=None, 1=Success, 2=Failed, or 3=SuccessWithErrors.

GeocodeItem

Property Type Description
Address Address The original input address.
Locations Location[] Candidate geocoding results for the address.

Location, LatLong, MatchCode

These models are shared across endpoints. See the full schema tables on Dispatch API (shared models) .

Error

Property Type Description
Message string Human-readable error or warning message.

Examples#

Use the following sections for REST and SOAP example requests and responses. Example code can remain language-neutral and does not need localization.

REST JSON request example#

Send one or more addresses in a single request.

{
  "IsNeedMatchCode": true,
  "Addresses": [
    {
      "Street": "6718 Whittier Avenue",
      "City": "McLean",
      "State": "VA",
      "PostalCode": "22101",
      "Country": "US"
    },
    {
      "Street": "1450 Old Chain Bridge Road",
      "City": "McLean",
      "State": "VA",
      "PostalCode": "22101",
      "Country": "US"
    }
  ]
}

REST request examples (multiple languages)#

curl -X POST "https://trackservice.trackroad.com/rest/geocode" \
  -H "Content-Type: application/json" \
  -H "X-API-Key: YOUR_TRACKSERVICEKEY" \
  -d '{
    "IsNeedMatchCode": true,
    "Addresses": [
      { "Street": "6718 Whittier Avenue", "City": "McLean", "State": "VA", "PostalCode": "22101", "Country": "US" }
    ]
  }'

REST JSON response example (shape)#

{
  "Items": [
    {
      "Address": {
        "Street": "6718 Whittier Avenue",
        "City": "McLean",
        "State": "VA",
        "PostalCode": "22101",
        "Country": "US"
      },
      "Locations": [
        {
          "MatchCode": 4,
          "LatLong": { "Latitude": 38.931594, "Longitude": -77.17602 },
          "Address": {
            "Street": "6718 Whittier Avenue",
            "City": "McLean",
            "State": "VA",
            "PostalCode": "22101",
            "Country": "US"
          }
        }
      ]
    }
  ],
  "Errors": [],
  "Status": 1
}

SOAP 1.1 request example#

SOAP Geocode uses SessionIDHeader with SessionID = TrackServiceKey and SOAPAction http://TrackService.TrackRoad.com/Geocode.

<!-- POST https://trackservice.trackroad.com/TrackService.asmx -->
<!-- Content-Type: text/xml; charset=utf-8 -->
<!-- SOAPAction: "http://TrackService.TrackRoad.com/Geocode" -->

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
               xmlns:xsd="http://www.w3.org/2001/XMLSchema"
               xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">

  <soap:Header>
    <SessionIDHeader xmlns="http://TrackService.TrackRoad.com/">
      <SessionID>YOUR_TRACKSERVICEKEY</SessionID>
    </SessionIDHeader>
  </soap:Header>

  <soap:Body>
    <Geocode xmlns="http://TrackService.TrackRoad.com/">
      <specification>
        <IsNeedMatchCode>true</IsNeedMatchCode>
        <Addresses>
          <Address>
            <Street>6718 Whittier Avenue</Street>
            <City>McLean</City>
            <State>VA</State>
            <PostalCode>22101</PostalCode>
            <Country>US</Country>
          </Address>
        </Addresses>
      </specification>
    </Geocode>
  </soap:Body>
</soap:Envelope>

SOAP request examples (multiple languages)#

SOAP Geocode uses SessionIDHeader with SessionID = TrackServiceKey and SOAPAction http://TrackService.TrackRoad.com/Geocode.

curl -X POST "https://trackservice.trackroad.com/TrackService.asmx" \
  -H "Content-Type: text/xml; charset=utf-8" \
  -H "SOAPAction: "http://TrackService.TrackRoad.com/Geocode"" \
  -d '<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
               xmlns:xsd="http://www.w3.org/2001/XMLSchema"
               xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Header>
    <SessionIDHeader xmlns="http://TrackService.TrackRoad.com/">
      <SessionID>YOUR_TRACKSERVICEKEY</SessionID>
    </SessionIDHeader>
  </soap:Header>
  <soap:Body>
    <Geocode xmlns="http://TrackService.TrackRoad.com/">
      <specification>
        <IsNeedMatchCode>true</IsNeedMatchCode>
        <Addresses>
          <Address>
            <Street>6718 Whittier Avenue</Street>
            <City>McLean</City>
            <State>VA</State>
            <PostalCode>22101</PostalCode>
            <Country>US</Country>
          </Address>
        </Addresses>
      </specification>
    </Geocode>
  </soap:Body>
</soap:Envelope>'

SOAP response example (shape)#

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>

    <GeocodeResponse xmlns="http://TrackService.TrackRoad.com/">
      <GeocodeResult>

        <Status>1</Status>
        <Errors />

        <Items>
          <GeocodeItem>

            <Address>
              <Street>6718 Whittier Avenue</Street>
              <City>McLean</City>
              <State>VA</State>
              <PostalCode>22101</PostalCode>
              <Country>US</Country>
            </Address>

            <Locations>
              <Location>
                <MatchCode>4</MatchCode>
                <LatLong>
                  <Latitude>38.931594</Latitude>
                  <Longitude>-77.17602</Longitude>
                </LatLong>
                <Address>
                  <Street>6718 Whittier Avenue</Street>
                  <City>McLean</City>
                  <State>VA</State>
                  <PostalCode>22101</PostalCode>
                  <Country>US</Country>
                </Address>
              </Location>
            </Locations>

          </GeocodeItem>
        </Items>

      </GeocodeResult>
    </GeocodeResponse>

  </soap:Body>
</soap:Envelope>

Common errors#

  • 401 / Unauthorized: missing or invalid X-API-Key on REST requests.
  • 403 / Forbidden: the key may be valid but blocked, expired, or unable to process the request.
  • Invalid or incomplete address: the service may return zero candidates, weak matches, or low MatchCode values.
  • SOAP authentication failure: missing or invalid SessionIDHeader where SessionID must contain your TrackServiceKey.

Best practices#

  • Cache geocoding results in your system so that you do not geocode the same address repeatedly unless it changes.
  • Use stable address inputs such as street, city, state, postal code, and country to reduce ambiguity.
  • Use MatchCode to filter or approve results when data quality matters.
  • Send LatLong to Dispatch or Route after geocoding to improve performance and avoid repeated lookups.
  • If Geocode returns multiple candidates, choose the best one using match quality and the formatted address that best fits your business rules.

FAQ#

What does the Geocode API do?
The Geocode API converts postal addresses into one or more candidate locations with latitude/longitude coordinates, helping you prepare accurate stop data for routing and dispatch.
How do I authenticate to the Geocode API?
For REST, send your TrackServiceKey in the X-API-Key header. For SOAP, send your TrackServiceKey in SessionIDHeader as SessionID.
Why can geocoding return multiple results?
Some addresses are ambiguous or incomplete, so the API may return multiple candidate locations. Use MatchCode and the returned address details to choose the best result.
Why should I geocode before route optimization?
Geocoding before route optimization improves route accuracy, ETAs, stop assignment, and distance calculations by ensuring that every stop has valid coordinates.

Next step: optimize routes with accurate coordinates

After geocoding addresses, use Dispatch or Route with latitude/longitude coordinates to generate more accurate ETAs, distances, and route sequences.

Go to Dispatch API View Swagger UI