This article is a simple guide on how to use CLUe API to retrieve event logs from CLUe Server.
Below examples uses cURL and C# WPF .NET examples.
TABLE OF CONTENTS
Prerequisite
In order to use CLUe API, you must have the following information provided .
- Your store's PlaceID
- API Key
- Device connected to CLUe for authentication
Register User
In order to authenticate user in device, you need to first register the user in CLUe.
Users are then automatically synced to connected devices in realtime.
1. API endpoint and Parameters
[POST] https://api.moon.supremainc.com/v1/be/places/:placeId/auths
Request Header:
Key | Type | Required | Value |
---|---|---|---|
Authorization | JWT Token | yes | Use API Key obtained from Suprema |
Content-Type | String | yes | application/json |
Accept | String | yes | */* |
Path Variables:
Key | Type | Required | Description |
---|---|---|---|
placeId | Number | yes | The assigned placeID of your store. Please request information from Suprema |
2. Request Body
Please request below information from your Suprema Agent.
Field | Type | Required | Remarks |
---|---|---|---|
user | Object | yes | |
user.name | String | yes | |
user.key | String | yes | Unique Key that customer can define. |
auth | Object | yes | |
auth.activeStatus | String | yes | ACTIVE or INACTIVE |
auth.startTime | Number | yes | Unix Time (Epoch milli second ) |
auth.endTime | Number | yes | Unix Time (Epoch milli second ) |
auth.doorAccessType | String | yes | ALL_DOOR or SPECIFIC ** If SPECIFIC, list the doors in auth.doorIds |
auth.scheduleType | String | yes | ALWAYS or SPECIFIC ** If SPECIFIC, list the schedule in auth.scheduleId |
auth.scheduleId | String | ||
auth.doorIds | Array | list of doors | |
auth.credentials | Object | yes | |
auth.credentials.cards | Array | list of card ID (decimal) | |
auth.credentials.faceImages | String | base64 image | |
auth.credentials.pin | Number | ||
auth.credentials.phone | Number |
Sample:
curl --location 'https://api.moon.supremainc.com/v1/be/places/178/auths' \ --header 'Content-Type: application/json' \ --header 'Authorization: ••••••' \ --data '{ "user": { "key": "1234567", "name": "namehere" }, "auth": { "startTime": 1718809200000, "endTime": 1718895540000, "doorAccessType": "SPECIFIC", "doorIds":[234, 235,236], "scheduleType":"SPECIFIC", "scheduleId":333, "credentials": { "cards": [ { "cardNumber": "12345", "formatType": "CSN" } ], "faceImages":["/9j/4AAQSkZJRgABAQAASABIAA..."] }, "activeStatus":"ACTIVE" } }'
3. Response Body
Field | Type | Nullable | Remarks |
---|---|---|---|
code | Number | No | API response code |
status | Boolean | No | API response status |
message | String | No | API response message |
data | Object | No | |
data.authId | Number | No | |
data.lastModifiedAt | Number | No | |
user | Object | No | |
user.userId | Number | No | |
user.key | String | No | |
user.name | String | No | |
user.realNameAuthStatusType | String | No | |
auth | Object | No | |
auth.startTime | Number | No | |
auth.endTime | Number | No | |
auth.doorAccessType | String | No | |
auth.scheduleType | String | No | |
auth.scheduleId | Number | Yes | |
auth.doors | Object | Yes | |
auth.doors.doorId | String | Yes | |
auth.doors.doorName | String | Yes | |
auth.credentials | Object | Yes | |
auth.credentials.modes | Array | Yes | |
auth.credentials.faceImages | String | Yes | |
auth.credentials.name | String | Yes | |
auth.activeStatus | String | No |
{ "code": 200, "status": true, "message": "OK", "data": { "authId": 118926, "lastModifiedAt": 1718841401642, "user": { "userId": 106569, "key": "34dab180-a14b-103b-8a4e-1166f21964da", "name": "test", "realNameAuthStatusType": "REAL_NAME_AUTH_BEFORE" }, "auth": { "startTime": 1718809200000, "endTime": 1718895540000, "doorAccessType": "SPECIFIC", "scheduleType": "SPECIFIC", "scheduleId": 333, "doors": [ { "doorId": 234, "doorName": "SmartLight" } ], "credentials": { "modes": [ "FACE" ], "faceImages": [ "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHAAAA..." ], "name": "test" }, "activeStatus": "ACTIVE" } } }
Retrieve Logs
1. API endpoint and Parameters
[GET] https://api.moon.supremainc.com/v1/be/events?startTime=1719932400000&endTime=1720623540000&filterEvents=DEV_FACE_AUTH_SUCCESS%2CDEV_FACE_AUTH_FAIL&page=0&size=200&sort=id%2Casc&placeId={placeID}
Request Header:
Key | Type | Required | Value |
---|---|---|---|
Authorization | JWT Token | yes | Use API Key obtained from Suprema |
Content-Type | String | yes | application/json |
Accept | String | yes | */* |
Query Parameter:
Key | Type | Required | Description |
---|---|---|---|
startTime | Unix Time (Millisec) | no | retrieve logs starting this date. Must be within 7 days from the end date. if not specified, all logs are displayed |
endTime | Unix Time (Millisec) | no | retrieve logs until this date if not specified, all logs are displayed |
filterEvents | string | no | filter by events |
page | Number | no | logs are displayed in multiples pages. if not specified, displayed in 1 page only. |
size | Number | no | number of logs to be retirieved from the startTime |
q | string | no | query |
sort | string | no | sort the logs by ID in ascending ('asc') or descending ('desc') order Example: id,desc |
curl --location 'https://api.moon.supremainc.com/v1/be/events?startTime=1719932400000&endTime=1720623540000&filterEvents=DEV_FACE_AUTH_SUCCESS%2CDEV_FACE_AUTH_FAIL&page=0&size=200&sort=id%2Casc&placeId=' \ --header 'Authorization: Bearer api_key_here'
2. Request Body
None
3. Response Body
Field | Type | Nullable | Description |
---|---|---|---|
code | Number | false | API response code |
status | Boolean | false | API response status |
message | String | false | API response message |
total | Number | false | total number of retrieved logs. |
data.logId | Number | false | CLUe server side's log ID. |
data.eventAt | Unix Time | false | Date and time when the event occurred. |
data.placeId | Number | false | Place ID |
data.deviceId | Number | true | Device ID |
data.doorId | Number | true | Door ID |
data.doorName | String | true | Door Name |
data.authId | Number | true | Authentication ID |
data.userId | Number | true | User Key |
data.useName | String | true | User Name |
data.localLogId | Number | false | Device side's log ID |
data.eventType | Event Type | false | event type |
{ "code": 200, "status": true, "message": "OK", "total": 75, "data": [ { "logId": "XjIAM5ABcB2c2xupDI6m", "eventAt": 1718842554980, "placeId": 448, "deviceId": 1343, "doorId": 645, "localLogId": 25280, "eventType": "DEV_DOOR_RELAY_OFF" }, { "logId": "XTIAM5ABcB2c2xupDI6m", "eventAt": 1718842553962, "placeId": 448, "deviceId": 1343, "doorId": 645, "localLogId": 25279, "eventType": "DEV_DOOR_RELAY_ON" }, { "logId": "WzIAM5ABcB2c2xupDI6m", "eventAt": 1718842553904, "placeId": 448, "authId": 107909, "deviceId": 1343, "doorId": 645, "doorName": "SupremaJP_In", "userId": "c2119100-fbb0-1fdf-82c6-7dba89b5fe29", "userName": "jinlee", "localLogId": 25278, "eventType": "DEV_FACE_AUTH_SUCCESS" }, { "logId": "iI7-MpABqzmfp6-HrEH7", "eventAt": 1718842462256, "placeId": 448, "deviceId": 1343, "doorId": 645, "localLogId": 25277, "eventType": "DEV_DOOR_RELAY_OFF" }, { "logId": "h47-MpABqzmfp6-HrEH7", "eventAt": 1718842461243, "placeId": 448, "deviceId": 1343, "doorId": 645, "localLogId": 25276, "eventType": "DEV_DOOR_RELAY_ON" } ] }
Event Explanation
- DEV_FACE_AUTH_SUCCESS - The user's face template is registered in CLUe server. Thus, it is successful when user authenticated from the device
- VENDOR_AUTH_SUCCESS - It means that the user's ID (example 64455 above) is registered and allowed access from the 3rd party system.
- DEV_DOOR_RELAY_ON - The relay of the device is turned ON. Door is unlocked.
- DEV_DOOR_RELAY_OFF - The relay of the device is turned OFF. Door is locked.
Sample Flow of Events for Authentication Success
Sample Flow of Events for Authentication Failed (CLUe Side)
Sample Flow of Events for Authentication Failed (3rd Party System side)