---
title: Route distance
slug: api-marketplace/route-distance
createdAt: 2024-02-12T06:03:54.319Z
---

## Introduction

Route Distance API provides distances between specified origin and destination coordinates, supporting various modes such as driving, walking, or bicycling.

***

## API details

### Endpoint

:::CodeblockTabs
Production Endpoint

```text
POST https://api.signzy.app/api/v3/geocoding/findRouteDistance
```
:::

:::CodeblockTabs
UAT Endpoint

```text
POST https://api-preproduction.signzy.app/api/v3/geocoding/findRouteDistance
```
:::

***

### Request body parameters

| **Parameter**         | **Data Type** | **Description**                                                                                                 | **Required** |
| --------------------- | ------------- | --------------------------------------------------------------------------------------------------------------- | ------------ |
| origin                | Object        | Object containing latitude and longitude of the starting point                                                  | Mandatory    |
| origin.latitude       | String        | Latitude of the starting point                                                                                  | Mandatory    |
| origin.longitude      | String        | Longitude of the starting point                                                                                 | Mandatory    |
| destination           | Object        | Object containing latitude and longitude of the destination                                                     | Mandatory    |
| destination.latitude  | String        | Latitude of the destination                                                                                     | Mandatory    |
| destination.longitude | String        | Longitude of the destination                                                                                    | Mandatory    |
| mode                  | String        | Transportation mode (Valid values are: driving, walking, bicycling, transit)<br />Default value will be driving | Optional     |



```json
{
    "origin": {
        "latitude": "21.1456113",
        "longitude": "79.1191487"
    },
    "destination": {
        "latitude": "21.1446313",
        "longitude": "79.1122491"
    },
    "mode": "driving"
}
```

***

### Request Headers

| **Name&#x20;** | **Value**        | **Required** | **Description**                                                                                            |
| -------------- | ---------------- | ------------ | ---------------------------------------------------------------------------------------------------------- |
| Content-type   | application/json | Mandatory    | The type of content that the request body contains.                                                        |
| Authorization  | XXXXXXXXXXXXXXX  | Mandatory    | An authentication token to authorize the request. Reach out to the Signzy support team to get one created. |

***

### Code Samples

:::CodeblockTabs
Curl

```json
curl --location 'https://api-preproduction.signzy.app/api/v3/geocoding/findRouteDistance' \
--header 'Content-Type: application/json' \
--header 'Authorization: <Authorization token>' \
--data '{
    "origin": {
        "latitude": "22.1432113",
        "longitude": "76.1121487"
    },
    "destination": {
        "latitude": "20.1442113",
        "longitude": "78.1122487"
    },
    "mode": "driving"
}'
```

Node.js

```nodejs
const axios = require('axios');
let data = JSON.stringify({
  "origin": {
    "latitude": "22.1432113",
    "longitude": "76.1121487"
  },
  "destination": {
    "latitude": "20.1442113",
    "longitude": "78.1122487"
  },
  "mode": "driving"
});

let config = {
  method: 'post',
  maxBodyLength: Infinity,
  url: 'https://api-preproduction.signzy.app/api/v3/geocoding/findRouteDistance',
  headers: { 
    'Content-Type': 'application/json', 
    'Authorization': '<Authorization token>'
  },
  data : data
};

axios.request(config)
.then((response) => {
  console.log(JSON.stringify(response.data));
})
.catch((error) => {
  console.log(error);
});

```

Python

```python
import requests
import json

url = "https://api-preproduction.signzy.app/api/v3/geocoding/findRouteDistance"

payload = json.dumps({
  "origin": {
    "latitude": "22.1432113",
    "longitude": "76.1121487"
  },
  "destination": {
    "latitude": "20.1442113",
    "longitude": "78.1122487"
  },
  "mode": "driving"
})
headers = {
  'Content-Type': 'application/json',
  'Authorization': '<Authorization token>'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)

```

GO

```go
package main

import (
  "fmt"
  "strings"
  "net/http"
  "io/ioutil"
)

func main() {

  url := "https://api-preproduction.signzy.app/api/v3/geocoding/findRouteDistance"
  method := "POST"

  payload := strings.NewReader(`{
    "origin": {
        "latitude": "22.1432113",
        "longitude": "76.1121487"
    },
    "destination": {
        "latitude": "20.1442113",
        "longitude": "78.1122487"
    },
    "mode": "driving"
}`)

  client := &http.Client {
  }
  req, err := http.NewRequest(method, url, payload)

  if err != nil {
    fmt.Println(err)
    return
  }
  req.Header.Add("Content-Type", "application/json")
  req.Header.Add("Authorization", "<Authorization token>")

  res, err := client.Do(req)
  if err != nil {
    fmt.Println(err)
    return
  }
  defer res.Body.Close()

  body, err := ioutil.ReadAll(res.Body)
  if err != nil {
    fmt.Println(err)
    return
  }
  fmt.Println(string(body))
}
```
:::

***

### Response body parameters

| **Parameter**             | **Data Type** | **Description**                                          |
| ------------------------- | ------------- | -------------------------------------------------------- |
| result                    | Object        | The root object containing the result of the operation.  |
| result.originAddress      | String        | The address representing the origin of the journey.      |
| result.destinationAddress | String        | The address representing the destination of the journey. |
| result.mode               | String        | The mode of transportation used for the journey.         |
| result.distanceInMeters   | Integer       | The distance of the journey in meters.                   |
| result.durationInSeconds  | Integer       | The duration of the journey in seconds.                  |

:::CodeblockTabs
200

```json
{
    "result": {
        "originAddress": "Sulgaon Rd, Ghoshla, Madhya Pradesh 451111, India",
        "destinationAddress": "Unnamed Road, Pahur, Maharashtra 445109, India",
        "mode": "driving",
        "distanceInMeters": 413212,
        "durationInSeconds": 34831
    }
}
```

400

```json
// Passing empty latitude or longitude in origin/destination
// Note: error message will change accordingly
{
    "error": {
        "name": "error",
        "message": "Origin latitude is not allowed to be empty",
        "status": "Bad Request",
        "statusCode": 400
    }
}

// Passing invalid latitude or longitude in origin/destination
// Note: error message will change accordingly
{
    "error": {
        "name": "error",
        "message": "Origin latitude is invalid",
        "status": "Bad Request",
        "statusCode": 400
    }
}

// Not passing mandatory parameter
// Note: error message will change accordingly
{
    "error": {
        "name": "error",
        "message": "Origin laititude is required",
        "status": "Bad Request",
        "statusCode": 400
    }
}

// Passing invalid mode
{
    "error": {
        "name": "error",
        "message": "Invalid mode",
        "status": "Bad Request",
        "statusCode": 400
    }
}
```

401

```json
// If Authorization token is not passed
{
    "message": "No API key found in request"
}

// If Authorization token is invalid
{
    "message": "Invalid authentication credentials"
}
```

404

```json
// If the origin and destination points provided are in 
// different geographical regions or are not connected by 
// feasible routes
{
    "error": {
        "statusCode": 404,
        "name": "Error",
        "message": "No Result found",
        "status": 404
    }
}
```

409

```json
{
    "error": {
        "name": "error",
        "message": "Upstream Down",
        "status": 409,
        "statusCode": 409
    }
}
```
:::

***

**Contact Us for Any Assistance**

If you have any questions or need assistance, please reach out to our customer support team. You can contact us via email at <font color="#2166ae">**help\@signzy.com**</font>. We strive to provide prompt and reliable assistance, ensuring your queries are addressed effectively.

We value your feedback and are committed to making your experience smooth and enjoyable. Our team is dedicated to assisting you with any needs you may have. Thank you for choosing our services. We look forward to helping you!
