# Matrix API

The **Mapbox Matrix API** calculates travel times between many locations in one API request. The Matrix API allows you to efficiently check the reachability of coordinates from each other, filter points by travel time, or run your own algorithms for solving optimization problems.

The number of sources and destinations in the API request are multiplied to build a matrix, or timetable, composed of the **elements** (that is, the source and destination coordinate pairs) needed to make the request. A valid Matrix API request returns a matrix of all the travel times in seconds for each element in the matrix.

For example, given three locations — A, B, and C — the Matrix API will return a matrix of all travel times in **seconds** between all the locations. Since the request contains *3 sources × 3 destinations*, the response contains *9 elements*:

A | B | C | |
---|---|---|---|

A | A → A | A → B | A → C |

B | B → A | B → B | B → C |

C | C → A | C → B | C → C |

A sample many to many Matrix API request looks like:

`https://api.mapbox.com/directions-matrix/v1/mapbox/driving/-122.42,37.78;-122.45,37.91;-122.48,37.73?access_token=YOUR_MAPBOX_ACCESS_TOKEN`

Since the Mapbox Matrix API handles bulk requests of varying sizes, use of the Matrix API is billed by the number of *elements returned* by a request, rather than by the number of requests made. For more details, see the Matrix API pricing information.

**Related resources:**