Calculate a Distance Matrix with Route Matrix API

Distance Matrix API: Multi-Location Route Matrix

Get travel times and distances for up to 1000 source or target locations at once

Solve logistics and route optimization challenges for your team or customers efficiently with our Route Matrix API:

  • Use the Geoapify Distance Matrix API as input for route optimization or analytics. Our API returns the distance and travel times between each pair of provided sources and targets.
  • Get results optimized for different travel modes including driving, trucking, cycling and walking.

Building a solution for your customers? Our API is an ideal starting point, enabling you to create an optimal travel planning experience.

Try Distance Matrix API

Try out the Route Matrix API right here. Click on the map to add origin and destination locations, then click the "Build a Route" button to see the route between the two locations.

Visit the API Playground to explore more Distance Matrix features. Easily avoid tolls, ferries, or highways, adjust the route type (choose from balanced, short, or fewer maneuvers), and account for rush hour traffic.

Use Cases for the Distance Matrix API

Use our Routing Matrix API to address routing and logistics challenges for your team or customers:

Effective Routing Solutions with Travel Time and Distance Insights

  • Solve Routing Issues: Display travel times and distances to streamline logistics. Effectively tackle the vehicle routing problem.
  • Location Routing Problems: Optimize routes for cleaning crews, maintenance staff, salespeople, delivery drivers, and more.
  • Analyze Reachability: Utilize isochrones and isodistances to evaluate travel times and accessibility. Perfect for route planning and assessing potential business locations. Whether setting up a corner store or a guest house, determine how many homes are within easy driving or walking distance and how close the location is to attractions and transport hubs.
  • Enhance Customer Experience: Allow customers to select a location on a map and see reachable amenities and their travel times. For example, customers can search for “stores near me” and receive accurate travel times and distances.
  • Estimate Travel Costs: Calculate travel costs for various locations.
  • Assess Road Conditions: Use travel times and distances to estimate road conditions along a route.
  • Find Nearest Places: Provide estimated travel times to nearby amenities. Perfect for store locators, tourist businesses showcasing nearby attractions, or real estate agents helping clients explore schools and shops near a new home.

Leverage the Route Matrix API for Route Optimization Libraries

Our Route Matrix API serves as essential input for route optimization libraries like Vroom or OR-tools.

By providing accurate travel times and distances between multiple locations, the API enables these libraries to generate optimal routes efficiently. Whether you're managing delivery fleets, service teams, or any logistics operations, integrating our Distance Matrix API with these powerful tools can significantly enhance your route planning and optimization processes.

Develop New Solutions or Utilize Our Pre-Built APIs

We harnessed the power of our Route Matrix API to create our optimization and analytics APIs. Explore them to see if they meet your needs!

Solve VRP with Route Planner API

Route Planner API

Our Route Planner API solves route optimization and route planning problems including VRP and its variants.

Use it to build optimal delivery and pickup routes, generate schedules for your agents, and plan the best use of shared resources such as tools.

Analyse reachability with Isoline API

Isochrone and Isodistance API

Our Isolines API calculates isochrones and isodistances.

Use it to optimize travel times, analyze reachability, and discover promising potential business locations.

Features and Capabilities

Retrieve Time in Seconds and Distance in Meters or Miles

The Distance Matrix API delivers precise travel information, providing time in seconds and distance in either meters or miles between specified origins and destinations. Below is an example of a result object:

    • [] 3 items
      • [] 3 items
        • [] 3 items
          • "metric"
          • "meters"
          • "drive"

        Configure Travel Modes and Restrictions

        Our API supports the travel modes and travel inputs from Routing API, allowing for easy calculation of distances and travel times for cars, trucks, bicycles, hiking, and walking. Additionally, you can instruct the API to avoid specific road elements such as tolls, highways, or ferries.

        Incorporate Traffic Flow

        The Route Matrix API uses estimated traffic data to simulate rush hour conditions, allowing you to account for traffic flow in your distance matrix calculations.

        Specify Route Type

        Our API can provide balanced routes, shorter routes, or routes with fewer maneuvers. The default is balanced, offering a compromise between time, cost, and distance. Short routes optimize for the shortest distance, while routes with fewer maneuvers apply additional penalties for each maneuver to minimize them.

        Calculate Exact Routes

        With the same parameters used in both the Route Matrix and Routing APIs, you can calculate precise routes using the Routing API.

        Getting started

        Our API works via HTTP and has simple data formats. Getting started is easy:

        Step 1. Sign Up and Obtain Your API Key

        To get started, register on MyProject Geoapify and obtain your API key.

        Step 2. Generate and Send an HTTP Post Request

        Create an HTTP Post request with the required input data and execute the call. Use our Distance Matrix API Playground to experiment, and refer to our documentation for detailed information on the API request/response structure.

        Here's an example of how to generate and send an API request:

        const body = {"mode":"drive","sources":[{"location":[0.29088658483271956,41.428888210134915]},{"location":[0.6067435184261285,41.515322262551194]},{"location":[1.0242239871765833,41.57493564781842]}],"targets":[{"location":[-4.52604990731777,39.59765683264655]},{"location":[-2.972263097038308,39.59765683264655]},{"location":[-1.3243073891652557,39.615794666459436]}]};    
        fetch('https://api.geoapify.com/v1/routematrix?apiKey=YOUR_API_KEY', {
            method: 'POST',
            headers: {
              'Content-Type': 'application/json'
            },
            body: JSON.stringify(body)
          })
        .then(res => res.json())
        .then(res => console.log(res));

        How Much Does It Cost?

        Our pricing is straightforward. The number of credits required per request depends on the number of source and target elements or matrix elements.

        We offer discounts for larger matrices. If the smallest dimension of your matrix exceeds 10 elements, we will reduce the cost as if it had only 10 elements. The formula is as follows:

        Max(NUMBER_OF_SOURCES, NUMBER_OF_TARGETS) * Min(NUMBER_OF_SOURCES, NUMBER_OF_TARGETS, 10)
        • Example: for 5 sources and 7 targets the API call will cost Max(5, 7) * Min(5, 7, 10) = 7 * 5 = 35 credits.
        • Another example: for 300 sources and 500 targets the API call will cost Max(300, 500) * Min(300, 500, 10) = 500 * 10 = 5000 credits.

        Use our Credits Calculator to determine the best Pricing Plan for your needs.

        Need assistance? Contact us, and we’ll gladly help you find the ideal solution for your business.

        FAQ

        What is the Distance Matrix API?

        The Distance Matrix API calculates travel times and distances between multiple locations, providing accurate data for efficient route planning and logistics.

        What types of travel modes are supported by the Distance Matrix API?

        For a complete list of supported travel modes and detailed usage instructions, refer to our documentation.

        Can I use the Distance Matrix API for route optimization?

        Yes, you can use the Distance Matrix API for route optimization. The API response can serve as input for optimization libraries such as Vroom or OR-tools. Alternatively, we offer the Route Planner API, a ready-to-use solution that allows you to calculate optimal routes and schedules directly, simplifying the process.

        What are some common use cases for the Distance Matrix API?

        Common use cases include delivery route optimization, fleet management, travel planning, and determining service areas for businesses.

        What input data is required for the Distance Matrix API?

        The Distance Matrix API requires origin and destination coordinates along with travel mode specifications to calculate travel times and distances.

        How many locations can I send to the Route Matrix API in one request?

        By default, the Route Matrix API can handle 1000 matrix elements at once. You can specify the dimensions, such as 1000x1, 20x50 or 31x32 dimensions. If you need more, please contact us. We will find a solution for you!

        Can I calculate a distance matrix with bigger dimensions?

        Yes. The elements of the matrix are independent, so you can split a bigger matrix into as many smaller ones as you need to do the calculation.

        Can we use the Geoapify Route Matrix to build a Route Optimizer solution and sell to our customers?

        Sure! We don't have restrictions for competitive APIs.

        Can you provide custom conditions for high volumes?

        Yes! Contact us and we'll find the best solution for you.

        World map

        Get Time and Distance Data For Multiple Locations

        Solve route optimization problems for your business, your fleet, or your customers, with our Routing Matrix API.

        Got questions? Get in touch and we'll help you get started.