API Quickstart Guide

Notes:

  • Pass your secret api key in the header
  • APIs with the option of page_number present, gives a maximum of 10 entries in the response.
  • app_id field in APIs if present, contains the number, and the last digit or the least significant digit represents the device platform, as given. "1" for Android and "2" for iOS

Get User API:

This API is responsible for giving you the list of users using your app corresponding to the project secret api key you provided.

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": [
        {
            "id": "5bc982b9eec1a5083d45ae8a",
            "account_id": "5bbdd7a8eec1a511b246490d",
            "app_id": "5bbdd865eec1a511b246490e_1",
            "device_token": null,
            "description": null,
            "device_arn": null,
            "is_deleted": false,
            "created_at": "2018-10-19T07:07:37.524000",
            "updated_at": "2018-10-22T05:05:20.634000"
        },
        {
            "id": "5bcd5a90eec1a504184c329a",
            "account_id": "5bbdd7a8eec1a511b246490d",
            "app_id": "5bbdd865eec1a511b246490e_1",
            "device_token": "SDFASDcsdcsdsssssssscsFASDF",
            "description": null,
            "device_arn": null,
            "is_deleted": false,
            "created_at": "2018-10-22T05:05:20.640000",
            "updated_at": "2018-10-22T05:05:20.640000"
        }
    ]
}




                              

Error Responses

Code:

400

Content:

JSON

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

  

                              

Description for this error:
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."
    }
  }

  

                              

Description for this error:
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.

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"
      }
  }

  

                              

Description for this error:
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:

This api is responsible for giving you the list of location for the selected user using your app corresponding to the project secret api key you provided.

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": [
        {
            "id": "5bcdabebeec1a5074f616231",
            "account_id": "5bbdd7a8eec1a511b246490d",
            "app_id": "5bbdd865eec1a511b246490e_1",
            "user_id": "5bb3177a02a89b3c7a6a8d4f",
            "coordinates": {
                "type": "Point",
                "coordinates": [
                    12.334,
                    77.88
                ]
            },
            "speed": 10.23,
            "accuracy": 0.23,
            "altitude": 23.33,
            "activity": "walking",
            "recorded_at": "2018-10-02T10:44:00.270000",
            "timezone_offset": "+0100",
            "started_at": null,
            "ended_at": null,
            "net_stat": true,
            "gps_stat": null,
            "motion_stat": null,
            "app_stat": null,
            "battery_remaining": null,
            "other_feature": null,
            "created_at": "2018-10-22T10:52:27.748000"
        },
        {
            "id": "5bcdabf1eec1a5074f616233",
            "account_id": "5bbdd7a8eec1a511b246490d",
            "app_id": "5bbdd865eec1a511b246490e_1",
            "user_id": "5bb3177a02a89b3c7a6a8d4f",
            "coordinates": {
                "type": "Point",
                "coordinates": [
                    77.68595,
                    12.91022
                ]
            },
            "speed": 0.001,
            "accuracy": 0.023,
            "altitude": 0,
            "activity": "walking",
            "recorded_at": "2018-10-22T10:20:48",
            "timezone_offset": "+0100",
            "started_at": null,
            "ended_at": null,
            "net_stat": false,
            "gps_stat": null,
            "motion_stat": null,
            "app_stat": null,
            "battery_remaining": null,
            "other_feature": null,
            "created_at": "2018-10-22T10:52:28.037000"
        },
        {
            "id": "5bcdacc0eec1a5074f616236",
            "account_id": "5bbdd7a8eec1a511b246490d",
            "app_id": "5bbdd865eec1a511b246490e_1",
            "user_id": "5bb3177a02a89b3c7a6a8d4f",
            "coordinates": {
                "type": "Point",
                "coordinates": [
                    77.68595,
                    12.91022
                ]
            },
            "speed": 0.001,
            "accuracy": 0.023,
            "altitude": 0,
            "activity": "walking",
            "recorded_at": "2018-10-22T10:20:48",
            "timezone_offset": "+0100",
            "started_at": null,
            "ended_at": null,
            "net_stat": false,
            "gps_stat": null,
            "motion_stat": null,
            "app_stat": null,
            "battery_remaining": null,
            "other_feature": null,
            "created_at": "2018-10-22T10:52:28.037000"
        },
        {
            "id": "5bcdad1feec1a5074f616239",
            "account_id": "5bbdd7a8eec1a511b246490d",
            "app_id": "5bbdd865eec1a511b246490e_1",
            "user_id": "5bb3177a02a89b3c7a6a8d4f",
            "coordinates": {
                "type": "Point",
                "coordinates": [
                    12.334,
                    77.88
                ]
            },
            "speed": 10.23,
            "accuracy": 0.23,
            "altitude": 23.33,
            "activity": "walking",
            "recorded_at": "2018-10-02T10:44:00.270000",
            "timezone_offset": "+0100",
            "started_at": null,
            "ended_at": null,
            "net_stat": true,
            "gps_stat": null,
            "motion_stat": null,
            "app_stat": null,
            "battery_remaining": null,
            "other_feature": null,
            "created_at": "2018-10-22T10:57:35.955000"
        },
        {
            "id": "5bcdad23eec1a5074f61623b",
            "account_id": "5bbdd7a8eec1a511b246490d",
            "app_id": "5bbdd865eec1a511b246490e_1",
            "user_id": "5bb3177a02a89b3c7a6a8d4f",
            "coordinates": {
                "type": "Point",
                "coordinates": [
                    77.63539,
                    12.91431
                ]
            },
            "speed": 0,
            "accuracy": 0.065,
            "altitude": 0.88,
            "activity": "walking",
            "recorded_at": "2018-10-22T10:12:09",
            "timezone_offset": "+0100",
            "started_at": null,
            "ended_at": null,
            "net_stat": false,
            "gps_stat": null,
            "motion_stat": null,
            "app_stat": null,
            "battery_remaining": null,
            "other_feature": null,
            "created_at": "2018-10-22T10:57:35.983000"
        },
        {
            "id": "5bcdad23eec1a5074f61623c",
            "account_id": "5bbdd7a8eec1a511b246490d",
            "app_id": "5bbdd865eec1a511b246490e_1",
            "user_id": "5bb3177a02a89b3c7a6a8d4f",
            "coordinates": {
                "type": "Point",
                "coordinates": [
                    155.27078,
                    25.82865
                ]
            },
            "speed": 0,
            "accuracy": 0.065,
            "altitude": 0.88,
            "activity": "walking",
            "recorded_at": "2018-10-22T20:24:19",
            "timezone_offset": "+0100",
            "started_at": null,
            "ended_at": null,
            "net_stat": false,
            "gps_stat": null,
            "motion_stat": null,
            "app_stat": null,
            "battery_remaining": null,
            "other_feature": null,
            "created_at": "2018-10-22T10:57:35.983000"
        },
        {
            "id": "5bcdad23eec1a5074f61623f",
            "account_id": "5bbdd7a8eec1a511b246490d",
            "app_id": "5bbdd865eec1a511b246490e_1",
            "user_id": "5bb3177a02a89b3c7a6a8d4f",
            "coordinates": {
                "type": "Point",
                "coordinates": [
                    -87.64593,
                    41.86793
                ]
            },
            "speed": 0,
            "accuracy": 0.23,
            "altitude": 23.33,
            "activity": "stop",
            "recorded_at": null,
            "timezone_offset": "+1:00",
            "started_at": "2018-10-02T11:42:00.270000",
            "ended_at": "2018-10-02T07:27:08.917000",
            "net_stat": true,
            "gps_stat": null,
            "motion_stat": null,
            "app_stat": null,
            "battery_remaining": null,
            "other_feature": null,
            "created_at": "2018-10-22T10:57:39.153000"
        },
        {
            "id": "5bcdb1c8eec1a50856f9233a",
            "account_id": "5bbdd7a8eec1a511b246490d",
            "app_id": "5bbdd865eec1a511b246490e_1",
            "user_id": "5bb3177a02a89b3c7a6a8d4f",
            "coordinates": {
                "type": "Point",
                "coordinates": [
                    12.334,
                    77.88
                ]
            },
            "speed": 10.23,
            "accuracy": 0.23,
            "altitude": 23.33,
            "activity": "walking",
            "recorded_at": "2018-10-02T10:44:00.270000",
            "timezone_offset": "+0100",
            "started_at": null,
            "ended_at": null,
            "net_stat": true,
            "gps_stat": null,
            "motion_stat": null,
            "app_stat": null,
            "battery_remaining": null,
            "other_feature": null,
            "created_at": "2018-10-22T11:17:28.918000"
        }
    ]
  }

  


                              

JSON

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



                              

Error Responses

Code:

400

Content:

JSON

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



                              

Description for this error:
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"
            }
        }
    }
  }



                              

Description for this error:
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."
            ]
        }
    }
  }



                              

Description for this error:
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"
    }
  }



                              

Description for this error:
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."
    }
  }



                              

Description for this error:
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:

This 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 [ longitude, latitude] (for circle) OR [[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.097644",
        "updated_at": "2018-10-28T13:40:05.097833"
    }
  }



                              

Error Responses

Code:

400

Content:

JSON

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

                              

Description for this error:
Occurs when an unknown error is caught. Given to ensure graceful fails.

Code:

400

Content:

JSON

                                  
                                    
  // when their 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"
              ]
          }
      }
  }



                              

Description for this error:
Occurs when un-supported Geometry type is passed, or when given coordinates are invalid.

Note : Invalid coordinates include wrong formatting and wrong data type. Doesn't include when Latitude/Longitude 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."
            ]
        }
    }
  }



                              

Description for this error:
Occurs when mandatory fields, geometry_type and coordinates 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"
    }
  }



                              

Description for this error:
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."
    }
  }



                              

Description for this error:
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:

This api is responsible for updating the infomation of existing geofences in your project.

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.122000",
          "updated_at": "2018-10-28T14:00:41.198509"
      }
  }



                              

Error Responses

Code:

400

Content:

JSON

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



                              

Description for this error:
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."
              ]
          }
      }
  }



                              

Description for this error:
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"
    }
  }



                              

Description for this error:
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."
    }
  }



                              

Description for this error:
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": [
          {
              "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.122000",
              "updated_at": "2018-10-28T14:09:44.128000"
          }
      ]
  }

  

                              

JSON

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



                                

Error Responses

Code:

400

Content:

JSON

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



                              

Description for this error:
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"
    }
  }



                              

Description for this error:
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."
    }
  }



                              

Description for this error:
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:

This 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"
    }
  }



                              

Description for this error:
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."
      }
  }



                              

Description for this error:
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."
              ]
          }
      }
  }



                              

Description for this error:
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"
    }
  }



                              

Description for this error:
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."
    }
  }



                              

Description for this error:
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": [
          {
              "id": "5bd2aba1eec1a50c7fa75583",
              "account_id": "5bbdd7a8eec1a511b246490d",
              "user_id": "5bb3177a02a89b3c7a6a8d4f",
              "geofence_id": "5bc89a4feec1a50e738db301",
              "location_id": "5bd2ab9deec1a50c7fa75581",
              "app_id": "5bbdd865eec1a511b246490e_1",
              "event_type": "entry",
              "confidence": null,
              "coordinates": {
                  "type": "Point",
                  "coordinates": [
                      -0.11893,
                      51.49614
                  ]
              },
              "recorded_at": "2018-10-02T10:44:00.270000",
              "timezone_offset": "+1:00",
              "started_at": null,
              "ended_at": null,
              "created_at": "2018-10-26T05:52:29.348000",
              "is_deleted": false
          }
      ]
  }

  

                              

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": {
              "geofence_id": {
                  "geofence_id": "This field is invalid"
              },
              "location_id": {
                  "location_id": "This field is invalid"
              }
          }
      }
  }



                              

Description for this error:
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"
      }
  }



                              

Description for this error:
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"
    }
  }



                              

Description for this error:
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."
    }
  }



                              

Description for this error:
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.

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.

Success Response

Code:

200 SUCCESS

Content:

JSON

                                  
                                    
  {
    "status": true,
    "msg": "Success.",
    "code": 200,
    "data": [
        {
            "trip_id": "5bd308e702a89b2949e7f828",
            "trip_started_at": "2018-10-26T12:30:30.646000"
        },
        {
            "trip_id": "5bd308eb02a89b2949e7f829",
            "trip_started_at": "2018-10-26T12:30:35.503000"
        },
        {
            "trip_id": "5bd308f002a89b2949e7f82a",
            "trip_started_at": "2018-10-26T12:30:40.555000",
            "trip_ended_at": "2018-10-26T12:30:52.981000"
        },
        {
            "trip_id": "5bd3095502a89b2949e7f82b",
            "trip_started_at": "2018-10-26T12:32:21.628000",
            "trip_ended_at": "2018-10-26T12:36:30.274000"
        },
    ]
  }

  

                              

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."
            ]
        }
    }
  }



                              

Description for this error:
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."
            ]
        }
    }
  }



                              

Description for this error:
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"
    }
  }



                              

Description for this error:
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"
    }
  }



                              

Description for this error:
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."
    }
  }



                              

Description for this error:
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.628000"
        },
        {
            "coordinates": [
                69.543942,
                45.965876
            ],
            "altitude": 24.22,
            "activity": "running",
            "recorded_at": "2018-10-26T12:33:05.125362"
        },
        {
            "coordinates": [
                74.857632,
                50.422156
            ],
            "altitude": 25.12,
            "activity": "running",
            "recorded_at": "2018-10-26T12:33:60.336548"
        }
    ]
  }

  

                              

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."
            ]
        }
    }
  }



                              

Description for this error:
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."
            ]
        }
    }
  }



                              

Description for this error:
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"
    }
  }



                              

Description for this error:
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"
    }
  }



                              

Description for this error:
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."
    }
  }



                              

Description for this error:
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))

  }