Distance Matrix API

The Distance Matrix API returns the driving distance between multiple pairs of origins and destinations. It’s ideal for logistics, routing, dispatch planning, and delivery network optimization.


It supports up to 3 origin points and 3 destination points, forming a maximum 3x3 matrix. Each cell in the matrix contains the driving distance for that specific origin-destination pair.

πŸ”‘ Authentication

  • All requests must include your API key.
  • Header Example:
  • Authorization: X-Authorization-Token (Get your token HERE)

🌐 Endpoint

  • GET /v4/distancematrix
  • Base URL: https://apihub.latlong.ai/v4/distancematrix

πŸ“₯ Request Parameters

ParameterTypeRequiredDescription
Origins StringYesPipe-separated list of lat,lng pairs. Max 3 origins
DestinationsStringYesPipe-separated list of lat,lng pairs. Max 3 destinations

πŸ“€ Sample Request

curl --location 'https://apihub.latlong.ai/v4/distancematrix.json?origins=19.4210814%2C72.8167569%20%7C%2019.09574%2C72.8746%20%7C%2019.1634518%2C72.9296933&destinations=19.06576709%2C73.00164192%7C%2019.0958737%2C72.8401187%20%7C%2019.12428%2C73.00588' 

πŸ“¦ Sample Response

 { 

  "code": 1001, 

  "status": "success", 

  "data": [ 

    { 

      "origin": "19.4210814,72.8167569", 

      "destination": "19.06576709,73.00164192", 

      "distance": "60.89 km" 

    }, 

    { 

      "origin": "19.4210814,72.8167569", 

      "destination": "19.0958737,72.8401187", 

      "distance": "50.21 km" 

    }, 

    { 

      "origin": "19.4210814,72.8167569", 

      "destination": "19.12428,73.00588", 

      "distance": "51.83 km" 

    }, 

    { 

      "origin": "19.09574,72.8746", 

      "destination": "19.06576709,73.00164192", 

      "distance": "23.11 km" 

    }, 

    { 

      "origin": "19.09574,72.8746", 

      "destination": "19.0958737,72.8401187", 

      "distance": "6.04 km" 

    }, 

    { 

      "origin": "19.09574,72.8746", 

      "destination": "19.12428,73.00588", 

      "distance": "23.14 km" 

    }, 

    { 

      "origin": "19.1634518,72.9296933", 

      "destination": "19.06576709,73.00164192", 

      "distance": "20.31 km" 

    }, 

    { 

      "origin": "19.1634518,72.9296933", 

      "destination": "19.0958737,72.8401187", 

      "distance": "19.24 km" 

    }, 

    { 

      "origin": "19.1634518,72.9296933", 

      "destination": "19.12428,73.00588", 

      "distance": "11.24 km" 

    } 

  ] 

}  

βœ… Matrix Rules

  • A maximum of 3 origin points and 3 destination points
  • Format: "lat1, lng1 | lat2, lng2 | lat3, lng3 "
  • Every origin will be paired with every destination

🧠 Features

  • 🚚

    Multi-drop delivery planning and optimization

  • πŸš•

    Taxi fare or ETA matrix for ride-sharing platforms

  • πŸ›οΈ

    Nearest store or warehouse lookup for a group of users

  • πŸ“¦

    Dispatching vehicles to multiple drop points

⚠️ Errors

Status CodeMessageDescription
400Missing required parametersWhen query is not provided
401UnauthorizedAPI key missing or invalid
500Internal Server ErrorSomething went wrong on our side