API Documentation

 

In the backend, we refer to Stores as Zones, so each store is related to a zone number.  This allows for multiple sensors to be associated with one zone.  In the example below we have zone 1, and sensor 4

 

The DEV environment currently is  https://web-new.scraffic.com. Set this as the default url for the examples below. The dataset will be returned in JSON formating.

 

POST sign_in

 

A validation token good for a session. The token must be sent with every request

SEND

$URL/users/sign_in.json?user[email]=example@example.com&user[password]=example

Curl example:

shell$ curl https://web-new.scraffic.com/users/sign_in.json -d user[email]=example@example.com -d user[password]=example

RECEIVE

{“token”:”TX3oRRsDTTP-h9Bta4Ni”}

 

To retrieve the list of zones (also thought of as stores) you’ll want to get a list of all the zones available to that user account.

 

GET /zones

SEND  

$URL/zones.json?token=token_received

Curl example:

shell$ curl https://web-new.scraffic.com/zones.json -G -d token=”xPQ5HBh1qZLfnPUciJfN”

RECEIVED

[{“id”:1,

“name”:”HillStree”,

“User_id”:49,

“Sensor_id”:null,

“url”:”https://web-new.scraffic.com/zones/19.json”},

{“id”:2,

“name”:”Copley”,

“user_id”:2,

“sensor_id”:null,

“url”:”https://web-new.scraffic.com/zones/2.json”}

]

 

-This will return zones for that user.

 

GET /zone/$ID/sensors

 

This will get the sensors for a particular zone in the previous time period (default 24h)

SEND

$URL/zones/1/sensors.json?token=token_received

Curl example

shell$ curl https://web-new.scraffic.com/zones/1/sensors.json -G -d token=”xPQ5HBh1qZLfnPUciJfN”

RECEIVED

[{“id”:4,

“zone_id”:”1″,

“count”:39,

“created_at”:”2016-05-10T02:57:54.000Z”,

“updated_at”:”2016-06-14T17:42:11.000Z”,

“user_id”:1,

“name”:”NZ2″,

“uuid”:null},

{“id”:6,

“zone_id”:”1″,

“count”:23,

“created_at”:

“2016-06-21T03:34:32.000Z”,

“updated_at”:

“2016-06-21T03:34:32.000Z”,

“user_id”:2,

“name”:”NZ2″,

“uuid”:null}

]

 

GET /zones/$ID/sensors/$ID.json

-This will return number of counts between specified dates by hour for the given sensor.

SEND

$URL/zones/1/sensors/4.json?start=20160801&end=20160801 &interval=3600

Curl Example:

curl https://web-new.scraffic.com/zones/1/sensors/4.json -G -d token=”xPQ5HBh1qZLfnPUciJfN” -d start=20160801 -d end=20160802 -d interval=3600

RECEIVED

{“time”:

[“Aug 01 11:00”,

“Aug 01 12:00”,

“Aug 01 14:00”,

“Aug 01 15:00”,

“Aug 01 16:00”,

“Aug 01 17:00”,

“Aug 01 18:00”,

“Aug 01 19:00”,

“Aug 01 20:00”,

“Aug 01 21:00”,

“Aug 01 22:00”,

“Aug 01 23:00”,

“Aug 02 00:00”,

“Aug 02 01:00”,

“Aug 02 03:00”,

“Aug 02 13:00”,

“Aug 02 14:00”,

“Aug 02 15:00”,

“Aug 02 16:00”,

“Aug 02 17:00”,

“Aug 02 18:00”,

“Aug 02 19:00”,

“Aug 02 20:00”,

“Aug 02 21:00”,

“Aug 02 22:00”,

“Aug 02 23:00”],

“count”:

[0,0,0,0,1.0,0,6.0,0,0,0,0,0,0,0,0,1.0,0,0,0,2.0,0,2.0,0,0,0],

 

“no_of_counts”:12}