Skip to main content

Overview

Nearest API snaps a single coordinate to the road network and returns the nearest n segments. Useful for validating whether a coordinate is routable, getting the exact snapped position, and obtaining hint values that speed up subsequent requests. Powered by the OSRM Nearest service.

Endpoint

Request Parameters

Service options

General options

These options apply to all routing services. Options that take one value per coordinate use the array-like encoding {option}={element};{element}[;...] — the number of elements must match the number of coordinates (except generate_hints and exclude). Pass an empty element to use the default for that coordinate, e.g. bearings=;90,20;.
Nearest returns only waypoints — with skip_waypoints=true the response contains just the code field. Technically possible, but not useful.

Quickstart

Response

response-example.json

Response fields

Typical uses

  • Coordinate cleanup: validate with nearest first — a large distance means the coordinate is far from any road
  • Speed up hot paths: cache the hint and reuse it in subsequent route/table requests