Examples
Sample requests in this document are presented using the curl command line tool.
Send request to initiate matrix generation
curl -X POST 'https://distancematrix.api.mappable.world/v2/async//driving/matrices/generate?apikey=YOUR_API_KEY' \
-H 'Content-Type: application/json'
-d '{"origins":[[37.540775,55.886412],[37.509132,55.825264],[37.484335,55.826820],[37.722153,55.721870],[37.468273,55.676837]],"destinations":[[37.619979,55.676799],[37.646084,55.826680],[37.661889,55.671596],[37.640079,55.780732],[37.494420,55.762688],[37.656392,55.874199]]}'
Example response
{
"id": "abc-012345",
"done": false
}
Get the status of the operation
Use the ID of the operation from the response of the previous request.
curl 'https://distancematrix.api.mappable.world/v2/async//driving/operations/get?apikey=YOUR_API_KEY&id=OPERATION_ID'
Example response when the operation is in-progress
{
"id": "abc-012345",
"done": false
}
Example response when the operation has completed
{
"id": "abc-012345",
"done": true,
"response": {
"matrixId": "7335312_8ad6-b4a6"
}
}
Example response when the operation has failed
{
"id": "abc-012345",
"done": true,
"error": {
"code": 500,
"message": "Internal Server Error"
}
}
Fetch the resulting matrix
Use the ID of the matrix from the response of the previous request.
Note that the response body for this request is gzip-encoded. To inspect the decoded content in the command line, you can pipe the response to the gunzip
command.
curl 'https://distancematrix.api.mappable.world/v2/async//driving/matrices/get?apikey=YOUR_API_KEY&id=MATRIX_ID' | gunzip
Example response
{
"cells": [
[ [36100, 6966], [26075, 5232], [44059, 8404], [28426, 5700], [29732, 5960], [31785, 6368]],
[ [34422, 6633], [24398, 4898], [42381, 8072], [26748, 5366], [28055, 5626], [30524, 6117]],
[ [36845, 5831], [25164, 5051], [42464, 7096], [27515, 5519], [1586, 325], [37445, 7492]],
[ [15570, 1925], [25146, 4101], [13327, 2681], [20942, 3262], [51957, 7639], [20934, 3613]],
[ [32949, 5056], [31305, 6272], [38568, 6322], [33656, 6739], [10300, 2082], [43586, 8709]]
]
}