API
Camlytics Service REST API
Camlytics Service provides a convenient way to access analytical events, reports, locations and channels data programmatically.
You may also be interested in webhooks for real-time metrics like
current occupancy and
current queue.
If you plan to receive analytical events in real time, we recommend using webhooks.
If you are interested in programmatic receiving the
Reports data, you may opt for
report feeds.
API key
Authentication to the Service REST API requires a valid API Key.
Public and secret API keys can be found in API key section in the Settings.
Request signing
Do the following steps to sign your API request:
- Create a SHA512 HMAC using your API Key secret and the request URI value.
- Include the resulting hash in your request in the X-Sign request header.
Example:
Javascript
const Crypto = require('crypto'); // if you use the since or/and until parameter. You should process it with encodeURIComponent function const since = encodeURIComponent('2020-10-13T06:12:00.000+01:00'); // 2020-10-13T06%3A12%3A00.000%2B01%3A00 const requestUri = '/service/api/v1/events?location_id=32&nonce=154&since=' + since; const secret = 'ehsd7485746548574'; const signature = Crypto.createHmac('sha512', secret) .update(requestUri) .digest('hex');
PHP
<?php // if you use the since or/and until parameter. You should process it with urlencode function $since = urlencode('2020-10-12T14:00:00Z'); // 2020-10-12T14%3A00%3A00Z $requestUri = '/service/api/v1/events?location_id=32&nonce=154&since=' . $since; $secret = 'ehsd7485746548574'; $sign = hash_hmac("sha512", $requestUri, $secret)
Request throttling
The current request limit is 1 request per second. If you make more requests you will receive response 503 or 429 error code.
Request parameters
Required header parameters
X-key - public API key
X-Sign - SHA512 HMAC using your API Key secret and the request URI value
Required query string parameter
Nonce - a monotonically increasing user-generated value (we recommend a UNIX-style timestamp in epoch second format). Nonce must be more than the previous one.
Methods & Models
Access
- APIKey
KeyParamName: X-Key
KeyInQuery:false
KeyInHeader:true - Signature
KeyParamName: X-Sign
KeyInQuery:false
KeyInHeader:true
Methods
[ Jump to Models ]Table of Contents
Dictionaries
Statistic
Dictionaries
get /channels
Query parameters
Return type
Example data
{ "msg" : "success", "result" : [ { "name" : "Lobby", "paid" : 0, "active" : 1, "id" : "47576ahb-56656-45786-acb45_000015E2", "location_id" : 123 }, { "name" : "Lobby", "paid" : 0, "active" : 1, "id" : "47576ahb-56656-45786-acb45_000015E2", "location_id" : 123 } ], "code" : 0 }
Produces
This API call produces the following media types according to the Accept request header; the media type will be conveyed by the Content-Type response header.application/json
Responses
200
channels list matching criteria inline_response_200_1get /locations
Query parameters
Return type
Example data
{ "msg" : "success", "result" : [ { "name" : "Manhattan store", "id" : 123, "version" : "3.2.1", "timezone_offset" : "+00:00", "hash" : "SwU8JH3ldduwsZoxzamSCNU9Xd/lCQGCUUQyJ/Fz9e0+Y+CTVKRvHsYZDBlsFMuVXps1UTFYea8wds6tiyEPSxsJUsKry3C3/1eMNs3h6y0dNYlqnMFCTR/J8NkujrBdndZyxATevYDPIidn51ZcU79DFWq1NYVnrYoY4pxCMNDNppZsCap0tAnGvyvq43MlKN1qvONBC/p5vVXf5bdfMGB3mhEhMTQ" }, { "name" : "Manhattan store", "id" : 123, "version" : "3.2.1", "timezone_offset" : "-04:00", "hash" : "SwU8JH3ldduwsZoxzamSCNU9Xd/lCQGCUUQyJ/Fz9e0+Y+CTVKRvHsYZDBlsFMuVXps1UTFYea8wds6tiyEPSxsJUsKry3C3/1eMNs3h6y0dNYlqnMFCTR/J8NkujrBdndZyxATevYDPIidn51ZcU79DFWq1NYVnrYoY4pxCMNDNppZsCap0tAnGvyvq43MlKN1qvONBC/p5vVXf5bdfMGB3mhEhMTQ" } ], "code" : 0 }
Produces
This API call produces the following media types according to the Accept request header; the media type will be conveyed by the Content-Type response header.application/json
Responses
200
locations list matching criteria inline_response_200get /triggers
Query parameters
Return type
Example data
{ "msg" : "success", "result" : [ { "name" : "Enter", "active" : 1, "id" : "47576ahb-56656-45786-acb45_000015E2", "type" : "Line", "channel_id" : "35576ahb-56656-45781-acb45_000015E2", "location_id" : 123 }, { "name" : "Enter", "active" : 1, "id" : "47576ahb-56656-45786-acb45_000015E2", "type" : "Line", "channel_id" : "35576ahb-56656-45781-acb45_000015E2", "location_id" : 123 } ], "code" : 0 }
Produces
This API call produces the following media types according to the Accept request header; the media type will be conveyed by the Content-Type response header.application/json
Responses
200
triggers list matching criteria inline_response_200_2Statistic
get /events
Query parameters
Return type
Example data
{ "msg" : "success", "result" : [ { "record_id" : 1635343534, "event_type" : "RegionJoin", "snapshot_id" : -235343534, "trigger_id" : "47576ahb-56656-45786-acb45_000015E2", "origin" : "Pedestrian", "suborigin" : "Unknown", "age_range" : "", "gender" : "", "id" : 34454545, "channel_id" : "35576ahb-56656-45781-acb45_000015E2", "object_id" : 6, "location_id" : 123, "event_time" : "2000-01-23T04:56:07.000+00:00" }, { "record_id" : 1635343534, "event_type" : "RegionJoin", "snapshot_id" : -235343534, "trigger_id" : "47576ahb-56656-45786-acb45_000015E2", "origin" : "Vehicle", "suborigin" : "Car", "age_range" : "", "gender" : "", "id" : 34454545, "channel_id" : "35576ahb-56656-45781-acb45_000015E2", "object_id" : 6, "location_id" : 123, "event_time" : "2000-01-23T04:56:07.000+00:00" }, { "record_id" : 1635343534, "event_type" : "RegionJoin", "snapshot_id" : -235343534, "trigger_id" : "47576ahb-56656-45786-acb45_000015E2", "origin" : "Face", "suborigin" : "", "age_range" : "26 - 35", "gender" : "Male", "id" : 34454545, "channel_id" : "35576ahb-56656-45781-acb45_000015E2", "object_id" : 6, "location_id" : 123, "event_time" : "2000-01-23T04:56:07.000+00:00" } ], "code" : 0 }
Produces
This API call produces the following media types according to the Accept request header; the media type will be conveyed by the Content-Type response header.application/json
Responses
200
events list matching criteria inline_response_200_3get /totals/triggers
Query parameters
Return type
Example data
{ "msg" : "success", "result" : [ { "trigger_name" : "Exit", "trigger_id" : "35576ahb-56656-45781-acb45_000015E2", "count" : 3012, "channel_id" : "85576ahb-56656-45781-acb41_000015E2", "location_id" : 423 }, { "trigger_name" : "Exit", "trigger_id" : "35576ahb-56656-45781-acb45_000015E2", "count" : 3012, "channel_id" : "85576ahb-56656-45781-acb41_000015E2", "location_id" : 423 } ], "code" : 0 }
Produces
This API call produces the following media types according to the Accept request header; the media type will be conveyed by the Content-Type response header.application/json
Responses
200
number of events matching criteria grouped by triggers inline_response_200_4get /totals/types
Query parameters
Return type
Example data
{ "msg" : "success", "result" : [ { "count" : 4712, "type" : "TripwireCrossed", "channel_id" : "35576ahb-56656-45781-acb45_000015E2" }, { "count" : 4712, "type" : "TripwireCrossed", "channel_id" : "35576ahb-56656-45781-acb45_000015E2" } ], "code" : 0 }
Produces
This API call produces the following media types according to the Accept request header; the media type will be conveyed by the Content-Type response header.application/json
Responses
200
number of events matching criteria grouped by types inline_response_200_5get /histograms
Query parameters
Return type
Example data
{ "msg" : "success", "result" : [ { "trigger_id" : "47576ahb-56656-45786-acb45_000015E2", "id" : 34454545, "channel_id" : "35576ahb-56656-45781-acb45_000015E2", "counting_data" : [ 3400.3, 199.7 ], "lifetime_data" : [ 10, 4, 0, 1 ], "location_id" : 123, "histogram_time" : "2000-01-23T04:00:00+00:00" }, { "trigger_id" : "47576ahb-56656-45786-acb45_000015E2", "id" : 34454545, "channel_id" : "35576ahb-56656-45781-acb45_000015E2", "counting_data" : [ 3600 ], "lifetime_data" : [ ], "location_id" : 123, "histogram_time" : "2000-01-23T05:00:00+00:00" } ], "code" : 0 }
Produces
This API call produces the following media types according to the Accept request header; the media type will be conveyed by the Content-Type response header.application/json
Responses
200
histograms list matching criteria inline_response_200_6Models
[ Jump to Methods ]Table of Contents
Channel
-Event
-EventTotalByTrigger
-EventTotalByType
-Histogram
-Location
-Trigger
-inline_response_200
-inline_response_200_1
-inline_response_200_2
-inline_response_200_3
-inline_response_200_4
-inline_response_200_5
-inline_response_200_6
-
Event
- Up
Histogram
- Up
Location
- Up
inline_response_200
- Up
inline_response_200_1
- Up
inline_response_200_2
- Up
inline_response_200_3
- Up
inline_response_200_4
- Up
inline_response_200_5
- Up
inline_response_200_6
- Up
Webhooks
Webhooks are the preferred way to receive events in real-time without making any excessive requests. In order to do that, you would need a webhook receiving endpoint.
For testing purposes, you can use requestbin.com service.
In order to access the webhooks settings, in cloud portal, go to Settings > Webhooks. There, you would set up the endpoint for each of the added channels or for the whole location. If you set the webhook for the whole location you would receive all events for any of the location channels.
The JSON structure of the webhook event is very similar to the API structure. The default webhook timeout is 10 seconds. The time of the event is in UTC time zone.
[ { "record_id" : 1635343534, "event_type" : "RegionJoin", "snapshot_id" : -235343534, "trigger_id" : "47576ahb-56656-45786-acb45_000015E2", "origin" : "Pedestrian", "suborigin" : "Unknown", "age_range" : "", "gender" : "", "id" : null, "channel_id" : "35576ahb-56656-45781-acb45_000015E2", "object_id" : 6, "location_id" : 123, "event_time" : "2000-01-23 04:56:07.000" }, { "record_id" : 1635343534, "event_type" : "RegionJoin", "snapshot_id" : -235343534, "trigger_id" : "47576ahb-56656-45786-acb45_000015E2", "origin" : "Vehicle", "suborigin" : "Car", "age_range" : "", "gender" : "", "id" : null, "channel_id" : "35576ahb-56656-45781-acb45_000015E2", "object_id" : 6, "location_id" : 123, "event_time" : "2000-01-23 04:56:07.000" }, { "record_id" : 1635343534, "event_type" : "RegionJoin", "snapshot_id" : -235343534, "trigger_id" : "47576ahb-56656-45786-acb45_000015E2", "origin" : "Face", "suborigin" : "", "age_range" : "26 - 35", "gender" : "Male", "id" : null, "channel_id" : "35576ahb-56656-45781-acb45_000015E2", "object_id" : 6, "location_id" : 123, "event_time" : "2000-01-23 04:56:07.000" } ]