The Snap to Roads API processes a series of GPS points (latitude, longitude pairs) and returns a corrected path by aligning those points to the nearest suitable road segments. This is especially useful when you want to display a cleaner, more accurate route on a map based on potentially noisy location data.
Authorization: X-Authorization-Token
(Get your token HERE)/v4/snap
https://apihub.latlong.ai/v4/snap
Parameter | Type | Required | Description |
---|---|---|---|
path | Array | Yes | Array list of latitude and longitude pairs |
curl --location -g 'https://apihub.latlong.ai/v4/snap.json?coordinates=[12.980722245625548%2C77.58638116585473]%2C[12.982604078764705%2C77.58715428157694]%2C[12.984109535016517%2C77.58900116913543]'
--data '{
"coordinates": [
[
18.971481,
72.84491
],
[
18.9706,
72.845169
]
]
}'
{
"code": 1001,
"status": "success",
"data": {
"snapped_coordinates": [
[
18.971556,
72.845273
],
[
18.972067,
72.845156
],
[
18.972083,
72.845222
],
[
18.970954,
72.845483
],
[
18.970826,
72.8455
],
[
18.970595,
72.845496
]
]
}
}
Field | Description |
---|---|
originalIndex | Index of the original coordinate pair in the input list |
location | The snapped latitude and longitude |
matchedRoad | Name of the road to which the point was snapped (optional) |
Smooth visual trace of delivery riders or moving vehicles
Clean GPS data on a map for playback/reports
οΈFixing inconsistencies in raw location logs
Displaying accurate route history in maps
Status Code | Message | Description |
---|---|---|
400 | Missing required parameters | When query is not provided |
401 | Unauthorized | API key missing or invalid |
500 | Internal Server Error | Something went wrong on our side |