The Mapbox Matrix API returns all travel times and distances between multiple locations. The Matrix API will always return the duration and distance of the fastest route between the locations. Durations between locations may not be symmetric (for example A to B may have a different duration than B to A), as the routes may differ by direction due to one-way streets or turn restrictions. The Matrix API returns durations in seconds and distances in meters. It does not return route geometries. Make sure to have a look at the Matrix API documentation if you want more information.

This API allows you to build tools that efficiently check the reachability of coordinates from each other, filter locations by travel time, or run your own algorithms for solving optimization problems.

The standard limit for request are a maximum 60 requests per minute and maximum 25 input coordinates. For example you can request a symmetric 25x25 matrix, an asymmetric 1x24 matrix with distinct coordinates or a 12x24 where sources and destinations share some coordinates. For higher volumes contact us.

Before using this wrapper:

  • Read the Mapbox Matrix API documentation. The API documentation contains all available parameters including some that are not listed in this guide.
  • Make sure you have included the correct permissions inside of your AndroidManifest.xml file if you plan to use this API inside of an Android application.

API request

Before requesting and receiving the Matrix response, you'll need to use the MapboxMatrix builder to set the request parameters. The request passes in a List of Point objects, sets the directions profile, and provides an access token.

MapboxMatrix matrixApiClient = MapboxMatrix.builder()

API response

Like all API calls inside of the Mapbox Java SDK, the response will come inside a Retrofit callback. Inside onResponse(), you can access the API's returned response if successful.

client.enqueueCall(new Callback<MatrixResponse>() {
public void onResponse(Call<MatrixResponse> call,
Response<MatrixResponse> response) {
public void onFailure(Call<MatrixResponse> call, Throwable throwable) {
Was this page helpful?