Skip to content
GuidesBlogPlaygroundDashboard

Optimize

Optimize route through waypoints
optimize().create(OptimizeCreateParamsparams, RequestOptionsrequestOptions = RequestOptions.none()) : OptimizeResult
POST/api/v1/optimize
Get async optimization result
optimize().retrieve(OptimizeRetrieveParamsparams = OptimizeRetrieveParams.none(), RequestOptionsrequestOptions = RequestOptions.none()) : OptimizeJobStatus
GET/api/v1/optimize/{job_id}
ModelsExpand Collapse
class OptimizeCompletedResult:

Completed optimization result as a GeoJSON FeatureCollection. Each Feature is a waypoint in optimized visit order. Top-level fields provide summary statistics.

features: List<Feature>

Waypoints in optimized visit order

geometry: GeoJsonGeometry

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
costS: Double

Travel time in seconds from the previous waypoint to this one (0 for the first waypoint)

cumulativeCostS: Double

Cumulative travel time in seconds from the start to this waypoint

waypointIndex: Long

Position of this waypoint in the optimized visit order (0-based)

type: Type
optimization: String

Optimization method used (e.g. nearest_neighbor, 2opt)

roundtrip: Boolean

Whether the route returns to the starting waypoint

totalCostS: Double

Total travel time for the optimized route in seconds

type: Type
class OptimizeJobStatus:

Status of an async optimization job. When completed, the result field contains the full OptimizeCompletedResult. When processing, the job is still running — poll again. Failed jobs return a standard Error response (HTTP 422), not this schema.

status: Status

Current job state

One of the following:
COMPLETED("completed")
PROCESSING("processing")
result: Optional<OptimizeCompletedResult>

Completed optimization result as a GeoJSON FeatureCollection. Each Feature is a waypoint in optimized visit order. Top-level fields provide summary statistics.

features: List<Feature>

Waypoints in optimized visit order

geometry: GeoJsonGeometry

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
costS: Double

Travel time in seconds from the previous waypoint to this one (0 for the first waypoint)

cumulativeCostS: Double

Cumulative travel time in seconds from the start to this waypoint

waypointIndex: Long

Position of this waypoint in the optimized visit order (0-based)

type: Type
optimization: String

Optimization method used (e.g. nearest_neighbor, 2opt)

roundtrip: Boolean

Whether the route returns to the starting waypoint

totalCostS: Double

Total travel time for the optimized route in seconds

type: Type
class OptimizeProcessingResult:

Async optimization in progress. Poll GET /api/v1/optimize/{job_id} until the status changes to completed or failed.

jobId: String

Job ID for polling the result

status: Status

Always processing

class OptimizeRequest:

Route optimization (Travelling Salesman) request. Finds the most efficient order to visit a set of waypoints. Minimum 2 waypoints, maximum 50. For large inputs, the request may be processed asynchronously.

waypoints: List<Waypoint>

Waypoints to visit in optimized order (2-50 points)

lat: Double

Latitude in decimal degrees (-90 to 90)

maximum90
minimum-90
lng: Double

Longitude in decimal degrees (-180 to 180)

maximum180
minimum-180
mode: Optional<Mode>

Travel mode (default: auto)

One of the following:
AUTO("auto")
FOOT("foot")
BICYCLE("bicycle")
roundtrip: Optional<Boolean>

Whether the route should return to the starting waypoint (default: true)

class OptimizeResult: A class that can be one of several variants.union

Optimization response — either a completed FeatureCollection with the optimized route, or an async job reference to poll.

class OptimizeCompletedResult:

Completed optimization result as a GeoJSON FeatureCollection. Each Feature is a waypoint in optimized visit order. Top-level fields provide summary statistics.

features: List<Feature>

Waypoints in optimized visit order

geometry: GeoJsonGeometry

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
costS: Double

Travel time in seconds from the previous waypoint to this one (0 for the first waypoint)

cumulativeCostS: Double

Cumulative travel time in seconds from the start to this waypoint

waypointIndex: Long

Position of this waypoint in the optimized visit order (0-based)

type: Type
optimization: String

Optimization method used (e.g. nearest_neighbor, 2opt)

roundtrip: Boolean

Whether the route returns to the starting waypoint

totalCostS: Double

Total travel time for the optimized route in seconds

type: Type
class OptimizeProcessingResult:

Async optimization in progress. Poll GET /api/v1/optimize/{job_id} until the status changes to completed or failed.

jobId: String

Job ID for polling the result

status: Status

Always processing