Skip to content
GuidesPlaygroundDashboard

Optimize

Optimize route through waypoints
optimize.create(**kwargs) -> OptimizeResult
POST/api/v1/optimize
Get async optimization result
optimize.retrieve(job_id) -> OptimizeJobStatus { status, error, result }
GET/api/v1/optimize/{job_id}
ModelsExpand Collapse
class OptimizeCompletedResult { geometry, properties, status, type }

Completed optimization — GeoJSON Feature with optimized route

geometry: GeoJsonGeometry { coordinates, type }
coordinates: Array[Float] | Array[Array[Float]] | Array[Array[Array[Float]]] | Array[Array[Array[Array[Float]]]]

GeoJSON coordinates array (nesting depth varies by geometry type)

One of the following:
Array[Float]
Array[Array[Float]]
Array[Array[Array[Float]]]
Array[Array[Array[Array[Float]]]]
type: :Point | :LineString | :Polygon | 3 more
One of the following:
:Point
:LineString
:Polygon
:MultiPoint
:MultiLineString
:MultiPolygon
properties: { distance, duration, waypoint_order}
distance: Float

Total distance in meters

duration: Float

Estimated duration in seconds

waypoint_order: Array[Integer]

Optimized waypoint ordering

status: :completed

Job status

type: :Feature
class 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

Error message when failed

result: untyped

Optimization result when completed

class OptimizeProcessingResult { job_id, status }

Async optimization in progress — poll with the job_id

job_id: String

Job ID for polling

status: :processing

Job status

class OptimizeRequest { waypoints, mode, roundtrip }

Route optimization request through waypoints

waypoints: GeoJsonGeometry { coordinates, type }

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

coordinates: Array[Float] | Array[Array[Float]] | Array[Array[Array[Float]]] | Array[Array[Array[Array[Float]]]]

GeoJSON coordinates array (nesting depth varies by geometry type)

One of the following:
Array[Float]
Array[Array[Float]]
Array[Array[Array[Float]]]
Array[Array[Array[Array[Float]]]]
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: bool

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:
class OptimizeCompletedResult { geometry, properties, status, type }

Completed optimization — GeoJSON Feature with optimized route

geometry: GeoJsonGeometry { coordinates, type }
coordinates: Array[Float] | Array[Array[Float]] | Array[Array[Array[Float]]] | Array[Array[Array[Array[Float]]]]

GeoJSON coordinates array (nesting depth varies by geometry type)

One of the following:
Array[Float]
Array[Array[Float]]
Array[Array[Array[Float]]]
Array[Array[Array[Array[Float]]]]
type: :Point | :LineString | :Polygon | 3 more
One of the following:
:Point
:LineString
:Polygon
:MultiPoint
:MultiLineString
:MultiPolygon
properties: { distance, duration, waypoint_order}
distance: Float

Total distance in meters

duration: Float

Estimated duration in seconds

waypoint_order: Array[Integer]

Optimized waypoint ordering

status: :completed

Job status

type: :Feature
class OptimizeProcessingResult { job_id, status }

Async optimization in progress — poll with the job_id

job_id: String

Job ID for polling

status: :processing

Job status