Using the Time-Distance-Matrix

Our Time Distance Matrix is a high-performance time distance matrix API (1000*1000), that can be used for planning applications, for cars, trucks, bikes, pedestrians, field force technicians and mobile sales force.

By entering up to 1.000 addresses, various routing options (shortest, fastest, safest, most efficient) will be provided as a matrix, which can be used in the planning or routing application.

If you’re already familiar with APIs, you can jump straight to the Swagger definitions.

In our examples, we will use Curl. If you’re on Linux or OS X, you will already have it installed.

Windows users can get it here. You can simply copy and paste the examples, but you will need to replace certain values with information that applies to your specific situation.

Let’s take you through some of the functionalities of the API through a step by step process.

Getting started

The Time Distance Matrix needs to be accessed in two steps, first you need to send a json file containing the job parameters and you will receive a queue id. Second using the queue id, you can retrieve the current status of your batch job and the potential result.

Request a batch job

To request a new batch job, first create a json file. We will use this file as input for the curl request next.

{
    "result":["cost","distance"],
    "origin_addresses":["4.54270,51.91240"],
    "destination_addresses":["4.54260,51.91241","4.53339,51.92548","4.5464,51.91478","4.54591,51.91479"]
}

Now make the actual curl request. Values you need to fill in yourself are located within the brackets.

curl https://api.and.com/tdmv1/order \
  -d @{path_to_json_file}
  -H 'x-api-key: {token}' \
  -H 'content-type: application/json'

The result will be:

{
  "uuid": "318e774a_f0c0_11e9_82e4_02e9457d8866"
}

Save the result as a json file, containing the uuid json output. Next supply the file location as a parameter in the following curl request.

Request batch job result

curl https://api.and.com/tdmv1/fetch \
  -d @{uuid.json} \
  -H "x-api-key: {token}" \
  -H "Content-Type: application/json" 

The result will be:

{
  "destination_addresses": [
    "4.54260,51.91241",
    "4.53339,51.92548",
    "4.5464,51.91478",
    "4.54591,51.91479"
  ],
  "distance": [
    [
      null,
      2869,
      540,
      574
    ]
  ],
  "duration": [
    [
      null,
      155,
      49,
      51
    ]
  ],
  "origin_addresses": [
    "4.54270,51.91240"
  ],
  "status": "Finished"
}

SDKS

It is also possible to access the Time Distance Matrix API using our supplied SKDS for Android and iOS. Each zip file contains a readme with details how to use the resource.

 

How to Purchase Our API Service

AND offers customer specific pricing for the TimeDistanceMatrix. Please send your request to sales@and.com