Skip to content
GuidesPlaygroundDashboard

Optimize

Optimize route through waypoints
client.optimize.create(OptimizeCreateParams { waypoints, mode, roundtrip } body, RequestOptionsoptions?): OptimizeResult
POST/api/v1/optimize
Get async optimization result
client.optimize.retrieve(stringjobID, RequestOptionsoptions?): OptimizeJobStatus { status, error, result }
GET/api/v1/optimize/{job_id}
ModelsExpand Collapse
OptimizeCompletedResult { geometry, properties, status, type }

Completed optimization — GeoJSON Feature with optimized route

geometry: GeoJsonGeometry { coordinates, type }
coordinates: Array<number> | Array<Array<number>> | Array<Array<Array<number>>> | Array<Array<Array<Array<number>>>>

GeoJSON coordinates array (nesting depth varies by geometry type)

One of the following:
Array<number>
Array<Array<number>>
Array<Array<Array<number>>>
Array<Array<Array<Array<number>>>>
type: "Point" | "LineString" | "Polygon" | 3 more
One of the following:
"Point"
"LineString"
"Polygon"
"MultiPoint"
"MultiLineString"
"MultiPolygon"
properties: Properties { distance, duration, waypoint_order }
distance?: number

Total distance in meters

duration?: number

Estimated duration in seconds

waypoint_order?: Array<number>

Optimized waypoint ordering

status: "completed"

Job status

type: "Feature"
OptimizeJobStatus { status, error, result }

Status of an async optimization job

status: "completed" | "processing" | "failed"

Job status

One of the following:
"completed"
"processing"
"failed"
error?: string | null

Error message when failed

result?: unknown

Optimization result when completed

OptimizeProcessingResult { job_id, status }

Async optimization in progress — poll with the job_id

job_id: string

Job ID for polling

status: "processing"

Job status

OptimizeRequest { waypoints, mode, roundtrip }

Route optimization request through waypoints

waypoints: GeoJsonGeometry { coordinates, type }

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

coordinates: Array<number> | Array<Array<number>> | Array<Array<Array<number>>> | Array<Array<Array<Array<number>>>>

GeoJSON coordinates array (nesting depth varies by geometry type)

One of the following:
Array<number>
Array<Array<number>>
Array<Array<Array<number>>>
Array<Array<Array<Array<number>>>>
type: "Point" | "LineString" | "Polygon" | 3 more
One of the following:
"Point"
"LineString"
"Polygon"
"MultiPoint"
"MultiLineString"
"MultiPolygon"
mode?: "auto" | "foot" | "bicycle"

Travel mode (default: auto)

One of the following:
"auto"
"foot"
"bicycle"
roundtrip?: boolean

Whether route returns to start (default: true)

OptimizeResult = OptimizeCompletedResult { geometry, properties, status, type } | OptimizeProcessingResult { job_id, status }

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

One of the following:
OptimizeCompletedResult { geometry, properties, status, type }

Completed optimization — GeoJSON Feature with optimized route

geometry: GeoJsonGeometry { coordinates, type }
coordinates: Array<number> | Array<Array<number>> | Array<Array<Array<number>>> | Array<Array<Array<Array<number>>>>

GeoJSON coordinates array (nesting depth varies by geometry type)

One of the following:
Array<number>
Array<Array<number>>
Array<Array<Array<number>>>
Array<Array<Array<Array<number>>>>
type: "Point" | "LineString" | "Polygon" | 3 more
One of the following:
"Point"
"LineString"
"Polygon"
"MultiPoint"
"MultiLineString"
"MultiPolygon"
properties: Properties { distance, duration, waypoint_order }
distance?: number

Total distance in meters

duration?: number

Estimated duration in seconds

waypoint_order?: Array<number>

Optimized waypoint ordering

status: "completed"

Job status

type: "Feature"
OptimizeProcessingResult { job_id, status }

Async optimization in progress — poll with the job_id

job_id: string

Job ID for polling

status: "processing"

Job status