Sorry, you need to enable JavaScript to visit this website.

Asynchronous Batch Download

 

Service version: 2
Last edit: 2019.11.29

On this page

Purpose

This endpoint fetches results of the Asynchronous batch processing.

  • It responds with HTTP 200 and the batch results assuming batch processing has completed, or HTTP 202 Accepted if the batch is still being processed.
  • HTTP 202 "Accepted" will be 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.
  • A HTTP 200 Response does not indicate that every batch item succeeded, but only that the batch calculation was completed.
  • Detailed information about the success or failure of the individual requests within the batch is provided in the HTTP 200 response.

The Batch download endpoint GET Request is a blocking long poll request.

Request data

HTTPS method: GET

URL format

For ease of viewing and identification:

  • Constants and parameters enclosed in angle brackets (< >) must be replaced with their values.
  • See the following Request parameters section with the Required and Optional parameters tables for these values.
https://<baseURL>/search/<versionNumber>/batch/<batchId>?key=<Your_API_Key>[&waitTimeSeconds=<waitTimeSeconds>]

Example

https://api.tomtom.com/search/2/batch/batchId?key=Your_API_Key

HTTP Request headers

The following table describes HTTP Request headers of particular interest to Batch Search service clients.

Required headers
Note: There are no required headers in this endpoint.
Optional headers
Header Description
Accept-Encoding
string
Should contain list of encodings acceptable by the client. Used to demand a compressed Response.
Value: gzip
Accept
string
Indicates the format of the download error Response (e.g., a batch with a 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 the download error Response will have the default format which is xml.
Note: In case of a successful Response, the Accept header value will not affect the batch Response format.
Values:

  • application/xml
  • application/json
Tracking-ID
string
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 format that matches this regular expression is UUID: (e.g., 9ac68072-c7a4-11e8-a8d5-f2801f1b9fd1). For details check RFC 4122.
  • If specified, it is replicated in the Tracking-ID Response header.
  • It is only meant to be used for support and does not involve tracking of you or your users in any form.

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, which are highlighted with [square brackets], may be used.
  • If there is a default value that will be assumed when an optional parameter is not used, it is shown in the table.
  • The order of Request parameters is not important.
  • Required parameters must be used or the call will fail.
  • Optional parameters may be used.
Required parameters
Parameter Description
baseURL
string
The base URL for calling the API.
Value: api.tomtom.com
versionNumber
string
Service version.
Value: The current value is 2.
key
string
An API Key valid for the requested service.
Value: Your valid API Key.
batchId
string
Unique id of the batch. Returned in the HTTP Location header of the Batch Submission Response.
Value: A unique ID generated by the submission.
Optional parameters
Parameter Description
[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 processed.

  • If the batch processing completes during the given number of seconds, then the batch processing result is returned.
  • Otherwise, if the batch is still processing, a HTTP 202 (Accepted) response is returned. The client should then retry the Request by following the Location header.
    Please 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
Minimum value: 5
Maximum value: 60

▲ Return to top

Response data

HTTP Status codes

Code Meaning and 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 Search 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 a provided batchId does not exist.
405 Method Not Allowed: The client used a HTTP method other than GET.
408 Request timeout: The request sent to the server took longer than it 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.

▲ Return to top

HTTP Response headers

Header Description
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 Search service.
Value: *
Content-Encoding The Batch Search service applies gzip compression to the responses if it is requested by the client 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/xml;charset=utf-8
  • application/json;charset=utf-8
Location Indicates the location where the batch results can be downloaded. Available only if the response is HTTP 202.
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.
  • It is only meant to be used for support and does not involve tracking of you or your users in any form.

Value: An identifier for the Request.

▲ Return to top

Successful Response structure

Each batch Response consists of one or more batchItem elements which correspond sequentially with the batchItem elements in the Request. Each batchItem element contains a successful Response from the invoked Search API endpoint or a status code indicating why the batch item failed.

XML Response

<?xml version="1.0" encoding="utf-8"?>
<batchResponse
  xmlns="http://api.tomtom.com/batch" formatVersion="0.0.1">
  <batchItems>
    <batchItem>
      <statusCode>...</statusCode>
      <response>
                ...
            </response>
    </batchItem>
                ...
    <batchItem>
      <statusCode>...</statusCode>
      <response>
                ...
            </response>
    </batchItem>
  </batchItems>
  <summary>
    <successfulRequests>...</successfulRequests>
    <totalRequests>...</totalRequests>
  </summary>
</batchResponse>

JSON Response

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

▲ Return to top

Successful Response fields

Field Description
batchResponse
object
Root element of the batch Response.
successfulRequests
string
Number of successful batch item requests.
totalRequests
string
Total number of items in batch Request.
batchItems
array
A set of batch items processing results.
batchItem
object
Contains results of processing of a single batch item.
statusCode
string
Status code of a Response from the underlying Search API endpoint for given batch item.
response
object
Content of the Response from the underlying Search API endpoint for given batch item query.

  • The full Response content will be included both in case of success and failure.
  • If the underlying service's Response content type does not match requested content type, then the Response will be wrapped to fit the requested content type.
summary
object
Summary of the batch Request.

▲ Return to top

Successful Response examples

The following code blocks in XML and JSON contain a complete example of a Response to a batch Request for three queries to the Fuzzy Search API.

  • Two of the batch items were successfully executed resulting in a HTTP 200 response, while one failed with a HTTP 400 error due to the use of an incorrect query parameter.
  • Note that batch success indicates that each batch item was executed, not that each batch item executed successfully.

Click to expand/collapse the following examples.

XML Response example

<?xml version="1.0" encoding="UTF-8"?>
<batchResponse xmlns="http://api.tomtom.com/batch" formatVersion="0.0.1">
  <batchItems>
    <batchItem>
      <statusCode>200</statusCode>
      <response>
        <response>
          <summary>
            <query>lodz</query>
            <queryType>NON_NEAR</queryType>
            <queryTime>95</queryTime>
            <numResults>1</numResults>
            <offset>0</offset>
            <totalResults>363</totalResults>
            <fuzzyLevel>1</fuzzyLevel>
          </summary>
          <results>
            <item>
              <type>Geography</type>
              <id>PL/GEO/p0/4455</id>
              <score>5.98</score>
              <info>search:decarta:ta:616013002038177-PL</info>
              <address>
                <municipality>Lodz</municipality>
                <countrySecondarySubdivision>Łódź</countrySecondarySubdivision>
                <countrySubdivision>Łódzkie</countrySubdivision>
                <countryCode>PL</countryCode>
                <country>Poland</country>
                <countryCodeISO3>POL</countryCodeISO3>
                <freeformAddress>Lodz</freeformAddress>
              </address>
              <position>
                <lat>51.75905</lat>
                <lon>19.4586</lon>
              </position>
            </item>
          </results>
        </response>
      </response>
    </batchItem>
    <batchItem>
      <statusCode>200</statusCode>
      <response>
        <response>
          <summary>
            <query>restaurant amsterdam</query>
            <queryType>NON_NEAR</queryType>
            <queryTime>186</queryTime>
            <numResults>3</numResults>
            <offset>0</offset>
            <totalResults>3731</totalResults>
            <fuzzyLevel>1</fuzzyLevel>
          </summary>
          <results>
            <item>
              <type>POI</type>
              <id>AU/POI/p0/261806</id>
              <score>7.5</score>
              <info>search:decarta:ta:036001105620466-AU</info>
              <poi>
                <name>Nieuw Amsterdam</name>
                <categories>
                  <item>restaurant</item>
                </categories>
                <classifications>
                  <item>
                    <code>RESTAURANT</code>
                    <names>
                      <item>
                        <nameLocale>en-US</nameLocale>
                        <name>restaurant</name>
                      </item>
                    </names>
                  </item>
                </classifications>
              </poi>
              <address>
                <streetNumber>112</streetNumber>
                <streetName>Hardware Street</streetName>
                <municipalitySubdivision>Melbourne CBD</municipalitySubdivision>
                <municipality>Melbourne</municipality>
                <countrySecondarySubdivision>Melbourne</countrySecondarySubdivision>
                <countrySubdivision>Vic</countrySubdivision>
                <postalCode>3000</postalCode>
                <countryCode>AU</countryCode>
                <country>Australia</country>
                <countryCodeISO3>AUS</countryCodeISO3>
                <freeformAddress>Hardware Street 112, Melbourne CBD Melbourne, Vic, 3000</freeformAddress>
              </address>
              <position>
                <lat>-37.8123</lat>
                <lon>144.96068</lon>
              </position>
            </item>
            <item>
              <type>POI</type>
              <id>BE/POI/p0/61115</id>
              <score>7.5</score>
              <info>review:decarta:ta:056001000066087-BE</info>
              <poi>
                <name>Borse van Amsterdam</name>
                <url>www.borsevanamsterdam.be</url>
                <categories>
                  <item>belgian</item>
                  <item>important tourist attraction</item>
                  <item>restaurant</item>
                </categories>
                <classifications>
                  <item>
                    <code>RESTAURANT</code>
                    <names>
                      <item>
                        <nameLocale>en-US</nameLocale>
                        <name>belgian</name>
                      </item>
                      <item>
                        <nameLocale>en-US</nameLocale>
                        <name>restaurant</name>
                      </item>
                    </names>
                  </item>
                  <item>
                    <code>IMPORTANT_TOURIST_ATTRACTION</code>
                    <names>
                      <item>
                        <nameLocale>en-US</nameLocale>
                        <name>important tourist attraction</name>
                      </item>
                    </names>
                  </item>
                </classifications>
              </poi>
              <address>
                <streetNumber>26</streetNumber>
                <streetName>Grote Markt</streetName>
                <municipalitySubdivision>Aalst</municipalitySubdivision>
                <municipality>Aalst</municipality>
                <countrySecondarySubdivision>Oost-Vlaanderen</countrySecondarySubdivision>
                <countryTertiarySubdivision>Aalst</countryTertiarySubdivision>
                <countrySubdivision>Vlaams Gewest</countrySubdivision>
                <postalCode>9300</postalCode>
                <countryCode>BE</countryCode>
                <country>Belgium</country>
                <countryCodeISO3>BEL</countryCodeISO3>
                <freeformAddress>Grote Markt 26, 9300 Aalst</freeformAddress>
              </address>
              <position>
                <lat>50.93852</lat>
                <lon>4.03821</lon>
              </position>
            </item>
            <item>
              <type>POI</type>
              <id>BG/POI/p0/11627</id>
              <score>7.5</score>
              <info>search:decarta:ta:100009000014937-BG</info>
              <poi>
                <name>Amsterdam</name>
                <phone>+(359)-(87)-8868962</phone>
                <categories>
                  <item>restaurant</item>
                </categories>
                <classifications>
                  <item>
                    <code>RESTAURANT</code>
                    <names>
                      <item>
                        <nameLocale>en-US</nameLocale>
                        <name>restaurant</name>
                      </item>
                    </names>
                  </item>
                </classifications>
              </poi>
              <address>
                <streetNumber>10</streetNumber>
                <streetName>улица К. Стоилов</streetName>
                <municipalitySubdivision>Plovdiv</municipalitySubdivision>
                <municipality>Пловдив</municipality>
                <countrySecondarySubdivision>Пловдив</countrySecondarySubdivision>
                <postalCode>4000</postalCode>
                <countryCode>BG</countryCode>
                <country>Bulgaria</country>
                <countryCodeISO3>BGR</countryCodeISO3>
                <freeformAddress>улица К. Стоилов 10, 4000 Plovdiv (Пловдив)</freeformAddress>
              </address>
              <position>
                <lat>42.14805</lat>
                <lon>24.7491</lon>
              </position>
            </item>
          </results>
        </response>
      </response>
    </batchItem>
    <batchItem>
      <statusCode>400</statusCode>
      <response>
        <response>
          <errorText>Error parsing 'maxFuzzyLevel': 'asd' is not a valid integer</errorText>
          <message>Error parsing 'maxFuzzyLevel': 'asd' is not a valid integer</message>
          <httpStatusCode>400</httpStatusCode>
        </response>
      </response>
    </batchItem>
  </batchItems>
  <summary>
    <successfulRequests>2</successfulRequests>
    <totalRequests>3</totalRequests>
  </summary>
</batchResponse>

JSON Response example

{
  "formatVersion": "0.0.1",
  "batchItems": [
    {
      "statusCode": 200,
      "response": {
        "summary": {
          "query": "lodz",
          "queryType": "NON_NEAR",
          "queryTime": 101,
          "numResults": 1,
          "offset": 0,
          "totalResults": 363,
          "fuzzyLevel": 1
        },
        "results": [
          {
            "type": "Geography",
            "id": "PL/GEO/p0/4455",
            "score": 5.98,
            "info": "search:decarta:ta:616013002038177-PL",
            "address": {
              "municipality": "Lodz",
              "countrySecondarySubdivision": "Łódź",
              "countrySubdivision": "Łódzkie",
              "countryCode": "PL",
              "country": "Poland",
              "countryCodeISO3": "POL",
              "freeformAddress": "Lodz"
            },
            "position": {
              "lat": 51.75905,
              "lon": 19.4586
            }
          }
        ]
      }
    },
    {
      "statusCode": 200,
      "response": {
        "summary": {
          "query": "restaurant amsterdam",
          "queryType": "NON_NEAR",
          "queryTime": 186,
          "numResults": 3,
          "offset": 0,
          "totalResults": 3731,
          "fuzzyLevel": 1
        },
        "results": [
          {
            "type": "POI",
            "id": "AU/POI/p0/261806",
            "score": 7.5,
            "info": "search:decarta:ta:036001105620466-AU",
            "poi": {
              "name": "Nieuw Amsterdam",
              "categories": [
                "restaurant"
              ],
              "classifications": [
                {
                  "code": "RESTAURANT",
                  "names": [
                    {
                      "nameLocale": "en-US",
                      "name": "restaurant"
                    }
                  ]
                }
              ]
            },
            "address": {
              "streetNumber": "112",
              "streetName": "Hardware Street",
              "municipalitySubdivision": "Melbourne CBD",
              "municipality": "Melbourne",
              "countrySecondarySubdivision": "Melbourne",
              "countrySubdivision": "Vic",
              "postalCode": "3000",
              "countryCode": "AU",
              "country": "Australia",
              "countryCodeISO3": "AUS",
              "freeformAddress": "Hardware Street 112, Melbourne CBD Melbourne, Vic, 3000"
            },
            "position": {
              "lat": -37.8123,
              "lon": 144.96068
            }
          },
          {
            "type": "POI",
            "id": "BE/POI/p0/61115",
            "score": 7.5,
            "info": "review:decarta:ta:056001000066087-BE",
            "poi": {
              "name": "Borse van Amsterdam",
              "url": "www.borsevanamsterdam.be",
              "categories": [
                "belgian",
                "important tourist attraction",
                "restaurant"
              ],
              "classifications": [
                {
                  "code": "RESTAURANT",
                  "names": [
                    {
                      "nameLocale": "en-US",
                      "name": "belgian"
                    },
                    {
                      "nameLocale": "en-US",
                      "name": "restaurant"
                    }
                  ]
                },
                {
                  "code": "IMPORTANT_TOURIST_ATTRACTION",
                  "names": [
                    {
                      "nameLocale": "en-US",
                      "name": "important tourist attraction"
                    }
                  ]
                }
              ]
            },
            "address": {
              "streetNumber": "26",
              "streetName": "Grote Markt",
              "municipalitySubdivision": "Aalst",
              "municipality": "Aalst",
              "countrySecondarySubdivision": "Oost-Vlaanderen",
              "countryTertiarySubdivision": "Aalst",
              "countrySubdivision": "Vlaams Gewest",
              "postalCode": "9300",
              "countryCode": "BE",
              "country": "Belgium",
              "countryCodeISO3": "BEL",
              "freeformAddress": "Grote Markt 26, 9300 Aalst"
            },
            "position": {
              "lat": 50.93852,
              "lon": 4.03821
            }
          },
          {
            "type": "POI",
            "id": "BG/POI/p0/11627",
            "score": 7.5,
            "info": "search:decarta:ta:100009000014937-BG",
            "poi": {
              "name": "Amsterdam",
              "phone": "+(359)-(87)-8868962",
              "categories": [
                "restaurant"
              ],
              "classifications": [
                {
                  "code": "RESTAURANT",
                  "names": [
                    {
                      "nameLocale": "en-US",
                      "name": "restaurant"
                    }
                  ]
                }
              ]
            },
            "address": {
              "streetNumber": "10",
              "streetName": "улица К. Стоилов",
              "municipalitySubdivision": "Plovdiv",
              "municipality": "Пловдив",
              "countrySecondarySubdivision": "Пловдив",
              "postalCode": "4000",
              "countryCode": "BG",
              "country": "Bulgaria",
              "countryCodeISO3": "BGR",
              "freeformAddress": "улица К. Стоилов 10, 4000 Plovdiv (Пловдив)"
            },
            "position": {
              "lat": 42.14805,
              "lon": 24.7491
            }
          }
        ]
      }
    },
    {
      "statusCode": 400,
      "response": {
          "errorText": "Error parsing 'maxFuzzyLevel': 'asd' is not a valid integer",
          "message": "Error parsing 'maxFuzzyLevel': 'asd' is not a valid integer",
          "httpStatusCode": 400
      }
    }
  ],
  "summary": {
    "successfulRequests": 2,
    "totalRequests": 3
  }
}

▲ Return to top

Other supported Search API suite responses

For details on particular supported Search API suite endpoint's response structure, consult the following respective API documentation pages:

Error Response

The default error Response format is XML. It may be changed by using the Accept header.

Error Response example (XML)

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<batchResponse xmlns="http://api.tomtom.com/batch" formatVersion="0.0.1">
  <error description="Batch not found for provided id."/>
  <detailedError>
    <code>BatchNotFound</code>
    <message>Batch not found for provided id.</message>
  </detailedError>
</batchResponse>

Error Response example (JSON)

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

▲ Return to top

Error Response fields

Primary fields
Field Description
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
Field Description
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
Field Description
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 details about this error.
innerError{} object
innerError{} object
Field Description
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 details about this error.
innerError{} object

▲ Return to top

Error code hierarchy

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

  • Top level codes relate to HTTP error codes.
  • They 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. The application must be ready for the occurrence of an unknown error code (e.g., by stopping error processing at the last understood level of detail).

Error code Description
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 ended with HTTP 404 Not Found caused by requesting batchId which does not exist, or the batch being already expired.
InvalidParameterValue The value of one of the parameters is invalid.
InternalServerError Top level code for Requests which ended with HTTP 500 Internal Server Error. The service cannot handle the request right now, an unexpected condition was encountered.
NotFound Top level code for Requests which ended with HTTP 404 Not Found caused by providing incorrect Request path.
ServiceUnavailable Top level code for Requests which ended with HTTP 503 Service Unavailable. The service cannot handle the request right now, this is certainly a temporary state.
ValueOutOfRange The value of one of the numeric parameters is out of the allowed range.

▲ Return to top

You are here