Skip to content
GuidesBlogPlaygroundDashboard

Routing

Calculate a route between two points
client.Routing.Route(ctx, params) (*RouteResult, error)
POST/api/v1/route
Snap a coordinate to the nearest road
client.Routing.Nearest(ctx, query) (*NearestResult, error)
GET/api/v1/nearest
Snap a coordinate to the nearest road
client.Routing.NearestPost(ctx, body) (*NearestResult, error)
POST/api/v1/nearest
Calculate an isochrone from a point
client.Routing.Isochrone(ctx, query) (*RoutingIsochroneResponse, error)
GET/api/v1/isochrone
Calculate an isochrone from a point
client.Routing.IsochronePost(ctx, body) (*RoutingIsochronePostResponse, error)
POST/api/v1/isochrone
Calculate a distance matrix between points
client.Routing.Matrix(ctx, body) (*MatrixResult, error)
POST/api/v1/matrix
ModelsExpand Collapse
type MatrixRequest struct{…}

Request body for distance matrix calculation. Computes travel durations (and optionally distances) between every origin-destination pair. Maximum 2,500 pairs (origins × destinations), each list capped at 50 coordinates.

Destinations []MatrixRequestDestination

Array of destination coordinates (max 50)

Lat float64

Latitude in decimal degrees (-90 to 90)

maximum90
minimum-90
Lng float64

Longitude in decimal degrees (-180 to 180)

maximum180
minimum-180
Origins []MatrixRequestOrigin

Array of origin coordinates (max 50)

Lat float64

Latitude in decimal degrees (-90 to 90)

maximum90
minimum-90
Lng float64

Longitude in decimal degrees (-180 to 180)

maximum180
minimum-180
Annotations stringoptional

Comma-separated list of annotations to include: duration (always included), distance. Example: duration,distance.

FallbackSpeed float64optional

Fallback speed in km/h for pairs where no route exists. When set, unreachable pairs get estimated values instead of null.

exclusiveMinimum
minimum0
Mode MatrixRequestModeoptional

Travel mode (default: auto)

One of the following:
const MatrixRequestModeAuto MatrixRequestMode = "auto"
const MatrixRequestModeFoot MatrixRequestMode = "foot"
const MatrixRequestModeBicycle MatrixRequestMode = "bicycle"
type MatrixResult map[string, unknown]

Distance matrix result. The exact response shape depends on the routing backend. Contains duration (and optionally distance) data for all origin-destination pairs. Null values indicate unreachable pairs.

type NearestResult struct{…}

GeoJSON Point Feature representing the nearest point on the road network to the input coordinate. Used for snapping GPS coordinates to roads.

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 NearestResultProperties

Snap result metadata

DistanceM float64optional

Distance from the input coordinate to the snapped point in meters

EdgeID int64optional

ID of the road network edge that was snapped to

EdgeLengthM float64optional

Length of the matched road edge in meters

Highway stringoptional

OSM highway tag value (e.g. residential, primary, motorway)

OsmWayID int64optional

OSM way ID of the matched road segment

Surface stringoptional

OSM surface tag value (e.g. asphalt, gravel, paved)

Type NearestResultType
type RouteRequest struct{…}

Request body for route calculation. Origin and destination are lat/lng coordinate objects. Supports optional waypoints, alternative routes, turn-by-turn steps, and EV routing parameters.

Destination RouteRequestDestination

Geographic coordinate as a JSON object with lat and lng fields.

Lat float64

Latitude in decimal degrees (-90 to 90)

maximum90
minimum-90
Lng float64

Longitude in decimal degrees (-180 to 180)

maximum180
minimum-180
Origin RouteRequestOrigin

Geographic coordinate as a JSON object with lat and lng fields.

Lat float64

Latitude in decimal degrees (-90 to 90)

maximum90
minimum-90
Lng float64

Longitude in decimal degrees (-180 to 180)

maximum180
minimum-180
Alternatives int64optional

Number of alternative routes to return (0-3, default 0). When > 0, response is a FeatureCollection of route Features.

maximum3
minimum0
Annotations booloptional

Include per-edge annotations (speed, duration) on the route (default: false)

DepartAt Timeoptional

Departure time for traffic-aware routing (ISO 8601)

formatdate-time
Ev RouteRequestEvoptional

Electric vehicle parameters for EV-aware routing

BatteryCapacityWh float64

Total battery capacity in watt-hours (required for EV routing)

ConnectorTypes []stringoptional

Acceptable connector types (e.g. ["ccs", "chademo"])

InitialChargePct float64optional

Starting charge as a fraction 0-1 (default: 0.8)

maximum1
minimum0
MinChargePct float64optional

Minimum acceptable charge at destination as a fraction 0-1 (default: 0.10)

maximum1
minimum0
MinPowerKw float64optional

Minimum charger power in kilowatts

Exclude stringoptional

Comma-separated road types to exclude (e.g. toll,motorway,ferry)

Geometries RouteRequestGeometriesoptional

Geometry encoding format. Default: geojson.

One of the following:
const RouteRequestGeometriesGeojson RouteRequestGeometries = "geojson"
const RouteRequestGeometriesPolyline RouteRequestGeometries = "polyline"
const RouteRequestGeometriesPolyline6 RouteRequestGeometries = "polyline6"
Mode RouteRequestModeoptional

Travel mode (default: auto)

One of the following:
const RouteRequestModeAuto RouteRequestMode = "auto"
const RouteRequestModeFoot RouteRequestMode = "foot"
const RouteRequestModeBicycle RouteRequestMode = "bicycle"
Overview RouteRequestOverviewoptional

Level of geometry detail: full (all points), simplified (Douglas-Peucker), false (no geometry). Default: full.

One of the following:
const RouteRequestOverviewFull RouteRequestOverview = "full"
const RouteRequestOverviewSimplified RouteRequestOverview = "simplified"
const RouteRequestOverviewFalse RouteRequestOverview = "false"
Steps booloptional

Include turn-by-turn navigation steps (default: false)

TrafficModel RouteRequestTrafficModeloptional

Traffic prediction model (only used when depart_at is set)

One of the following:
const RouteRequestTrafficModelBestGuess RouteRequestTrafficModel = "best_guess"
const RouteRequestTrafficModelOptimistic RouteRequestTrafficModel = "optimistic"
const RouteRequestTrafficModelPessimistic RouteRequestTrafficModel = "pessimistic"
Waypoints []RouteRequestWaypointoptional

Intermediate waypoints to visit in order (maximum 25)

Lat float64

Latitude in decimal degrees (-90 to 90)

maximum90
minimum-90
Lng float64

Longitude in decimal degrees (-180 to 180)

maximum180
minimum-180
type RouteResult struct{…}

GeoJSON Feature representing a calculated route. The geometry is a LineString or MultiLineString of the route path. When alternatives > 0, the response is a FeatureCollection containing multiple route Features.

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 RouteResultProperties

Route metadata

DistanceM float64

Total route distance in meters

DurationS float64

Estimated travel duration in seconds

Annotations map[string, unknown]optional

Per-edge annotations (present when annotations: true in request)

ChargeProfile [][]float64optional

Battery charge level at route waypoints as [distance_fraction, charge_pct] pairs (EV routes only)

ChargingStops []map[string, unknown]optional

Recommended charging stops along the route (EV routes only)

Edges []map[string, unknown]optional

Edge-level route details (present when annotations: true)

EnergyUsedWh float64optional

Total energy consumed in watt-hours (EV routes only)

Type RouteResultType