API
API REST de Camlytics Service
Camlytics Service proporciona una forma conveniente de acceder a eventos analíticos, informes, datos de ubicaciones y canales de forma programática.
Para mayor comodidad, puedes probar y explorar la API utilizando nuestra Colección de Postman.
Contiene solicitudes preconfiguradas para los puntos finales más comunes.
Puedes descargar la colección aquí: Colección de Postman
También puedes estar interesado en los webhooks para métricas en tiempo real como
la ocupación actual y
la cola actual.
Si planeas recibir eventos analíticos en tiempo real, recomendamos usar webhooks.
Si estás interesado en recibir de forma programática los
Informes, puedes optar por
feeds de informes.
Clave de API
La autenticación en la API REST del Servicio requiere una Clave de API válida.
Las claves de API públicas y secretas se pueden encontrar en la sección de claves de API en la Configuración.
Firma de solicitud
Sigue los siguientes pasos para firmar tu solicitud de API:
- Crea un HMAC SHA512 utilizando la clave secreta de tu API y el valor de la URI de la solicitud.
- Incluye el hash resultante en tu solicitud en el encabezado de solicitud X-Sign.
Ejemplo:
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)
Limitación de solicitudes
El límite actual de solicitudes es de 1 solicitud por segundo. Si realizas más solicitudes, recibirás un código de error 503 o 429.
Parámetros de solicitud
Parámetros de encabezado requeridos
X-key - clave de API pública
X-Sign - HMAC SHA512 utilizando la clave secreta de tu API y el valor de la URI de la solicitud
Parámetro de cadena de consulta requerido
Nonce - un valor generado por el usuario que aumenta monótonamente (recomendamos un sello de tiempo de estilo UNIX en formato de segundo de época). Nonce debe ser mayor que el anterior.
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 /channelsQuery 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 /locationsQuery 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 /locations/statusQuery parameters
Return type
Example data
{ "msg" : "success", "result" : [ { "id" : 123, "state" : "offline", "channels" : [ ] }, { "id" : 124, "state" : "online", "channels" : [ { "id" : "35576ahb-56656-45781-acb45_000015E2", "state" : "Camera OK" }, { "id" : "76576ahb-56656-45781-acb45_00001547", "state" : "No signal" } ] } ], "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_200_7get /triggersQuery 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 /eventsQuery 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/triggersQuery 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/typesQuery 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 /histogramsQuery 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-LocationStatus-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-inline_response_200_7-
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
inline_response_200_7 - Up
Webhooks
Los webhooks son la forma preferida de recibir eventos en tiempo real sin realizar solicitudes excesivas. Para hacerlo, necesitarías un punto de recepción de webhook.
Para propósitos de prueba, puedes usar el servicio requestbin.com.
Para acceder a la configuración de webhooks, en el portal en la nube, ve a Configuración > Webhooks. Allí, configurarías el punto final para cada uno de los canales agregados o para toda la ubicación. Si configuras el webhook para toda la ubicación, recibirías todos los eventos de cualquiera de los canales de la ubicación.
La estructura JSON del evento del webhook es muy similar a la estructura de la API. El tiempo del evento está en la zona horaria UTC. El tiempo de espera predeterminado del webhook es de 10 segundos.
[ { "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" } ]
Alimentación de datos de informes
Además de visualizar informes en el panel de control, también puedes recuperar cualquier dato de informe de forma programática a través de la API en formatos JSON o CSV. Esto es útil para la automatización, la integración con sistemas externos, análisis personalizados y copias de seguridad.
Cada feed es una URL que proporciona datos de informe actualizados en función de todos los filtros y parámetros aplicados. Se admite la autenticación básica y con Token Bearer.
Power BI
Los eventos de Camlytics también se pueden exportar a Microsoft Power BI utilizando un feed de datos de eventos. Conecta la URL del feed como una fuente de datos web para construir informes interactivos, paneles de control y visualizaciones personalizadas en Power BI.
Consulta la sección de Feed de datos de eventos para obtener instrucciones sobre cómo generar y utilizar la URL del feed.