---
title: "Distance Matrix"
method: GET
path: "/distancematrix/json"
tags: ["Routing"]
---

# Distance Matrix

`GET /distancematrix/json`

Nextbillion.ai Distance Matrix API computes distances and ETAs between a set of origins and destinations — could be for one-to-many or many-to-many scenarios. The API call returns a matrix of ETAs and distances for each origin and destination pair.   For example, If the set is Origins {A,B} and Destinations {C,D,E} we can get the following set of results with distance (meters) and time (seconds) for each.
The GET method can only handle up to 100 locations (1 location is either 1 origin or 1 destination).

## Query parameters

- `key` string, 32 character alphanumeric string, required
- `origins` string, latitude_1,longitude_1|latitude_2,longitude_2|..., required
- `destinations` string, latitude_1, longitue_1|latitude_2, longitude_2|..., required
- `mode` 'car' | 'truck'
- `avoid` 'toll' | 'ferry' | 'highway' | 'none', value_1|value_2|...
- `bearings` string, degree_0,range_0;degree_1,range_1;...
- `approaches` 'unrestricted' | 'curb', approaches_1;approaches_2;....
- `route_failed_prompt` boolean

## Response `200`

- object
  - `status` string — A string indicating the state of the response. On normal responses, the value will be Ok. Indicative HTTP error codes are returned for different errors. See the [API Errors Codes](#api-error-codes) section below for more information.
  - `msg` string — Displays the error message in case of a failed request or operation. Please note that this parameter is not returned in the response in case of a successful request.
  - `rows` object[] — Container object for a response with an array of arrays structure.
    - `elements` object[] — An array of objects. Each elements array corresponds to a single origins coordinate and contains objects with distance and duration values for each of the destinations. The details in the first elements array correspond to the first origins point and the first object corresponds to the first destinations point and so on.
      - `duration` number — Duration of the trip from an origin to a destination, in seconds.
      - `distance` number — Distance of the route from an origin to a destination, in meters.

---

[API](https://skmtc.net/nextbillion-ai/apis/one-spec-service.md) · [All operations](https://skmtc.net/nextbillion-ai/apis/one-spec-service/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/nextbillion-ai/one-spec-service/versions/b647f1808dda/schema)
