Skip to content
GuidesPlaygroundDashboard

Optimize route through waypoints

optimize.create(OptimizeCreateParams**kwargs) -> OptimizeResult
POST/api/v1/optimize

Optimize route through waypoints

ParametersExpand Collapse

Waypoints to visit (GeoJSON MultiPoint geometry, minimum 2 points)

coordinates: Union[List[float], List[List[float]], List[List[List[float]]], List[List[List[List[float]]]]]

GeoJSON coordinates array (nesting depth varies by geometry type)

One of the following:
List[float]
List[List[float]]
List[List[List[float]]]
List[List[List[List[float]]]]
type: Literal["Point", "LineString", "Polygon", 3 more]
One of the following:
"Point"
"LineString"
"Polygon"
"MultiPoint"
"MultiLineString"
"MultiPolygon"
mode: Optional[Literal["auto", "foot", "bicycle"]]

Travel mode (default: auto)

One of the following:
"auto"
"foot"
"bicycle"
roundtrip: Optional[bool]

Whether route returns to start (default: true)

ReturnsExpand Collapse

Optimization response — either a completed GeoJSON Feature route or an async job reference

One of the following:
class OptimizeCompletedResult:

Completed optimization — GeoJSON Feature with optimized route

geometry: GeoJsonGeometry
coordinates: Union[List[float], List[List[float]], List[List[List[float]]], List[List[List[List[float]]]]]

GeoJSON coordinates array (nesting depth varies by geometry type)

One of the following:
List[float]
List[List[float]]
List[List[List[float]]]
List[List[List[List[float]]]]
type: Literal["Point", "LineString", "Polygon", 3 more]
One of the following:
"Point"
"LineString"
"Polygon"
"MultiPoint"
"MultiLineString"
"MultiPolygon"
properties: Properties
distance: Optional[float]

Total distance in meters

duration: Optional[float]

Estimated duration in seconds

waypoint_order: Optional[List[int]]

Optimized waypoint ordering

status: Literal["completed"]

Job status

type: Literal["Feature"]
class OptimizeProcessingResult:

Async optimization in progress — poll with the job_id

job_id: str

Job ID for polling

status: Literal["processing"]

Job status

Optimize route through waypoints

import os
from plaza import Plaza

client = Plaza(
    api_key=os.environ.get("PLAZA_API_KEY"),  # This is the default and can be omitted
)
optimize_result = client.optimize.create(
    waypoints={
        "coordinates": [0],
        "type": "Point",
    },
)
print(optimize_result)
Returns Examples