Skip to content
GuidesBlogPlaygroundDashboard

Calculate a route between two points

RouteResult Routing.Route(RoutingRouteParamsparameters, CancellationTokencancellationToken = default)
POST/api/v1/route

Calculate a route between two points

ParametersExpand Collapse
RoutingRouteParams parameters
required Destination destination

Body param: Geographic coordinate as a JSON object with lat and lng fields.

required Double Lat

Latitude in decimal degrees (-90 to 90)

maximum90
minimum-90
required Double Lng

Longitude in decimal degrees (-180 to 180)

maximum180
minimum-180
required Origin origin

Body param: Geographic coordinate as a JSON object with lat and lng fields.

required Double Lat

Latitude in decimal degrees (-90 to 90)

maximum90
minimum-90
required Double Lng

Longitude in decimal degrees (-180 to 180)

maximum180
minimum-180
string format

Query param: Response format for alternatives: json (default), geojson, csv, ndjson

Long alternatives

Body param: Number of alternative routes to return (0-3, default 0). When > 0, response is a FeatureCollection of route Features.

maximum3
minimum0
Boolean annotations

Body param: Include per-edge annotations (speed, duration) on the route (default: false)

DateTimeOffset? departAt

Body param: Departure time for traffic-aware routing (ISO 8601)

formatdate-time
Ev? ev

Body param: Electric vehicle parameters for EV-aware routing

required Double BatteryCapacityWh

Total battery capacity in watt-hours (required for EV routing)

IReadOnlyList<string>? ConnectorTypes

Acceptable connector types (e.g. ["ccs", "chademo"])

Double InitialChargePct

Starting charge as a fraction 0-1 (default: 0.8)

maximum1
minimum0
Double MinChargePct

Minimum acceptable charge at destination as a fraction 0-1 (default: 0.10)

maximum1
minimum0
Double? MinPowerKw

Minimum charger power in kilowatts

string? exclude

Body param: Comma-separated road types to exclude (e.g. toll,motorway,ferry)

Geometries geometries

Body param: Geometry encoding format. Default: geojson.

"geojson"Geojson
"polyline"Polyline
"polyline6"Polyline6
Mode mode

Body param: Travel mode (default: auto)

"auto"Auto
"foot"Foot
"bicycle"Bicycle
Overview overview

Body param: Level of geometry detail: full (all points), simplified (Douglas-Peucker), false (no geometry). Default: full.

"full"Full
"simplified"Simplified
"false"False
Boolean steps

Body param: Include turn-by-turn navigation steps (default: false)

TrafficModel? trafficModel

Body param: Traffic prediction model (only used when depart_at is set)

"best_guess"BestGuess
"optimistic"Optimistic
"pessimistic"Pessimistic
IReadOnlyList<Waypoint>? waypoints

Body param: Intermediate waypoints to visit in order (maximum 25)

required Double Lat

Latitude in decimal degrees (-90 to 90)

maximum90
minimum-90
required Double Lng

Longitude in decimal degrees (-180 to 180)

maximum180
minimum-180
ReturnsExpand Collapse
class RouteResult:

GeoJSON Feature representing a calculated route. The geometry is a LineString or MultiLineString of the route path. When alternatives > 0, the response is a FeatureCollection containing multiple route Features.

required GeoJsonGeometry Geometry

GeoJSON Geometry object per RFC 7946. Coordinates use [longitude, latitude] order. 3D coordinates [lng, lat, elevation] are used for elevation endpoints.

required Coordinates Coordinates

Coordinates array. Nesting depth varies by geometry type: Point = [lng, lat], LineString = [[lng, lat], ...], Polygon = [[[lng, lat], ...], ...], etc.

One of the following:
IReadOnlyList<Double>
IReadOnlyList<IReadOnlyList<Double>>
IReadOnlyList<IReadOnlyList<IReadOnlyList<Double>>>
IReadOnlyList<IReadOnlyList<IReadOnlyList<IReadOnlyList<Double>>>>
required Type Type

Geometry type

One of the following:
"Point"Point
"LineString"LineString
"Polygon"Polygon
"MultiPoint"MultiPoint
"MultiLineString"MultiLineString
"MultiPolygon"MultiPolygon
required Properties Properties

Route metadata

required Double DistanceM

Total route distance in meters

required Double DurationS

Estimated travel duration in seconds

IReadOnlyDictionary<string, JsonElement>? Annotations

Per-edge annotations (present when annotations: true in request)

IReadOnlyList<IReadOnlyList<Double>>? ChargeProfile

Battery charge level at route waypoints as [distance_fraction, charge_pct] pairs (EV routes only)

IReadOnlyList<IReadOnlyDictionary<string, JsonElement>>? ChargingStops

Recommended charging stops along the route (EV routes only)

IReadOnlyList<IReadOnlyDictionary<string, JsonElement>>? Edges

Edge-level route details (present when annotations: true)

Double? EnergyUsedWh

Total energy consumed in watt-hours (EV routes only)

required Type Type

Calculate a route between two points

RoutingRouteParams parameters = new()
{
    Destination = new()
    {
        Lat = 48.8584,
        Lng = 2.2945,
    },
    Origin = new()
    {
        Lat = 48.8566,
        Lng = 2.3522,
    },
};

var routeResult = await client.Routing.Route(parameters);

Console.WriteLine(routeResult);
{
  "geometry": {
    "coordinates": [
      2.3522,
      48.8566
    ],
    "type": "Point"
  },
  "properties": {
    "distance_m": 4523.7,
    "duration_s": 847.2,
    "annotations": {
      "foo": "bar"
    },
    "charge_profile": [
      [
        0
      ]
    ],
    "charging_stops": [
      {
        "foo": "bar"
      }
    ],
    "edges": [
      {
        "foo": "bar"
      }
    ],
    "energy_used_wh": 0
  },
  "type": "Feature"
}
Returns Examples
{
  "geometry": {
    "coordinates": [
      2.3522,
      48.8566
    ],
    "type": "Point"
  },
  "properties": {
    "distance_m": 4523.7,
    "duration_s": 847.2,
    "annotations": {
      "foo": "bar"
    },
    "charge_profile": [
      [
        0
      ]
    ],
    "charging_stops": [
      {
        "foo": "bar"
      }
    ],
    "edges": [
      {
        "foo": "bar"
      }
    ],
    "energy_used_wh": 0
  },
  "type": "Feature"
}