Skip to main content

GET /v1/nearest

Overview​

Snap-to-road corrects a single GPS coordinate by finding the nearest point on the road network. This is useful for fixing a GPS reading that drifted off-road due to signal issues.

Unlike map matching which processes an entire GPS trace, this endpoint handles a single point.

Coordinate Order

The /v1/nearest endpoint returns the snapped coordinate as a location: [longitude, latitude] array following the GeoJSON standard order, not as separate lat/lon fields. Read snapped.location[0] for longitude and snapped.location[1] for latitude.

info

The format query parameter (for requesting GeoJSON output) is not supported on this endpoint. The response is always JSON. Use /v1/geocode or /v1/reverse if you need GeoJSON output.

Request​

GET https://api.geocodeme.net/v1/nearest

Required header: X-Api-Key: gm_YOUR_API_KEY

Parameters​

ParameterTypeRequiredDefaultDescription
latfloatYesn/aLatitude of the GPS point (-90 to 90)
lonfloatYesn/aLongitude of the GPS point (-180 to 180)
profilestringNocarRouting profile: car, bike, foot, truck, or moto (plan-gated)

Cost: 1 credit per request. Plan gating: car on every plan; bike/foot from Startup; truck/moto from Growth. A profile outside your plan returns 403 PLAN_UPGRADE_REQUIRED, and never consumes credits.

Code Examples​

curl -H "X-Api-Key: gm_YOUR_API_KEY" \
"https://api.geocodeme.net/v1/nearest?lat=48.8566&lon=2.3522"

Response​

info

All responses include rate limiting headers (X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Monthly-Remaining, etc.).

{
"snapped": {
"location": [2.3519, 48.8567],
"name": "Rue de Rivoli",
"distance_meters": 3.2
},
"attribution": "Route data (c) OpenStreetMap contributors",
"meta": {
"took_ms": 12,
"cache_hit": false
}
}

Schema​

Top-level response​

FieldTypeDescription
snappedobject | nullThe snapped point, or null when no road is found nearby
attributionstringAlways "Route data (c) OpenStreetMap contributors"
metaobjectRequest metadata
meta.took_msintegerServer processing time in milliseconds
meta.cache_hitbooleanWhether the response was served from cache

snapped​

FieldTypeDescription
locationarraySnapped coordinate as [longitude, latitude]
namestringName of the nearest road segment (may be empty for unnamed roads)
distance_metersfloatDistance in meters from the input point to the snapped location

Error Responses​

{
"error": {
"code": "MISSING_PARAMETER",
"message": "Required parameter 'lat' is missing",
"field": "lat"
}
}
tip

All endpoints are also subject to INVALID_API_KEY (401) and RATE_LIMIT_EXCEEDED / QUOTA_EXCEEDED (429) errors. See Error Codes for the full reference.