Events

The Get Events API lets you fetch the entry or exit events of the users from your event enabled geofences. The API also lets you filter by user or geofence, or location, and other options.

get
Get Events API

https://api.geospark.co/v1/api/event/
This API is responsible for giving the list of events.
Request
Response
Request
Headers
Api-Key
required
string
33223kjhdcscijhb5sdbsdmjsdcbj5f
Content-Type
required
string
application/json
Query Parameters
start_date
optional
string
This field can be used for defining a start date from which the list of events needs to shown. Input Data: 2018-10-19
end_date
optional
string
This field can be used to define a range of time till when the last document needs to be provided. 'end_date' should always be greater than 'start_date'. If end_date is provided then start_date should also be provided. If only start_date is passed, the event list for same day will be returned. Input Data: 2018-10-20
user_id
optional
string
Filters events data for the given user_id.
page_number
optional
integer
Returns the data in the page provided. A page will have a maximum of 10 entries. If the response returns an empty list in data field, it is safe to assume the pages are exhausted.
geofence_id
optional
string
Returns Events only for the given geofence_id. Input Data: 5bd2aee1eec1a50d8faf1293
location_id
optional
string
Used to check if there's an event associated with a particular location, identified by it's location_id. Input Data: 5bd2ab9deec1a50c7fa75581
event_type
optional
string
Filter by entry or exit type events. Input Data: entry or exit
Response
200: OK
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"
}
]
}
}

Sample Call

cURL
JavaScript
Python
Java
Swift
Go
cURL
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'
JavaScript
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);
});
Python
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)
Java
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();
Swift
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()
Go
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))
}