TrackerPro Admin API: Overview
September 13, 2024TrackerPro Admin API: Creating PAYT Clients & Users
September 13, 2024TrackerPro Admin API: Data Concepts
Type 2 responses (ones with dataset) are returned from the TrackerPro Admin API in a format that is based on (but does not fully follow) the Google Visualization JSON format. This is described here:
A typical successful call to the TrackerPro Admin API will result in a status of “ok” and a “dataset” field. This is where the payload of the TrackerPro Admin API deviates a little from a Google DataSource.
{
"version":"0.6",
"reqId":"0",
"status":"ok",
"sig":"-42971447",
"dataset":{........}
A Google DataSource would normally contain a field ‘table’, the TrackerPro Admin APIcontains a “dataset” field. The Pay as you Track “dataset” field is a simple object that allows for an array of tables.
{
"dataset":{
"datasetname":"TasksDataSet",
"tables":[....
Each table in the ‘tables’ array is formatted as a self describing Google DataSource table. This allows for multiple data fragments to be returned from the server in the same call. If desired the data in these tables can be used to create a Google Visualization DataTable (new DataTable(…)) for use in Google Visualizations.
An Example
Lets look at an example. Here is a truncated response from the Admin-GetTasksByDate call.
{
"version":"0.6",
"reqId":"",
"status":"ok",
"sig":"-1819704926",
"dataset":{
"datasetname":"TasksDataSet",
"tables":[
{
"cols":[
{
"id":"0",
"label":"TaskID",
"type":"number",
"p":{
"autoincrement":true
}
},
{
"id":"1",
"label":"ExtID",
"type":"number",
"p":{
}
},
{
"id":"2",
"label":"Type",
"type":"string",
"p":{
}
},
{
"id":"3",
"label":"Name",
"type":"string",
"p":{
}
},
{
"id":"4",
"label":"Description",
"type":"string",
"p":{
}
},
{
"id":"5",
"label":"StartDateTime",
"type":"datetime",
"p":{
}
},
{
"id":"6",
"label":"EndDateTime",
"type":"datetime",
"p":{
}
},
{
"id":"7",
"label":"GracePeriodMins",
"type":"number",
"p":{
}
},
{
"id":"8",
"label":"AssignedTo",
"type":"string",
"p":{
}
},
{
"id":"9",
"label":"RegionGeoJson",
"type":"string",
"p":{
}
},
{
"id":"10",
"label":"ParameterJson",
"type":"string",
"p":{
}
},
{
"id":"11",
"label":"Status",
"type":"string",
"p":{
}
},
{
"id":"12",
"label":"ETA",
"type":"datetime",
"p":{
}
},
{
"id":"13",
"label":"ArrivedDateTime",
"type":"datetime",
"p":{
}
},
{
"id":"14",
"label":"DepartedDateTime",
"type":"datetime",
"p":{
}
},
{
"id":"15",
"label":"ModifierID",
"type":"number",
"p":{
}
},
{
"id":"16",
"label":"ClientName",
"type":"string",
"p":{
}
}
],
"rows":[
{
"c":[
{
"v":1
},
{
"v":666
},
{
"v":"APPOINTMENT"
},
{
"v":"MyName"
},
{
"v":"MyDescription"
},
{
"v":1725958800000
},
{
"v":1725962400000
},
{
"v":60
},
{
"v":"5151"
},
{
"v":"{\"type\": \"Point\",\"coordinates\": [-1.8198263664727126,53.925394269663265],\"radius\": 200}"
},
{
"v":"{}"
},
{
"v":"PENDING"
},
{
"v":null
},
{
"v":null
},
{
"v":null
},
{
"v":0
},
{
"v":"Demo"
}
],
"p":{
"rowstate":"unchanged"
}
}
],
"p":{
"tablename":"Tasks",
"primarykey":[0
]
}
}
]
}
}
We can see that the dataset is called TasksDataSet, and contains one table called ‘Tasks’. Important properties of the returned json include the “cols” array (table column descriptors) and “rows” array (the actual data).
DateTimes
The section details how datetimes are returned in the JSON response. The JSON specification doesn’t have a standard for returning datetimes.
By default, the TrackerPro Admin API returns datetimes as a number of milliseconds since 1970. Here is a JSON fragment showing the default way that dates are returned.
"cols":[
{
"id":"0",
"label":"CurrentUTC",
"type":"datetime",
"p":{}
}
],
"rows":[
{
"c":[
{
"v":1614936565690
}
],
"p":{}
}
]...
If this isn’t to your liking a developer can pass a ‘dtm’ query parameter and set a datetime format string. To return dates in ISO format set this as dtm=o. For example, “2021-03-05T09:46:31.4570000”
Back to: Contents