Skip to content
GuidesBlogPlaygroundDashboard

Optimize

Optimize route through waypoints
client.Optimize.New(ctx, params) (*OptimizeResult, error)
POST/api/v1/optimize
Get async optimization result
client.Optimize.Get(ctx, jobID) (*OptimizeJobStatus, error)
GET/api/v1/optimize/{job_id}
ModelsExpand Collapse
type OptimizeCompletedResult struct{…}

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

Features []OptimizeCompletedResultFeature

Waypoints in optimized visit order

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

Coordinates GeoJsonGeometryCoordinatesUnion

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

One of the following:
type GeoJsonGeometryCoordinatesPoint []float64

[longitude, latitude] or [longitude, latitude, elevation]

type GeoJsonGeometryCoordinatesLineStringOrMultiPoint [][]float64

Array of [lng, lat] positions

type GeoJsonGeometryCoordinatesPolygonOrMultiLineString [][][]float64

Array of linear rings / line strings

type GeoJsonGeometryCoordinatesMultiPolygon [][][][]float64

Array of polygons

Type GeoJsonGeometryType

Geometry type

One of the following:
const GeoJsonGeometryTypePoint GeoJsonGeometryType = "Point"
const GeoJsonGeometryTypeLineString GeoJsonGeometryType = "LineString"
const GeoJsonGeometryTypePolygon GeoJsonGeometryType = "Polygon"
const GeoJsonGeometryTypeMultiPoint GeoJsonGeometryType = "MultiPoint"
const GeoJsonGeometryTypeMultiLineString GeoJsonGeometryType = "MultiLineString"
const GeoJsonGeometryTypeMultiPolygon GeoJsonGeometryType = "MultiPolygon"
Properties OptimizeCompletedResultFeaturesProperties
CostS float64

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

CumulativeCostS float64

Cumulative travel time in seconds from the start to this waypoint

WaypointIndex int64

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

Type OptimizeCompletedResultFeaturesType
Optimization string

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

Roundtrip bool

Whether the route returns to the starting waypoint

TotalCostS float64

Total travel time for the optimized route in seconds

Type OptimizeCompletedResultType
type OptimizeJobStatus struct{…}

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 OptimizeJobStatusStatus

Current job state

One of the following:
const OptimizeJobStatusStatusCompleted OptimizeJobStatusStatus = "completed"
const OptimizeJobStatusStatusProcessing OptimizeJobStatusStatus = "processing"

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

Features []OptimizeCompletedResultFeature

Waypoints in optimized visit order

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

Coordinates GeoJsonGeometryCoordinatesUnion

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

One of the following:
type GeoJsonGeometryCoordinatesPoint []float64

[longitude, latitude] or [longitude, latitude, elevation]

type GeoJsonGeometryCoordinatesLineStringOrMultiPoint [][]float64

Array of [lng, lat] positions

type GeoJsonGeometryCoordinatesPolygonOrMultiLineString [][][]float64

Array of linear rings / line strings

type GeoJsonGeometryCoordinatesMultiPolygon [][][][]float64

Array of polygons

Type GeoJsonGeometryType

Geometry type

One of the following:
const GeoJsonGeometryTypePoint GeoJsonGeometryType = "Point"
const GeoJsonGeometryTypeLineString GeoJsonGeometryType = "LineString"
const GeoJsonGeometryTypePolygon GeoJsonGeometryType = "Polygon"
const GeoJsonGeometryTypeMultiPoint GeoJsonGeometryType = "MultiPoint"
const GeoJsonGeometryTypeMultiLineString GeoJsonGeometryType = "MultiLineString"
const GeoJsonGeometryTypeMultiPolygon GeoJsonGeometryType = "MultiPolygon"
Properties OptimizeCompletedResultFeaturesProperties
CostS float64

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

CumulativeCostS float64

Cumulative travel time in seconds from the start to this waypoint

WaypointIndex int64

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

Type OptimizeCompletedResultFeaturesType
Optimization string

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

Roundtrip bool

Whether the route returns to the starting waypoint

TotalCostS float64

Total travel time for the optimized route in seconds

Type OptimizeCompletedResultType
type OptimizeProcessingResult struct{…}

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 OptimizeProcessingResultStatus

Always processing

type OptimizeRequest struct{…}

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 []OptimizeRequestWaypoint

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

Lat float64

Latitude in decimal degrees (-90 to 90)

maximum90
minimum-90
Lng float64

Longitude in decimal degrees (-180 to 180)

maximum180
minimum-180
Mode OptimizeRequestModeoptional

Travel mode (default: auto)

One of the following:
const OptimizeRequestModeAuto OptimizeRequestMode = "auto"
const OptimizeRequestModeFoot OptimizeRequestMode = "foot"
const OptimizeRequestModeBicycle OptimizeRequestMode = "bicycle"
Roundtrip booloptional

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

type OptimizeResult interface{…}

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

One of the following:
type OptimizeCompletedResult struct{…}

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

Features []OptimizeCompletedResultFeature

Waypoints in optimized visit order

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

Coordinates GeoJsonGeometryCoordinatesUnion

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

One of the following:
type GeoJsonGeometryCoordinatesPoint []float64

[longitude, latitude] or [longitude, latitude, elevation]

type GeoJsonGeometryCoordinatesLineStringOrMultiPoint [][]float64

Array of [lng, lat] positions

type GeoJsonGeometryCoordinatesPolygonOrMultiLineString [][][]float64

Array of linear rings / line strings

type GeoJsonGeometryCoordinatesMultiPolygon [][][][]float64

Array of polygons

Type GeoJsonGeometryType

Geometry type

One of the following:
const GeoJsonGeometryTypePoint GeoJsonGeometryType = "Point"
const GeoJsonGeometryTypeLineString GeoJsonGeometryType = "LineString"
const GeoJsonGeometryTypePolygon GeoJsonGeometryType = "Polygon"
const GeoJsonGeometryTypeMultiPoint GeoJsonGeometryType = "MultiPoint"
const GeoJsonGeometryTypeMultiLineString GeoJsonGeometryType = "MultiLineString"
const GeoJsonGeometryTypeMultiPolygon GeoJsonGeometryType = "MultiPolygon"
Properties OptimizeCompletedResultFeaturesProperties
CostS float64

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

CumulativeCostS float64

Cumulative travel time in seconds from the start to this waypoint

WaypointIndex int64

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

Type OptimizeCompletedResultFeaturesType
Optimization string

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

Roundtrip bool

Whether the route returns to the starting waypoint

TotalCostS float64

Total travel time for the optimized route in seconds

Type OptimizeCompletedResultType
type OptimizeProcessingResult struct{…}

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 OptimizeProcessingResultStatus

Always processing