Skip to content
GuidesBlogPlaygroundDashboard

Calculate a route between two points

RouteResult routing().route(RoutingRouteParamsparams, RequestOptionsrequestOptions = RequestOptions.none())
POST/api/v1/route

Calculate a route between two points

ParametersExpand Collapse
RoutingRouteParams params
Optional<String> format

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

RouteRequest routeRequest

Request body for route calculation. Origin and destination are lat/lng coordinate objects. Supports optional waypoints, alternative routes, turn-by-turn steps, and EV routing parameters.

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.

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

Coordinates coordinates

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

One of the following:
List<double>
List<List<double>>
List<List<List<double>>>
List<List<List<List<double>>>>
Type type

Geometry type

One of the following:
POINT("Point")
LINE_STRING("LineString")
POLYGON("Polygon")
MULTI_POINT("MultiPoint")
MULTI_LINE_STRING("MultiLineString")
MULTI_POLYGON("MultiPolygon")
Properties properties

Route metadata

double distanceM

Total route distance in meters

double durationS

Estimated travel duration in seconds

Optional<Annotations> annotations

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

Optional<List<List<Double>>> chargeProfile

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

Optional<List<ChargingStop>> chargingStops

Recommended charging stops along the route (EV routes only)

Optional<List<Edge>> edges

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

Optional<Double> energyUsedWh

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

Type type

Calculate a route between two points

package com.plazafyi.example;

import com.plazafyi.client.PlazaClient;
import com.plazafyi.client.okhttp.PlazaOkHttpClient;
import com.plazafyi.models.routing.RouteRequest;
import com.plazafyi.models.routing.RouteResult;
import com.plazafyi.models.routing.RoutingRouteParams;

public final class Main {
    private Main() {}

    public static void main(String[] args) {
        PlazaClient client = PlazaOkHttpClient.fromEnv();

        RouteRequest params = RouteRequest.builder()
            .destination(RouteRequest.Destination.builder()
                .lat(48.8584)
                .lng(2.2945)
                .build())
            .origin(RouteRequest.Origin.builder()
                .lat(48.8566)
                .lng(2.3522)
                .build())
            .build();
        RouteResult routeResult = client.routing().route(params);
    }
}
{
  "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"
}