Matrix API (1.0.0)

Matrix API computes the road distance and the travel time between every pair of locations in a set, in one request. With the Matrix API, you can:

  • Get the distance and duration from every waypoint to every other waypoint: N waypoints give N x N values
  • Feed route optimization, dispatching or nearest-vehicle searches with road-network distances and travel times instead of straight lines
  • Compute matrices for car, truck, pedestrian and bike, with the road, cross, city and mountain bike profiles

Matrix

Returns the distance and duration matrix between waypoints via POST

Returns the distance in meters and the duration in seconds of the fastest route from every waypoint to every waypoint. Row i holds the values from waypoint i, column j the values to waypoint j; the diagonal is 0. A pair with no route between its waypoints has null in both matrices.

Authorizations:
ApiKey
Request Body schema: application/json
required

Matrix parameters

transport
string
Default: "car"
Enum: "car" "truck" "pedestrian" "bike"

transport mode. Every value of the matrix is the fastest route for this transport mode

waypoints
required
Array of numbers [ 2 .. 5000 ] items [ items <double > = 2 items [ items <double > ] ]

the locations, each as [ lon, lat ] ( longitude first ). At least 2 and at most 5000; N waypoints give N x N values. The same location may appear more than once ( 0 between its copies ). Every waypoint must be matched to the road network of the transport mode, otherwise the request returns an error with code -19 ( HTTP 422 ) instead of a matrix

profile
string
Default: "city"
Enum: "road" "cross" "city" "mountain"

bike profile, for transport "bike" only. Any other profile ( e-bike or pedestrian profiles ) or a profile with another transport mode is rejected as invalid

object

vehicle characteristics; only profile is accepted

profile
string
Enum: "road" "cross" "city" "mountain"

bike profile, for transport "bike" only. Any other profile ( e-bike or pedestrian profiles ) or a profile with another transport mode is rejected as invalid

debug
boolean
Default: false

if true, the response is pretty-printed

Responses

Response Schema: application/json
object
copyrights
Array of strings
object (errorObject)

the error, returned instead of the matrices

code
integer

error code:

  • -15: invalid request ( HTTP 400 ); details names the parameter
  • -19: a waypoint could not be matched to the road network of the transport mode ( HTTP 422 ); details names its index
  • -38: too many requests ( HTTP 429 )
  • -22, -25, -36: a service or data the calculation needs is not available ( HTTP 503 )
  • -21, -1: internal error ( HTTP 500 )
reason
string

error description

details
string

what in the request caused the error

distances
Array of integers or null[ items ]

distance matrix in meters. Row i = from waypoint i, column j = to waypoint j; null when no route connects the two waypoints

durations
Array of integers or null[ items ]

duration matrix in seconds, the same layout as distances

Response Schema: application/json
object
copyrights
Array of strings
required
object (errorObject)

the error, returned instead of the matrices

code
integer

error code:

  • -15: invalid request ( HTTP 400 ); details names the parameter
  • -19: a waypoint could not be matched to the road network of the transport mode ( HTTP 422 ); details names its index
  • -38: too many requests ( HTTP 429 )
  • -22, -25, -36: a service or data the calculation needs is not available ( HTTP 503 )
  • -21, -1: internal error ( HTTP 500 )
reason
string

error description

details
string

what in the request caused the error

Response Schema: application/json
object
copyrights
Array of strings
required
object (errorObject)

the error, returned instead of the matrices

code
integer

error code:

  • -15: invalid request ( HTTP 400 ); details names the parameter
  • -19: a waypoint could not be matched to the road network of the transport mode ( HTTP 422 ); details names its index
  • -38: too many requests ( HTTP 429 )
  • -22, -25, -36: a service or data the calculation needs is not available ( HTTP 503 )
  • -21, -1: internal error ( HTTP 500 )
reason
string

error description

details
string

what in the request caused the error

Response Schema: application/json
object
copyrights
Array of strings
required
object (errorObject)

the error, returned instead of the matrices

code
integer

error code:

  • -15: invalid request ( HTTP 400 ); details names the parameter
  • -19: a waypoint could not be matched to the road network of the transport mode ( HTTP 422 ); details names its index
  • -38: too many requests ( HTTP 429 )
  • -22, -25, -36: a service or data the calculation needs is not available ( HTTP 503 )
  • -21, -1: internal error ( HTTP 500 )
reason
string

error description

details
string

what in the request caused the error

Response Schema: application/json
object
copyrights
Array of strings
required
object (errorObject)

the error, returned instead of the matrices

code
integer

error code:

  • -15: invalid request ( HTTP 400 ); details names the parameter
  • -19: a waypoint could not be matched to the road network of the transport mode ( HTTP 422 ); details names its index
  • -38: too many requests ( HTTP 429 )
  • -22, -25, -36: a service or data the calculation needs is not available ( HTTP 503 )
  • -21, -1: internal error ( HTTP 500 )
reason
string

error description

details
string

what in the request caused the error

Response Schema: application/json
object
copyrights
Array of strings
required
object (errorObject)

the error, returned instead of the matrices

code
integer

error code:

  • -15: invalid request ( HTTP 400 ); details names the parameter
  • -19: a waypoint could not be matched to the road network of the transport mode ( HTTP 422 ); details names its index
  • -38: too many requests ( HTTP 429 )
  • -22, -25, -36: a service or data the calculation needs is not available ( HTTP 503 )
  • -21, -1: internal error ( HTTP 500 )
reason
string

error description

details
string

what in the request caused the error

Request samples

Content type
application/json
Example
{
  • "transport": "car",
  • "waypoints": [
    • [
      • 4.3517,
      • 50.8503
      ],
    • [
      • 4.4025,
      • 51.2194
      ],
    • [
      • 5.5797,
      • 50.6326
      ]
    ]
}

Response samples

Content type
application/json
Example
{
  • "info": {
    • "copyrights": [
      • "MagicLane"
      ]
    },
  • "distances": [
    • [
      • 0,
      • 55393,
      • 97517
      ],
    • [
      • 44793,
      • 0,
      • 133347
      ],
    • [
      • 97709,
      • 132066,
      • 0
      ]
    ],
  • "durations": [
    • [
      • 0,
      • 2690,
      • 3927
      ],
    • [
      • 2605,
      • 0,
      • 5126
      ],
    • [
      • 4013,
      • 5051,
      • 0
      ]
    ]
}