Synchronous Request

Using the synchronous API means simply sending a matrix calculation request to the server and waiting for the response. Synchronous requests have further limitations on matrix dimensions. See API Reference.

Request a Matrix Calculation

To request a synchronous matrix calculation set the async query parameter to a value of false. Otherwise, the contents of a synchronous matrix request are the same as those of an asynchronous request. Submit a matrix calculation request. The service validates the request and adds it to a queue until resources are available to calculate the matrix. When the calculation is finished or if an error occurred, the service directly returns the matrix result.

Note the query parameter async=false in the following example:

Note

Depending on your authentication method you either need to add an Authorization header with a Bearer token or a query parameter to the example request shown here. For details, see the Identity & Access Management Developer Guide.

POST https://matrix.router.hereapi.com/v8/matrix?async=false
Content-Type: application/json
Body:
{
    "origins": [{"lat": 0.0, "lng": 0.0}, {"lat": 0.1, "lng": 0.1}, ...],
    "destinations": [...],  // if omitted same as origins
    "regionDefinition": {
        "type": "circle",
        "center": {"lat": 0.0, "lng": 0.0},
        "radius": 10000
    }
}

If you get status code 200, that means your request was successfully calculated. The matrix result has the following structure:

{
    "matrixId": "{matrixId}",
    "matrix": {
        "numOrigins": 10,
        "numDestinations": 1000,
        // 10,000 travel times
        // entry k corresponds to origin i and destination j by the formula:
        // k = num_origins * i + j
        "travelTimes": [10, 20, 0, ...],
        "errorCodes": [0, 0, 0, ...]   // error for each pair of (origin, dest) if any
    },
    // same as request
    "regionDefinition": {
        "type": "circle",
        "center": {"lat": 0.0, "lng": 0.0},
        "radius": 10000
    }
}

In addition to the calculated routing matrix, the matrix result contains:

  • A matrixId - a unique identifier of the matrix.
  • A regionDefinition - the region definition used to calculate the matrix. Either the one specified by the user, or an automatically derived one (in case autoCircle was requested).

results matching ""

    No results matching ""