Geofence

The geofence and route APIs allow you to manage virtual geographical areas or geofences for your account on MapmyIndia's telematics platform. Geographic areas are defined as geometries in the form of geographic polygons, circles, or points that are relevant for any connected device/sensor: The presence or absence (entry or exit) of a vehicle to such geographic areas needs to be monitored and/or events generated on the basis of such transitions. The events might be alarms or reports of vehicles entering or exiting such geofences. These Geofence APIs allow you to create/edit/assign/delink/update geofences.

Create Geofence

GET request: This API is used to create geofences in an account on Intouch. A geofence is a bounded circle of defined radius which acts as a user defined area for related events.

Input:

  • License_key: the REST API license key allocated to you. This is part of URL structure.
  • name: Name of the Geofence
  • latitude
  • longitude
  • radius: Value of the radius in meters. Maximum limit 36000
  • level: Optional parameter. This can be used to set the zoom level for the viewing purpose
  • createdBy : Optional parameter. Name of the user who created the geofence.
Output:
  • geofenceId
  • message: "success"
  • status: 200

Example URL Response:
https://apis.mapmyindia.com/intouch/v1/<licence_key>/createGeofence?name=Ashoknagar&latitude=28.588619&longitude=77.301576&radius=1000&level=14

{  "geofenceId": 45604,  "message": "success",  "status": 200  }

Get Geofence

GET request: This API is used to request the list and details of geofence areas using the geofence ID assigned to it for an account on Intouch.

Input:

  • License_key: the REST API license key allocated to you. This is part of URL structure.
  • geofenceId : Optional parameter. It is geozone specific ID generated while creation of a geofence area. This parameter can be used if any particular geo fence needs to be checked.
  • state: Optional parameter. State parameter takes epoch timestamp into consideration and filter out the results. To consider time parameter or not, will depend on state value. If any specific timestamp is entered under state input, then API will only return the data of those geofence areas for which are created post the input timestamp.
    If state is 0, then API will show details for all the geofence areas.
Output:
  • name
  • latitude
  • longitude
  • level : Zoom level
  • radius : in meters
  • createdby
  • timestamp: Creation time in epoch time notation
  • updatedby

Example URL Response:
http://apis.mapmyindia.com/intouch/v1/<licence_key>/getGeofence

{  "data": {  "45604": {  "latitude": 28.686355,  "longitude": 77.203896,  "level": 18,  "radius": 50,  "createdby": "Kunal",  "timestamp": 1478087667,  "updatedby": "Kunal",  "name": "D8"  }  },  "message": "success",  "status": 200  }

Update Geofence

GET request: This API is used to update a circular geofence in an account on Intouch.

Input:

  • License_key: the REST API license key allocated to you. This is part of URL structure.
  • geofenceId: MapmyIndia Geofence ID
  • name: Geofence name
  • latitude
  • longitude
  • radius: Value of the radius in meters. Maximum limit 36000
  • createdBy : Optional parameter. Name of the user who has created the geofence.
Output:
  • message: "success"
  • status: 200

Example URL Response:
https://apis.mapmyindia.com/intouch/v1/<licence_key>/updateGeofence?name=Ashoknagar&latitude=28.588619&longitude=77.301576&radius=2000&level=14

{  "message": "success",  "status": 200  }

Assign Geofence

GET request: This API is used to assign a geofence to a device in an account on Intouch.

Input:

  • License_key: the REST API license key allocated to you. This is part of URL structure. -geofenceId: MapmyIndia Geofence ID
  • deviceId : MapmyIndia Device ID. Multiple entries are not allowed.
  • type: This parameter is used to assign the geofence entry/exit alarms .
    0 needs to be used to assign both Entry and Exit alarms;
    1 needs to be used to assign Entry alarms;
    2 needs to be used to assign Exit alarms;
Output:
  • message:success or fail
  • status: 200

Example URL Response:
https://apis.mapmyindia.com/intouch/v1/<licence_key>/assignGeofence?geofenceId=45472&type=0

{  "message": "success",  "status": 200  }

Delink Geofence

GET request: This API is used to delink a geofence from a device using its geofence id for an account on Intouch.

Input:

  • License_key: the REST API license key allocated to you. This is part of URL structure.
  • geofenceId: MapmyIndia Geofence ID.
  • deviceId: MapmyIndia Device ID. Multiple entries are not allowed.
Output:
  • message:success or fail
  • status: 200

Example URL Response:
https://apis.mapmyindia.com/intouch/v1/<licence_key>/delinkGeofence?deviceId=1346&geofenceId=45472

{  "message": "success",  "status": 200  }

Get GeofenceLog

GET request: This API is used to access the alarms logs of a vehicle in an account on Intouch.

Input:

  • License_key: the REST API license key allocated to you. This is part of URL structure.
  • geofenceId : Optional Parameter. Multiple entries supported
  • startTime : Optional parameter. startTime needs to be fed as epoch timestamp according to the user choice.If not specified, automatically epoch timestamp of 24 hours before the endTime is taken into consideration.
  • endTime : Optional parameter.endTime needs to be fed as epoch timestamp according to the user choice.If not specified, automatically current epoch timestamp is taken as input.
  • deviceId: optional- Multiple entries supported
Output:
  • geozoneID
  • geofenceName
  • deviceid
  • lat
  • lng
  • timestamp : Epoch time of alarm generation
  • entryexit: This will show type of alarm
    0 – Alarm for the Exit
    1 – Alarm for Entry

Example URL Response:
https://apis.mapmyindia.com/intouch/v1/<licence_key>>/getGeofenceLog?startTime=1476599502&endTime= 1476772302&geofenceId=6247

{  "message": "success",  "logs": [  {  "geofenceId": 6251,  "geofenceName": "Home",  "deviceId": 281,  "lat": 28.6187,  "lng": 77.2865,  "timestamp": 1478066439,  "entryexit": 0  }  ],  "status": 200  }