Geofence list

This API returns a list of all geofences with their characteristics, including coordinates, type, color, and group.

How to get data

Method

POST

Request address

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

Request parameters

  • cmd=geofencelist — API command to get the list of geofences
  • node — node number where the command should be executed
 

Example request

https://<server_address>/api/api.php?cmd=geofencelist&node=1
Response
{
  "code": 0,
  "msg": "OK",
  "data": [
    {
      "id": 157828,
      "zonename": "Test Magnit",
      "zonetype": 2,
      "external_id": null,
      "created_at": 1609780839,
      "updated_at": 1609780839,
      "color": "#00CC00",
      "info": "geozone text info",
      "group_name": "TEST",
      "group_id": 6531,
      "geometry": {
        "type": "Circle",
        "coordinates": [40.036497, 46.981936],
        "radius": 305
      }
    },
    {
      "id": 153244,
      "zonename": "school",
      "zonetype": 1,
      "external_id": 1234,
      "created_at": 1609780839,
      "updated_at": 1609780839,
      "color": "#FF9900",
      "info": "kml upload",
      "group_name": "TEST",
      "group_id": 6531,
      "geometry": {
        "type": "Polygon",
        "coordinates": [
          [
            [55.184334, 25.112866],
            [55.183512, 25.113472],
            [55.182154, 25.112516],
            [55.183511, 25.111016],
            [55.184923, 25.112133]
          ]
        ]
      }
    }
  ]
}
In response to the API request, the following is returned:
  • code — result code (0 = success)
  • msg — server message
  • data — array of geofence objects, each containing:
  • id — geofence identifier
  • zonename — geofence name
  • zonetype — geofence type (1 — polygon, 2 — circle)
  • external_id — external identifier (if any)
  • created_at — creation time (Unix timestamp)
  • updated_at — last update time (Unix timestamp)
  • color — color of the geofence in the interface
  • info — additional information
  • group_name — name of the geofence group
  • group_id — group identifier
  • geometry — geofence geometry:
  • type — type (Circle or Polygon)
  • coordinates — coordinates (for circle: [longitude, latitude]; for polygon: array of arrays of coordinates)
  • radius — radius for circle geofence in meters