Snap To Roads API

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.

πŸ”‘ Authentication

  • All requests must include your API key.
  • Header Example:
  • Authorization: X-Authorization-Token (Get your token HERE)

🌐 Endpoint

  • GET /v4/snap
  • Base URL: https://apihub.latlong.ai/v4/snap

πŸ“₯ Request Parameters

ParameterTypeRequiredDescription
pathArrayYesArray list of latitude and longitude pairs

πŸ“€ Sample Request


    
    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 

        ] 

    ] 

}' 

 

πŸ“¦ Sample Response

{ 

  "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 

      ] 

    ] 

  } 

}  

πŸ“Š Response Fields

FieldDescription
originalIndexIndex of the original coordinate pair in the input list
locationThe snapped latitude and longitude
matchedRoadName of the road to which the point was snapped (optional)

🧠 Features

  • πŸ›΅

    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

⚠️ Errors

Status CodeMessageDescription
400Missing required parametersWhen query is not provided
401UnauthorizedAPI key missing or invalid
500Internal Server ErrorSomething went wrong on our side