apyhub
GEOLOCATION

Find Nearest Road Segment in US API

What it does

Nearest Road Segment returns the nearest major road segment for a coordinate pair. Send lat and lon, and optionally set max_distance_m to limit how far the lookup can search.

Use it when you need to snap a location to a nearby road for routing, map display, logistics, or location cleanup. The service is built for point-based lookups where a raw GPS coordinate needs to be matched to road infrastructure.

The request schema is small and direct: latitude and longitude are required, and max_distance_m defaults to 2000 with a valid range from 50 to 50000. The response returns the matched road segment for the provided coordinates along with related location details and metadata.

Nearest Road Segment fits workflows that enrich geospatial events, validate coordinate proximity to roads, or prepare data for downstream routing and mapping logic.

GET
Get Nearest Road Segment
https://api.eu.apyhub.com/dosvak/nearest-major-road-segment

QUICKSTART

GUIDE

Quickstart

Find the nearest major road segment for a latitude/longitude pair.

curl -X GET "https://api.eu.apyhub.com/dosvak/nearest-major-road-segment?lat=34.0522&lon=-118.2437&max_distance_m=2000" \
  -H "apy-token: $APY_TOKEN"

What you'll get back

Returns a JSON object containing the matched road segment and related metadata.

{
  "input": {
    "lat": 34.0522,
    "lon": -118.2437,
    "max_distance_m": 2000
  },
  "road": {
    "road_name": "West 1st Street",
    "road_type": "primary",
    "distance_m": 23.69
  },
  "attribution": [ 
  ]
}
TRY ITLIVE · 100 ATOMS
Loading your default key…
The full key is used to call the gateway and stays in this tab — never sent to orbit or saved.

About this endpoint

What it does

Finds the nearest major road segment for the provided latitude and longitude, with an optional maximum search distance in meters.

Query Parameter(s)

AttributeTypeMandatoryDescription
latNumberYesLatitude in degrees. Minimum -90, maximum 90.
lonNumberYesLongitude in degrees. Minimum -180, maximum 180.
max_distance_mIntegerNoMaximum search distance in meters. Default 2000. Minimum 50, maximum 50000.

Response

Returns a JSON object containing the matched road segment and related metadata.

Query parameters

Name
Type
Description
latREQUIRED
number
lonREQUIRED
number
max_distance_mOPTIONAL
integer
DEFAULT 2000
▣ COMMON ERRORS

Errors any endpoint can return

400bad_request

Required parameter missing or malformed body.

401unauthorized

API key missing, revoked, or not authorized for this service.

429rate_limited

Your plan's per-second rate exceeded. Retry with exponential backoff.

503upstream_busy

Backend temporarily unavailable. Try again in a few seconds.