> ## Documentation Index
> Fetch the complete documentation index at: https://docs.justrouting.tech/llms.txt
> Use this file to discover all available pages before exploring further.

# nearest

> Snap a single coordinate to the nearest routable segments



## OpenAPI

````yaml /openapi/openapi.json get /nearest/v1/{profile}/{coordinates}
openapi: 3.1.0
info:
  title: JustRouting API
  version: v1
  description: >-
    OSRM-compatible routing services (route, table, match, trip, nearest) and a
    hosted VROOM vehicle routing solver (optimize). All requests require a
    Bearer API key. Coordinates use `lng,lat` order and must be within a single
    country (Southeast Asia).
  contact:
    email: hello@justrouting.tech
    name: JustRouting
    url: https://justrouting.tech
servers:
  - url: https://api.justrouting.tech
    description: Production
security:
  - bearerAuth: []
tags:
  - name: route
    description: Directions between coordinates
  - name: table
    description: NxN travel time/distance matrix
  - name: match
    description: Map matching for GPS traces
  - name: trip
    description: Traveling salesman optimization
  - name: nearest
    description: Snap a coordinate to the road network
  - name: optimize
    description: Hosted VROOM vehicle routing solver
  - name: geocode
    description: 'Forward geocoding: place name or address into coordinates'
paths:
  /nearest/v1/{profile}/{coordinates}:
    get:
      tags:
        - nearest
      summary: Snap a single coordinate to the nearest routable segments
      operationId: getNearest
      parameters:
        - name: profile
          in: path
          required: true
          schema:
            type: string
            enum:
              - driving
              - motorcycle
        - name: coordinates
          in: path
          required: true
          schema:
            type: string
          description: A single `{lng},{lat}` pair.
        - name: number
          in: query
          schema:
            type: integer
            minimum: 1
            default: 1
          description: Number of nearest segments to return.
        - $ref: '#/components/parameters/Bearings'
        - $ref: '#/components/parameters/Radiuses'
        - $ref: '#/components/parameters/Hints'
        - $ref: '#/components/parameters/Approaches'
        - $ref: '#/components/parameters/Exclude'
        - $ref: '#/components/parameters/Snapping'
        - $ref: '#/components/parameters/GenerateHints'
        - $ref: '#/components/parameters/SkipWaypoints'
      responses:
        '200':
          description: Snapped segments
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NearestResponse'
        '400':
          description: Bad request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OsrmError'
        '401':
          description: Missing or invalid API key
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AuthError'
        '429':
          description: Rate limited
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RateLimitError'
components:
  parameters:
    Bearings:
      name: bearings
      in: query
      schema:
        type: string
      description: '`{bearing},{range};...` per coordinate, e.g. `0,20` = north ±20°.'
    Radiuses:
      name: radiuses
      in: query
      schema:
        type: string
      description: Snapping radius in meters per coordinate, or `unlimited`.
    Hints:
      name: hints
      in: query
      schema:
        type: string
      description: Base64 hints from a previous response to speed up snapping.
    Approaches:
      name: approaches
      in: query
      schema:
        type: string
      description: >-
        Restrict the road direction at each waypoint: `curb` / `opposite` /
        `unrestricted` (default), e.g. `curb;opposite`.
    Exclude:
      name: exclude
      in: query
      schema:
        type: string
      description: Road classes to avoid (additive list), e.g. `motorway`.
    Snapping:
      name: snapping
      in: query
      schema:
        type: string
        enum:
          - default
          - any
        default: default
      description: >-
        `default` avoids edges that cannot be used as start/end points; `any`
        snaps to any edge in the graph.
    GenerateHints:
      name: generate_hints
      in: query
      schema:
        type: boolean
        default: true
      description: Add a `hint` to response waypoints for reuse in later requests.
    SkipWaypoints:
      name: skip_waypoints
      in: query
      schema:
        type: boolean
        default: false
      description: Remove waypoints from the response (still calculated, not serialized).
  schemas:
    NearestResponse:
      type: object
      properties:
        code:
          type: string
          enum:
            - Ok
        waypoints:
          type: array
          items:
            $ref: '#/components/schemas/Waypoint'
    OsrmError:
      type: object
      properties:
        code:
          type: string
          enum:
            - InvalidUrl
            - InvalidService
            - InvalidVersion
            - InvalidOptions
            - InvalidQuery
            - InvalidValue
            - NoSegment
            - NoRoute
            - NoTable
            - NoMatch
            - NoTrips
            - TooBig
            - DisabledDataset
            - NotImplemented
        message:
          type: string
    AuthError:
      type: object
      properties:
        error:
          type: string
          description: '`missing Authorization header` or `invalid or revoked API key`.'
    RateLimitError:
      type: object
      properties:
        code:
          type: string
          enum:
            - rate_limited
        message:
          type: string
    Waypoint:
      type: object
      properties:
        name:
          type: string
          description: Street name the coordinate snapped to.
        location:
          type: array
          items:
            type: number
          minItems: 2
          maxItems: 2
          description: Snapped position as `[lng, lat]`.
        distance:
          type: number
          description: Snapping offset in meters.
        hint:
          type: string
          description: Opaque segment identifier, reusable as the `hints` parameter.
        nodes:
          type: array
          items:
            type: integer
          description: OSM node ids of the segment.
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: API key created in the JustRouting dashboard.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.