> ## Documentation Index
> Fetch the complete documentation index at: https://docs.rebellapp.com/llms.txt
> Use this file to discover all available pages before exploring further.

# my.calculateRoute

> Calculate a route between two points.

Calculate navigation route between origin and destination.

## Parameters

| Property        | Type     | Required | Description                                                                           |
| --------------- | -------- | -------- | ------------------------------------------------------------------------------------- |
| searchType      | String   | No       | Mode of transportation: `walk`, `bus`, `drive`, `ride`. Default is `walk`             |
| startLat        | Number   | Yes      | Start latitude                                                                        |
| startLng        | Number   | Yes      | Start longitude                                                                       |
| endLat          | Number   | Yes      | End latitude                                                                          |
| endLng          | Number   | Yes      | End longitude                                                                         |
| throughPoints   | Array    | No       | A set of points along the route                                                       |
| mode            | Number   | No       | Different modes of the route. Only supported for driving and public transit modes     |
| city            | String   | Yes      | The city of the route. Required in public transit mode                                |
| destinationCity | String   | Yes      | The destination city where the route ends. Required in cross-city public transit mode |
| gAPIKey         | String   | No       | The API key required to call this API (Google Maps only)                              |
| success         | Function | No       | Callback with route                                                                   |
| fail            | Function | No       | Callback on failure                                                                   |
| complete        | Function | No       | Callback that always executes                                                         |

## Success Callback

| Property | Type    | Description                                                         |
| -------- | ------- | ------------------------------------------------------------------- |
| success  | Boolean | Whether the API call is successful                                  |
| distance | Number  | The distance between the starting point and the endpoint            |
| duration | Number  | The length of time spent according to the planned route, in seconds |

## Error Codes

Default error code is `1900`. On Google Maps, the response includes `status` and `errorMessage` fields corresponding to the Google Maps DirectionsStatus.

## Code Example

```javascript theme={null}
my.calculateRoute({
  searchType: 'drive',
  startLat: 40.7128,
  startLng: -74.0060,
  endLat: 40.7580,
  endLng: -73.9855,
  success: (res) => {
    console.log('Distance:', res.distance);
    console.log('Duration:', res.duration);
  }
});
```
