Route - Post Route Matrix Preview

Applies to: S1 pricing tier.

The Matrix Routing service allows calculation of a matrix of route summaries for a set of routes defined by origin and destination locations. For every given origin, this service calculates the cost of routing from that origin to every given destination. The set of origins and the set of destinations can be thought of as the column and row headers of a table and each cell in the table contains the costs of routing from the origin to the destination for that cell. For each route, the travel times and distances are calculated. You can use the computed costs to determine which routes to calculate using the Routing Directions API. If waitForResults parameter in the request is set to false (default value), this API returns a 202 response code along a redirect URL in the Location field of the response header. This URL should be checked periodically until the response data or error information is available.

The maximum size of a matrix for this API is 700 (the number of origins multiplied by the number of destinations). With that constraint in mind, examples of possible matrix dimensions are: 50x10, 10x10, 28x25. 10x70 (it does not need to be square).

The asynchronous responses are stored for 14 days. The redirect URL returns a 404 response if used after the expiration period.

Download Async Results

When a request issues a 202 Accepted response, the request is being processed using our async pipeline. You will be given a URL to check the progress of your async request in the location header of the response.

The URL provided by the location header will return the following responses when a GET request is issued.

HTTP 202 Accepted - Matrix request was accepted but is still being processed. Please try again in some time.

HTTP 200 OK - Matrix request successfully processed. The response body contains all of the results.

POST https://atlas.microsoft.com/route/matrix/json?api-version=1.0
POST https://atlas.microsoft.com/route/matrix/json?subscription-key={subscription-key}&api-version=1.0&waitForResults={waitForResults}&computeTravelTimeFor={computeTravelTimeFor}&sectionType={sectionType}&arriveAt={arriveAt}&departAt={departAt}&vehicleAxleWeight={vehicleAxleWeight}&vehicleLength={vehicleLength}&vehicleHeight={vehicleHeight}&vehicleWidth={vehicleWidth}&vehicleMaxSpeed={vehicleMaxSpeed}&vehicleWeight={vehicleWeight}&windingness={windingness}&hilliness={hilliness}&travelMode={travelMode}&avoid={avoid}&traffic={traffic}&routeType={routeType}&vehicleLoadType={vehicleLoadType}

URI Parameters

Name In Required Type Description
format
path True

Desired format of the response. Only json format is supported.

traffic
query
  • boolean

Possible values:

  • true - Do consider all available traffic information during routing
  • false - Ignore current traffic data during routing. Note that although the current traffic data is ignored during routing, the effect of historic traffic on effective road speeds is still incorporated.
avoid
query

Specifies something that the route calculation should try to avoid when determining the route. Can be specified multiple times in one request, for example, '&avoid=motorways&avoid=tollRoads&avoid=ferries'. In calculateReachableRange requests, the value alreadyUsedRoads must not be used.

travelMode
query

The mode of travel for the requested route. Note that the requested travelMode may not be available for the entire route. Where the requested travelMode is not available for a particular section, the travelMode element of the response for that section will be other. Note that travel modes bus, motorcycle, taxi and van are BETA functionality. Full restriction data is not available in all areas. In calculateReachableRange requests, the values bicycle and pedestrian must not be used

hilliness
query

Degree of hilliness for thrilling route. This parameter can only be used in conjunction with routeType=thrilling.

windingness
query

Level of turns for thrilling route. This parameter can only be used in conjunction with routeType=thrilling.

vehicleWeight
query
  • integer

Weight of the vehicle in kilograms.

vehicleMaxSpeed
query
  • integer

Maximum speed of the vehicle in km/hour. A value of 0 means that an appropriate value for the vehicle will be determined and applied during route planning. A non-zero value may be overridden during route planning.

vehicleWidth
query
  • number
float

Width of the vehicle in meters. A value of 0 means that width restrictions are not considered.

routeType
query

The type of route requested.

vehicleHeight
query
  • number
float

Height of the vehicle in meters. A value of 0 means that height restrictions are not considered.

vehicleAxleWeight
query
  • integer

Weight per axle of the vehicle in kg. A value of 0 means that weight restrictions per axle are not considered.

departAt
query
  • string
date-time

The date and time of departure from the origin point. Departure times apart from now must be specified as a dateTime. When a time zone offset is not specified, it will be assumed to be that of the origin point. The departAt value must be in the future in the date-time format (1996-12-19T16:39:57-08:00).

arriveAt
query
  • string
date-time

The date and time of arrival at the destination point. It must be specified as a dateTime. When a time zone offset is not specified it will be assumed to be that of the destination point. The arriveAt value must be in the future. The arriveAt parameter cannot be used in conjunction with departAt, minDeviationDistance or minDeviationTime.

sectionType
query

Specifies which of the section types is reported in the route response.

For example if sectionType = pedestrian the sections which are suited for pedestrians only are returned. Multiple types can be used. The default sectionType refers to the travelMode input. By default travelMode is set to car

computeTravelTimeFor
query

Specifies whether to return additional travel times using different types of traffic information (none, historic, live) as well as the default best-estimate travel time.

waitForResults
query
  • boolean

Boolean to indicate whether to execute the request synchronously. If set to true, user will get a 200 response if the request is finished under 120 seconds. Otherwise, user will get a 202 response right away. Please refer to the API description for more details on 202 response.

api-version
query True
  • string

Version number of Azure Maps API. Current version is 1.0

subscription-key
query
  • string

One of the Azure Maps keys provided from an Azure Map Account. Refer to the subscription-key security definition.

vehicleLength
query
  • number
float

Length of the vehicle in meters. A value of 0 means that length restrictions are not considered.

vehicleLoadType
query

Types of cargo that may be classified as hazardous materials and restricted from some roads. Available vehicleLoadType values are US Hazmat classes 1 through 9, plus generic classifications for use in other countries. Values beginning with USHazmat are for US routing while otherHazmat should be used for all other countries. vehicleLoadType can be specified multiple times. This parameter is currently only considered for travelMode=truck.

Request Header

Name Required Type Description
x-ms-client-id
  • string

Specifies which account is intended for usage in conjunction with the Azure AD security model. It represents a unique ID for the Azure Maps account and can be retrieved from Azure Maps management plane Account API. To use Azure AD security in Azure Maps see the following articles for guidance.

Request Body

Name Type Description
destinations

A valid GeoJSON MultiPoint geometry type. Please refer to RFC 7946 for details.

origins

A valid GeoJSON MultiPoint geometry type. Please refer to RFC 7946 for details.

Responses

Name Type Description
200 OK

OK

202 Accepted
  • object

Request Accepted: The request has been accepted for processing. Please use the URL in the Location Header to retry or access the results.

Headers

  • Location: string
400 Bad Request

Bad request: one or more parameters were incorrectly specified or are mutually exclusive.

401 Unauthorized

Access denied due to invalid subscription key or invalid Azure Active Directory bearer token. Make sure to provide a valid key for an active Azure subscription and Maps resource. Otherwise, verify the WWW-Authenticate header for error code and description of the provided AAD bearer token.

Headers

  • WWW-Authenticate: string
403 Forbidden

Permission, capacity, or authentication issues.

404 Not Found

Not Found: the requested resource could not be found, but it may be available again in the future.

500 Internal Server Error

An error occurred while processing the request. Please try again later.

Security

azure_auth

These are the Azure Active Directory OAuth2 Flows. When paired with Azure Role Based Access control it can be used to control access to Azure Maps REST APIs. Azure Role based access controls are used to designate access to one or more Azure Maps resource account or sub-resources. Any user, group, or service principal can be granted access via a built in role or a custom role composed of one or more permissions to Azure Maps REST APIs.

To implement scenarios we recommend viewing authentication concepts. In summary, this security definition provides a solution for modeling application(s) via objects capable of access control on specific APIs and scopes.

Note

  • This security definition requires the use of the x-ms-client-id header to indicate which Azure Maps resource the application is requesting access to. This can be acquired from the Maps management API.
  • The Authorization URL is specific to the Azure public cloud instance. Sovereign clouds have unique Authorization URLs and Azure Active directory configurations.
  • The Azure role based access control is configured from the Azure management plane via Azure portal, Powershell, CLI, Azure SDKs, or REST APIs.
  • Usage of the Azure Maps Web SDK allows for configuration based setup of an application for multiple use cases.
  • Currently Azure Active Directory v1.0 tokens are supported.

Type: oauth2
Flow: implicit
Authorization URL: https://login.microsoftonline.com/common/oauth2/authorize

subscription-key

This is a shared key which is provisioned when creating an Azure Maps resource through the Azure management plane via Azure portal, Powershell, CLI, Azure SDKs, or REST APIs. With this key, any application is authorized to access all REST APIs. In other words, these can currently be treated as master keys to the account which they are issued for. For publicly exposed applications our recommendation is to use server to server access of Azure Maps REST APIs where this key can be securely stored.

Type: apiKey
In: query

Examples

MatrixRoute

Sample Request

POST https://atlas.microsoft.com/route/matrix/json?subscription-key=[subscription-key]&api-version=1.0&routeType=shortest
{
  "origins": {
    "type": "MultiPoint",
    "coordinates": [
      [
        4.85106,
        52.36006
      ],
      [
        4.85056,
        52.36187
      ]
    ]
  },
  "destinations": {
    "type": "MultiPoint",
    "coordinates": [
      [
        4.85003,
        52.36241
      ],
      [
        13.42937,
        52.50931
      ]
    ]
  }
}

Sample Response

{
  "formatVersion": "0.0.1",
  "matrix": [
    [
      {
        "statusCode": 200,
        "response": {
          "routeSummary": {
            "lengthInMeters": 495,
            "travelTimeInSeconds": 134,
            "trafficDelayInSeconds": 0,
            "departureTime": "2018-07-27T22:55:29+00:00",
            "arrivalTime": "2018-07-27T22:57:43+00:00"
          }
        }
      },
      {
        "statusCode": 200,
        "response": {
          "routeSummary": {
            "lengthInMeters": 647651,
            "travelTimeInSeconds": 26835,
            "trafficDelayInSeconds": 489,
            "departureTime": "2018-07-27T22:55:29+00:00",
            "arrivalTime": "2018-07-28T06:22:44+00:00"
          }
        }
      }
    ],
    [
      {
        "statusCode": 200,
        "response": {
          "routeSummary": {
            "lengthInMeters": 338,
            "travelTimeInSeconds": 104,
            "trafficDelayInSeconds": 0,
            "departureTime": "2018-07-27T22:55:29+00:00",
            "arrivalTime": "2018-07-27T22:57:13+00:00"
          }
        }
      },
      {
        "statusCode": 200,
        "response": {
          "routeSummary": {
            "lengthInMeters": 647494,
            "travelTimeInSeconds": 26763,
            "trafficDelayInSeconds": 469,
            "departureTime": "2018-07-27T22:55:29+00:00",
            "arrivalTime": "2018-07-28T06:21:32+00:00"
          }
        }
      }
    ]
  ],
  "summary": {
    "successfulRoutes": 4,
    "totalRoutes": 4
  }
}
Location: New URL to check the status of the long running request.
{}
{
  "error": {
    "code": "400 BadRequest",
    "message": "Bad request: one or more parameters were incorrectly specified or are mutually exclusive."
  }
}
{
  "error": {
    "code": "401 Unauthorized",
    "message": "Access denied due to invalid subscription key. Make sure to provide a valid key for an active subscription."
  }
}
{
  "error": {
    "code": "403 Forbidden",
    "message": "Permission, capacity, or authentication issues."
  }
}
{
  "error": {
    "code": "404 NotFound",
    "message": "Not Found: the requested resource could not be found, but it may be available again in the future."
  }
}
{
  "error": {
    "code": "500 InternalServerError",
    "message": "An error occurred while processing the request. Please try again later."
  }
}

Definitions

Avoid

Specifies something that the route calculation should try to avoid when determining the route. Can be specified multiple times in one request, for example, '&avoid=motorways&avoid=tollRoads&avoid=ferries'. In calculateReachableRange requests, the value alreadyUsedRoads must not be used.

ComputeTravelTimeFor

Specifies whether to return additional travel times using different types of traffic information (none, historic, live) as well as the default best-estimate travel time.

Error

This object is returned when an error occurs in the Maps API

ErrorResponse

This response object is returned when an error occurs in the Maps API

GeoJSONMultiPoint

A valid GeoJSON MultiPoint geometry type. Please refer to RFC 7946 for details.

Hilliness

Degree of hilliness for thrilling route. This parameter can only be used in conjunction with routeType=thrilling.

JsonFormat

Desired format of the response. Only json format is supported.

RouteMatrixRequestBody

An object with a matrix of coordinates.

RouteMatrixResponse

This object is returned from a successful Route Matrix call. For ex, if 2 origins and 3 destinations are provided, there are going to 2 arrays with 3 elements in each. Each element's content depends on the options provided in the query.

RouteMatrixSummary

Summary object

RouteType

The type of route requested.

SectionType

Specifies which of the section types is reported in the route response.

For example if sectionType = pedestrian the sections which are suited for pedestrians only are returned. Multiple types can be used. The default sectionType refers to the travelMode input. By default travelMode is set to car

TravelMode

The mode of travel for the requested route. Note that the requested travelMode may not be available for the entire route. Where the requested travelMode is not available for a particular section, the travelMode element of the response for that section will be other. Note that travel modes bus, motorcycle, taxi and van are BETA functionality. Full restriction data is not available in all areas. In calculateReachableRange requests, the values bicycle and pedestrian must not be used

VehicleLoadType

Types of cargo that may be classified as hazardous materials and restricted from some roads. Available vehicleLoadType values are US Hazmat classes 1 through 9, plus generic classifications for use in other countries. Values beginning with USHazmat are for US routing while otherHazmat should be used for all other countries. vehicleLoadType can be specified multiple times. This parameter is currently only considered for travelMode=truck.

Windingness

Level of turns for thrilling route. This parameter can only be used in conjunction with routeType=thrilling.

Avoid

Specifies something that the route calculation should try to avoid when determining the route. Can be specified multiple times in one request, for example, '&avoid=motorways&avoid=tollRoads&avoid=ferries'. In calculateReachableRange requests, the value alreadyUsedRoads must not be used.

Name Type Description
alreadyUsedRoads
  • string

Avoids using the same road multiple times. Most useful in conjunction with routeType=thrilling.

carpools
  • string

Avoids routes that require the use of carpool (HOV/High Occupancy Vehicle) lanes.

ferries
  • string

Avoids ferries

motorways
  • string

Avoids motorways

tollRoads
  • string

Avoids toll roads.

unpavedRoads
  • string

Avoids unpaved roads

ComputeTravelTimeFor

Specifies whether to return additional travel times using different types of traffic information (none, historic, live) as well as the default best-estimate travel time.

Name Type Description
all
  • string

Computes travel times for all types of traffic information and specifies all results in the fields noTrafficTravelTimeInSeconds, historicTrafficTravelTimeInSeconds and liveTrafficIncidentsTravelTimeInSeconds being included in the summaries in the route response.

none
  • string

Does not compute additional travel times.

Error

This object is returned when an error occurs in the Maps API

Name Type Description
code
  • string

The HTTP status code.

message
  • string

If available, a human readable description of the error.

ErrorResponse

This response object is returned when an error occurs in the Maps API

Name Type Description
error

This object is returned when an error occurs in the Maps API

GeoJSONMultiPoint

A valid GeoJSON MultiPoint geometry type. Please refer to RFC 7946 for details.

Name Type Description
coordinates
  • array[]

Coordinates for the MultiPoint geometry.

type
  • string

Specifies the type for the geometry. Value should always be equal to "MultiPoint".

Hilliness

Degree of hilliness for thrilling route. This parameter can only be used in conjunction with routeType=thrilling.

Name Type Description
high
  • string

high

low
  • string

low

normal
  • string

normal

JsonFormat

Desired format of the response. Only json format is supported.

Name Type Description
json
  • string

The JavaScript Object Notation Data Interchange Format

RouteMatrixRequestBody

An object with a matrix of coordinates.

Name Type Description
destinations

A valid GeoJSON MultiPoint geometry type. Please refer to RFC 7946 for details.

origins

A valid GeoJSON MultiPoint geometry type. Please refer to RFC 7946 for details.

RouteMatrixResponse

This object is returned from a successful Route Matrix call. For ex, if 2 origins and 3 destinations are provided, there are going to 2 arrays with 3 elements in each. Each element's content depends on the options provided in the query.

Name Type Description
formatVersion
  • string

Format Version property

matrix
  • array[]

Results as a 2 dimensional array of route summaries.

summary

Summary object

RouteMatrixSummary

Summary object

Name Type Description
successfulRoutes
  • integer

Number of successful routes in the response.

totalRoutes
  • integer

Total number of routes requested. Number of cells in the input matrix.

RouteType

The type of route requested.

Name Type Description
eco
  • string

A route balanced by economy and speed.

fastest
  • string

The fastest route.

shortest
  • string

The shortest route by distance.

thrilling
  • string

Includes interesting or challenging roads and uses as few motorways as possible. You can choose the level of turns included and also the degree of hilliness. See the hilliness and windingness parameters for how to set this. There is a limit of 900 km on routes planned with routeType=thrilling

SectionType

Specifies which of the section types is reported in the route response.

For example if sectionType = pedestrian the sections which are suited for pedestrians only are returned. Multiple types can be used. The default sectionType refers to the travelMode input. By default travelMode is set to car

Name Type Description
carTrain
  • string

Get sections if the route includes car trains.

country
  • string

Countries the route has parts in.

ferry
  • string

Get sections if the route includes ferries.

motorway
  • string

Get sections if the route includes motorways.

pedestrian
  • string

Get sections which are suited for pedestrians.

tollRoad
  • string

Get sections which require a toll to be payed.

tollVignette
  • string

Get sections which require a toll vignette to be present.

traffic
  • string

Get sections which contain traffic information.

travelMode
  • string

Get sections in relation to the request parameter travelMode.

tunnel
  • string

Get sections if the route includes tunnels.

TravelMode

The mode of travel for the requested route. Note that the requested travelMode may not be available for the entire route. Where the requested travelMode is not available for a particular section, the travelMode element of the response for that section will be other. Note that travel modes bus, motorcycle, taxi and van are BETA functionality. Full restriction data is not available in all areas. In calculateReachableRange requests, the values bicycle and pedestrian must not be used

Name Type Description
bicycle
  • string

bicycle

bus
  • string

bus

car
  • string

car

motorcycle
  • string

motorcycle

pedestrian
  • string

pedestrian

taxi
  • string

taxi

truck
  • string

truck

van
  • string

van

VehicleLoadType

Types of cargo that may be classified as hazardous materials and restricted from some roads. Available vehicleLoadType values are US Hazmat classes 1 through 9, plus generic classifications for use in other countries. Values beginning with USHazmat are for US routing while otherHazmat should be used for all other countries. vehicleLoadType can be specified multiple times. This parameter is currently only considered for travelMode=truck.

Name Type Description
USHazmatClass1
  • string

Explosives

USHazmatClass2
  • string

Compressed gas

USHazmatClass3
  • string

Flammable liquids

USHazmatClass4
  • string

Flammable solids

USHazmatClass5
  • string

Oxidizers

USHazmatClass6
  • string

Poisons

USHazmatClass7
  • string

Radioactive

USHazmatClass8
  • string

Corrosives

USHazmatClass9
  • string

Miscellaneous

otherHazmatExplosive
  • string

Explosives

otherHazmatGeneral
  • string

Miscellaneous

otherHazmatHarmfulToWater
  • string

Harmful to water

Windingness

Level of turns for thrilling route. This parameter can only be used in conjunction with routeType=thrilling.

Name Type Description
high
  • string

high

low
  • string

low

normal
  • string

normal