Driving Distance API: From One Pair of Addresses to Hundreds of Origins in One Request

Calculate road distance and drive time for one trip with the Routing API, or for 483 origins and one destination with a single Route Matrix request, with real Chicago data

Chicago map: 483 school dots colored by drive time, linked to the Field Museum, beside a Driving Distance API title
Chicago map: 483 school dots colored by drive time, linked to the Field Museum, beside a Driving Distance API title

To calculate driving distance with an API, turn each address into coordinates, then ask a routing engine for the road distance: the Routing API for one trip, the Route Matrix API for many origins and one destination (or any grid) in one POST request of up to 1,000 pairs. In Chicago, Willis Tower to Wrigley Field is 7.9 km in a straight line but 12.5 km by car. And 483 schools to the Field Museum came back in one request, with a drive time for every school. This post shows both cases with real requests and responses from the Geoapify Routing API and Route Matrix API, plus what they cost.

Key takeaways

  • One pair: Geocoding API → Routing API with mode=drive. You get distance in meters (or miles with units=imperial) and time in seconds.
  • Many-to-one: send the origins as sources and the destination as the only target. The response has one row per origin, and source_index maps it back to your data.
  • Direction matters: A→B and B→A are not the same trip. Our pair is 12.5 km one way and 13.3 km back; for the schools, the two directions differ by up to 7 minutes.
  • Cost: a matrix costs max(S,T) × min(S,T,10) credits. A 483×1 matrix is 483 credits, the same as 483 routes but in one request; square matrices above 10×10 cost less than separate routes.
  • Limit: up to 1,000 source–target pairs per regular call and 2,000 per Batch API call. Split larger jobs.

What Is a Driving Distance API?

A driving distance API is a web service that returns the distance and travel time between two or more locations along the road network for a car. It answers "how far is it to drive?", not "how far is it on the map?". The result depends on streets, one-way rules, bridges and turn restrictions, so it is almost always longer than the straight line.

Our test pair in Chicago shows how big the gap can be. From Willis Tower (233 S Wacker Dr) to Wrigley Field (1060 W Addison St), the straight-line distance is 7.9 km. The driving distance from the Routing API is 12,503 m, about 58% more, and the drive takes 880 seconds, about 14.7 minutes.

MeasureWillis Tower → Wrigley Field
Straight line (haversine)7,891 m
Driving distance, mode=drive12,503 m
Drive time, free-flow880.269 s (about 14.7 min)

A straight line is fine for a first filter. Use road distance when the number drives a decision: a delivery fee, a service area, an ETA or the choice of the nearest location.

Map of Chicago with a dashed straight line from Willis Tower to Wrigley Field and the longer driving route along city streets
Willis Tower to Wrigley Field: 7.9 km in a straight line, 12.5 km by car. Route from the Geoapify Routing API. Map: Geoapify, © OpenMapTiles, © OpenStreetMap contributors.

How Do You Calculate Driving Distance Between Two Addresses?

Routing works with coordinates, not with address text. So the calculation has two steps: geocode both addresses, then request a route between the two points.

Step 1. Geocode both addresses

The Geocoding API turns an address string into coordinates. One REST request per address:

https://api.geoapify.com/v1/geocode/search?text=233%20S%20Wacker%20Dr%2C%20Chicago%2C%20IL%2060606&format=json&limit=1&apiKey=YOUR_API_KEY

Simplified response:

{
  "results": [
    {
      "name": "Willis Tower",
      "formatted": "Willis Tower, 233 South Wacker Drive, Chicago, IL 60606, United States of America",
      "lat": 41.878738,
      "lon": -87.6359612,
      "result_type": "amenity",
      "rank": {
        "confidence": 1,
        "confidence_city_level": 1,
        "confidence_street_level": 1,
        "confidence_building_level": 1,
        "match_type": "inner_part"
      }
    }
  ]
}

rank.confidence tells you how well the result matches the input, from 0 to 1. Both of our addresses matched with confidence 1: Wrigley Field resolved to 41.9481846, -87.655559. Check this value before you route. A wrong match gives a precise answer to the wrong question.

Step 2. Request the route

With both coordinates, one GET request to the Routing API returns the driving distance and time. Waypoints go in lat,lon order, separated by |:

https://api.geoapify.com/v1/routing?waypoints=41.878738,-87.6359612|41.9481846,-87.655559&mode=drive&format=json&apiKey=YOUR_API_KEY

Simplified response, without the geometry and the legs:

{
  "results": [
    {
      "mode": "drive",
      "units": "metric",
      "distance": 12503,
      "distance_units": "meters",
      "time": 880.269
    }
  ]
}

distance is in meters and time in seconds. The full response also contains the route geometry and turn-by-turn steps, which you need only if you draw the route or guide a driver. The example uses the default free_flow traffic model, like every number in this post except the one traffic comparison below.

Units, route type and direction

Three parameters change the numbers you get back: units, type, and the order of the waypoints. We ran the same pair with each change:

RequestDistanceTime
Default: mode=drive (metric)12,503 m880.269 s
units=imperial7.7691 miles (distance_units: "miles")880.269 s
type=short8,963 m913.439 s
Reverse: Wrigley Field → Willis Tower13,347 m943.316 s

units=imperial changes only the distance unit; the time stays in seconds. type=short asks for the shortest route instead of the default balanced one: here it saved 3.5 km but took 33 seconds longer. The reverse trip is 844 m longer, because one-way streets and turn rules are not symmetric. Request the direction your users actually travel.

When Do You Need a Matrix Instead of Routes?

A route matrix (also called a distance matrix or time-distance matrix) is a table of travel times and distances between every source and every target. Use a matrix when you compare many trips and need only the numbers. Use routes when you need the path itself.

The question has four common shapes:

ShapeExample questionAPIWhat you get
One-to-oneHow far is it from the office to the stadium?Routing APIDistance, time, geometry, steps
One-to-manyWhich of 10 stores is closest to this customer?Route Matrix API: 1 source, many targetsOne row of distances and times
Many-to-oneHow long does each of 483 schools drive to the museum?Route Matrix API: many sources, 1 targetOne row per source, one cell each
Many-to-manyTravel times between all depots and all customersRoute Matrix API: S sources × T targetsA full S × T table

The key difference is the output. The Route Matrix API returns distance and time only, with no route geometry and no steps. The Routing API returns the line to draw and the instructions to follow. A common pattern is to rank candidates with a matrix and then request one route for the winner.

Diagram of four trip shapes: one-to-one served by the Routing API, and one-to-many, many-to-one and many-to-many served by the Route Matrix API
One trip needs a route; many trips need a matrix. The many-to-one shape sends the origins as sources and one destination as the target.

For a broader look at matrix use cases, see Time-distance matrix and three ways to use it.

How Do You Calculate a Many-to-One Travel Time Matrix?

A many-to-one travel time matrix gives the drive time from each of many origins to one destination. You build it with one Route Matrix API request: the origins go into sources, the destination is the only item in targets. The same shape answers "which driver is closest to this pickup?", as the nearest-by-travel-time how-to describes.

Example: 483 Chicago schools to the Field Museum

Imagine planning school field trips to the Field Museum (1400 S Lake Shore Dr). Which schools are within a 20-minute drive? We needed a list of schools and one destination.

The schools came from the Places API, with the education.school category and the Chicago city boundary as a filter. The place_id for the filter comes from a geocoding request with text=Chicago&type=city:

https://api.geoapify.com/v2/places?categories=education.school&filter=place:CHICAGO_PLACE_ID&limit=500&apiKey=YOUR_API_KEY

The request returned 500 schools. We kept the 483 that have a name. The museum geocoded to [-87.617035, 41.866211]. Then one POST request to the Route Matrix API:

POST https://api.geoapify.com/v1/routematrix?apiKey=YOUR_API_KEY
Content-Type: application/json

{
  "mode": "drive",
  "sources": [
    { "location": [-87.5346632, 41.7068962] },
    { "location": [-87.5676239, 41.7144085] },
    ...
  ],
  "targets": [
    { "location": [-87.617035, 41.866211] }
  ]
}

Note the coordinate order: the matrix body uses [longitude, latitude], the opposite of Routing API waypoints. The response came back with 483 rows of one cell each, and every cell had a time and a distance.

Simplified response, first two schools:

{
  "sources": [
    { "original_location": [-87.5346632, 41.7068962], "location": [-87.534657, 41.706896] },
    { "original_location": [-87.5676239, 41.7144085], "location": [-87.567686, 41.714355] }
  ],
  "targets": [
    { "original_location": [-87.617035, 41.866211], "location": [-87.617497, 41.865514] }
  ],
  "sources_to_targets": [
    [{ "distance": 21970, "time": 1560, "source_index": 0, "target_index": 0 }],
    [{ "distance": 20429, "time": 1439, "source_index": 1, "target_index": 0 }]
  ],
  "units": "metric",
  "distance_units": "meters",
  "mode": "drive"
}

original_location is what you sent, and location is the point snapped to the nearest road. Matrix times are whole seconds; the 1×1 matrix for Willis Tower → Wrigley Field returned "time": 880 where the Routing API returned 880.269.

To turn the rows into a ranked list, map each cell back to your data with source_index. This JavaScript runs in Node.js 18+ or a browser:

const apiKey = "YOUR_API_KEY";
const origins = [
  { name: "Gallistel Language Academy", location: [-87.5346632, 41.7068962] },
  { name: "Burnham Elementary School", location: [-87.5676239, 41.7144085] },
  // ... one object per school, [longitude, latitude]
];
const destination = [-87.617035, 41.866211]; // Field Museum

const response = await fetch(
  `https://api.geoapify.com/v1/routematrix?apiKey=${apiKey}`,
  {
    method: "POST",
    headers: { "Content-Type": "application/json" },
    body: JSON.stringify({
      mode: "drive",
      sources: origins.map(o => ({ location: o.location })),
      targets: [{ location: destination }]
    })
  }
);
const matrix = await response.json();
if (!response.ok) throw new Error(matrix.message);

// One row per source, one cell per row (a single target)
const driveTimes = matrix.sources_to_targets
  .map(([cell]) => ({
    name: origins[cell.source_index].name,
    minutes: Number.isFinite(cell.time) ? cell.time / 60 : null,
    km: Number.isFinite(cell.distance) ? cell.distance / 1000 : null
  }))
  .sort((a, b) => (a.minutes ?? Infinity) - (b.minutes ?? Infinity));

console.table(driveTimes);

We ran this code with Node.js 24 and the first two schools: Burnham Elementary School came first at 23.98 minutes and 20.429 km. Cells without a finite time are kept as unreachable instead of breaking the sort.

Map of Chicago with 483 school dots colored by free-flow drive time to the Field Museum, from under 10 minutes near downtown to over 30 minutes at the far south and northwest edges
483 Chicago schools colored by drive time to the Field Museum (free-flow): 0–10, 10–20, 20–30 and 30+ minutes. One Route Matrix API request. Data: Geoapify Places API, © OpenStreetMap contributors.

What the numbers say

With all 483 drive times in one table, the planning questions have direct answers. All times are free-flow, the API's default traffic model:

ResultValue
Nearest schoolJones College Prep: 272 s (4.5 min), 2,041 m
Median drive time1,058 s (17.6 min)
Farthest schoolMarist High School: 2,102 s (35.0 min), 30,163 m
Within 20 minutes307 of 483 schools
Within 30 minutes481 of 483 schools

Free-flow times assume no traffic influence, so treat "within 20 minutes" as "within 20 minutes on free-flowing roads". The next section shows how much the answer changed with the approximated traffic model in our test.

Free-flow vs approximated traffic: one observed test

The numbers above use free_flow, the default traffic model, which calculates times optimistically with no traffic influence. The approximated model "decreases speed for potentially heavy-loaded roads", as the Route Matrix API reference puts it. We ran the same requests with both models to see how much that changes the Chicago results.

Settings: requests sent on December 3, 2026; mode: "drive", default type (balanced), no avoid; the same Willis Tower → Wrigley Field waypoints and the same 483 sources and one target as above. The only change was traffic.

Requestfree_flow (default)approximated
Willis Tower → Wrigley Field, Routing API12,503 m, 880 s (14.7 min)11,587 m, 2,456 s (40.9 min)
483 schools → Field Museum, median time1,058 s (17.6 min)3,227 s (53.8 min)
Ratio of the two times per school—from 2.1× to 3.9×, median 3.3×
Schools within 20 minutes307 of 4837 of 483
Schools within 30 minutes481 of 48335 of 483

Read this table as one observed test, not as a rule. approximated is a model of likely congestion, not live traffic for a particular day and hour, and the ratio we saw in Chicago is not a general multiplier for other cities, routes or times. The model can also pick a different route: for the single pair it chose a 0.9 km shorter route. If your ETAs need a conservative estimate, test both models on your own locations and pick one for your product.

Many-to-one vs one-to-many

A trip to the museum and a trip back are different trips, so the direction you choose changes the answer. We ran the reverse matrix too: the museum as the only source and the 483 schools as targets. The response is then one row with 483 cells, mapped by target_index.

  • Median drive time: 17.6 min to the museum, 16.5 min back to the schools.
  • Schools with a gap over 2 minutes between the two directions: 105 of 483.
  • Largest gap: 423 seconds, about 7 minutes.

The nearest-by-travel-time how-to states this directly: source-to-target and target-to-source times are not necessarily equal. For arrivals (field trips, drivers to a pickup), send the origins as sources. For departures from one place (deliveries from a depot), send that place as the source.

What Does a Matrix Cost and How Big Can It Be?

The Route Matrix API charges by matrix shape, not by request. The formula from the Route Matrix pricing docs is:

credits = max(sources, targets) × min(sources, targets, 10)

The smaller side is capped at 10, so a square matrix gets cheaper than separate routes once it is larger than 10×10. A Routing API route costs 1 credit per waypoint pair for routes under 500 km, according to the Routing pricing docs.

JobRoute Matrix APISeparate Routing API calls
1 pair (1×1)1 credit, 1 request1 credit, 1 request
483 schools → museum (483×1)483 credits, 1 request483 credits, 483 requests
30 locations, all pairs (30×30)300 credits, 1 request900 credits, 900 requests

Some options add credits. Each avoid toggle (tolls, ferries, highways, green zones) adds 1 credit, and every returned distance adds floor(distance / 500 km) credits, so long-distance matrices cost more. The Free plan includes 3,000 credits per day; see Geoapify pricing for the paid plans.

Size limits

A matrix has two limits, and a request that exceeds either one returns 400 Bad Request:

LimitRegular API callBatch API call
Matrix size (sources × targets)Up to 1,000 pairsUp to 2,000 pairs
Sum of all source–target distances300,000 km1,000,000 km

Our 483×1 matrix used 483 pairs and about 7,808 km in total, well inside both limits. We also sent 1,001 sources and one target on purpose. The API rejected it:

{
  "statusCode": 400,
  "error": "Bad Request",
  "message": "Matrix is too big. Matrix size should not exceed 1000 elements for a regular API call, and 2000 elements for an asynchronous batch API call. Requested matrix size is 1001"
}

For larger jobs, split the sources into chunks of up to 1,000 pairs and merge the results, keeping track of the offset for source_index. If you don't need the answer immediately, the Batch API also runs matrices: with the default priority of 0.5 a job costs 50% of the credits, and with priority 1 it costs full credits and is processed faster.

What Should You Check Before Going Live?

Most driving distance bugs come from the input and the mapping, not from the routing. Check these points before users rely on the numbers:

  1. Geocoding confidence. Read rank.confidence for every address and send low-confidence matches for review. For lists of up to 1,000 addresses, the Batch Geocoding API handles the whole list in one job.
  2. Coordinate order. Routing API waypoints are lat,lon; Route Matrix location values are [lon, lat]. A swapped pair can point to a completely different place.
  3. Mapping by index. Keep your sources and targets in request order and map cells back with source_index and target_index. Keep your own coordinates as the business record; location in the response is the road-snapped point.
  4. Unreachable cells. Treat a missing or non-finite time as unreachable, as the nearest-by-travel-time how-to does. In the Routing API, an island without a bridge, a car-free area or a strict avoid rule returns 400 with "No path could be found for input"; see handle waypoints with no connecting path.
  5. Traffic model. The default traffic value is free_flow: times are calculated optimistically, with no traffic influence. traffic: "approximated" decreases speed on potentially heavy-loaded roads. The parameter applies only to motorized modes such as drive and truck. In our Chicago test the two models gave very different times, so test both on your own locations, choose one for customer-facing ETAs and keep it consistent.
  6. Direction. Decide whether you measure arrivals or departures, and build the matrix in that direction.
  7. Units. With units: "imperial" distances come back in miles and times stay in seconds. Read distance_units instead of assuming meters.
  8. Repeated inputs. Schools and museums don't move. Reuse results for fixed location sets instead of recalculating them on every page view, and recalculate when the list changes.

AI Request Examples: Ask a Coding Agent to Build It

You don't have to write the geocoding, routing and matrix code by hand. A coding agent can build a script, a page or a module from a clear request.

Before you start

  1. Get a free API key in Geoapify MyProjects.
  2. Create a new folder for the project, or open an existing one.
  3. In that folder, create a file named .env with one line: GEOAPIFY_API_KEY= followed by your key.
  4. Open the folder in your coding agent, for example Claude Code, Codex or Cursor.
  5. Paste one of the prompts below.

The first prompt creates a quick script that prints the driving distance between two addresses:

Create a small Node.js script in this folder that prints the driving distance and drive time between two addresses, using Geoapify APIs.

- Read the API key from `GEOAPIFY_API_KEY` in the `.env` file in this folder. Never print the key, show it in chat or copy it to another file.
- Geocode each address with the Geoapify Geocoding API: `GET https://api.geoapify.com/v1/geocode/search` with `text`, `format=json` and `limit=1` (docs: https://apidocs.geoapify.com/docs/geocoding/forward-geocoding/). Print the matched address (`formatted`) and `rank.confidence`, and warn when the confidence is below 0.8.
- Request the route with the Geoapify Routing API: `GET https://api.geoapify.com/v1/routing` with `waypoints=lat,lon|lat,lon`, `mode=drive` and `format=json` (docs: https://apidocs.geoapify.com/docs/routing/). Print `distance` in kilometers and miles and `time` in minutes.
- Take the two addresses as command-line arguments. Without arguments, use "233 S Wacker Dr, Chicago, IL 60606" and "1060 W Addison St, Chicago, IL 60613".
- Use the built-in `fetch`. If you need a package to read `.env`, install its current release pinned to an exact version.
- If an API returns an error, show its `message` instead of a stack trace.

Run the script with the default addresses, then show me its output and the exact command to run it with my own addresses.

What happened in our test:

  • The agent wrote one file, distance.mjs, and installed no package: it read .env with Node.js's built-in process.loadEnvFile (Node.js 20.12 or later; we used Node.js 24).
  • Both default addresses matched with confidence 1, as Willis Tower and Wrigley Field.
  • The output was Driving distance: 12.50 km (7.77 mi) and Drive time: 14.7 min, the same as our own Routing API request.
  • With an invalid key, the script printed Geocoding API error 401: Invalid apiKey and exited without a stack trace.

The second prompt creates a standalone page that ranks many addresses by drive time to one destination:

Create a single HTML page in this folder, with no build tools, that calculates drive times from a list of addresses to one destination with Geoapify APIs.

- The page needs the API key: take it from `GEOAPIFY_API_KEY` in the `.env` file in this folder and put it in one constant at the top of the script. Don't show the key in chat, and remind me to restrict it to my website in Geoapify MyProjects before I publish the page.
- The page has a text area for origin addresses (one per line), a field for the destination address and a "Calculate" button.
- Geocode every address with the Geoapify Geocoding API (`GET https://api.geoapify.com/v1/geocode/search`, `text`, `format=json`, `limit=1`; docs: https://apidocs.geoapify.com/docs/geocoding/forward-geocoding/), one request at a time. Flag addresses that were not found or have `rank.confidence` below 0.8.
- Send all geocoded origins as `sources` and the destination as the only `target` in one POST to the Geoapify Route Matrix API: `https://api.geoapify.com/v1/routematrix?apiKey=…`, JSON body with `"mode": "drive"` and locations in `[longitude, latitude]` order (docs: https://apidocs.geoapify.com/docs/route-matrix/). One request holds up to 1,000 source–target pairs, so split longer lists into several requests.
- Map each result back to its address with `source_index`. Show a table sorted by drive time: address, distance in km, time in minutes. Mark a row as unreachable when its `time` is missing or not a number.
- Test it with these origins and the destination "1400 S Lake Shore Dr, Chicago, IL 60605":
  233 S Wacker Dr, Chicago, IL 60606
  1060 W Addison St, Chicago, IL 60613
  5700 S Lake Shore Dr, Chicago, IL 60637
  2430 N Cannon Dr, Chicago, IL 60614
  1901 W Madison St, Chicago, IL 60612

Open the page in a browser, run the test, save a screenshot of the result, and tell me how to open the page myself.

What happened in our test:

  • The agent wrote one index.html file with the key in a single constant, served it with python3 -m http.server and tested it in headless Chrome.
  • All five origins and the destination matched with confidence 1, and one Route Matrix request returned a reachable cell for each origin.
  • The table, sorted by time: 233 S Wacker Dr 6.1 km / 9 min, 1901 W Madison St 6.8 km / 10 min, 5700 S Lake Shore Dr 10.1 km / 11 min, 2430 N Cannon Dr 10.0 km / 13 min, 1060 W Addison St 14.5 km / 18 min. Lake Shore Drive is slightly longer than Cannon Drive but 2 minutes faster, so ranking by distance and by time gives different orders.
  • It reminded us to restrict the key to our website in MyProjects before publishing the page.

The third prompt adds a many-to-one function to a project you already have:

Add a function to this project that returns drive times from many origins to one destination with the Geoapify Route Matrix API.

- First inspect the project: language, module style, how it reads configuration and environment variables, its HTTP client and its tests. Follow its conventions and make the smallest change that works. Ask me only what the project doesn't answer.
- The API key comes from the `GEOAPIFY_API_KEY` environment variable, read the way the project already reads its settings. Never print the key or write it into code.
- Add `getDriveTimesToDestination(origins, destination, options)`. Origins and destination are `[longitude, latitude]` pairs. `options` can set `mode` (default `"drive"`) and `units` (`"metric"` or `"imperial"`).
- Call `POST https://api.geoapify.com/v1/routematrix?apiKey=…` with the origins as `sources` and the destination as the only `target` (docs: https://apidocs.geoapify.com/docs/route-matrix/). One request holds up to 1,000 source–target pairs: split longer lists into chunks of 1,000 and merge the results.
- Map every cell back to its origin with `source_index` and return the results in the input order: `{ origin, distance, time, reachable }`. Treat a missing or non-numeric `time` as unreachable. On an HTTP error, throw an error that includes the API's `message`.
- Add a unit test with a mocked API response, including the chunking and an unreachable cell. Then run one live check with three origins from the project's own data.

Run the tests, then report the files you changed, the test results, and the command to use the new function.

What happened in our test:

  • We gave the agent a small Express project that reads settings through dotenv and tests with node:test. It inspected the project first, reused the existing config module and the built-in fetch, and added two new files without changing existing ones.
  • Its unit test mocks 1,501 origins (two requests: 1,000 and 501), cells returned in reverse order, unreachable cells and a 400 error with the API's message. All 3 tests passed.
  • The project had no destination, so the agent used one of its own stores and asked which real destination to use. The live check returned 0 m for that store, 8,996 m / 690 s and 11,671 m / 750 s for the other two.
  • The command it suggested for trying the function was a one-line node -e script: fine for a developer, less so for a non-technical reader.

How Do You Calculate Your First Driving Distance?

The fastest way to see your own numbers is the Route Matrix API playground: place sources and targets on a map, pick a mode and read the matrix. It also generates the request code. For one trip with a route line, use the Routing API playground.

AI assistants can calculate the same matrix through the Geoapify MCP Server. The calculate_route_matrix tool takes sources and optional targets as lat/lon objects; when targets is omitted, it uses the sources. Sources × targets must not exceed 1,000. MCP tool call, the Willis Tower → Wrigley Field pair:

{
  "name": "calculate_route_matrix",
  "arguments": {
    "sources": [{ "lat": 41.878738, "lon": -87.6359612 }],
    "targets": [{ "lat": 41.9481846, "lon": -87.655559 }],
    "mode": "drive"
  }
}

The tool supports drive, truck, light_truck, medium_truck, bus, motorcycle, scooter, bicycle, walk and hike. See the calculate_route_matrix reference. If you are moving from another provider, our Google Maps Distance Matrix alternative post compares the request formats.

Frequently Asked Questions

How do I calculate driving distance with an API?

Geocode both addresses with the Geocoding API, then send the coordinates to the Routing API with mode=drive. The response contains distance in meters and time in seconds. For many origins or destinations, use the Route Matrix API instead of one route per pair.

What is a many-to-one travel time matrix?

It is a table of travel times and distances from many origins to one destination. In the Route Matrix API you send the origins as sources and the destination as the only target; the response has one row per origin, mapped by source_index. In our test, 483 Chicago schools to the Field Museum came back in one request. See the Route Matrix API docs.

Is driving distance from A to B the same as from B to A?

Not necessarily. One-way streets and turn restrictions make road travel directional. Willis Tower to Wrigley Field was 12,503 m, and the reverse trip 13,347 m. For 483 schools, the two directions differed by more than 2 minutes for 105 schools. The nearest-by-travel-time how-to explains which direction to use.

How many origins can I send in one Route Matrix request?

A regular request holds up to 1,000 source–target pairs, so up to 1,000 origins for one destination. A Batch API call holds up to 2,000 pairs. The sum of all distances is limited to 300,000 km for regular calls and 1,000,000 km for batch calls. Larger requests return 400 Bad Request; split them into chunks.

How are Route Matrix API credits calculated?

The base cost is max(sources, targets) × min(sources, targets, 10) credits. A 483×1 matrix costs 483 credits, and a 30×30 matrix costs 300 credits instead of 900 for separate routes. Avoid options and distances over 500 km add credits, and Batch API jobs with the default priority cost 50%. See the pricing details and plans.

Can I get driving distance in miles?

Yes. Set units=imperial in the Routing API, or "units": "imperial" in the Route Matrix request body. Distances come back in miles and distance_units says miles; times stay in seconds. Willis Tower to Wrigley Field is 7.7691 miles. See the Routing API docs.

Does the Route Matrix API return route geometry?

No. The Route Matrix API returns distance and time for each source–target pair, plus the original and road-snapped locations. For the route line and turn-by-turn steps, request the pair you need from the Routing API.

World map

Try the Route Matrix API

Get a free API key, test your locations in the playground,
and calculate hundreds of drive times in one request.