×

Finding the nearest vehicles

This API allows you to search for vehicles within a specified radius from a given point, sorted by distance.
It is useful for rapid response scenarios (e.g., police, emergency services), where operators need to quickly determine which vehicles are closest to an incident location.

How to get data

Method

GET

Request address

To get the data, use the address: https://<server_address>/api/api.php?

Request parameters

To get the required data, add the following parameters to the URL:
  • cmd=get_nearest_vehicles— command to get nearest vehicles
  • group_id— ID of the vehicle group (orgdep.id)
  • lat— latitude of the target point (from −90 to 90)
  • lon— longitude of the target point (from −180 to 180)
  • radius— search radius. Supports values like 500M, 1KM, 10KM, 20KM, or a numeric value in meters
     

Example request

https://<server_address>/api/api.php?cmd=get_nearest_vehicles&group_id=228&lat=43.28191&lon=76.90723&radius=50KM
Response
{
  "code": 0,
  "msg": "OK",
  "group_id": 123,
  "group_name": "Police Fleet",
  "location": { "latitude": 24.4539, "longitude": 54.3773 },
  "radius_meters": 10000,
  "vehicles_found": 2,
  "vehicles": [
    {
      "vehiclenumber": "POL-001",
      "agentid": 456,
      "veh_id": 789,
      "imei": "123456789",
      "model": "Toyota Land Cruiser",
      "vehicle_type": "Car",
      "location": {
        "address": "Sheikh Zayed Road, Dubai, UAE",
        "latitude": 24.4550,
        "longitude": 54.3780,
        "altitude": 10
      },
      "status": {
        "active": 1,
        "speed": 0,
        "direction": 0,
        "altitude": 10,
        "satsinview": 12,
        "ignition": 1,
        "unixtimestamp": 1706964000,
        "zone": []
      },
      "distance": {
        "meters": 1234,
        "kilometers": 1.23,
        "straight_line_meters": 1200
      },
      "travel_time": {
        "seconds": 180,
        "minutes": 3.0,
        "formatted": "3 min"
      }
    }
  ]
}
In response to the API request, the following is returned:
  • group_id — ID of the vehicle group
  • group_name— name of the vehicle group
  • location— coordinates of the target point
  • latitude — latitude
  • longitude — longitude
  • radius_meters — search radius in meters
  • vehicles_found — number of vehicles found
  • vehicles — array of vehicles with details:
  • vehiclenumber — vehicle number
  • agentid — agent/device ID
  • veh_id — vehicle ID
  • imei — device IMEI
  • model — vehicle model
  • vehicle_type — vehicle type (Car, Truck, etc.)
  • location — vehicle location
  • address — address (from geocoder)
  • latitude, longitude, altitude
  • status — current vehicle status
  • active — active status (1 = active)
  • speed — speed in km/h
  • direction — movement direction
  • altitude — altitude
  • satsinview — number of satellites in view
  • ignition — ignition status (1 = on)
  • unixtimestamp — event timestamp in UNIX format
  • zone — array of active geofences
  • distance — distance to target
  • meters — distance in meters
  • kilometers — distance in kilometers
  • straight_line_meters — straight-line distance in meters
  • travel_time — estimated travel time to target
  • seconds — in seconds
  • minutes — in minutes
  • formatted — formatted string, e.g., "3 min"