How to Use the TomTom Routing API for Estimated Time of Arrival
Jose Jose Rojas·Mar 17, 2020

How to Use the TomTom Routing API for Estimated Time of Arrival

Jose Jose RojasJose Jose Rojas
Jose Jose Rojas
Jose Jose Rojas is Developer Evangelist for the TomTom Developer Relations team. He is passionate about: new product designs, electric scooters and mobile game development. Prior to his time at TomTom, he worked in a variety of roles including software developer, product owner and team lead.
Mar 17, 2020 · 7 min read

The Routing API is a powerful tool which can be used to get accurate directions for diverse types of vehicles-- with routes like the fastest, shortest, and most exciting. But one overlooked feature from the API is the option to fetch a summary of the requested routes. The Matrix Routing API lets us fetch different summaries with a single call, where we can get ETAs from different destinations.

A Quick Summary of the Routing API


The Routing API is a powerful tool which can be used to get accurate directions for diverse types of vehicles-- with routes like the fastest, shortest, most exciting, etc. It can also provide you with the geometrical shape of the desired route and instructions.

But one overlooked feature from the API is the option to fetch a summary of the requested routes. It is useful to display possibilities to the user, like in this example: we need to find the closest hospital or pharmacy. By getting the summaries, we can offer a better selection using the Matrix Routing Example found here.


Another classic use case for this is a Ride Sharing application. Calculating a best choice driver from a list of providers spread around an area gets tricky when we don’t need to actually create routes to compare, since we only need either driving distance or ETAs. This is when the Summary works its magic.

The summary is requested with the following parameter:


The value ‘polyline’ will return the route graphical representation in a LatLng pairs array, while the summaryOnly will get you an extra JSON section in the response like this :


There are some interesting data here that differentiates this API itself in particular from others:

  1. You can see there are different ETAs with No traffic, Live Traffic and Historical traffic consideration.

  2. You can get alternative routes and see how much deviation from the original one there is.

NOTE: The deviations and alternative routes are only available when an initial route is calculated first.NOTE 2: The fuel consumption is estimated. But if we pass consumption models – for either Electric or Combustion Engine Vehicles – the calculation becomes much more accurate.

Now let’s go and check out a real-life example…

Different types, different ETAs

We are going to check a few different ETAs from our hotel in downtown Chicago – how about "La Quinta Inn"? For this hotel, we’ll use the location :

2  "lat": 42.37806,
3  "lon": -87.94427

From the hotel, we would like to find a close by a restaurant, a Cajun creole style restaurant. For this we can use the Category search API [] to get a list of possible restaurants around the hotel (using the LatLng of the Hotel as the Position Bias).

Removing unused data, we get a small list. This is the first element:

2  "type": "POI",
3  "id": "US/POI/p0/6986772",
4  "score": 5.66156005859375,
5  "dist": 1841.0411486661037,
6  "info": "search:ta:840179003788996-US",
7  "poi": {
8    "name": "Cajun Grill",
9  },
10  "position": {
11    "lat": 42.39081,
12    "lon": -87.95857
13  }

So you can see, we also get the distance to our hotel as part of the result. But this value – in meters– is a direct point of view distance, not the real distance by driving or walking. You can replicate my results by executing this Curl Command.

1curl -X GET "*****" -H "accept: */*"

For the real driving distance we use the Routing API, requesting only the Summary and adding the option to calculate for different travel times. This is the API Endpoint that we can use:

1curl -X GET "
287.94427%3A42.39081%2C-87.95857/json?routeRepresentation=summaryOnly&computeTravelTimeFor=all&routeType=fastest&traffic=true&avoid=unpavedRoads&key=*****" -H "accept: */*"

Which gives us:

2  "formatVersion": "0.0.12",
3  "routes": [
4    {
5      "summary": {
6        "lengthInMeters": 3428,
7        "travelTimeInSeconds": 526,
8        "trafficDelayInSeconds": 0,
9        "departureTime": "2020-02-17T06:40:53-06:00",
10        "arrivalTime": "2020-02-17T06:49:38-06:00",
11        "noTrafficTravelTimeInSeconds": 518,
12        "historicTrafficTravelTimeInSeconds": 526,
13        "liveTrafficIncidentsTravelTimeInSeconds": 526
14      },
15      "legs": [
16        {
17          "summary": {
18            "lengthInMeters": 3428,
19            "travelTimeInSeconds": 526,
20            "trafficDelayInSeconds": 0,
21            "departureTime": "2020-02-17T06:40:53-06:00",
22            "arrivalTime": "2020-02-17T06:49:38-06:00",
23            "noTrafficTravelTimeInSeconds": 518,
24            "historicTrafficTravelTimeInSeconds": 526,
25            "liveTrafficIncidentsTravelTimeInSeconds": 526
26          }
27        }
28      ],
29      "sections": [
30        {
31          "startPointIndex": 0,
32          "endPointIndex": 157,
33          "sectionType": "TRAVEL_MODE",
34          "travelMode": "car"
35        }
36      ]
37    }
38  ]

While this is good enough for now, we need to get even MORE routes to compare, and for that nothing is better than using the Matrix Routing API.

Getting all possible routes / Routes to many destinations

From the documentation in our Developer Portal:

The Matrix Routing service enables the calculation of a matrix of route summaries for a set of routes defined with origin and destination locations.
  • For every given origin, this service calculates the cost of routing from that origin to every given destination.
  • The set of origins and the set of destinations can be thought of as the column and row headers of a table, while each cell in the table contains the costs of routing from the origin to the destination for that cell.
The following costs are computed for each route:
  • Travel times
  • Distances

Check the full documentation here :

This looks like exactly what we need.

In our case we are going to calculate driving and pedestrian summaries so we can decide if we want to walk or drive and since the requests are simple enough – no complicated routes here – so we can use the synchronous version: We will wait for a response once all the routes have been calculated.

NOTE: The synchronous version of the matrix routing API will timeout after 60 secs, so make sure to use it only with small routes.

The end point is a HTTP-POST request. This is the URL we are going to use:


The POST Body: Here we will set the different routes (same origin, different destinations) requests. It follows this format:


So in our case this is our POST Body:

2  "origins": [
3    {
4      "point": {"latitude":42.37806,"longitude": -87.94427}
5    }
6  ],
7  "destinations": [
8    {"point": {"latitude": 42.39081,"longitude": -87.95857}},
9    {"point": {"latitude": 42.24304,"longitude": -87.94959}},
10    {"point": {"latitude": 42.17424,"longitude": -87.82099}},
11    {"point": {"latitude": 42.13930,"longitude": -87.95802}},
12    {"point": {"latitude": 42.06633,"longitude": -88.04281}},
13    {"point": {"latitude": 42.05039,"longitude": -87.83661}},
14    {"point": {"latitude": 42.03845,"longitude": -88.14389}},
15    {"point": {"latitude": 42.04051,"longitude": -87.71484}},
16    {"point": {"latitude": 42.04204,"longitude": -87.68083}},
17    {"point": {"latitude": 42.01446,"longitude": -88.14491}}
18  ]

With this request we get the following result, truncated for editorial purposes:

2    "formatVersion": "0.0.1",
3    "matrix": [
4        [
5            {
6                "statusCode": 200,
7                "response": {
8                    "routeSummary": {
9                        "lengthInMeters": 3144,
10                        "travelTimeInSeconds": 2264,
11                        "trafficDelayInSeconds": 0,
12                        "departureTime": "2020-02-20T07:00:33-06:00",
13                        "arrivalTime": "2020-02-20T07:38:16-06:00"
14                    }
15                }
16            },
17            {
18                "statusCode": 200,
19                "response": {
20                    "routeSummary": {
21                        "lengthInMeters": 17385,
22                        "travelTimeInSeconds": 12517,
23                        "trafficDelayInSeconds": 0,
24                        "departureTime": "2020-02-20T07:00:33-06:00",
25                        "arrivalTime": "2020-02-20T10:29:10-06:00"
26                    }
27                }
28            }.

For every destination we get a response object and its RouteSummary with the same needed information we got from executing a simple call. Here we see that the ‘Cajun Grill’ restaurant is the closest to us for driving. With this we can populate a list or a display for the user. Try to change the travel Mode to Pedestrian if you want a walking route. Ex. For pedestrian routes:


Using this request, we see that the ‘Cajun Grill’ restaurant is ALSO the closest to us by walking distance, but in the case that we have different restaurants to choose from, we can always use the Batch Routing API to create all the needed routes using a single call:

This way we only create the routes that we need to display to the user.

In Summary

In this article we took a look at the Routing API and how to fetch ETAs and real driving or walking distances via the Summary object in the response of the Matrix Routing API.

The Matrix Routing API let us fetch different summaries with a single call where we can get such ETAs from different destinations.

I hope this article helps you understand the TomTom Routing API better- thank you for reading and Happy Mapping!

To learn more about TomTom's services and solutions for last-mile mobility and transportation services, check out the Mobility and On-Demand page here.

Get the developer newsletter.
No marketing fuff. Tech content only.

* Required field. By submitting your contact details to TomTom, you agree that we can contact you about marketing offers, newsletters, or to invite you to webinars and events. We could further personalize the content that you receive via cookies. You can unsubscribe at any time by the link included in our emails. Review our privacy policy.