API Quickstart Guide

Notes:
  • Pass your secret api key in the header
  • API parameter page_number, gives a maximum of 10 entries per page in response.
  • app_id field in the APIs if present, contains a number in last character of the string . And this numeric character represents device platform, i.e. "1" for Android and "2" for iOS
  • For list apis the "next_page" and "prep_page" fields will be "null" if not present. and "pages" will be 0 if not present.

Get User API:

Get User API provides the list of users who are using your app corresponding to the project secret api key provided by you.

Url

/v1/api/user/

Method

GET

Header Params

Api-Key:33223kjhdcscijhb5sdbsdmjsdcbj5f

Required

Content-Type:application/json

URL Params

/v1/api/user/?page_number=1

Param Input Data Type Description
page_number 1 (optional) This field can be used for getting 10 entries at a time. if the response returns an empty list in data field, it is safe to assume the pages are exhausted.

Success Response

Code:
200 SUCCESS
Content:

JSON

                                  
                                    
  {
   "status": true,
   "msg": "Success.",
   "code": 200,
   "data": {
          "next_page": null,
          "pages": 1,
          "prev_page": null,
          "account_id": "5bbdd7a8eec1a511b246490d",
          "users": [
            {
               "id": "5bc982b9eec1a5083d45ae8a",
               "app_id": "5bbdd865eec1a511b246490e_1",
               "created_at": "2018-10-19T07:07:37.524",
               "updated_at": "2018-10-22T05:05:20.634"
            },
            {
               "id": "5bcd5a90eec1a504184c329a",
               "app_id": "5bbdd865eec1a511b246490e_1",
               "created_at": "2018-10-22T05:05:20.640",
               "updated_at": "2018-10-30T05:13:14.279"
            },
            {
               "id": "5bd7e86aeec1a52a6f7e1763",
               "app_id": "5bbdd865eec1a511b246490e_1",
               "created_at": "2018-10-30T05:13:14.284",
               "updated_at": "2018-11-01T10:31:19.100"
            },
           {
               "id": "5bdad5f7eec1a507afa2fece",
               "app_id": "5bbdd865eec1a511b246490e_1",
               "device_token": "this is for testing the description",
               "description": "this is for testing the description",
               "created_at": "2018-11-01T10:31:19.105",
               "updated_at": "2018-11-26T09:51:32.358"
           },
           {
               "id": "5bf63c38eec1a504c51e7d85",
               "app_id": "5bbdd865eec1a511b246490e_1",
               "device_token": "SDFASDcsdcsdsssssssscsFASDF",
               "description": "this is no good",
               "created_at": "2018-11-22T05:18:48.284",
               "updated_at": "2018-11-22T05:18:48.285"
           }
        ]
    }
}   




                              

JSON

                                  
                                    
// if page is exhausted
{
  "status": true,
  "msg": "Success.",
  "code": 200,
  "data": {
      "next_page": null,
      "pages": 1,
      "prev_page": null,
      "account_id": null,
      "users": []
  }
}                                    


                                  
                                

Error Responses

Code:
400
Content:

JSON

                                  
                                    
  {
    "status": false,
    "msg": "Unknown Error.",
    "code": 400,
    "error": {
        "ErrorCode": "GS400",
        "ErrorMessage": "An error occured"
    }
  }

  

                              
Error Description:
Occurs when an unknown error is caught. Given to ensure graceful fails.
Code:
401
Content:

JSON

                                  
                                    
  {
    "status": true,
    "msg": "Invalid Api key.",
    "code": 401,
    "error": {
        "ErrorCode": "GS401",
        "ErrorMessage": "Invalid Api key",
        "details": "Invalid Api key."
    }
  }

  

                              
Error Description:
Occurs when an invalid API key of any form is passed. Note : API key of any inactive/deleted project or account is considered as Invalid.
Code:
401
Content:

JSON

                                  
                                    
  {
      "status": true,
      "msg": "No Api key in Header provided",
      "code": 401,
      "error": {
          "ErrorCode": "GS401",
          "ErrorMessage": "Invalid Api key",
          "details": "No Api key in Header provided"
      }
  }

  

                              
Error Description:
Occurs when API key is not provided in the request.

Sample Call

                        
                          
  curl -X GET \
    'https://api.geospark.co/v1/api/user/?page_number=-1' \
    -H 'Api-Key: 2fd72b3b94b149018957eae89c2d1c86' 
  var settings = {
    "async": true,
    "crossDomain": true,
    "url": "https://api.geospark.co/v1/api/user/?page_number=-1",
    "method": "GET",
    "headers": {
      "Api-Key": "2fd72b3b94b149018957eae89c2d1c86"
    }
  }

  $.ajax(settings).done(function (response) {
    console.log(response);
  });
  import requests

  url = "https://api.geospark.co/v1/api/user/"

  querystring = {"page_number":"-1"}

  headers = {
      'Api-Key': "2fd72b3b94b149018957eae89c2d1c86"
      }

  response = requests.request("GET", url, headers=headers, params=querystring)

  print(response.text)
  OkHttpClient client = new OkHttpClient();

  Request request = new Request.Builder()
    .url("https://api.geospark.co/v1/api/user/?page_number=-1")
    .get()
    .addHeader("Api-Key", "2fd72b3b94b149018957eae89c2d1c86")
    .build();

  Response response = client.newCall(request).execute(); 
  import Foundation

  let headers = [
    "Api-Key": "2fd72b3b94b149018957eae89c2d1c86"
  ]

  let request = NSMutableURLRequest(url: NSURL(string: "https://api.geospark.co/v1/api/user/?page_number=-1")! as URL,
                                          cachePolicy: .useProtocolCachePolicy,
                                      timeoutInterval: 10.0)
  request.httpMethod = "GET"
  request.allHTTPHeaderFields = headers

  let session = URLSession.shared
  let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
    if (error != nil) {
      print(error)
    } else {
      let httpResponse = response as? HTTPURLResponse
      print(httpResponse)
    }
  })

  dataTask.resume() 
  package main

  import (
    "fmt"
    "net/http"
    "io/ioutil"
  )

  func main() {

    url := "https://api.geospark.co/v1/api/user/?page_number=-1"

    req, _ := http.NewRequest("GET", url, nil)

    req.Header.Add("Api-Key", "2fd72b3b94b149018957eae89c2d1c86")

    res, _ := http.DefaultClient.Do(req)

    defer res.Body.Close()
    body, _ := ioutil.ReadAll(res.Body)

    fmt.Println(res)
    fmt.Println(string(body))
  }
                          
                          
                      

Get Location API:

Get Location API provides the list of locations of the users who are using your app for a specified project corresponding to the project secret api key provided by you.

Url

/v1/api/location/

Method

GET

Header Params

Api-Key:33223kjhdcscijhb5sdbsdmjsdcbj5f

Required

Content-Type:application/json

URL Params

/v1/api/location/?user_id=5bb3177a02a89b3c7a6a8d4f&page_number=12

Param Input Data Type Description
page_number 1 Optional This field can be used for getting 10 entries at a time. if the response returns an empty list in data field, it is safe to assume the pages are exhausted.
User_id 5bb3177a02a89b3c7a6a8d4f Required Mandatory field. The Location data returned, is of the user provided in this parameter.

Success Response

Code:
200 SUCCESS
Content:

JSON

                                  
                                    
  {
    "status": true,
    "msg": "Success.",
    "code": 200,
    "data": {
        "next_page": 2,
        "pages": 17,
        "prev_page": null,
        "account_id": "5bbdd7a8eec1a511b246490d",
        "app_id": "5bbdd865eec1a511b246490e_1",
        "user_id": "5bdad5f7eec1a507afa2fece",
        "locations": [
            {
                "id": "5bf69fe8eec1a5110972e407",
                "coordinates": {
                    "type": "Point",
                    "coordinates": [
                        -0.11893,
                        51.49614
                    ]
                },
                "speed": 10.23,
                "accuracy": 0.23,
                "altitude": 23.33,
                "activity": "WALK",
                "recorded_at": "2018-10-02T10:44:00.270",
                "timezone_offset": "+0100",
                "net_stat": true,
                "battery_remaining": 99,
                "address": "301 patel nest , bangalore 560102",
                "state": "karnataka",
                "city": "bangalore",
                "street_address": "24th main garden layout",
                "country_code": "IN",
                "country": "India",
                "postal_code": 560102,
                "created_at": "2018-11-22T12:24:08.346"
            },
            {
                "id": "5bf69fe8eec1a5110972e409",
                "coordinates": {
                    "type": "Point",
                    "coordinates": [
                        -87.64593,
                        41.86793
                    ]
                },
                "speed": 10,
                "accuracy": 1,
                "altitude": 26,
                "activity": "DRIVE",
                "recorded_at": "2017-11-18T11:42:41.000",
                "timezone_offset": "+0100",
                "bat_stat": "Full",
                "created_at": "2018-11-22T12:24:08.578"
            },
            {
                "id": "5bf69fe8eec1a5110972e40a",
                "coordinates": {
                    "type": "Point",
                    "coordinates": [
                        -87.6449,
                        41.85924
                ]
            },
                "speed": 15,
                "altitude": 23,
                "activity": "DRIVE",
                "recorded_at": "2017-11-18T11:42:51.000",
                "timezone_offset": "+0100",
                "bat_stat": "Full",
                "created_at": "2018-11-22T12:24:08.578"
            },
            {
                "id": "5bf69fe8eec1a5110972e40b",
                "coordinates": {
                    "type": "Point",
                    "coordinates": [
                        -87.64559,
                        41.85489
                    ]
            },
              "speed": 25,
              "accuracy": 1,
              "altitude": 3,
              "activity": "DRIVE",
              "recorded_at": "2017-11-18T11:43:15.000",
              "timezone_offset": "+0100",
              "bat_stat": "Full",
              "created_at": "2018-11-22T12:24:08.578"
            },
            {
                  "id": "5bf69fe8eec1a5110972e40c",
                  "coordinates": {
                      "type": "Point",
                      "coordinates": [
                          77.64559,
                          12.84952
                    ]
            },
              "speed": 40,
              "accuracy": 4,
              "altitude": 12,
              "activity": "DRIVE",
              "recorded_at": "2017-11-18T11:43:21.000",
              "timezone_offset": "+0100",
              "bat_stat": "Full",
              "created_at": "2018-11-22T12:24:08.578"
            },
            {
                  "id": "5bf69fe8eec1a5110972e40d",
                  "coordinates": {
                      "type": "Point",
                      "coordinates": [
                          -87.63357,
                          41.84415
                  ]
            },
              "speed": 50,
              "accuracy": 2,
              "altitude": 10,
              "activity": "DRIVE",
              "recorded_at": "2017-11-18T11:43:53.000",
              "timezone_offset": "+0100",
              "bat_stat": "Full",
              "created_at": "2018-11-22T12:24:08.579"
            },
            {
              "id": "5bf69fe8eec1a5110972e40f",
              "accuracy": 0.23,
              "altitude": 23.33,
              "activity": "STOP",
              "timezone_offset": "+0100",
              "started_at": "2018-10-02T11:42:00.271",
              "ended_at": "2018-10-02T07:27:08.917",
              "net_stat": true,
              "app_stat": "BACKGROUND",
              "created_at": "2018-11-22T12:24:08.596"
            },
            {
                "id": "5bf7f704eec1a518a227a99f",
                "coordinates": {
                    "type": "Point",
                    "coordinates": [
                        -0.11893,
                        51.49614
              ]
            },
              "speed": 10.23,
              "accuracy": 0.23,
              "altitude": 23.33,
              "activity": "WALK",
              "recorded_at": "2018-10-02T10:44:00.270",
              "timezone_offset": "+0100",
              "net_stat": true,
              "address": "301 patel nest , bangalore 560102",
              "state": "karnataka",
              "city": "bangalore",
              "street_address": "24th main garden layout",
              "country_code": "IN",
              "country": "India",
              "postal_code": 560102,
              "created_at": "2018-11-23T12:48:04.793"
            },
            {
              "id": "5bf7f71aeec1a518a227a9a1",
              "coordinates": {
                  "type": "Point",
                  "coordinates": [
                      -87.64593,
                      41.86793
              ]
            },
              "speed": 10,
              "accuracy": 1,
              "altitude": 26,
              "activity": "DRIVE",
              "recorded_at": "2017-11-18T11:42:41.000",
              "timezone_offset": "+0100",
              "bat_stat": "Full",
              "created_at": "2018-11-23T12:48:26.129"
            },
            {
              "id": "5bf7f71aeec1a518a227a9a2",
              "coordinates": {
                  "type": "Point",
                  "coordinates": [
                      -87.6449,
                      41.85924
              ]
            },
              "speed": 15,
              Error Responses
              Code: 400
              Content:
              Description for this error: Occurs when an unknown error is caught. Given to ensure graceful
              fails.
              Code: 400
              "altitude": 23,
              "activity": "DRIVE",
              "recorded_at": "2017-11-18T11:42:51.000",
              "timezone_offset": "+0100",
              "bat_stat": "Full",
              "created_at": "2018-11-23T12:48:26.129"
            }
        ]
    }
}

  


                              

JSON

                                  
                                    
  // if page is exhausted
  {
      "status": true,
      "msg": "Success.",
      "code": 200,
      "data": {
          "next_page": null,
          "pages": 17,
          "prev_page": null,
          "account_id": null,
          "app_id": null,
          "user_id": null,
          "locations": []
      }
  }



                              

Error Responses

Code:
400
Content:

JSON

                                  
                                    
  {
    "status": false,
    "msg": "Unknown Error.",
    "code": 400,
    "error": {
        "ErrorCode": "GS400",
        "ErrorMessage": "An error occured"
    }
  }



                              
Error Description:
Occurs when an unknown error is caught. Given to ensure graceful fails.
Code:
400
Content:

JSON

                                  
                                    
  {
    "status": false,
    "msg": "Error Occured.",
    "code": 400,
    "error": {
        "ErrorCode": "GS402",
        "ErrorMessage": "Invalid request",
        "details": {
            "user_id": {
                "user_id": "This field is invalid"
            }
        }
    }
  }



                              
]
Error Description:
Occurs when the user_id provided is invalid.
Code:
400
Content:

JSON

                                  
                                    
  {
    "status": false,
    "msg": "Error Occured.",
    "code": 400,
    "error": {
        "ErrorCode": "GS402",
        "ErrorMessage": "Invalid request",
        "details": {
            "user_id": [
                "This field is required."
            ]
        }
    }
  }



                              
Error Description:
Occurs when user_id is not passed in the request header.
Code:
401
Content:

JSON

                                  
                                    
  {
    "status": true,
    "msg": "No Api key in Header provided",
    "code": 401,
    "error": {
        "ErrorCode": "GS401",
        "ErrorMessage": "Invalid Api key",
        "details": "No Api key in Header provided"
    }
  }



                              
Error Description:
Occurs when API key is not provided in the request header.
Code:
401
Content:

JSON

                                  
                                    
  {
    "status": true,
    "msg": "Invalid Api key.",
    "code": 401,
    "error": {
        "ErrorCode": "GS401",
        "ErrorMessage": "Invalid Api key",
        "details": "Invalid Api key."
    }
  }



                              
Error Description:
Occurs when an invalid API key of any form is passed. Note : Valid keys will become invalid if it's associated Project or Account is deleted, and error will be thrown when those keys are used again.

Sample Call

                                
  curl -X GET \
    'https://api.geospark.co/v1/api/location/?user_id=5bb3177a02a89b3c7a6a8d4f&page_number=1' \
    -H 'Api-Key: 2fd72b3b94b149018957eae89c2d1c86'
  var settings = {
    "async": true,
    "crossDomain": true,
    "url": "https://api.geospark.co/v1/api/location/?user_id=5bb3177a02a89b3c7a6a8d4f&page_number=1",
    "method": "GET",
    "headers": {
      "Api-Key": "2fd72b3b94b149018957eae89c2d1c86"
    }
  }

  $.ajax(settings).done(function (response) {
    console.log(response);
  });
  import requests

  url = "https://api.geospark.co/v1/api/location/"

  querystring = {"user_id":"5bb3177a02a89b3c7a6a8d4f","page_number":"1"}

  headers = {
      'Api-Key': "2fd72b3b94b149018957eae89c2d1c86"
      }

  response = requests.request("GET", url, headers=headers, params=querystring)

  print(response.text)
  OkHttpClient client = new OkHttpClient();

  Request request = new Request.Builder()
    .url("https://api.geospark.co/v1/api/location/?user_id=5bb3177a02a89b3c7a6a8d4f&page_number=1")
    .get()
    .addHeader("Api-Key", "2fd72b3b94b149018957eae89c2d1c86")
    .build();

  Response response = client.newCall(request).execute(); 
  import Foundation

  let headers = [
    "Api-Key": "2fd72b3b94b149018957eae89c2d1c86"
  ]

  let request = NSMutableURLRequest(url: NSURL(string: "https://api.geospark.co/v1/api/location/?user_id=5bb3177a02a89b3c7a6a8d4f&page_number=1")! as URL,
                                          cachePolicy: .useProtocolCachePolicy,
                                      timeoutInterval: 10.0)
  request.httpMethod = "GET"
  request.allHTTPHeaderFields = headers

  let session = URLSession.shared
  let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
    if (error != nil) {
      print(error)
    } else {
      let httpResponse = response as? HTTPURLResponse
      print(httpResponse)
    }
  })

  dataTask.resume() 
  package main

  import (
    "fmt"
    "net/http"
    "io/ioutil"
  )

  func main() {

    url := "https://api.geospark.co/v1/api/location/?user_id=5bb3177a02a89b3c7a6a8d4f&page_number=1"

    req, _ := http.NewRequest("GET", url, nil)

    req.Header.Add("Api-Key", "2fd72b3b94b149018957eae89c2d1c86")

    res, _ := http.DefaultClient.Do(req)

    defer res.Body.Close()
    body, _ := ioutil.ReadAll(res.Body)

    fmt.Println(res)
    fmt.Println(string(body))

  }
                               
                               
                            

Create Geofence Api:

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.

Url

/v1/api/geofence/

Method

POST

Header Params

Api-Key:33223kjhdcscijhb5sdbsdmjsdcbj5f

Required

Content-Type:application/json

URL Params

Param Input Data Type Description
NA NA NA NA

Data Params

JSON

                                  
                                    
// for a circle
{
  "geometry_type": "circle",
  "coordinates": [ -72.28122, 42.926042 ] ,
  "geometry_radius": 50
}

// for a polygon
{
  "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 ]] 
}



                              
Param Input Data Type Description
coordinates Circle [longitude, latitude], OR Polygon [[longitude, latitude], [longitude, latitude], ...] List Field (for circle) and List of List for a polygon (required) This field is mandatory for creating the geofence
geometry_type circle or polygon String Field (required) Defines the type of Geometry
geometry_radius 50 to 1000 max Integer Field(required only for type circle. Field value ignored if sent, when geometry_type is Polygon. Defines the radius of circular GeoFence in meters. Range 50m to 1000m.
color_code fffff String Field (optional) Defines the color of Geofence and how it is displayed in the dashboard. Type : Hex Code for CSS colors. Note : Pass the code without '#'.
tag hotel String Field (optional) Tag the GeoFences for future reference and filtering.
description This is just a 5 star cool hotel where you can stay. String Field (optional) Optional description for the geofence.
is_enabled true or false Boolean Field(optional) Enable/Disable 'event_trigger' for Geofences. By default event trigger are disabled.

Success Response

Code:
201 CREATED SUCCESS
Content:

JSON

                                  
                                    
  {
    "status": true,
    "msg": "Geofence Added successfully.",
    "code": 201,
    "data": {
        "id": "5bd5bc35eec1a504f3d87382",
        "geometry": null,
        "account_id": "5bbdd7a8eec1a511b246490d",
        "project_id": "5bbdd865eec1a511b246490e",
        "geometry_type": "circle",
        "geometry_radius": 50,
        "geometry_center": {
            "type": "Point",
            "coordinates": [
                -72.28122,
                42.926042
            ]
        },
        "is_enabled": false,
        "description": null,
        "color_code": null,
        "tag": null,
        "created_at": "2018-10-28T13:40:05.097",
        "updated_at": "2018-10-28T13:40:05.097"
    }
  }



                              

Error Responses

Code:
400
Content:

JSON

                                  
                                    
  {
    "status": false,
    "msg": "Unknown Error.",
    "code": 400,
    "error": {
        "ErrorCode": "GS400",
        "ErrorMessage": "An error occured"
    }
  }
  

                              
Error Description:
Occurs when an unknown error is caught. Given to ensure graceful fails.
Code:
400
Content:

JSON

                                  
                                    
  // when there is required geometry type mismatch 
  {
      "status": false,
      "msg": "Error Occured.",
      "code": 400,
      "error": {
          "ErrorCode": "GS402",
          "ErrorMessage": "Invalid request",
          "details": {
              "geometry_type": [
                  "\"circles\" is not a valid choice."
              ]
          }
      }
  }

  // invalid coordiantes
  {
      "status": false,
      "msg": "Error Occured.",
      "code": 400,
      "error": {
          "ErrorCode": "GS402",
          "ErrorMessage": "Invalid request",
          "details": {
              "coordinates": [
                  "Invalid coordinates for given geometry type"
              ]
          }
      }
  }



                              
Error Description:
Occurs when unsupported/invalid Geometry type is passed, or when given coordinates are invalid. Note : Invalid coordinates include wrong formatting and wrong data type. It is advised not to pass Latitude/Longitude data when they are out of their respective ranges. Unknown error occurs in that case.
Code:
400
Content:

JSON

                                  
                                    
  {
    "status": false,
    "msg": "Error Occured.",
    "code": 400,
    "error": {
        "ErrorCode": "GS402",
        "ErrorMessage": "Invalid request",
        "details": {
            "geometry_type": [
                "This field is required."
            ],
            "coordinates": [
                "This field is required."
            ]
        }
    }
  }



                              
Error Description:
Occurs when mandatory fields, geometry_type and coordinate parameters are not passed.
Code:
401
Content:

JSON

                                  
                                    
  {
    "status": true,
    "msg": "No Api key in Header provided",
    "code": 401,
    "error": {
        "ErrorCode": "GS401",
        "ErrorMessage": "Invalid Api key",
        "details": "No Api key in Header provided"
    }
  }



                              
Error Description:
Occurs when API key is not provided in the request header.
Code:
401
Content:

JSON

                                  
                                    
  {
    "status": true,
    "msg": "Invalid Api key.",
    "code": 401,
    "error": {
        "ErrorCode": "GS401",
        "ErrorMessage": "Invalid Api key",
        "details": "Invalid Api key."
    }
  }



                              
Error Description:
Occurs when an invalid API key of any form is passed.

Note : Valid keys will become invalid if it's associated Project or Account is deleted, and error will be thrown when those keys are used again.

Sample Call

                                
  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
  }'
  var settings = {
    "async": true,
    "crossDomain": true,
    "url": "https://api.geospark.co/v1/api/geofence/",
    "method": "POST",
    "headers": {
      "Api-Key": "2fd72b3b94b149018957eae89c2d1c86",
      "Content-Type": "application/json"
    },
    "processData": false,
    "data": "{\n\t\"geometry_type\": \"circle\",\n\t\"coordinates\": [-72.28122, 42.926042] ,\n\t\"geometry_radius\": 50\n}"
  }

  $.ajax(settings).done(function (response) {
    console.log(response);
  });
  import requests

  url = "https://api.geospark.co/v1/api/geofence/"

  payload = "{\n\t\"geometry_type\": \"circle\",\n\t\"coordinates\": [-72.28122, 42.926042] ,\n\t\"geometry_radius\": 50\n}"
  headers = {
      'Api-Key': "2fd72b3b94b149018957eae89c2d1c86",
      'Content-Type': "application/json"
      }

  response = requests.request("POST", url, data=payload, headers=headers)

  print(response.text)
  OkHttpClient client = new OkHttpClient();

  MediaType mediaType = MediaType.parse("application/json");
  RequestBody body = RequestBody.create(mediaType, "{\n\t\"geometry_type\": \"circle\",\n\t\"coordinates\": [-72.28122, 42.926042] ,\n\t\"geometry_radius\": 50\n}");
  Request request = new Request.Builder()
    .url("https://api.geospark.co/v1/api/geofence/")
    .post(body)
    .addHeader("Api-Key", "2fd72b3b94b149018957eae89c2d1c86")
    .addHeader("Content-Type", "application/json")
    .build();

  Response response = client.newCall(request).execute(); 
  import Foundation

  let headers = [
    "Api-Key": "2fd72b3b94b149018957eae89c2d1c86",
    "Content-Type": "application/json"
  ]
  let parameters = [
    "geometry_type": "circle",
    "coordinates": [-72.28122, 42.926042],
    "geometry_radius": 50
  ] as [String : Any]

  let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

  let request = NSMutableURLRequest(url: NSURL(string: "https://api.geospark.co/v1/api/geofence/")! as URL,
                                          cachePolicy: .useProtocolCachePolicy,
                                      timeoutInterval: 10.0)
  request.httpMethod = "POST"
  request.allHTTPHeaderFields = headers
  request.httpBody = postData as Data

  let session = URLSession.shared
  let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
    if (error != nil) {
      print(error)
    } else {
      let httpResponse = response as? HTTPURLResponse
      print(httpResponse)
    }
  })

  dataTask.resume() 
  package main

  import (
    "fmt"
    "strings"
    "net/http"
    "io/ioutil"
  )

  func main() {

    url := "https://api.geospark.co/v1/api/geofence/"

    payload := strings.NewReader("{\n\t\"geometry_type\": \"circle\",\n\t\"coordinates\": [-72.28122, 42.926042] ,\n\t\"geometry_radius\": 50\n}")

    req, _ := http.NewRequest("POST", url, payload)

    req.Header.Add("Api-Key", "2fd72b3b94b149018957eae89c2d1c86")
    req.Header.Add("Content-Type", "application/json")

    res, _ := http.DefaultClient.Do(req)

    defer res.Body.Close()
    body, _ := ioutil.ReadAll(res.Body)

    fmt.Println(res)
    fmt.Println(string(body))

  }
                               
                               
                            

Update Geofence API:

Update details for existing geofence of any specific project using Update Geofence API.

Url

/v1/api/geofence/

Method

PUT

Header Params

Api-Key:33223kjhdcscijhb5sdbsdmjsdcbj5f

Required

Content-Type:application/json

URL Params

Param Input Data Type Description
NA NA NA NA

Data Params

JSON

                                  
                                    
  {
    "geofence_id": "5bd2aee1eec1a50d8faf1293",
    "is_enabled": true,
    "description": "testing geofence",
    "tag": "border code",
    "color_code": "ffff"
  }

  

                              
Param Input Data Type Description
geofence_id "5bd2aee1eec1a50d8faf1293" String Field (required) Mandatory field, that identifies the Geofence
color_code fffff String Filed (optional) Defines the color of Geofence and how it is displayed in the dashboard. Type : Hex Code for CSS colors. Note : Pass the code without '#'.
tag hotel String Field (optional) This is to tag your geofence for your structural property.
description This is just a 5 star cool hotel where you can stay. String Field (optional) Optional description for the geofence.
is_enabled true or false Boolean Field(optional) Enable/Disable 'event_trigger' for Geofences. By Default event trigger are disabled.

Success Response

Code:
200 SUCCESS
Content:

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_radius": null,
          "geometry_center": {
              "type": "Point",
              "coordinates": [
                  -72.28080043090077,
                  42.92531143047176
              ]
          },
          "is_enabled": true,
          "description": "testing geofence",
          "color_code": "ffff",
          "tag": "border code",
          "created_at": "2018-10-26T06:06:25.122",
          "updated_at": "2018-10-28T14:00:41.198"
      }
  }



                              

Error Responses

Code:
400
Content:

JSON

                                  
                                    
  {
    "status": false,
    "msg": "Unknown Error.",
    "code": 400,
    "error": {
        "ErrorCode": "GS400",
        "ErrorMessage": "An error occured"
    }
  }



                              
Error Description:
Occurs when an unknown error is caught. Given to ensure graceful fails.
Code:
400
Content:

JSON

                                  
                                    
  {
      "status": false,
      "msg": "Error Occured.",
      "code": 400,
      "error": {
          "ErrorCode": "GS402",
          "ErrorMessage": "Invalid request",
          "details": {
              "geofence_id": [
                  "This field is required."
              ]
          }
      }
  }



                              
Error Description:
Occurs when geofence_id is not passed in the request header.
Code:
401
Content:

JSON

                                  
                                    
  {
    "status": true,
    "msg": "No Api key in Header provided",
    "code": 401,
    "error": {
        "ErrorCode": "GS401",
        "ErrorMessage": "Invalid Api key",
        "details": "No Api key in Header provided"
    }
  }



                              
Error Description:
Occurs when API key is not provided in the request header.
Code:
401
Content:

JSON

                                  
                                    
  {
    "status": true,
    "msg": "Invalid Api key.",
    "code": 401,
    "error": {
        "ErrorCode": "GS401",
        "ErrorMessage": "Invalid Api key",
        "details": "Invalid Api key."
    }
  }



                              
Error Description:
Occurs when an invalid API key of any form is passed.

Note : Valid keys will become invalid if it's associated Project or Account is deleted, and error will be thrown when those keys are used again.

Sample Call

                                
  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": "testing geofence",
    "tag": "border code",
    "color_code": "ffff"
  }'
  var settings = {
    "async": true,
    "crossDomain": true,
    "url": "https://api.geospark.co/v1/api/geofence/",
    "method": "PUT",
    "headers": {
      "Api-Key": "2fd72b3b94b149018957eae89c2d1c86",
      "Content-Type": "application/json"
    },
    "processData": false,
    "data": "{\n\t\"geofence_id\": \"5bd2aee1eec1a50d8faf1293\",\n\t\"is_enabled\": true,\n\t\"description\": \"testing geofence\",\n\t\"tag\": \"border code\",\n\t\"color_code\": \"ffff\"\n}"
  }

  $.ajax(settings).done(function (response) {
    console.log(response);
  });
  import requests

  url = "https://api.geospark.co/v1/api/geofence/"

  payload = "{\n\t\"geofence_id\": \"5bd2aee1eec1a50d8faf1293\",\n\t\"is_enabled\": true,\n\t\"description\": \"testing geofence\",\n\t\"tag\": \"border code\",\n\t\"color_code\": \"ffff\"\n}"
  headers = {
      'Api-Key': "2fd72b3b94b149018957eae89c2d1c86",
      'Content-Type': "application/json"
      }

  response = requests.request("PUT", url, data=payload, headers=headers)

  print(response.text)
  OkHttpClient client = new OkHttpClient();

  MediaType mediaType = MediaType.parse("application/json");
  RequestBody body = RequestBody.create(mediaType, "{\n\t\"geofence_id\": \"5bd2aee1eec1a50d8faf1293\",\n\t\"is_enabled\": true,\n\t\"description\": \"testing geofence\",\n\t\"tag\": \"border code\",\n\t\"color_code\": \"ffff\"\n}");
  Request request = new Request.Builder()
    .url("https://api.geospark.co/v1/api/geofence/")
    .put(body)
    .addHeader("Api-Key", "2fd72b3b94b149018957eae89c2d1c86")
    .addHeader("Content-Type", "application/json")
    .build();

  Response response = client.newCall(request).execute(); 
  package main

  import (
    "fmt"
    "strings"
    "net/http"
    "io/ioutil"
  )

  func main() {

    url := "https://api.geospark.co/v1/api/geofence/"

    payload := strings.NewReader("{\n\t\"geofence_id\": \"5bd2aee1eec1a50d8faf1293\",\n\t\"is_enabled\": true,\n\t\"description\": \"testing geofence\",\n\t\"tag\": \"border code\",\n\t\"color_code\": \"ffff\"\n}")

    req, _ := http.NewRequest("PUT", url, payload)

    req.Header.Add("Api-Key", "2fd72b3b94b149018957eae89c2d1c86")
    req.Header.Add("Content-Type", "application/json")

    res, _ := http.DefaultClient.Do(req)

    defer res.Body.Close()
    body, _ := ioutil.ReadAll(res.Body)

    fmt.Println(res)
    fmt.Println(string(body))

  }
                               
                               
                            

Get Geofence API:

This api gives you the filtered list of geofences.

Url

/v1/api/geofence/

Method

GET

Header Params

Api-Key:33223kjhdcscijhb5sdbsdmjsdcbj5f

Required

Content-Type:application/json

URL Params

/v1/api/geofence/?geometry_type=polygon&color_code=ffff&tag=hotel&page_number=1

or

/v1/api/geofence/

Param Input Data Type Description
page_number 1 (Optional) 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 fffff String Field (optional) Defines the color of Geofence and how it is displayed in the dashboard. Type : Hex Code for CSS colors. Note : Pass the code without '#'.
tag hotel String Field (optional) Tag the GeoFences for future reference and filtering.
geometry_type circle or polygon String Field (optional) Type of the Geofence. Can be either a Circle or Polygon.
geofence_id "5bd2aee1eec1a50d8faf1293" String Field (optional) To get the data only for a single geofence, pass it's geofence_id.

Success Response

Code:
200 SUCCESS
Content:

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,
            "tag": "testing",
            "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,
                    Error Responses
                    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": "kumar",
          "created_at": "2018-10-18T14:36:37.747",
          "updated_at": "2018-10-18T14:36:37.747"
       }
      ]
  }
}

  

                              

JSON

                                  
                                    
// if page is exhausted
{
    "status": true,
    "msg": "Success.",
    "code": 200,
    "data": {
        "next_page": null,
        "pages": 1,
        "prev_page": null,
        "account_id": null,
        "project_id": null,
        "geofences": []
    }
}



                                

Error Responses

Code:
400
Content:

JSON

                                  
                                      
  {
    "status": false,
    "msg": "Unknown Error.",
    "code": 400,
    "error": {
        "ErrorCode": "GS400",
        "ErrorMessage": "An error occured"
    }
  }



                              
Error Description:
Occurs when an unknown error is caught. Given to ensure graceful fails.Possibly bad formatting in the request.
Code:
401
Content:

JSON

                                  
                                      
  {
    "status": true,
    "msg": "No Api key in Header provided",
    "code": 401,
    "error": {
        "ErrorCode": "GS401",
        "ErrorMessage": "Invalid Api key",
        "details": "No Api key in Header provided"
    }
  }



                              
Error Description:
Occurs when API key is not provided in the request header.
Code:
401
Content:

JSON

                                  
                                        
  {
    "status": true,
    "msg": "Invalid Api key.",
    "code": 401,
    "error": {
        "ErrorCode": "GS401",
        "ErrorMessage": "Invalid Api key",
        "details": "Invalid Api key."
    }
  }



                              
Error Description:
Occurs when an invalid API key of any form is passed.

Note : Valid keys will become invalid if it's associated Project or Account is deleted, and error will be thrown when those keys are used again.

Sample Call

                                
  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'
 var settings = {
    "async": true,
    "crossDomain": true,
    "url": "https://api.geospark.co/v1/api/geofence/?geometry_type=polygon&color_code=ffff&tag=border%20code&page_number=1",
    "method": "GET",
    "headers": {
      "Api-Key": "2fd72b3b94b149018957eae89c2d1c86"
    }
  }

  $.ajax(settings).done(function (response) {
    console.log(response);
  });
  import requests

  url = "https://api.geospark.co/v1/api/geofence/"

  querystring = {"geometry_type":"polygon","color_code":"ffff","tag":"border%20code","page_number":"1"}

  headers = {
      'Api-Key': "2fd72b3b94b149018957eae89c2d1c86"
      }

  response = requests.request("GET", url, headers=headers, params=querystring)

  print(response.text)
 OkHttpClient client = new OkHttpClient();

  Request request = new Request.Builder()
    .url("https://api.geospark.co/v1/api/geofence/?geometry_type=polygon&color_code=ffff&tag=border%20code&page_number=1")
    .get()
    .addHeader("Api-Key", "2fd72b3b94b149018957eae89c2d1c86")
    .build();

  Response response = client.newCall(request).execute(); 
  import Foundation

  let headers = [
    "Api-Key": "2fd72b3b94b149018957eae89c2d1c86"
  ]

  let request = NSMutableURLRequest(url: NSURL(string: "https://api.geospark.co/v1/api/geofence/?geometry_type=polygon&color_code=ffff&tag=border%20code&page_number=1")! as URL,
                                          cachePolicy: .useProtocolCachePolicy,
                                      timeoutInterval: 10.0)
  request.httpMethod = "GET"
  request.allHTTPHeaderFields = headers

  let session = URLSession.shared
  let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
    if (error != nil) {
      print(error)
    } else {
      let httpResponse = response as? HTTPURLResponse
      print(httpResponse)
    }
  })

  dataTask.resume() 
  package main

  import (
    "fmt"
    "net/http"
    "io/ioutil"
  )

  func main() {

    url := "https://api.geospark.co/v1/api/geofence/?geometry_type=polygon&color_code=ffff&tag=border%20code&page_number=1"

    req, _ := http.NewRequest("GET", url, nil)

    req.Header.Add("Api-Key", "2fd72b3b94b149018957eae89c2d1c86")
   
    res, _ := http.DefaultClient.Do(req)

    defer res.Body.Close()
    body, _ := ioutil.ReadAll(res.Body)

    fmt.Println(res)
    fmt.Println(string(body))

  }
                               
                               
                            

Delete Geofence API:

Delete Geofence API allows you to delete already existing geofences for a project.

Url

/v1/api/geofence/

Method

DELETE

Header Params

Api-Key: 33223kjhdcscijhb5sdbsdmjsdcbj5f

Required

Content-Type:application/json

URL Params

Param Input Data Type Description
NA NA NA NA

Data Params

JSON

                                  
                                    
  {
    "geofence_id": "5bd2aee1eec1a50d8faf1293"
  }
  
  

                                
Param Input Data Type Description
geofence_id 5bb3177a02a89b3c7a6a8d4f String Field (Required) Mandatory field. Deletes the geofence given here.

Success Response

Code:
200 SUCCESS
Content:

JSON

                                  
                                      
 {
      "status": true,
      "msg": "Geofence deleted successfully.",
      "code": 200,
      "data": {}
  }



                                

Error Responses

Code:
400
Content:

JSON

                                  
                                      
  {
    "status": false,
    "msg": "Unknown Error.",
    "code": 400,
    "error": {
        "ErrorCode": "GS400",
        "ErrorMessage": "An error occured"
    }
  }



                              
Error Description:
Occurs when an unknown error is caught. Given to ensure graceful fails.Possibly bad formatting in the request.
Code:
400
Content:

JSON

                                  
                                      
  {
      "status": false,
      "msg": "Error Occured.",
      "code": 400,
      "error": {
          "ErrorCode": "GS400",
          "ErrorMessage": "An error occured",
          "details": "Geofence does not exist."
      }
  }



                              
Error Description:
Occurs when the given geofence doesn't exist.
Code:
400
Content:

JSON

                                  
                                      
  {
      "status": false,
      "msg": "Error Occured.",
      "code": 400,
      "error": {
          "ErrorCode": "GS402",
          "ErrorMessage": "Invalid request",
          "details": {
              "geofence_id": [
                  "This field is required."
              ]
          }
      }
  }



                              
Error Description:
Occurs when geofence_id is not provided.
Code:
401
Content:

JSON

                                  
                                    
  {
    "status": true,
    "msg": "No Api key in Header provided",
    "code": 401,
    "error": {
        "ErrorCode": "GS401",
        "ErrorMessage": "Invalid Api key",
        "details": "No Api key in Header provided"
    }
  }



                              
Error Description:
Occurs when API key is not provided in the request header.
Code:
401
Content:

JSON

                                  
                                      
  {
    "status": true,
    "msg": "Invalid Api key.",
    "code": 401,
    "error": {
        "ErrorCode": "GS401",
        "ErrorMessage": "Invalid Api key",
        "details": "Invalid Api key."
    }
  }



                              
Error Description:
Occurs when an invalid API key of any form is passed.

Note : Valid keys will become invalid if it's associated Project or Account is deleted, and error will be thrown when those keys are used again.

Sample Call

                                
  curl -X DELETE \
    https://api.geospark.co/v1/api/geofence/ \
    -H 'Api-Key: 2fd72b3b94b149018957eae89c2d1c86' \
    -H 'Content-Type: application/json'
    -d '{
    "geofence_id": "5bd2aee1eec1a50d8faf1293"
  }'
  var settings = {
    "async": true,
    "crossDomain": true,
    "url": "https://api.geospark.co/v1/api/geofence/",
    "method": "DELETE",
    "headers": {
      "Api-Key": "2fd72b3b94b149018957eae89c2d1c86",
      "Content-Type": "application/json"
    },
    "processData": false,
    "data": "{\n\t\"geofence_id\": \"5bd2aee1eec1a50d8faf1293\"\n}"
  }

  $.ajax(settings).done(function (response) {
    console.log(response);
  });
  import requests

  url = "https://api.geospark.co/v1/api/geofence/"

  payload = "{\n\t\"geofence_id\": \"5bd2aee1eec1a50d8faf1293\"\n}"
  headers = {
      'Api-Key': "2fd72b3b94b149018957eae89c2d1c86",
      'Content-Type': "application/json"
      }

  response = requests.request("DELETE", url, data=payload, headers=headers)

  print(response.text)
  OkHttpClient client = new OkHttpClient();

  MediaType mediaType = MediaType.parse("application/json");
  RequestBody body = RequestBody.create(mediaType, "{\n\t\"geofence_id\": \"5bd2aee1eec1a50d8faf1293\"\n}");
  Request request = new Request.Builder()
    .url("https://api.geospark.co/v1/api/geofence/")
    .delete(body)
    .addHeader("Api-Key", "2fd72b3b94b149018957eae89c2d1c86")
    .addHeader("Content-Type", "application/json")
    .build();

  Response response = client.newCall(request).execute(); 
  import Foundation

  let headers = [
    "Api-Key": "2fd72b3b94b149018957eae89c2d1c86",
    "Content-Type": "application/json"
  ]
  let parameters = ["geofence_id": "5bd2aee1eec1a50d8faf1293"] as [String : Any]

  let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

  let request = NSMutableURLRequest(url: NSURL(string: "https://api.geospark.co/v1/api/geofence/")! as URL,
                                          cachePolicy: .useProtocolCachePolicy,
                                      timeoutInterval: 10.0)
  request.httpMethod = "DELETE"
  request.allHTTPHeaderFields = headers
  request.httpBody = postData as Data

  let session = URLSession.shared
  let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
    if (error != nil) {
      print(error)
    } else {
      let httpResponse = response as? HTTPURLResponse
      print(httpResponse)
    }
  })

  dataTask.resume() 
  package main

  import (
    "fmt"
    "strings"
    "net/http"
    "io/ioutil"
  )

  func main() {

    url := "https://api.geospark.co/v1/api/geofence/"

    payload := strings.NewReader("{\n\t\"geofence_id\": \"5bd2aee1eec1a50d8faf1293\"\n}")

    req, _ := http.NewRequest("DELETE", url, payload)

    req.Header.Add("Api-Key", "2fd72b3b94b149018957eae89c2d1c86")
    req.Header.Add("Content-Type", "application/json")

    res, _ := http.DefaultClient.Do(req)

    defer res.Body.Close()
    body, _ := ioutil.ReadAll(res.Body)

    fmt.Println(res)
    fmt.Println(string(body))

  }
                               
                               
                            

Get Events API:

This api is responsible for giving the list of events.

Url

/v1/api/event/

Method

GET

Header Params

Api-Key: 33223kjhdcscijhb5sdbsdmjsdcbj5f

Required

Content-Type:application/json

URL Params

/v1/api/event/?geofence_id=5bc89a4feec1a50e738db301&location_id=5bd2ab9deec1a50c7fa75581&event_type=entry&page_number=1

or

/v1/api/event/

Param Input Data Type Description
page_number 1 (Optional) 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.
geofence_id 5bd2aee1eec1a50d8faf1293 (Optional) Returns Events only for the given geofence_id
location_id 5bd2ab9deec1a50c7fa75581 (Optional) Used to check if there's an event associated with a particular location, identified by it's location_id.
event_type entry or exit (Optional) Filter by entry or exit type events.

Success Response

Code:
200 SUCCESS
Content:

JSON

                                  
                                    
  {
    "status": true,
    "msg": "Success.",
    "code": 200,
    "data": {
        "next_page": 2,
        "pages": 2,
        "prev_page": null,
        "account_id": "5bbdd7a8eec1a511b246490d",
        "events": [
            {
                "id": "5bfa9599eec1a50778901421",
                "user_id": "5bdad5f7eec1a507afa2fece",
                "geofence_id": "5bc89a4feec1a50e738db301",
                "location_id": "5bfa9595eec1a5077890141e",
                "app_id": "5bbdd865eec1a511b246490e_1",
                "event_type": "entry",
                "coordinates": {
                    "type": "Point",
                    "coordinates": [
                        -0.11893,
                        51.49614
                    ]
                },
                "recorded_at": "2018-10-02T10:44:00.000",
                "timezone_offset": "+0100",
                "created_at": "2018-11-25T12:29:09.273"
            },
            {
                "id": "5bfa959aeec1a50778901422",
                "user_id": "5bdad5f7eec1a507afa2fece",
                "geofence_id": "5bc89a75eec1a50e738db302",
                "location_id": "5bfa9595eec1a5077890141e",
                "app_id": "5bbdd865eec1a511b246490e_1",
                "event_type": "entry",
                "coordinates": {
                    "type": "Point",
                    "coordinates": [
                        -0.11893,
                        51.49614
                    ]
                },
                "recorded_at": "2018-10-02T10:44:00.000",
                "timezone_offset": "+0100",
                "created_at": "2018-11-25T12:29:13.925"
            },
            {
                "id": "5bfa985beec1a507c7a12711",
                "user_id": "5bdad5f7eec1a507afa2fece",
                "geofence_id": "5bc89a4feec1a50e738db301",
                "location_id": "5bfa9854eec1a507c7a1270e",
                "app_id": "5bbdd865eec1a511b246490e_1",
                "event_type": "exit",
                "coordinates": {
                    "type": "Point",
                    "coordinates": [
                        -87.64593,
                        71.86793
                    ]
                },
                "timezone_offset": "+0100",
                "started_at": "2018-10-02T11:42:00.000",
                "ended_at": "2018-10-02T07:27:08.000",
                "created_at": "2018-11-25T12:40:52.981"
            },
            {
                "id": "5bfa985ceec1a507c7a12712",
                "user_id": "5bdad5f7eec1a507afa2fece",
                "geofence_id": "5bc89a75eec1a50e738db302",
                "location_id": "5bfa9854eec1a507c7a1270e",
                "app_id": "5bbdd865eec1a511b246490e_1",
                "event_type": "exit",
                "coordinates": {
                    "type": "Point",
                    "coordinates": [
                        -87.64593,
                        71.86793
                    ]
                },
                "timezone_offset": "+0100",
                "started_at": "2018-10-02T11:42:00.000",
                "ended_at": "2018-10-02T07:27:08.000",
                "created_at": "2018-11-25T12:40:59.632"
            },
            {
                "id": "5bfa98efeec1a507f7b5b425",
                "user_id": "5bdad5f7eec1a507afa2fece",
                "geofence_id": "5bc89a4feec1a50e738db301",
                "location_id": "5bfa98eaeec1a507f7b5b422",
                "app_id": "5bbdd865eec1a511b246490e_1",
                "event_type": "entry",
                "coordinates": {
                    "type": "Point",
                    "coordinates": [
                        -0.11893,
                        51.49614
                    ]
                },
                "recorded_at": "2018-10-02T10:44:00.000",
                "timezone_offset": "+0100",
                "created_at": "2018-11-25T12:43:22.679"
            },
            {
                "id": "5bfa98f1eec1a507f7b5b426",
                "user_id": "5bdad5f7eec1a507afa2fece",
                "geofence_id": "5bc89a75eec1a50e738db302",
                "location_id": "5bfa98eaeec1a507f7b5b422",
                "app_id": "5bbdd865eec1a511b246490e_1",
                "event_type": "entry",
                "coordinates": {
                    "type": "Point",
                    "coordinates": [
                        -0.11893,
                        51.49614
                    ]
                },
                "recorded_at": "2018-10-02T10:44:00.000",
                "timezone_offset": "+0100",
                "created_at": "2018-11-25T12:43:27.103"
            },
            {
                "id": "5bfa992aeec1a507f7b5b435",
                "user_id": "5bdad5f7eec1a507afa2fece",
                "geofence_id": "5bc89a4feec1a50e738db301",
                "location_id": "5bfa98f1eec1a507f7b5b432",
                "app_id": "5bbdd865eec1a511b246490e_1",
                "event_type": "exit",
                "coordinates": {
                    "type": "Point",
                    "coordinates": [
                        -87.64593,
                        71.86793
                    ]
                },
                "timezone_offset": "+0100",
                "started_at": "2018-10-02T11:42:00.000",
                "ended_at": "2018-10-02T07:27:08.000",
                "created_at": "2018-11-25T12:43:29.353"
            },
            {
                "id": "5bfa992deec1a507f7b5b436",
                "user_id": "5bdad5f7eec1a507afa2fece",
                "geofence_id": "5bc89a75eec1a50e738db302",
                "location_id": "5bfa98f1eec1a507f7b5b432",
                "app_id": "5bbdd865eec1a511b246490e_1",
                "event_type": "exit",
                "coordinates": {
                    "type": "Point",
                    "coordinates": [
                        -87.64593,
                        71.86793
                    ]
                },
                "timezone_offset": "+0100",
                "started_at": "2018-10-02T11:42:00.000",
                "ended_at": "2018-10-02T07:27:08.000",
                "created_at": "2018-11-25T12:44:26.586"
            },
            {
                "id": "5bfa9961eec1a5080f9bb823",
                "user_id": "5bdad5f7eec1a507afa2fece",
                "geofence_id": "5bc89a4feec1a50e738db301",
                "location_id": "5bfa995ceec1a5080f9bb820",
                "app_id": "5bbdd865eec1a511b246490e_1",
                "event_type": "entry",
                "coordinates": {
                    "type": "Point",
                    "coordinates": [
                        -0.11893,
                        51.49614
                    ]
                },
                "recorded_at": "2018-10-02T10:44:00.000",
                "timezone_offset": "+0100",
                "created_at": "2018-11-25T12:45:21.302"
            },
            {
                "id": "5bfa9962eec1a5080f9bb824",
                "user_id": "5bdad5f7eec1a507afa2fece",
                "geofence_id": "5bc89a75eec1a50e738db302",
                "location_id": "5bfa995ceec1a5080f9bb820",
                "app_id": "5bbdd865eec1a511b246490e_1",
                "event_type": "entry",
                "coordinates": {
                    "type": "Point",
                    "coordinates": [
                        -0.11893,
                        51.49614
                    ]
                },
                "recorded_at": "2018-10-02T10:44:00.000",
                "timezone_offset": "+0100",
                "created_at": "2018-11-25T12:45:22.602"
            }
        ]
    }
}

  

                              

JSON

                                  
                                    
// if page is exhausted
{
    "status": true,
    "msg": "Success.",
    "code": 200,
    "data": {
        "next_page": null,
        "pages": 2,
        "prev_page": null,
        "account_id": null,
        "events": []
    }
}



                                

Error Responses

Code:
400
Content:

JSON

                                  
                                    
  {
      "status": false,
      "msg": "Error Occured.",
      "code": 400,
      "error": {
          "ErrorCode": "GS402",
          "ErrorMessage": "Invalid request",
          "details": {
              "geofence_id": {
                  "geofence_id": "This field is invalid"
              },
              "location_id": {
                  "location_id": "This field is invalid"
              }
          }
      }
  }



                              
Error Description:
Occurs when either given geofence_id or location_id is invalid or doesn't exist or the given geofence_id is not event_enabled.
Code:
400
Content:

JSON

                                  
                                      
  {
      "status": false,
      "msg": "Unknown Error.",
      "code": 400,
      "error": {
          "ErrorCode": "GS400",
          "ErrorMessage": "An error occured"
      }
  }



                              
Error Description:
Occurs when an unknown error is caught. Given to ensure graceful fails.Possibly bad formatting in the header.
Code:
401
Content:

JSON

                                  
                                      
  {
    "status": true,
    "msg": "No Api key in Header provided",
    "code": 401,
    "error": {
        "ErrorCode": "GS401",
        "ErrorMessage": "Invalid Api key",
        "details": "No Api key in Header provided"
    }
  }



                              
Error Description:
Occurs when API key is not provided in the request header.
Code:
401
Content:

JSON

                                  
                                      
  {
    "status": true,
    "msg": "Invalid Api key.",
    "code": 401,
    "error": {
        "ErrorCode": "GS401",
        "ErrorMessage": "Invalid Api key",
        "details": "Invalid Api key."
    }
  }



                              
Error Description:
Occurs when an invalid API key of any form is passed.

Note : Valid keys will become invalid if it's associated Project or Account is deleted, and error will be thrown when those keys are used again.

Sample Call

                                
  curl -X GET \
    'https://api.geospark.co/v1/api/event/?geofence_id=5bc89a4feec1a50e738db301&location_id=5bd2ab9deec1a50c7fa75581&event_type=entry&page_number=1' \
    -H 'Api-Key: 2fd72b3b94b149018957eae89c2d1c86'
 var settings = {
    "async": true,
    "crossDomain": true,
    "url": "https://api.geospark.co/v1/api/event/?geofence_id=5bc89a4feec1a50e738db301&location_id=5bd2ab9deec1a50c7fa75581&event_type=entry&page_number=1",
    "method": "GET",
    "headers": {
      "Api-Key": "2fd72b3b94b149018957eae89c2d1c86"
    }
  }

  $.ajax(settings).done(function (response) {
    console.log(response);
  });
  import requests

  url = "https://api.geospark.co/v1/api/event/"

  querystring = {"geofence_id":"5bc89a4feec1a50e738db301","location_id":"5bd2ab9deec1a50c7fa75581","event_type":"entry","page_number":"1"}

  headers = {
      'Api-Key': "2fd72b3b94b149018957eae89c2d1c86"
      }

  response = requests.request("GET", url, headers=headers, params=querystring)

  print(response.text)
 OkHttpClient client = new OkHttpClient();

  Request request = new Request.Builder()
    .url("https://api.geospark.co/v1/api/event/?geofence_id=5bc89a4feec1a50e738db301&location_id=5bd2ab9deec1a50c7fa75581&event_type=entry&page_number=1")
    .get()
    .addHeader("Api-Key", "2fd72b3b94b149018957eae89c2d1c86")
    .build();

  Response response = client.newCall(request).execute(); 
  import Foundation

  let headers = [
    "Api-Key": "2fd72b3b94b149018957eae89c2d1c86"
  ]

  let request = NSMutableURLRequest(url: NSURL(string: "https://api.geospark.co/v1/api/event/?geofence_id=5bc89a4feec1a50e738db301&location_id=5bd2ab9deec1a50c7fa75581&event_type=entry&page_number=1")! as URL,
                                          cachePolicy: .useProtocolCachePolicy,
                                      timeoutInterval: 10.0)
  request.httpMethod = "GET"
  request.allHTTPHeaderFields = headers

  let session = URLSession.shared
  let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
    if (error != nil) {
      print(error)
    } else {
      let httpResponse = response as? HTTPURLResponse
      print(httpResponse)
    }
  })

  dataTask.resume() 
  package main

  import (
    "fmt"
    "net/http"
    "io/ioutil"
  )

  func main() {

    url := "https://api.geospark.co/v1/api/event/?geofence_id=5bc89a4feec1a50e738db301&location_id=5bd2ab9deec1a50c7fa75581&event_type=entry&page_number=1"

    req, _ := http.NewRequest("GET", url, nil)

    req.Header.Add("Api-Key", "2fd72b3b94b149018957eae89c2d1c86")

    res, _ := http.DefaultClient.Do(req)

    defer res.Body.Close()
    body, _ := ioutil.ReadAll(res.Body)

    fmt.Println(res)
    fmt.Println(string(body))

  }
                               
                               
                            

Get Trips List API:

This api gives you the list of all trips (both active and ended) of an user.

You can view trip summary for the users. It will help you track your user's completed and ongoing trips. You will get a concise information like trip start time, end time, start location, end location, Trip duration and distance covered.

Url

/v1/api/trip/

Method

GET

Header Params

Api-Key:33223kjhdcscijhb5sdbsdmjsdcbj5f

Required

Content-Type:application/json

URL Params

/v1/api/trip/?user_id=5bd3086002a89b26a5d2a1d2&app_id=5bc83d7f02a89b01450c5a6c_1

Param Input Data Type Description
user_id 5bd3086002a89b26a5d2a1d2 (Required) Mandatory field. Returns the trips of the user identified by this parameter.
app_id 5bc83d7f02a89b01450c5a6c_1 (Required) Mandatory field. app_id to identify the device_platform of the given user.

Metrics:

  • Distance covered is calculated in meters.
  • Duration is calculated in minutes.
  • This API return the list of ended trips of a user on a given date, with short summary of each trip.

Success Response

Code:
200 SUCCESS
Content:

JSON

                                  
                                    
  {
      "status": true,
      "msg": "Success.",
      "code": 200,
      "data": {
          "next_page": null,
          "pages": 1,
          "prev_page": null,
          "trips": [
              {
                  "trip_id": "5c0128509e633c17a7eb1714",
                  "description": "Bannergatta to electronic city",
                  "trip_started_at": "2018-11-26T12:20:26.019000",
                  "trip_ended_at": "2018-11-26T13:01:26.019000",
                  "start_address": "ragigudda temple",
                  "end_address": "electronc city",
                  "distance_covered": 227.04,
                  "duration": 41
              },
              {
                  "trip_id": "5c0128509e332517a7eb6512",
                  "description": "Malleshwaram to HSR Layout",
                  "trip_started_at": "2018-11-26T12:20:26.019000",
                  "trip_ended_at": "2018-11-26T13:02:26.019000",
                  "start_address": "9tth main CPS school",
                  "end_address": "HSR  Layout sector 3",
                  "distance_covered": 326.06,
                  "duration": 42
              },
              {
                  "trip_id": "5c04d3dd9e633c235631e93f",
                  "description": "Bannergatta to electronic city",
                  "trip_started_at": "2018-11-27T15:20:55.019000",
                  "start_address": "ragigudda temple"
              }
          ]
      }
  }

  

                              

JSON

                                  
                                      
// if page is exhausted
{
    "status": true,
    "msg": "Success.",
    "code": 200,
    "data": {
        "next_page": null,
        "pages": 1,
        "prev_page": null,
        "trips": []
    } 
}



                                

Error Responses

Code:
400
Content:

JSON

                                  
                                      
  {
    "status": false,
    "msg": "Error Occured.",
    "code": 400,
    "error": {
        "ErrorCode": "GS402",
        "ErrorMessage": "Invalid request",
        "details": {
            "app_id": [
                "This field is required."
            ]
        }
    }
  }



                              
Error Description:
Occurs when mandatory field app_id is not provided.
Code:
400
Content:

JSON

                                  
                                      
  {
    "status": false,
    "msg": "Error Occured.",
    "code": 400,
    "error": {
        "ErrorCode": "GS402",
        "ErrorMessage": "Invalid request",
        "details": {
            "user_id": [
                "This field is required."
            ]
        }
    }
  }



                              
Error Description:
Occurs when mandatory field user_id is not provided.
Code:
400
Content:

JSON

                                  
                                      
  {
    "status": false,
    "msg": "Unknown Error.",
    "code": 400,
    "error": {
        "ErrorCode": "GS400",
        "ErrorMessage": "An error occured"
    }
  }



                              
Error Description:
Occurs when an unknown error is caught. Given to ensure graceful fails. Possibly bad formatting in the request.
Code:
401
Content:

JSON

                                  
                                      
  {
    "status": true,
    "msg": "No Api key in Header provided",
    "code": 401,
    "error": {
        "ErrorCode": "GS401",
        "ErrorMessage": "Invalid Api key",
        "details": "No Api key in Header provided"
    }
  }



                              
Error Description:
Occurs when API key is not provided in the request header.
Code:
401
Content:

JSON

                                  
                                      
  {
    "status": true,
    "msg": "Invalid Api key.",
    "code": 401,
    "error": {
        "ErrorCode": "GS401",
        "ErrorMessage": "Invalid Api key",
        "details": "Invalid Api key."
    }
  }



                              
Error Description:
Occurs when an invalid API key of any form is passed.

Note : Valid keys will become invalid if it's associated Project or Account is deleted, and error will be thrown when those keys are used again.

Sample Call

                                
  curl -X GET \
  'https://api.geospark.co/v1/api/trip/?
  user_id=5bd3086002a89b26a5d2a1d2&app_id=5bc83d7f02a89b01450c5a6c_1' \
  -H 'Api-key: ad0b961be07b4b0c94f6b59df489edc1'
 var settings = {
    "async": true,
    "crossDomain": true,
    "url": "https://api.geospark.co/v1/api/trip/?user_id=5bd3086002a89b26a5d2a1d2&app_id=5bc83d7f02a89b01450c5a6c_1",
    "method": "GET",
    "headers": {
      "Api-key": "ad0b961be07b4b0c94f6b59df489edc1"
    }
  }

  $.ajax(settings).done(function (response) {
    console.log(response);
  });
 import requests

  url = "https://api.geospark.co/v1/api/trip/"

  querystring = {"user_id":"5bd3086002a89b26a5d2a1d2","app_id":"5bc83d7f02a89b01450c5a6c_1"}

  headers = {
      'Api-key': "ad0b961be07b4b0c94f6b59df489edc1"
      }

  response = requests.request("GET", url, headers=headers, params=querystring)

  print(response.text)
 OkHttpClient client = new OkHttpClient();

  Request request = new Request.Builder()
    .url("https://api.geospark.co/v1/api/trip/?user_id=5bd3086002a89b26a5d2a1d2&app_id=5bc83d7f02a89b01450c5a6c_1")
    .get()
    .addHeader("Api-key", "ad0b961be07b4b0c94f6b59df489edc1")
    .build();

  Response response = client.newCall(request).execute(); 
  import Foundation

  let headers = [
    "Api-key": "ad0b961be07b4b0c94f6b59df489edc1"
  ]

  let request = NSMutableURLRequest(url: NSURL(string: "https://api.geospark.co/v1/api/trip/?user_id=5bd3086002a89b26a5d2a1d2&app_id=5bc83d7f02a89b01450c5a6c_1")! as URL,
                                          cachePolicy: .useProtocolCachePolicy,
                                      timeoutInterval: 10.0)
  request.httpMethod = "GET"
  request.allHTTPHeaderFields = headers

  let session = URLSession.shared
  let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
    if (error != nil) {
      print(error)
    } else {
      let httpResponse = response as? HTTPURLResponse
      print(httpResponse)
    }
  })

  dataTask.resume() 
  package main

  import (
    "fmt"
    "net/http"
    "io/ioutil"
  )

  func main() {

    url := "https://api.geospark.co/v1/api/trip/?user_id=5bd3086002a89b26a5d2a1d2&app_id=5bc83d7f02a89b01450c5a6c_1"

    req, _ := http.NewRequest("GET", url, nil)

    req.Header.Add("Api-key", "ad0b961be07b4b0c94f6b59df489edc1")
    res, _ := http.DefaultClient.Do(req)

    defer res.Body.Close()
    body, _ := ioutil.ReadAll(res.Body)

    fmt.Println(res)
    fmt.Println(string(body))

  }
                               
                               
                            

Get Trips Route API:

This api gives the locations covered within a trip by a user.

Url

/v1/api/trip/

Method

GET

Header Params

Api-Key: 33223kjhdcscijhb5sdbsdmjsdcbj5f

Required

Content-Type:application/json

URL Params

/v1/api/trip/route/?trip_id=5bd3095502a89b2949e7f82b&app_id=5bc83d7f02a89b01450c5a6c_1

Param Input Data Type Description
trip_id 5bd3095502a89b2949e7f82b (Required) Mandatory Field. Response contains the locations identified by this field.
app_id 5bc83d7f02a89b01450c5a6c_1 (Required) Mandatory field. app_id to identify the device_platform of the given user.

Success Response

Code:
200 SUCCESS
Content:

JSON

                                  
                                    
  {
    "status": true,
    "msg": "Success.",
    "code": 200,
    "data": [
        {
            "coordinates": [
                65.64593,
                41.86793
            ],
            "altitude": 23.33,
            "activity": "walking",
            "recorded_at": "2018-10-26T12:32:21.628"
        },
        {
            "coordinates": [
                69.543942,
                45.965876
            ],
            "altitude": 24.22,
            "activity": "running",
            "recorded_at": "2018-10-26T12:33:05.125"
        },
        {
            "coordinates": [
                74.857632,
                50.422156
            ],
            "altitude": 25.12,
            "activity": "running",
            "recorded_at": "2018-10-26T12:33:60.336"
        }
    ]
  }

  

                              

JSON

                                  
                                      
// if page is exhausted
{
    "status": true,
    "msg": "Success.",
    "code": 200,
    "data": []
}



                                

Error Responses

Code:
400
Content:

JSON

                                  
                                      
  {
    "status": false,
    "msg": "Error Occured.",
    "code": 400,
    "error": {
        "ErrorCode": "GS402",
        "ErrorMessage": "Invalid request",
        "details": {
            "app_id": [
                "This field is required."
            ]
        }
    }
  }



                              
Error Description:
Occurs when mandatory field app_id is not provided.
Code:
400
Content:

JSON

                                  
                                      
  {
    "status": false,
    "msg": "Error Occured.",
    "code": 400,
    "error": {
        "ErrorCode": "GS402",
        "ErrorMessage": "Invalid request",
        "details": {
            "trip_id": [
                "This field is required."
            ]
        }
    }
  }



                              
Error Description:
Occurs when mandatory field trip_id is not provided.
Code:
400
Content:

JSON

                                  
                                      
  {
    "status": false,
    "msg": "Unknown Error.",
    "code": 400,
    "error": {
        "ErrorCode": "GS400",
        "ErrorMessage": "An error occured"
    }
  }



                              
Error Description:
Occurs when an unknown error is caught. Given to ensure graceful fails. Possibly bad formatting in the request.
Code:
401
Content:

JSON

                                  
                                      
  {
    "status": true,
    "msg": "No Api key in Header provided",
    "code": 401,
    "error": {
        "ErrorCode": "GS401",
        "ErrorMessage": "Invalid Api key",
        "details": "No Api key in Header provided"
    }
  }



                              
Error Description:
Occurs when API key is not provided in the request header.
Code:
401
Content:

JSON

                                  
                                      
  {
    "status": true,
    "msg": "Invalid Api key.",
    "code": 401,
    "error": {
        "ErrorCode": "GS401",
        "ErrorMessage": "Invalid Api key",
        "details": "Invalid Api key."
    }
  }



                              
Error Description:
Occurs when an invalid API key of any form is passed.

Note : Valid keys will become invalid if it's associated Project or Account is deleted, and error will be thrown when those keys are used again.

Sample Call

                                
  curl -X GET \
  'https://api.geospark.co/v1/api/trip/route/?trip_id=5bd3095502a89b2949e7f82b&app_id=5bc83d7f02a89b01450c5a6c_1' \
  -H 'Api-key: ad0b961be07b4b0c94f6b59df489edc1'
 var settings = {
    "async": true,
    "crossDomain": true,
    "url": "https://api.geospark.co/v1/api/trip/route/?trip_id=5bd3095502a89b2949e7f82b&app_id=5bc83d7f02a89b01450c5a6c_1",
    "method": "GET",
    "headers": {
      "Api-key": "ad0b961be07b4b0c94f6b59df489edc1"
    }
  }

  $.ajax(settings).done(function (response) {
    console.log(response);
  });
 import requests

  url = "https://api.geospark.co/v1/api/trip/route/"

  querystring = {"trip_id":"5bd3095502a89b2949e7f82b","app_id":"5bc83d7f02a89b01450c5a6c_1"}

  headers = {
      'Api-key': "ad0b961be07b4b0c94f6b59df489edc1"
      }

  response = requests.request("GET", url, headers=headers, params=querystring)

  print(response.text)
 OkHttpClient client = new OkHttpClient();

  Request request = new Request.Builder()
    .url("https://api.geospark.co/v1/api/trip/route/?trip_id=5bd3095502a89b2949e7f82b&app_id=5bc83d7f02a89b01450c5a6c_1")
    .get()
    .addHeader("Api-key", "ad0b961be07b4b0c94f6b59df489edc1")
    .build();

  Response response = client.newCall(request).execute(); 
  import Foundation

  let headers = [
    "Api-key": "ad0b961be07b4b0c94f6b59df489edc1"
  ]

  let request = NSMutableURLRequest(url: NSURL(string: "https://api.geospark.co/v1/api/trip/route/?trip_id=5bd3095502a89b2949e7f82b&app_id=5bc83d7f02a89b01450c5a6c_1")! as URL,
                                          cachePolicy: .useProtocolCachePolicy,
                                      timeoutInterval: 10.0)
  request.httpMethod = "GET"
  request.allHTTPHeaderFields = headers

  let session = URLSession.shared
  let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
    if (error != nil) {
      print(error)
    } else {
      let httpResponse = response as? HTTPURLResponse
      print(httpResponse)
    }
  })

  dataTask.resume() 
  package main

  import (
      "fmt"
      "net/http"
      "io/ioutil"
  )

  func main() {

      url := "https://api.geospark.co/v1/api/trip/route/?trip_id=5bd3095502a89b2949e7f82b&app_id=5bc83d7f02a89b01450c5a6c_1"

      req, _ := http.NewRequest("GET", url, nil)

      req.Header.Add("Api-key", "ad0b961be07b4b0c94f6b59df489edc1")

      res, _ := http.DefaultClient.Do(req)

      defer res.Body.Close()
      body, _ := ioutil.ReadAll(res.Body)

      fmt.Println(res)
      fmt.Println(string(body))

  }
                               
                               
                            

Webhook, Slack and Hangout Integration:

Slack and hangout can be added in a similar fashion as we are integrating web hooks.

Below are the steps:

  • First login to GeoSpark dashboard, select a project or create one and add apps in it.
  • Add geofences for that project from our geofence page accessible via top navigation tabs. Enable the geofences status for triggering events, whenever the user using your app enters or exits the geofence.
  • Go to settings tab in dashboard, where you will see options for webhook, slack and hangout integration. This again has an option which lets you choose which one you want to enable and actively use for subscription.
  • Now you can enable this feature by entering the respective URL's and please configure the same URL at your end for getting in your webhook, slack or hangout notifications.
  • Note: These are the URL's you create from your slack and hangout and put it in our dashboard.
  • After integration you can monitor the users and geofence events.

Sample webhook url for notifications:

https://www.example.com/< YOUR-WEBHOOK-ENDPOINT >

Response as input:

JSON

                                  
                                      
  {
    “geofence_id”: “5bc89a4feec1a44e738db309”,
    “geofence_description”:  “test from lambda”,
    “project_id”: “5bc25a4feec1a44e738db116”,
    “event_type”: “entry”,
    “user_id”: “5bdad5f7eec1a507afa2fece”,
    “user_description”: “test user”,
    “recorded_at”: 2018-11-23T10:27:32.000,
    “event_id”:  “5bed5a6e878b1b00012xaec5”
  }



                              
OR

JSON

                                  
                                      
  {
    “geofence_id”: “5bc89a4feec1a44e738db309”,
    “geofence_description”:  “test from lambda”,
    “project_id”: “5bc25a4feec1a44e738db116”,
    “event_type”: “exit”,
    “user_id”: “5bdad5f7eec1a507afa2fece”,
    “user_description”: “test user”,
    “recorded_at”: 2018-11-23T10:28:32.000,
    “event_id”:  “5bed5a6e878b1b00012xaec7”
  }



                              

Sample hangout url for notifications:

https://chat.googleapis.com/v1/spaces/AAAAXpwaM8c/messages?key=AIzaSyDdI0hCZtE6vySjMm-WEfRq3CPzqKqqsHI&token=Iagv0ff_1Gd4CQMVFQgNc5-6W3zBNJTaiOPO77kZ3KU%3D

Sample slack url for notifications:

https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX

Response:

JSON

                                  
                                      
  Event Triggered:
  Type: entry
  User ID:  5bdad5f7eec1a507afa2fece
  User Description: test user
  Geofence ID: 5bc89a4feec1a44e738db309
  Geofence Description: test from lambda
  Recorded At: 2018-11-23T10:27:32.000
  Event ID: 5bed5a6e878b1b00012xaec5



                              
OR

JSON

                                  
                                      
  Event Triggered:
  Type: exit
  User ID:  5bdad5f7eec1a507afa2fece
  User Description: test user
  Geofence ID: 5bc89a4feec1a44e738db309
  Geofence Description: test from lambda
  Recorded At: 2018-11-23T10:28:32.000
  Event ID: 5bed5a6e878b1b00012xaef6