Predictive Distance Matrix API

Adding driving directions API would help to add predicted travel time & duration from a given origin point to a number of points. This REST API computes the distance and duration of a route between a source/primary position (geographical coordinates) and a list of all supplied secondary positions. Optionally one can input the dep_time parameter and get the distance and duration optimized for that part of day of a week. Time based functionality is available for selected cities only. Supported region (countries) are India, Sri Lanka, Nepal, Bangladesh & Bhutan. Please note that maximum number of points are limited to 100 only including source and secondary positions.

Security Type

  • License key based authentication
  • IP/domain based whitelisting

Input Method

GET

Contructing the request URL

Table 1. Requesting a Route
Element Value Description
Base URL https://apis.mapmyindia.com/advancedmaps/v1/ Production environment
Authorization "assigned_REST_license_key" The REST API license key authorized to access the resource
Resources distance_matrix_predictive to calculate the route & duration using predictive eta algorithm considering historical traffic conditions.
Profile driving Meant for car routing using rdictive eta agorth conidern hstoricl traffic condiions
Coordinates "sr and secondary coordinates" The coordinates pairs on which route is to be calculated. Minumum two pairs needed.

Example URL:

https://apis.mapmyindia.com/advancedmaps/v1/< assigned_license_key>/distance_matrix_predictive/driving/77.983936,28.255904;77.05993,28.487555;77.15993,28.587555?dep_time=1531543500

where:

  • "distance_matrix_predictive" is the chosen resource.
  • profile is "driving"
  • "77.983936,28.255904" & other similar parts after it are the positions.
  • "1531543500" is the epoch value at which the predictive ETA is calculated.

Note: The position input is in decimal degree notation of longitude,latitude.

Request Parameters

Mandatory Parameters
  1. lic_key: Allocated REST API license key. (part of URL).
  2. source: The first location is pair of comma separated longitude & latitude value which is taken as the source from which distance and ETA is to be calculated for the other locations specified in the rest of the ‘secondary_locations’ (part of URL).
  3. secondary_locations: The coordinates of rest of the locations whose distance from source will be calculated (part of URL). Format for each coordinate is the same as for the source, and they are semi-colon “;” delimited. For example 77.983936,28.255904;77.05993,28.487555.
Optional Parameters
  1. dep_time: the UNIX timestamp of departure in seconds. Distance and ETA will be optimized as per given time.

Response Type

JSON: response will served as JSON

Response Parameters

  1. responseCode: See the service dependent and general status codes.
  2. check: internal response (for MMI internal purposes only)
  3. version: API’s version information.
  4. results: array of results, each consisting of the following parameters:
    • code: if the request was successful, code is ok.
    • durations: Duration in seconds for source to source (default 0), 1st, 2nd, 3rd secondary locations... from source.
    • distances: Distance in meters for source to source (default 0), 1st, 2nd, 3rd secondary locations... from source.

Response Codes {as HTTP response code}

  • 200: To denote a successful API call.
  • 204: DB Connection error.
  • 400: Bad Request, User made an error while creating a valid request.
  • 401: Unauthorized, Developer’s key is not allowed to send a request.
  • 403: Forbidden, Developer’s key has hit its daily/hourly limit or IP or domain not white-listed.
  • 404: HTTP not found
  • 412: Precondition Failed, i.e. Mandatory parameter is missing
  • 500: Internal Server Error, the request caused an error in our systems.
  • 503: Service Unavailable, during our maintenance break or server down-times.

Sample Input

https://apis.mapmyindia.com/advancedmaps/v1/<assigned_lic_key>/distance_matrix_predictive/driving/77.5998448,12.5090914;77.5800417,12.5092973?dep_time=1531543500

Sample Response

{  "responseCode": 200,  "check": 5025,  "version": "191.17",  "results": {  "code": "Ok",  "distances": [  [  0,  3038.2  ]  ],  "durations": [  [  0,  1839.6  ]  ]  }  }"responseCode": 200,  "check": 5025,  "version": "191.17",  "results": {  "code": "Ok",  "distances": [  [  0,  3038.2  ]  ],  "durations": [  [  0,  1839.6  ]  ]  }"responseCode": 200,  "version": "191.17",  "results": {  "code": "Ok",  "distances": [  [  0,  6817.7,  20475.7  ]  ],  "durations": [  [  0,  1844.4,  5307.5  ]  ]  }  }