Add geofence
This API creates a new geofence, specifying its name, type, color, group, and geometry.
How to get data
Method
GET
Request address
To get the data, use the address: https://<server_address>/api/api.php?
Request parameters
-
cmd=geofenceadd — command to add a geofence
-
zonename — geofence name
-
zonetype — type of the geofence (1 — polygon, 2 — circle)
-
color — geofence color in HEX format (e.g., #FFFFFF)
-
info — text information about the geofence
-
group_name — name of the geofence group (created if it doesn’t exist, optional)
-
group_id — ID of an existing group (if specified, group_name is ignored, optional)
-
geometry — GEOJson describing the polygon or circle
-
external_id — external identifier for the geofence (optional)
-
node — node number where the command should be executed
Example requests
Polygon:
http://<server_address>/api/api.php?cmd=geofenceadd&zonetype=1&zonename=test_api_polygon&external_id=12354&info=blabla&color=%23FF3300&group_name=TEST_API&geometry={"type":"Polygon","coordinates":[[[55.184334,25.112866],[55.183512,25.113472],[55.182154,25.112516],[55.183511,25.111016],[55.184923,25.112133]]]}&node=1
|
Circle:
http://<server_address>/api/api.php?cmd=geofenceadd&zonetype=2&zonename=test_api_circle&external_id=12345&info=circle_info&color=%23FF3300&group_name=TEST_API&geometry={"type":"Circle","coordinates":[55.184334,25.112866],"radius":150}&node=1
|
Response
{
"code": 0,
"msg": "OK",
"data": {
"id": 158412,
"zonename": "test_api_polygon",
"zonetype": 1,
"external_id": "12354",
"created_at": 1610536445,
"updated_at": 1610536445,
"color": "#FF3300",
"info": "blabla",
"group_id": 6984
}
}
|
In response to the API request, the following is returned:
-
code — result code (0 = success)
-
msg — server message
-
data — object with information about the created geofence:
-
id — geofence identifier
-
zonename — geofence name
-
zonetype — geofence type (1 — polygon, 2 — circle)
-
external_id — external identifier
-
created_at — creation time (Unix timestamp)
-
updated_at — last update time (Unix timestamp)
-
color — geofence color
-
info — text information
-
group_id — geofence group identifier