Users

This set of APIs will help in fetching the user data, user location data and update the user events.

  • Pass your secret API key in the header

  • API parameter page_number, gives a maximum of 10 entries per page in response

  • Suffix of app_id represents device platform , i.e. "_1" for android and "_2" for iOS

  • For list APIs the "next_page" and "prev_page" fields will be "null" if not present. and "pages" will be 0 if not present.

get
Get User API

https://api.geospark.co/v1/api/user/
Get User API provides the list of users who are using your app corresponding to the project secret API key provided.
Request
Response
Request
Headers
Content-Type
required
string
application/json
Api-Key
required
string
33223kjhdcscijhb5sdbsdmjsdcbj5f
Query Parameters
user_id
optional
string
For searching a particular user. Note: Use this field for only searching. No other field should be combined with it. E.g. /api/user/?user_id=5c2f43e8fb979679beba0cce Input Data: 5bd2aee1eec1a55d8faf1193
timezone_offset
optional
string
If timezone is provided then the response will be returned as per provided local timezone. If the timezone is not passed, response will be returned in UTC. Input Data: Asia/Kolkata
start_date
optional
string
This field can be used for defining a start date from which the list of users 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 user list for same day will be returned. Input Data: 2018-10-20
page_number
optional
integer
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.
Response
200: OK
JSON
{
"status": true,
"msg": "Success.",
"code": 200,
"data": {
"next_page": null,
"pages": 1,
"prev_page": null,
"account_id": "5d15e6029694061560ed8d64",
"users": [
{
"id": "5d947b80e47bae6d700650cd",
"app_id": "5d15e65a9694061560ed8de7_1",
"device_token": "c6IDEE9eq7A:APA91bEg_q3zDuKNmlwIsSdDAdycCxrM-xGA8FcCRwIrTt5gCXCbAQWg2pUc25dB_-MbWeBrEEtgkCN0lbkwjuqNhls7pDotBSzdHTsyLOPVJ8i2dnrGSWj8aLHHYwCkX5xRCey2SeEe",
"device_uuid": "51ad2d53-9057-49c3-93cf-a4817045bf48",
"description": "James",
"brand": "asus",
"model": "ASUS_Z012DB",
"os_version": "26",
"sdk_version": "2.1.1",
"device_arn": "arn:aws:sns:us-east-1:218937252071:endpoint/GCM/app_5d15e65a9694061560ed8de7_1_ddba9c68-dee2-4e33-8258-ff7f7515a672/4f497606-3ae6-3c1d-99f6-a015af4fd42d",
"geofence_events": true,
"motion_events": true,
"trips_events": true,
"is_deleted": false,
"created_at": "2019-10-02T15:57:11.970",
"last_location_update": {
"id": "5d947b82e47bae6d700650ce",
"coordinates": {
"type": "Point",
"coordinates": [
77.6354213,
12.9143926
]
},
"speed": 0.0,
"accuracy": 26.04800033569336,
"altitude": 795.8999633789062,
"activity": "WALK",
"recorded_at": "2019-10-02T10:27:14.053",
"timezone_offset": "+0530",
"net_stat": true,
"gps_stat": true,
"motion_stat": true,
"app_stat": "MANUAL",
"battery_remaining": 57,
"bat_stat": "Unknown",
"bat_saver_mode": false,
"location_permission": true,
"airplane_mode": false,
"created_at": "2019-10-02T10:27:14.256"
}
},
{
"id": "5d94703396940667bc0a1732",
"app_id": "5d15e65a9694061560ed8de7_1",
"device_token": "d1QlKpq-QJU:APA91bFCKZIG3Ypi6n6Z5zZyo6w-E0ZJg6GRxoT7aImxURvlFDtlRkGllykc6g3kW7C0aPDYN2L8ouMr--WVDrJA3tU0pHRA-ENuNc0PIZUqipqKNfmq4NfELNGIjzRGJPtypK0PIKIs",
"device_uuid": "3da30854-1525-48a8-812d-bb17c797df47",
"description": "sujith",
"brand": "samsung",
"model": "SM-G950F",
"os_version": "28",
"sdk_version": "2.1.1",
"device_arn": "arn:aws:sns:us-east-1:218937252071:endpoint/GCM/app_5d15e65a9694061560ed8de7_1_ddba9c68-dee2-4e33-8258-ff7f7515a672/76560c7e-dfed-3b0f-85a8-8df5b7d75e19",
"geofence_events": true,
"motion_events": true,
"trips_events": true,
"is_deleted": false,
"created_at": "2019-10-02T15:08:59.020",
"last_location_update": {
"id": "5d94703596940667bc0a1736",
"coordinates": {
"type": "Point",
"coordinates": [
77.6353995,
12.9144113
]
},
"speed": 0.0,
"accuracy": 28.9419994354248,
"altitude": 795.899963378906,
"activity": "STOP",
"address": "GeoSpark, 164, 9th Main Road, Sector 5, HSR Layout Ward, Bommanahalli Zone, Bengaluru, Bangalore Urban, Karnataka, 560102, India"
"timezone_offset": "+0530",
"started_at": "2019-10-02T09:38:59.883",
"ended_at": "2019-10-02T09:39:00.512",
"net_stat": true,
"gps_stat": true,
"motion_stat": true,
"app_stat": "FOREGROUND",
"battery_remaining": 94,
"bat_stat": "Unknown",
"bat_saver_mode": false,
"location_permission": true,
"airplane_mode": false,
"created_at": "2019-10-02T09:39:01.371"
}
}
]
}
}

Sample Call

cURL
JavaScript
Python
Java
Swift
Go
cURL
curl -X GET \
'https://api.geospark.co/v1/api/user/?start_date=2019-01-10&end_date=2019-01-12&timezone_offset=Asia/Kolkata' \
-H 'Api-Key: 28c44e3f33de40fbafa0f9dad776b6b2'
JavaScript
var settings = {
"async": true,
"crossDomain": true,
"url": "https://api.geospark.co/v1/api/user/?start_date=2019-01-10&end_date=2019-01-12&timezone_offset=Asia/Kolkata"",
"method": "GET",
"headers": {
"Api-Key": "28c44e3f33de40fbafa0f9dad776b6b2"
}
}
$.ajax(settings).done(function (response) {
console.log(response);
});
Python
import requests
url = "https://api.geospark.co/v1/api/user/"
querystring = {"start_date":"2019-01-10","end_date":"2019-01-12","timezone_offset":"Asia/Kolkata"}
headers = {
'Api-Key': "28c44e3f33de40fbafa0f9dad776b6b2"
}
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/user/?start_date=2019-01-10&end_date=2019-01-12&timezone_offset=Asia/Kolkata")
.get()
.addHeader("Api-Key", "28c44e3f33de40fbafa0f9dad776b6b2")
.build();
Response response = client.newCall(request).execute();
Swift
import Foundation
let headers = [
"Api-Key": "28c44e3f33de40fbafa0f9dad776b6b2"
]
let request = NSMutableURLRequest(url: NSURL(string: "https://api.geospark.co/v1/api/user/?start_date=2019-01-10&end_date=2019-01-12&timezone_offset=Asia/Kolkata")! 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/user/?start_date=2019-01-10&end_date=2019-01-12&timezone_offset=Asia/Kolkata"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Api-Key", "28c44e3f33de40fbafa0f9dad776b6b2")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}

get
Get Location API

https://api.geospark.co/v1/api/location/
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.
Request
Response
Request
Headers
Content-Type
required
string
application/json
Api-Key
required
string
33223kjhdcscijhb5sdbsdmjsdcbj5f
Query Parameters
points_encoded
optional
boolean
This field can be used to get the location data in encoded polyline and time aware polyline. This will be false by default.
user_id
required
string
Filters the location data for the given user_id. Input Data: 5bb3177a02a89b3c7a6a8d4f
timezone_offset
optional
string
If timezone is provided then the response will be returned as per provided local timezone. If the timezone is not passed, response will be returned in UTC. If points_encoded value is true, then this value will be UTC by default. Input Data: Asia/Kolkata
start_date
optional
string
This field can be used for defining a start date from which the list of user's locations 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 user list for same day will be returned. Input Data: 2018-10-20
page_number
optional
integer
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. If points_encoded value is true, then this value will not be considered.
Response
200: OK
JSON
{
"status": true,
"msg": "Success.",
"code": 200,
"data": {
"next_page": 2,
"pages": 15,
"prev_page": null,
"app_id": "5d68c56255c9d50640802ff8_2",
"user_id": "5d931e4896940667bc0834dd",
"locations": [
{
"id": "5d93696096940667bc0893fe",
"coordinates": {
"type": "Point",
"coordinates": [
77.63033406133458,
13.01788769586474
]
},
"speed": 0.0,
"accuracy": 10.0,
"altitude": 897.4580940078257,
"activity": "STOP",
"address": "GeoSpark, 164, 9th Main Road, Sector 5, HSR Layout Ward, Bommanahalli Zone, Bengaluru, Bangalore Urban, Karnataka, 560102, India"
"timezone_offset": "+0530",
"started_at": "2019-10-01T14:57:05.444",
"ended_at": "2019-10-01T14:57:35.986",
"net_stat": true,
"gps_stat": true,
"motion_stat": true,
"app_stat": "BACKGROUND",
"battery_remaining": 98,
"bat_stat": "Charging",
"created_at": "2019-10-01T14:57:36.300"
},
{
"id": "5d93692b96940667bc08939a",
"coordinates": {
"type": "Point",
"coordinates": [
77.63077092364209,
13.017818061647022
]
},
"speed": 18.0,
"accuracy": 5.0,
"altitude": 902.267219543457,
"activity": "DRIVE",
"timezone_offset": "+0530",
"net_stat": true,
"gps_stat": true,
"motion_stat": true,
"app_stat": "BACKGROUND",
"battery_remaining": 97,
"bat_stat": "Charging",
"created_at": "2019-10-01T14:56:43.420",
"recorded_at": "2019-10-01T14:56:43.092"
},
{
"id": "5d93690396940667bc089332",
"coordinates": {
"type": "Point",
"coordinates": [
77.63258644386906,
13.017401564878428
]
},
"speed": 20.0,
"accuracy": 5.0,
"altitude": 902.8652420043945,
"activity": "DRIVE",
"timezone_offset": "+0530",
"net_stat": true,
"gps_stat": true,
"motion_stat": true,
"app_stat": "BACKGROUND",
"battery_remaining": 97,
"bat_stat": "Charging",
"created_at": "2019-10-01T14:56:03.421",
"recorded_at": "2019-10-01T14:56:03.078"
},
{
"id": "5d9368e196940667bc0892e5",
"coordinates": {
"type": "Point",
"coordinates": [
77.63434211730737,
13.016522638511859
]
},
"speed": 22.0,
"accuracy": 10.0,
"altitude": 907.4284744262695,
"activity": "DRIVE",
"timezone_offset": "+0530",
"net_stat": true,
"gps_stat": true,
"motion_stat": true,
"app_stat": "BACKGROUND",
"battery_remaining": 97,
"bat_stat": "Charging",
"created_at": "2019-10-01T14:55:29.285",
"recorded_at": "2019-10-01T14:55:29.082"
},
{
"id": "5d9368ca96940667bc0892b9",
"coordinates": {
"type": "Point",
"coordinates": [
77.63618052012998,
13.01624611952623
]
},
"speed": 15.0,
"accuracy": 5.0,
"altitude": 909.6889724731445,
"activity": "DRIVE",
"timezone_offset": "+0530",
"net_stat": true,
"gps_stat": true,
"motion_stat": true,
"app_stat": "BACKGROUND",
"battery_remaining": 97,
"bat_stat": "Charging",
"created_at": "2019-10-01T14:55:06.267",
"recorded_at": "2019-10-01T14:55:06.081"
},
{
"id": "5d93688f96940667bc089232",
"coordinates": {
"type": "Point",
"coordinates": [
77.6364021391822,
13.017499802693466
]
},
"speed": 23.0,
"accuracy": 10.0,
"altitude": 908.5708084106445,
"activity": "DRIVE",
"timezone_offset": "+0530",
"net_stat": true,
"gps_stat": true,
"motion_stat": true,
"app_stat": "BACKGROUND",
"battery_remaining": 97,
"bat_stat": "Charging",
"created_at": "2019-10-01T14:54:07.437",
"recorded_at": "2019-10-01T14:54:07.086"
},
{
"id": "5d93686de47bae6d7004c5d3",
"coordinates": {
"type": "Point",
"coordinates": [
77.63686545491203,
13.01945139072632
]
},
"speed": 19.0,
"accuracy": 10.068562831803998,
"altitude": 909.973518371582,
"activity": "DRIVE",
"timezone_offset": "+0530",
"net_stat": true,
"gps_stat": true,
"motion_stat": true,
"app_stat": "BACKGROUND",
"battery_remaining": 97,
"bat_stat": "Charging",
"created_at": "2019-10-01T14:53:33.295",
"recorded_at": "2019-10-01T14:53:33.091"
},
{
"id": "5d93684596940667bc0891b4",
"coordinates": {
"type": "Point",
"coordinates": [
77.63702449676983,
13.021435016003837
]
},
"speed": 10.0,
"accuracy": 11.166095059679792,
"altitude": 910.216194152832,
"activity": "DRIVE",
"timezone_offset": "+0530",
"net_stat": true,
"gps_stat": true,
"motion_stat": true,
"app_stat": "BACKGROUND",
"battery_remaining": 97,
"bat_stat": "Charging",
"created_at": "2019-10-01T14:52:53.272",
"recorded_at": "2019-10-01T14:52:53.101"
},
{
"id": "5d93680ae47bae6d7004c4c5",
"coordinates": {
"type": "Point",
"coordinates": [
77.63657012402616,
13.02296174115325
]
},
"speed": 0.0,
"accuracy": 10.0,
"altitude": 902.1354044576965,
"activity": "STOP",
"address": "GeoSpark, 164, 9th Main Road, Sector 5, HSR Layout Ward, Bommanahalli Zone, Bengaluru, Bangalore Urban, Karnataka, 560102, India"
"timezone_offset": "+0530",
"started_at": "2019-10-01T14:51:23.087",
"ended_at": "2019-10-01T14:51:53.976",
"net_stat": true,
"gps_stat": true,
"motion_stat": true,
"app_stat": "BACKGROUND",
"battery_remaining": 97,
"bat_stat": "Charging",
"created_at": "2019-10-01T14:51:54.176"
}
]
}
}

Sample Call

cURL
JavaScript
Python
Java
Swift
Go
cURL
curl -X GET \
'http://api.geospark.co/v1/api/location/?user_id=5c90e5b19533a37823dd4331' \
-H 'Api-Key: aef49fac20f9475ebb880319b0c54d00' \
-H 'Postman-Token: 99aa945c-7fbd-4642-ab9c-ca17e66d2579' \
-H 'cache-control: no-cache'
JavaScript
var settings = {
"async": true,
"crossDomain": true,
"url": "https://api.geospark.co/v1/api/location/?user_id=5bb3177a02a89b3c7a6a8d4f&start_date=2019-01-06&end_date=2019-01-09&page_number=1",
"method": "GET",
"headers": {
"Api-Key": "eade6d3a72924eb895a19feb44895372"
}
}
$.ajax(settings).done(function (response) {
console.log(response);
});
Python
import requests
url = "https://api.geospark.co/v1/api/location/"
querystring = {"user_id":"5bb3177a02a89b3c7a6a8d4f","start_date":"2019-01-06","end_date":"2019-01-09","page_number":"1"}
headers = {
'Api-Key': "eade6d3a72924eb895a19feb44895372"
}
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/location/?user_id=5bb3177a02a89b3c7a6a8d4f&start_date=2019-01-06&end_date=2019-01-09&page_number=1")
.get()
.addHeader("Api-Key", "eade6d3a72924eb895a19feb44895372")
.build();
Response response = client.newCall(request).execute();
Swift
import Foundation
let headers = [
"Api-Key": "eade6d3a72924eb895a19feb44895372"
]
let request = NSMutableURLRequest(url: NSURL(string: "https://api.geospark.co/v1/api/location/?user_id=5bb3177a02a89b3c7a6a8d4f&start_date=2019-01-06&end_date=2019-01-09&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/location/?user_id=5bb3177a02a89b3c7a6a8d4f&start_date=2019-01-06&end_date=2019-01-09&page_number=1"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Api-Key", "eade6d3a72924eb895a19feb44895372")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}

put
Update User API

https://api.geospark.co/v1/api/user/
This API lets you enable or disable the events for the given user_id.
Request
Response
Request
Path Parameters
Content-Type
required
string
application/json
Api-key
required
string
3323kjhdcscijhb5sdbsdmjsdcbj5f
Body Parameters
user_id
required
string
User id which need to be updated.
motion_events
optional
boolean
Turn on/off events for change in activity.
geofence_events
optional
boolean
Turn on/off geofence events.
trips_events
optional
boolean
Turn on/off trips events.
Response
200: OK
{
"status": true,
"msg": "Success.",
"code": 200,
"data": {
"id": "5d948d735f37c615833719d2",
"account_id": "5d01de8aaa6ad90610ac7aaf",
"app_id": "5d948d61670dc805827b09b5_2",
"device_token": "devicetoken",
"device_uuid": null,
"description": "postman device test",
"brand": "Samsung",
"model": "S8",
"group_id": null,
"os_version": "8.1",
"sdk_version": "2.1",
"device_arn": null,
"geofence_events": true,
"motion_events": true,
"trips_events": true,
"metadata": null,
"is_deleted": false,
"created_at": "2019-10-02T11:43:47.765",
"updated_at": "2019-10-02T12:20:34.749"
}
}

Sample Call

cURL
Go
JavaScript
Python
Java
cURL
curl -X PUT \
http://api.geospark.co/v1/api/user/ \
-H 'Api-Key: cbdd0c41a4e5461e97d1fbedb67f159f' \
-H 'Content-Type: application/json' \
-d '{
"user_id": "5d948d735f37c615833719d2",
"geofence_events": true,
"motion_events": true,
"trips_events": true
}'
Go
package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
url := "http://api.geospark.co/v1/api/user/"
payload := strings.NewReader("{\t\n\t\"user_id\": \"5d948d735f37c615833719d2\",\n\t\"geofence_events\": true,\n\t\"motion_events\": true,\n\t\"trips_events\": true\n}")
req, _ := http.NewRequest("PUT", url, payload)
req.Header.Add("Api-Key", "cbdd0c41a4e5461e97d1fbedb67f159f")
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))
}
JavaScript
var settings = {
"async": true,
"crossDomain": true,
"url": "http://api.geospark.co/v1/api/user/",
"method": "PUT",
"headers": {
"Api-Key": "cbdd0c41a4e5461e97d1fbedb67f159f",
"Content-Type": "application/json"
},
"processData": false,
"data": "{\t\n\t\"user_id\": \"5d948d735f37c615833719d2\",\n\t\"geofence_events\": true,\n\t\"motion_events\": true,\n\t\"trips_events\": true\n}"
}
$.ajax(settings).done(function (response) {
console.log(response);
});
Python
import requests
url = "http://api.geospark.co/v1/api/user/"
payload = "{\t\n\t\"user_id\": \"5d948d735f37c615833719d2\",\n\t\"geofence_events\": true,\n\t\"motion_events\": true,\n\t\"trips_events\": true\n}"
headers = {
'Api-Key': "cbdd0c41a4e5461e97d1fbedb67f159f",
'Content-Type': "application/json"
}
response = requests.request("PUT", url, data=payload, headers=headers)
print(response.text)
Java
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\t\n\t\"user_id\": \"5d948d735f37c615833719d2\",\n\t\"geofence_events\": true,\n\t\"motion_events\": true,\n\t\"trips_events\": true\n}");
Request request = new Request.Builder()
.url("http://api.geospark.co/v1/api/user/")
.put(body)
.addHeader("Api-Key", "cbdd0c41a4e5461e97d1fbedb67f159f")
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();