- Developers
- Mapas Sygic
- Routing API
- Batch Distance Matrix
Batch Distance Matrix
- Move to section
Please note Sygic does no longer issue new Sygic Maps API keys. This documentation is for existing customers only. If you wish to include maps & navigation into your project, please refer to Sygic Maps SDK.
Overview
Sygic Batch Distance Matrix supports up to 10 000 waypoints at a time. To enable more than 10 000 waypoints, please contact our team.
Request
API Reference
https://distancematrix.api.sygic.com/v0/api/batch/distancematrix?key=yourAPIkey
Request authentication is done via parameter key, which must be included in the request URL.
Methods
Method | Description |
POST | Initiate batch calculation. Contains JSON data to be processed. |
GET | Monitor status and retrieve results from the server once processed. |
Parameters
For the full list of supported parameters see Distance Matrix API documentation.
Create batch job
Batch Distance Matrix API is asynchronous, accepts POST
request to initiate batch processing and returns URL where result will be found when done.
Request
POST https://distancematrix.api.sygic.com/v0/api/batch/distancematrix?key=yourAPIkey
Content-Type: application/json
Request Body
{
"origins": [
"48.15539,17.16049",
"48.15597,17.16322",
"48.15539,17.16049",
"48.14202,17.16483",
"48.12413,17.11385",
"48.15771,17.10494",
"48.12413,17.11385"
],
"destinations": [
"48.15539,17.16049",
"48.15597,17.16322",
"48.15539,17.16049",
"48.14202,17.16483",
"48.12413,17.11385",
"48.15771,17.10494",
"48.12413,17.11385"
]
}
Response
Response header Location contains URI for polling the execution status and results retrieval.
Status: 202 Accepted
Location: https://distancematrix.api.sygic.com/v0/api/batch/distancematrix/<id>
{
"status": "OK",
"copyright": "© 2018 Sygic a.s."
}
Monitor batch job
Batch job state can be monitored by performing GET
operation on the returned URL location.
Request
GET https://distancematrix.api.sygic.com/v0/api/batch/distancematrix/<id>
Response
Status: 200
Retry-After: 1
{
"state": "WAITING|RUNNING|FINISHED|FAILED",
"status": "OK|NO_RESULTS",
"error": {
"code": "...",
"message": "..."
}
}
Client is expected to perform regular polling on the result url until the job is finished. Client should wait between each try, as advised by Retry-After
header value (in seconds).
State | Status | Description |
Waiting | NO_RESULTS | Request has been accepted and batch job is waiting to be processed. |
Running | NO_RESULTS | Batch job is running. |
Finished | OK | Batch job has succeeded and distance matrix is ready. |
Failed | NO_RESULTS | Batch job has failed to produce result, error object contains further details. |
Get batch result
Successfully finished batch job contains calculated distance matrix in response body:
GET https://distancematrix.api.sygic.com/v0/api/batch/distancematrix/<id>
Status: 200
{
"origins": [
"48.15539,17.16049",
"48.15597,17.16322",
"48.15539,17.16049",
"48.14202,17.16483",
"48.12413,17.11385",
"48.15771,17.10494",
"48.12413,17.11385"
],
"destinations": [
"48.15539,17.16049",
"48.15597,17.16322",
"48.15539,17.16049",
"48.14202,17.16483",
"48.12413,17.11385",
"48.15771,17.10494",
"48.12413,17.11385"
],
"distances":
[
[ 0, 568, 0, 3488, 6444, 4980, 6444 ],
[ 568, 0, 568, 3541, 6497, 4906, 6497 ],
[ 0, 568, 0, 3488, 6444, 4980, 6444 ],
[ 3936, 3767, 3936, 0, 8802, 9657, 8802 ],
[ 7169, 7000, 7169, 5085, 0, 4486, 0 ],
[ 6738, 6490, 6738, 7721, 6649, 0, 6649 ],
[ 7169, 7000, 7169, 5085, 0, 4486, 0 ]
],
"durations":
[
[ 0, 56, 0, 298, 543, 498, 543 ],
[ 56, 0, 56, 303, 548, 481, 548 ],
[ 0, 56, 0, 298, 543, 498, 543 ],
[ 301, 284, 301, 0, 561, 746, 561 ],
[ 593, 577, 593, 322, 0, 389, 0 ],
[ 648, 624, 648, 684, 586, 0, 586 ],
[ 593, 577, 593, 322, 0, 389, 0 ]
],
"state": "Finished",
"status": "OK",
"copyright": "© 2018 Sygic a.s."
}
- Previous article: Distance Matrix
- Next article: Send Route to Navigation