Geofences

OW
Last updated 16 days ago

This set of APIs lets you create, get, update, and delete geofences, specific to the project and helps you to keep track of them.

By default, GeoFences are not "event trigger" enabled. To make a geofence "event trigger" enabled, update that particular geofence using Update API and pass the below option.

JSON
{"is_enabled": true}

post
Create Geofence API

https://api.geospark.co/v1
/api/geofence/
Create Geofence API is responsible for creating geofences for projects. Note : All Latitude and Longitude Coordinates mentioned, use EPSG 4236 WGS 84 (Web Mercator Projection) as Coordinate Reference System. GPS from both Android and iOS devices return in the same format. No other CRS is supported.
Request
Response
Headers
Content-Type
required
string
application/json
Api-Key
required
string
33223kjhdcscijhb5sdbsdmjsdcbj5f
Body Parameters
color_code
optional
string
Defines the color of Geofence and how it is displayed in the dashboard. Type : Hex Code for CSS colors. Note : Pass the code without '#'. Input Data: ffffff
tag
optional
string
Tag the GeoFences for future reference and filtering. Input Data: hotel
description
optional
string
Optional description for the geofence. Input Data: This is just a 5 star cool hotel where you can stay.
is_enabled
optional
boolean
Enable/Disable 'event_trigger' for Geofences. By default event trigger are disabled. Input Data: true or false
geometry_radius
required
integer
Defines the radius of circular GeoFence in meters. Range 50m to 1000m. ( Required only for type circle. Field value ignored if sent, when geometry_type is Polygon.) Input Data: 50m to 1000m max
geometry_type
required
string
Defines the type of Geometry Input Data: circle or polygon
coordinates
required
array
This field is mandatory for creating the geofence. Input Data: Circle [longitude, latitude], OR Polygon [[longitude, latitude], [longitude, latitude], ...]
200: OK
JSON
{
"status": true,
"msg": "Geofence Added successfully.",
"code": 201,
"data": {
"id": "5bd5bc35eec1a504f3d87382",
"account_id": "5bbdd7a8eec1a511b246490d",
"project_id": "5bbdd865eec1a511b246490e",
"geometry_type": "circle",
"geometry_radius": 50,
"geometry_center": {
"type": "Point",
"coordinates": [
-72.28122,
42.926042
]
},
"is_enabled": false,
"color_code": "00BFFF",
"tag": "Hotel",
"created_at": "2018-10-28T13:40:05.097",
"updated_at": "2018-10-28T13:40:05.097"
‚Äč
}
}

Sample Call

cURL
JavaScript
Python
Java
Swift
Go
curl -X POST \
https://api.geospark.co/v1/api/geofence/ \
-H 'Api-Key: 2fd72b3b94b149018957eae89c2d1c86' \
-H 'Content-Type: application/json' \
-d '{
"geometry_type": "circle",
"coordinates": [-72.28122, 42.926042] ,
"geometry_radius": 50,
"color_code": "00BFFF",
"tag": "Hotel"
}'

put
Update Geofence API

https://api.geospark.co/v1
/api/geofence/
Update details for existing geofence of any specific project using Update Geofence API.
Request
Response
Headers
Content-Type
required
string
application/json
Api-Key
required
string
33223kjhdcscijhb5sdbsdmjsdcbj5f
Body Parameters
geofence_id
required
string
Identifies the Geofence. Input Data: 5bd2aee1eec1a50d8faf1293
color_code
optional
string
Defines the color of Geofence and how it is displayed in the dashboard. Type : Hex Code for CSS colors. Note : Pass the code without '#'. Input Data: ffffff
tag
optional
string
This is to tag your geofence for your structural property. Input Data: hotel
description
optional
string
Optional description for the geofence. Input Data: This is just a 5 star cool hotel where you can stay.
is_enabled
optional
boolean
Enable/Disable 'event_trigger' for Geofences. By Default event trigger are disabled. Input Data: true or false
200: OK
JSON
{
"status": true,
"msg": "Geofence updated successfully.",
"code": 200,
"data": {
"id": "5bd2aee1eec1a50d8faf1293",
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
-72.28122,
42.926042
],
[
-72.2823209,
42.9250442
],
[
-72.2804648,
42.9243686
],
[
-72.2795207,
42.9254685
],
[
-72.2800592,
42.9261249
],
[
-72.28122,
42.926042
]
]
]
},
"account_id": "5bbdd7a8eec1a511b246490d",
"project_id": "5bbdd865eec1a511b246490e",
"geometry_type": "polygon",
"geometry_center": {
"type": "Point",
"coordinates": [
-72.28080043090077,
42.92531143047176
]
},
"is_enabled": true,
"description": "Private Resort area",
"color_code": "ffff",
"tag": "Hotel",
"created_at": "2018-10-26T06:06:25.122",
"updated_at": "2018-10-28T14:00:41.198"
}
}

Sample Call

cURL
JavaScript
Python
Java
Go
curl -X PUT \
https://api.geospark.co/v1/api/geofence/ \
-H 'Api-Key: 2fd72b3b94b149018957eae89c2d1c86' \
-H 'Content-Type: application/json' \
-d '{
"geofence_id": "5bd2aee1eec1a50d8faf1293",
"is_enabled": true,
"description": "Private Resort area",
"tag": "Hotel",
"color_code": "ffff"
}'

get
Get Geofence API

https://api.geospark.co/v1
/api/geofence/
This API gives you the filtered list of geofences.
Request
Response
Headers
Api-Key
required
string
33223kjhdcscijhb5sdbsdmjsdcbj5f
Content-Type
required
string
application/json
Query Parameters
page_number
optional
integer
Returns the data in the page provided. A page will have a maximum of 10 entries. If the response returns an empty list in data field, it is safe to assume the pages are exhausted.
color_code
optional
string
Defines the color of Geofence and how it is displayed in the dashboard. Type : Hex Code for CSS colors. Note : Pass the code without '#'. Input Data: ffffff
tag
optional
string
Tag the GeoFences for future reference and filtering. Input Data: hotel
geometry_type
optional
string
Type of the Geofence. Can be either a Circle or Polygon. Input Data: circle or polygon
geofence_id
optional
string
To get the data only for a single geofence, pass it's geofence_id. Input Data: 5bd2aee1eec1a50d8faf1293
200: OK
JSON
{
"status": true,
"msg": "Success.",
"code": 200,
"data": {
"next_page": null,
"pages": 1,
"prev_page": null,
"account_id": "5bbdd7a8eec1a511b246490d",
"project_id": "5bbdd865eec1a511b246490e",
"geofences": [
{
"id": "5bc89a4feec1a50e738db301",
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
-0.107524,
51.505716
],
[
-0.100071,
51.492607
],
[
-0.149201,
51.490107
],
[
-0.107524,
51.505716
]
]
]
},
"geometry_type": "polygon",
"geometry_center": {
"type": "Point",
"coordinates": [
-0.11893199999993373,
51.49614333333265
]
},
"is_enabled": true,
"description": "Hotel Area",
"tag": "Hotel",
"created_at": "2018-10-18T14:35:59.810",
"updated_at": "2018-10-18T14:35:59.810"
},
{
"id": "5bc89a75eec1a50e738db302",
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
-0.107524,
51.505716
],
[
-0.100071,
51.492607
],
[
-0.149201,
51.490107
],
[
-0.107524,
51.505716
]
]
]
},
"geometry_type": "polygon",
"geometry_center": {
"type": "Point",
"coordinates": [
-0.11893199999993373,
51.49614333333265
]
},
"is_enabled": true,
"tag": "Office",
"created_at": "2018-10-18T14:36:37.747",
"updated_at": "2018-10-18T14:36:37.747"
}
]
}
}

Sample Call

cURL
JavaScript
Python
Java
Swift
Go
curl -X GET \
'https://api.geospark.co/v1/api/geofence/?geometry_type=polygon&color_code=ffff&tag=border%20code&page_number=1' \
-H 'Api-Key: 2fd72b3b94b149018957eae89c2d1c86'

delete
Delete Geofence API

https://api.geospark.co/v1
/api/geofence/
Delete Geofence API allows you to delete already existing geofences for a project.
Request
Response
Headers
Api-Key
required
string
33223kjhdcscijhb5sdbsdmjsdcbj5f
Content-Type
required
string
application/json
Body Parameters
geofence_id
required
string
Deletes the geofence given here. Input Data: 5bb3177a02a89b3c7a6a8d4f
200: OK
JSON
{
"status": true,
"msg": "Geofence deleted successfully.",
"code": 200,
"data": {}
}

Sample Call

cURL
JavaScript
Python
Java
Swift
Go
curl -X DELETE \
https://api.geospark.co/v1/api/geofence/ \
-H 'Api-Key: 2fd72b3b94b149018957eae89c2d1c86' \
-H 'Content-Type: application/json'
-d '{
"geofence_id": "5bd2aee1eec1a50d8faf1293"
}'