Routing API

Asynchronous batch download

Purpose

The asynchronous batch download endpoint fetches results of the asynchronous batch processing.

  • It responds with HTTP 200 and the batch results, assuming that batch processing has completed, or with HTTP 202 “Accepted” if the batch is still being processed.
  • HTTP 202 “Accepted” is sent after 120 seconds by default. This behavior can be overridden as needed by passing the waitTimeSeconds parameter with a desired value. The client should then retry the request by following the Location header.
  • An HTTP 200 response means that batch processing has completed, but it doesn’t tell you about the status of the individual batch items. Also check the statusCode fields in the response.
  • Detailed information about the success or failure of the individual requests within the batch is provided in the HTTP 200 response.
  • The batch download GET request is a blocking long-poll request.

Request data

HTTP method: GET

  • Constants and parameters enclosed in curly brackets { } must be replaced with their values.
  • See the following Request parameters section for tables of required and optional parameters and their values. The generic request format is as follows.

URL request format

get
URL request format
https://{baseURL}/routing/{versionNumber}/batch/{batchId}?key={Your_API_Key}&waitTimeSeconds={waitTimeSeconds}

URL request example

get
URL request example
https://api.tomtom.com/routing/1/batch/{batchId}?key={Your_API_Key}

curl request example

get
curl request example
curl 'https://api.tomtom.com/routing/1/batch/{batchId}?key={Your_API_Key}'

Request headers

The following table describes HTTP request headers relevant to Batch Routing service clients.

Note: There are no required headers in this endpoint.

Optional headersDescription
Accept-Encoding

Should contain a list of encodings acceptable by the client. Used to demand a compressed response.
Value: gzip

Accept

Indicates the format of the download error response (e.g., a batch with the provided batchId does not exist). For instance, if a client submitted a batch with an output format set to json and would like to get the download error response in the same format, the Accept header should be set to application/json. Otherwise, for historical reasons, the download error response will have the xml format.
Note: In case of a successful response , the Accept header value does not affect the batch response format.
Value: application/json

Tracking-ID

Specifies an identifier for the request.

  • It can be used to trace a call.
  • The value must match the regular expression '^[a-zA-Z0-9-]{1,100}$'.

  • An example of a format that matches this regular expression is a UUID: (e.g., 9ac68072-c7a4-11e8-a8d5-f2801f1b9fd1). For details, see RFC 4122 .

  • If specified, it is replicated in the Tracking-ID response header.

  • Used for support purposes only. It does not track you or your users.

Value: An identifier for the request.

Request parameters

The following table describes the request parameters.

  • Required parameters must be used, or the call will fail.
  • Optional parameters may be used.
  • A parameter’s data type is beneath its name.
Required parametersDescription

baseURL
string

Base URL for calling the API.
Values:

versionNumber
string

Service version.
Value: The current value is 1.

key
string

An API key valid for the requested service.
Value: Your valid API Key.

batchId
string

The unique id of the batch returned in the HTTP Location header of the batch submission response.
Value: A unique ID.

Optional parametersDescription

waitTimeSeconds
integer

Allows changing the maximum amount of time, in seconds, for which the client may have to wait for an asynchronous batch download response while the batch is being calculated.

  • If the batch processing completes during the given number of seconds, the result is returned.

  • Otherwise, if the batch is still processing, an HTTP 202 (Accepted) response is returned. The client should retry the request by following the Location header.

Note that the provided waitTimeSeconds parameter and its value are passed to the Location response header as a part of the URI.
Default value: 120
Value: It may be either:

  • 5..60

  • 120

Response data

HTTP status codes

CodeMeaning & possible causes
200

OK: The batch job has completed. Results are streamed to the client.

202

Accepted: The request has been accepted for processing, but the processing has not been completed. A Location header is added to the response containing a link to retry later.

400

Bad request: Missing required parameters, or parameters did not pass validation.

403

Forbidden:

  • The API key is missing, inactive, invalid, or not entitled to use Batch Routing API over QPS (queries per second) or over QPD (queries per day).

  • Can also occur when using HTTP instead of HTTPS.
404

Not Found: The requested resource could not be found. For example, a batch with the provided batchId does not exist.

405

Method Not Allowed: The client used an HTTP method other than GET.

408

request timeout: The request sent to the server took longer than the server was prepared to wait.

414

requested URI is too long: Indicates that the URI requested by the client is longer than the server is willing to interpret.

429

Too Many requests: The API key is over QPS (queries per second).

500

An error occurred while processing the request. Please try again later.

502

Internal network connectivity issue. Please try again later.

503

Service currently unavailable. Please try again later.

504

Internal network connectivity issue or a request that has taken too long to complete. Please try again later.

596

Service not found. request contains an incorrect FQDN and/or path.

Response headers

The following data table lists HTTP headers of particular interest to the service clients.

HeaderDescription
Access-Control-Expose-Headers

A comma-separated list of HTTP header names that browsers are allowed to access.
Value: Content-Length

Access-Control-Allow-Origin

A header instructing browsers to allow customer websites to contact the Batch Routing service.
Value: *

Content-Encoding

The Batch Routing service applies gzip compression to responses if the client requests it with the Accept-Encoding header.
Value: gzip

Content-Type

The format of the response as chosen by the client. See the contentType request parameter.
Values: application/json;charset=utf-8

Location

Indicates the location where the batch results can be downloaded.
Value: URI

Tracking-ID

An identifier for the request.

  • If the Tracking-ID header was specified, it is replicated in the response.

  • Otherwise, it is generated automatically by the service.
  • Used for support purposes only. It does not involve tracking you or your users.

Value: An identifier for the request.

Successful response structure

Each batch response consists of one or more elements, which correspond sequentially to the elements in the request. Each element contains either a successful response from the invoked Routing API suite endpoint or a status code indicating why the batch item failed.

JSON Response body example
{
"formatVersion": "0.0.1",
"batchItems": [
{
"statusCode": ...,
"response": {...}
},
...,
{
"statusCode": ...,
"response": {...}
}
],
"summary": {
"successfulRequests": ...,
"totalRequests": ...
}
}

Successful response fields

FieldDescription
batchItemsA set of batch items processing results.
statusCode

Status code of a response from the underlying Routing API suite endpoint for given batch item.

response

Content of the response from the underlying Routing API suite endpoint for a given batch item query.

  • The full response content is included in both success and failure cases.

  • If the underlying service’s response content type does not match the requested content type, the response is wrapped to fit the requested content type.

summarySummary of the batch request.
successfulRequestsNumber of successful batch item requests.
totalRequestsTotal number of items in a batch request.

Successful response example

To improve the readability of the example, the copyright and privacy sections inside a batch item response are skipped.

JSON response example
{
"formatVersion": "0.0.1",
"batchItems": [
{
"statusCode": 200,
"response": {
"formatVersion": "0.0.12",
"copyright": "...",
"privacy": "...",
"routes": [
{
"summary": {
"lengthInMeters": 223,
"travelTimeInSeconds": 66,
"trafficDelayInSeconds": 0,
"departureTime": "2016-04-22T13:43:25+02:00",
"arrivalTime": "2016-04-22T13:44:31+02:00"
},
"legs": [
{
"summary": {
"lengthInMeters": 223,
"travelTimeInSeconds": 66,
"trafficDelayInSeconds": 0,
"departureTime": "2016-04-22T13:43:25+02:00",
"arrivalTime": "2016-04-22T13:44:31+02:00"
},
"points": [
{
"latitude": 52.36006,
"longitude": 4.85109
},
{
"latitude": 52.36084,
"longitude": 4.85106
},
{
"latitude": 52.36176,
"longitude": 4.85104
},
{
"latitude": 52.36176,
"longitude": 4.85056
}
]
}
],
"sections": [
{
"startPointIndex": 0,
"endPointIndex": 3,
"travelMode": "car"
}
]
}
]
}
},
{
"statusCode": 400,
"response": {
"formatVersion": "0.0.12",
"copyright": "...",
"privacy": "...",
"error": {
"description": "Invalid travel mode value: [teleport]"
}
}
},
{
"statusCode": 200,
"response": {
"formatVersion": "0.0.1",
"copyright": "...",
"privacy": "...",
"reachableRange": {
"center": {
"latitude": 52.36176,
"longitude": 4.85056
},
"boundary": [
{
"latitude": 52.78716,
"longitude": 4.81318
},
{
"latitude": 52.78983,
"longitude": 4.79019
},
{
"latitude": 52.78346,
"longitude": 4.70485
},
{
"latitude": 52.77541,
"longitude": 4.67377
},
{
"latitude": 52.73947,
"longitude": 4.6453
},
{
"latitude": 52.61481,
"longitude": 4.64891
},
{
"latitude": 52.61362,
"longitude": 4.64887
},
{
"latitude": 52.53855,
"longitude": 4.65841
},
{
"latitude": 52.49834,
"longitude": 4.64125
},
{
"latitude": 52.47165,
"longitude": 4.60932
},
{
"latitude": 52.46203,
"longitude": 4.58628
},
{
"latitude": 52.44705,
"longitude": 4.59327
},
{
"latitude": 52.37132,
"longitude": 4.52544
},
{
"latitude": 52.32164,
"longitude": 4.57722
},
{
"latitude": 52.26437,
"longitude": 4.45996
},
{
"latitude": 52.11393,
"longitude": 4.28383
},
{
"latitude": 50.98539,
"longitude": 2.23052
},
{
"latitude": 50.98863,
"longitude": 2.35777
},
{
"latitude": 50.43132,
"longitude": 2.84907
},
{
"latitude": 50.33847,
"longitude": 2.92668
},
{
"latitude": 50.22934,
"longitude": 3.27133
},
{
"latitude": 50.45216,
"longitude": 3.76045
},
{
"latitude": 50.48706,
"longitude": 4.08585
},
{
"latitude": 49.98206,
"longitude": 4.51402
},
{
"latitude": 50.49117,
"longitude": 4.6182
},
{
"latitude": 50.09545,
"longitude": 5.13195
},
{
"latitude": 49.91044,
"longitude": 5.29447
},
{
"latitude": 50.02166,
"longitude": 5.69731
},
{
"latitude": 50.07049,
"longitude": 5.73492
},
{
"latitude": 50.21669,
"longitude": 6.23432
},
{
"latitude": 50.11697,
"longitude": 6.43576
},
{
"latitude": 50.46513,
"longitude": 6.7001
},
{
"latitude": 50.37483,
"longitude": 7.41121
},
{
"latitude": 50.52358,
"longitude": 7.67539
},
{
"latitude": 50.87047,
"longitude": 7.96531
},
{
"latitude": 51.02269,
"longitude": 7.82893
},
{
"latitude": 51.54443,
"longitude": 8.1081
},
{
"latitude": 52.2334,
"longitude": 9.25347
},
{
"latitude": 52.86505,
"longitude": 8.23947
},
{
"latitude": 52.95622,
"longitude": 8.56608
},
{
"latitude": 53.18553,
"longitude": 8.10646
},
{
"latitude": 53.32431,
"longitude": 6.87906
},
{
"latitude": 53.24864,
"longitude": 6.46143
},
{
"latitude": 53.21977,
"longitude": 5.98597
},
{
"latitude": 53.20076,
"longitude": 5.64319
},
{
"latitude": 53.18381,
"longitude": 5.45848
},
{
"latitude": 53.03505,
"longitude": 5.23428
},
{
"latitude": 52.95193,
"longitude": 5.0762
},
{
"latitude": 52.7731,
"longitude": 4.956
},
{
"latitude": 52.73059,
"longitude": 4.89175
}
]
}
}
},
{
"statusCode": 200,
"response": {
"formatVersion": "0.0.1",
"copyright": "...",
"privacy": "...",
"reachableRange": {
"center": {
"latitude": 52.36178,
"longitude": 4.85216
},
"boundary": [
{
"latitude": 52.55238,
"longitude": 4.831
},
{
"latitude": 52.58944,
"longitude": 4.81481
},
{
"latitude": 52.61593,
"longitude": 4.75696
},
{
"latitude": 52.61869,
"longitude": 4.73182
},
{
"latitude": 52.60065,
"longitude": 4.72924
},
{
"latitude": 52.5704,
"longitude": 4.69259
},
{
"latitude": 52.56248,
"longitude": 4.66803
},
{
"latitude": 52.51754,
"longitude": 4.65152
},
{
"latitude": 52.51005,
"longitude": 4.65357
},
{
"latitude": 52.47165,
"longitude": 4.60932
},
{
"latitude": 52.46203,
"longitude": 4.58628
},
{
"latitude": 52.44705,
"longitude": 4.59327
},
{
"latitude": 52.40392,
"longitude": 4.54964
},
{
"latitude": 52.34494,
"longitude": 4.58513
},
{
"latitude": 52.27725,
"longitude": 4.51188
},
{
"latitude": 52.17925,
"longitude": 4.40661
},
{
"latitude": 52.13387,
"longitude": 4.40049
},
{
"latitude": 52.08084,
"longitude": 4.4085
},
{
"latitude": 52.12844,
"longitude": 4.54478
},
{
"latitude": 52.14113,
"longitude": 4.6569
},
{
"latitude": 52.13626,
"longitude": 4.69284
},
{
"latitude": 52.18881,
"longitude": 4.76185
},
{
"latitude": 52.24121,
"longitude": 4.81595
},
{
"latitude": 52.25268,
"longitude": 4.8248
},
{
"latitude": 52.2258,
"longitude": 4.85207
},
{
"latitude": 52.22231,
"longitude": 4.86311
},
{
"latitude": 52.11528,
"longitude": 4.91272
},
{
"latitude": 52.10203,
"longitude": 4.91813
},
{
"latitude": 52.15657,
"longitude": 4.9549
},
{
"latitude": 52.07171,
"longitude": 5.03885
},
{
"latitude": 52.03868,
"longitude": 5.06395
},
{
"latitude": 52.06083,
"longitude": 5.09541
},
{
"latitude": 52.12659,
"longitude": 5.1081
},
{
"latitude": 52.23269,
"longitude": 5.04984
},
{
"latitude": 52.17824,
"longitude": 5.18006
},
{
"latitude": 52.20553,
"longitude": 5.27285
},
{
"latitude": 52.21432,
"longitude": 5.33036
},
{
"latitude": 52.35769,
"longitude": 5.3551
},
{
"latitude": 52.4155,
"longitude": 5.38742
},
{
"latitude": 52.37996,
"longitude": 4.97327
},
{
"latitude": 52.39278,
"longitude": 4.96466
},
{
"latitude": 52.45905,
"longitude": 5.03088
},
{
"latitude": 52.49351,
"longitude": 5.03124
},
{
"latitude": 52.54294,
"longitude": 5.02473
},
{
"latitude": 52.65356,
"longitude": 5.07229
},
{
"latitude": 52.67399,
"longitude": 5.06906
},
{
"latitude": 52.7202,
"longitude": 5.02538
},
{
"latitude": 52.63563,
"longitude": 4.9565
},
{
"latitude": 52.54702,
"longitude": 4.87765
},
{
"latitude": 52.54899,
"longitude": 4.86904
}
]
}
}
}
],
"summary": {
"successfulRequests": 3,
"totalRequests": 4
}
}

Error response

Note: For historical reasons, the default error response format is XML. It may be changed using the Accept header.

JSON error response example
{
"formatVersion": "0.0.1",
"error": {
"description": "Batch not found for provided id."
},
"detailedError": {
"code": "BatchNotFound",
"message": "Batch not found for provided id."
}
}

Error response fields

Primary fields
FieldDescription
formatVersion
string
Version of the batch error response format.
error
object

Simplified information about the error.
error object

detailedError
object

Detailed information about the error.
detailedError object

error object
FieldDescription
description
string

A human-readable description of the error.
It is intended as an aid to developers and is not suitable for exposure to end users.

detailedError object
FieldDescription

code
string

One of the defined error codes .

message
string

A human-readable description of the error code. It is intended as an aid to developers and is not suitable for exposure to end users.

target
string

Optional.
Target of the particular error.
Values:

  • The name of the request parameter.
  • postBody

details
array

Optional.
An array of root causes (more detailed errors) that led to this error.
detailedError array

innerError`
object

Optional.
A higher level of detail about this error.
innerError object

innerError object
FieldDescription

code
string

One of the defined error codes .

message
string

Optional.
A human-readable representation of the error code.
It is intended as an aid to developers and is not suitable for exposure to end users.

innerError
object

Optional.
A higher level of detail about this error.
innerError object

Error code hierarchy

List of predefined, hierarchical, human-readable error codes.

  • Top-level codes correspond to HTTP error codes.
  • These may be refined by error codes in details or innerError.
  • Further levels of refinement are possible by nesting innerError inside innerError.

In the future, the list may be extended with additional codes. Applications must be ready to handle unknown error codes (e.g., by stopping error processing at the last understood level of detail).

Error codeDescription
BadArgument

One of the request parameters did not pass validation. The target field contains the name of the related parameter.

Possible inner errors:

  • InvalidParameterValue

  • ValueOutOfRange

BatchNotFound

Top-level code for requests which resulted in an HTTP 404 Not Found caused by requesting a batchId that does not exist or by the batch having already expired.

InvalidParameterValueThe value of one of the parameters is invalid.
InternalServerError

Top-level code for requests that resulted in an HTTP 500 Internal Server Error. The service cannot handle the request right now due to an unexpected condition.

NotFound

Top-level code for requests that resulted in an HTTP 404 Not Found caused by providing incorrect request path.

ServiceUnavailable

Top-level code for requests that resulted in an HTTP 503 Service Unavailable. The service cannot handle the request right now; this is typically a temporary state.

ValueOutOfRange

The value of one of the numeric parameters is outside the allowed range.