Cloud API

1 Background

SUNMI Store is a store management system provided by SUNMI for merchants to manage the IoT devices in stores.

As an open platform, SUNMI Store support the interface with the data of third-party SaaS suppliers including product information, transaction information and membership system interface.

2 Interface Specifications

2.1 Protocols

Currently, Open APIs use HTTPS method only, and all messages use POST method.

Not: the message payload should not exceed 1M, and any request larger than 1M will be rejected directly.

Content-Typeapplication/x-www-form-urlencoded
Data formatReturn in JSON format
Character encodingUTF-8 character encodings
Signature AlgorithmMD5
Sign rulesRefer to 2.2 for sign rules


2.2  Sign Rules

Please refer to Open API – Authentication.

2.3 Common Parameters

ParameterRequiredTypeDescriptionsExample
app_idYesstringThe unique ID of the one who applies for interfacing, which can be obtained from SUNMI EF3OG8R5B32X0
randomYesstringA random character string (6-10 digit) which is constituted by numbers and alphabets 123123
timestampYesintThe current unix timestamp (a 10-digit number) which is accurate to second1578969281
signYesstringSignature information. Please refer to 3.2.2 for details 57178021FE900A04C6F98DA6281598AF

3 Specifications for Store Design

Please refer to Open API – Align Merchants/Stores.

4 The Interface for Device Management

4.1 Interface Description

Those interfaces are used to manage the essential attributes (name, e.g.) of an IPC.

4.2 Interface List

InterfaceDescription
/device/ipc/getListAcquire the list of devices
/device/ipc/getInfoAcquire the basic information of devices
/device/ipc/updateNameChange the device name

4.3 Details of Interfaces

4.3.1 Acquire the List of Devices

Intro to the interface: users can acquire the list of devices in relevant stores by using this interface.

Request link: /device/ipc/getList

Interface parameter:

ParameterRequiredTypeIntroduction Example
shop_idYesstringThe ID of the store to be interfaced with on SaaS platform, which should be provided by the SaaS supplier.10096

Sample request :

  "method": "POST",
  "url": "https://store.uat.sunmi.com/openapi/device/ipc/getList",
  "headers": {
    "Content-Type": "application/x-www-form-urlencoded"
  },
  formData: {
    "shop_id": "10096",
    "app_id": "LMWWQVTW4QGCC",
    "timestamp": 1581333970,
    "random": "5dsf6698",
    "sign": "5EA14F9445D72DDE113AA95B04797D29"
  }

Return value:

{
    "data": {
        "total_count": 1,
        "ipc_list": [
            {
                "ipc_id": "549755805878",
                "ipc_sn": "C101P98200023",
                "ipc_name": "小松松大魔王",
                "model_name": "FM010",
                "software_version": "1.2.6",
                "check_version_time": 1566365781,
                "active_status": 0,
                "screenshot_url": "https://xxxxxxxx/IMG/IPC/e36654e8a95a9ad27b5bb585a0f7df50a0de0dd6e0aeaee47b4e34c4f4636f9a"
            }
        ]
    },
    "code": 0,  /* Please refer to the error list for other errors */
    "msg": "succeed"
}

Return field description: active_status

active_status valueDescription
0The device is offline
1The device is online

Error codes:

Error code Description
5000Database error
5013No data found
5041No shop_id parameter found in the request

4.3.2 Acquire the Basic Information of the Device

Intro to the interface: users can obtain the basic information of a specified device by calling this interface.

Interface request: /device/ipc/getInfo

Interface parameters:

ParameterRequiredTypeDescription Example
shop_idYesstringThe ID of the store to be interfaced with on SaaS platform, which should be provided by the SaaS supplier.10096
ipc_idYesstringThe unique ID of an IPC549755805878

Sample request :

  "method": "POST",
  "url": "https://store.uat.sunmi.com/openapi/device/ipc/getInfo",
  "headers": {
    "Content-Type": "application/x-www-form-urlencoded"
  },
  formData: {
    "shop_id": "10096",
    "ipc_id": "549755805878",
    "app_id": "LMWWQVTW4QGCC",
    "timestamp": 1581333970,
    "random": "5dsf6698",
    "sign": "140E3195C0F00DB09457E015AA79D79B"
  }

Return value:

{
    "data": {
        "ipc_id": "549755805878",
        "ipc_sn": "C101P98200023",
        "ipc_name": "小松松大魔王",
        "model_name": "FM010",
        "software_version": "1.2.6",
        "check_version_time": 1566365781,
        "active_status": 0,
        "screenshot_url": "https://xxxxxxxx/IMG/IPC/e36654e8a95a9ad27b5bb585a0f7df50a0de0dd6e0aeaee47b4e34c4f4636f9a"
    },
    "code": 0,  /* Please refer to the error list for other errors */
    "msg": "succeed"
}

Return field description: active_status

active_status valueDescription
0The device is offline
1The device is online

Error codes:

Error code Description
5000Database error
5013No data found
5041No shop_id parameter found in the request
5501The IPC does not exist

4.3.3 Change the Device Name

Intro to the device: users can change the device name by calling this interface.

Request link: /device/ipc/updateName

Interface parameters:

ParameterRequiredTypeDescriptionExample
shop_idYesstringThe ID of the store to be interfaced with on SaaS platform, which should be provided by the SaaS supplier.10096
ipc_idYesstringThe unique ID of an IPC549755805878
ipc_nameYesstringThe updated name of an IPCThe sample equipment

Sample request :

  "method": "POST",
  "url": "https://store.uat.sunmi.com/openapi/device/ipc/updateName",
  "headers": {
    "Content-Type": "application/x-www-form-urlencoded"
  },
  formData: {
    "shop_id": "10096",
    "ipc_id": "549755805878",
    "ipc_name": "示例设备",
    "app_id": "LMWWQVTW4QGCC",
    "timestamp": 1581333970,
    "random": "5dsf6698",
    "sign": "140E3195C0F00DB09457E015AA79D79B"
  }

Return value:

{
    "code": 0,  /* Please refer to the error list for other errors */
    "msg": "succeed",
    "data": {}
}

Error codes:

Error code Description
5000Database error
5011Error in communication with the device
5013No data found
5041No shop_id parameter found in the request
5501The IPC doesn’t exist
5506No data of this IPC found in the database
5510Unbound device

5 The Interface to Manage Face Group

5.1 Interface Description

It is an interface used to manage the interfaces related to faces. SUNMI Store will save relevant authorized data and configuration on the cloud and synchronize data needed to the IPC in the store.

5.2 Interface List

InterfaceDescription
/face/group/getListAcquire the list of face group
/face/group/getInfoAcquire the information of a specified face group
/face/group/createAdd face group
/face/group/updateModify a specified face group
/face/group/deleteDelete a specified face group
/face/group/getFaceListAcquire the face list of a specified face group
/face/getInfoAcquire the detailed information of a specified face
/face/addAdd face information to a specified face group
/face/updateModify the attribute information of a specified face
/face/updatePictureModify the attribute information of a specified face image
/face/deleteDelete face information from a specified face group
/face/group/moveMove a specified face among face groups
/face/group/updateMoveStrategyModify the strategies on moving new customers among groups

5.3 Details of Interfaces

5.3.1 Acquire the List of Face Group

Intro to the interface: users can acquire the list of face group by calling this interface.

Request link: /fact/group/getList

Interface parameter:

ParameterRequiredTypeDescriptionExample
shop_idYesstringThe ID of the store to be interfaced with on SaaS platform, which should be provided by the SaaS supplier. 10096

Sample request :

  "method": "POST",
  "url": "https://store.uat.sunmi.com/openapi/face/group/getList",
  "headers": {
    "Content-Type": "application/x-www-form-urlencoded"
  },
  formData: {
    "shop_id": "10096",
    "app_id": "LMWWQVTW4QGCC",
    "timestamp": 1581383983,
    "random": "5dsf6698",
    "sign": "33C18A18282733A71F998BB5A5E4319D"
  }

Return value:

{
    "data": {
        "group_list": [
            {
                "group_id": "578968814328",
                "type": 1,
                "count": 0,
                "capacity": 1000,
                "last_modified_time": 0,
                "group_name": "stranger",
                "description": "",
                "customer_key1": "",
                "customer_key2": "",
                "customer_key3": "",
                "customer_key4": "",
                "customer_key5": ""
            },
            {
                "group_id": "578968814329",
                "type": 2,
                "count": 0,
                "capacity": 1000,
                "last_modified_time": 0,
                "group_name": "regular",
                "description": "",
                "customer_key1": "",
                "customer_key2": "",
                "customer_key3": "",
                "customer_key4": "",
                "customer_key5": ""
            },
            {
                "group_id": "578968814330",
                "type": 3,
                "count": 0,
                "capacity": 1000,
                "last_modified_time": 0,
                "group_name": "employee",
                "description": "",
                "customer_key1": "",
                "customer_key2": "",
                "customer_key3": "",
                "customer_key4": "",
                "customer_key5": ""
            },
            {
                "group_id": "578968817934",
                "type": 5,
                "count": 0,
                "capacity": 1000,
                "last_modified_time": 0,
                "group_name": "YiliuTest",
                "description": "",
                "customer_key1": "",
                "customer_key2": "",
                "customer_key3": "",
                "customer_key4": "",
                "customer_key5": ""
            }
        ]
    },
    "code": 0,  /* Please refer to the error list for other errors */
    "msg": "succeed"
}

Return field description: type

type valueDescription
1New customer face library
2Repeat customer face library
3Shop assistant face library
5Customized face library

Error codes:

Error code Description
5000Database error
5013No data found
5041No shop_id parameter found in the request

5.3.2 Acquire the Information of a Specified Face Group

Interface description: users can acquire the information of a specified face group by calling this interface.

Request link: /face/group/getInfo

Interface parameters:

ParameterRequiredTypeDescriptionExample
shop_idYesstringThe ID of the store to be interfaced with on SaaS platform, which should be provided by the SaaS supplier.10096
group_idstringThe unique ID of a face group578968814328

Sample request :

  "method": "POST",
  "url": "https://store.uat.sunmi.com/openapi/face/group/getInfo",
  "headers": {
    "Content-Type": "application/x-www-form-urlencoded"
  },
  formData: {
    "shop_id": "10096",
    "group_id": "578968814328",
    "app_id": "LMWWQVTW4QGCC",
    "timestamp": 1581383983,
    "random": "5dsf6698",
    "sign": "33C18A18282733A71F998BB5A5E4319D"
  }

Return value:

{
    "data": {
        "group_id": "578968814328",
        "type": 1,
        "count": 0,
        "capacity": 1000,
        "last_modified_time": 0,
        "group_name": "stranger",
        "description": "",
        "customer_key1": "",
        "customer_key2": "",
        "customer_key3": "",
        "customer_key4": "",
        "customer_key5": ""
    },
    "code": 0,  /* Please refer to the error list for other errors */
    "msg": "succeed"
}

Return field description: type

type valueDescription
1New customer face library
2Repeat customer face library
3Shop assistant face library
5Customized face library

Error codes:

Error code Description
5000Database error
5013No data found
5041No shop_id parameter found in the request

5.3.3 Add a Face Group

Interface description: users can add a face group by calling this interface.

Request link: /face/group/create

Interface parameters:

ParameterRequiredTypeDescriptionExample
shop_idYesstringThe ID of the store to be interfaced with on SaaS platform, which should be provided by the SaaS supplier.10096
nameYesstringThe name of a face groupMike
typeYesintThe type of a face group (1: new customer, 2: repeat customer, 3: shop assistant, 5: customized)5
capacityYesintThe capacity of a face group10000
descriptionNostringThe description of a face group 此分组用于对于金卡会员管理
customer_key1NostringFace group customized extended field 1 namevip_level
customer_key2NostringFace group customized extended field 2 namehobby
customer_key3NostringFace group customized extended field 3 nameforeigner
customer_key4NostringFace group customized extended field 4 namefigure
customer_key5NostringFace group customized extended field 5 namehairstyle

Sample request :

  "method": "POST",
  "url": "https://store.uat.sunmi.com/openapi/face/group/create",
  "headers": {
    "Content-Type": "application/x-www-form-urlencoded"
  },
  formData: {
    "shop_id": "10096",
    "name": "Mike",
    "type": 5,
    "capacity": 1000,
    "app_id": "LMWWQVTW4QGCC",
    "timestamp": 1581383983,
    "random": "5dsf6698",
    "sign": "33C18A18282733A71F998BB5A5E4319D"
  }

Return value:

{
    "code": 0,  /* Please refer to the error list for other errors  */
    "msg": "succeed",
    "data": {}
}

Error codes:

Error code Description
5000Database error
5013No data found
5041No shop_id parameter found in the request
5520The number of face groups or the face capacity reaches the upper limit
5523This face group already exists

5.3.4 Modify a Specified Face Group

Interface description: users can modify a specified face group by calling this interface.

Request link: /face/group/update

Interface parameters:

ParameterRequiredTypeDescriptionExample
shop_idYesstringThe ID of the store to be interfaced with on SaaS platform, which should be provided by the SaaS supplier.15220
group_idYesstringThe unique ID of a face group578968817476
nameNostringThe name of a face groupMike
capacityNointThe capacity of a face group10000
descriptionNostringThe description of a face group 此分组用于对于金卡会员管理
customer_key1NostringFace group customized extended field 1 namevip_level
customer_key2NostringFace group customized extended field 2 namehobby
customer_key3NostringFace group customized extended field 3 nameforeigner
customer_key4NostringFace group customized extended field 4 namefigure
customer_key5NostringFace group customized extended field 5 namehairstyle

Sample request :

  "method": "POST",
  "url": "https://store.uat.sunmi.com/openapi/face/group/update",
  "headers": {
    "Content-Type": "application/x-www-form-urlencoded"
  },
  formData: {
    "shop_id": "10096",
    "name": "Mike",
    "type": 5,
    "capacity": 1000,
    "app_id": "LMWWQVTW4QGCC",
    "timestamp": 1581383983,
    "random": "5dsf6698",
    "sign": "33C18A18282733A71F998BB5A5E4319D"
  }

Return value:

{
    "code": 0,  /* Please refer to the error list for other errors  */
    "msg": "succeed",
    "data": {}
}

Error codes:

Error code Description
5000Database error
5013No data found
5041No shop_id parameter found in the request
5506The data has not been found
5520The number of face groups or the face capacity reaches the upper limit
5525The default face library is not allowed to be modified

5.3.5 Delete a Specified Face Group

Interface description: users can delete a specified face group by calling this interface.

Request link: /face/group/delete

Interface parameters:

ParameterRequiredTypeDescriptionExample
shop_idYesstringThe ID of the store to be interfaced with on SaaS platform, which should be provided by the SaaS supplier.15220
group_idYesstringThe unique ID of a face group578968817476

Sample request :

  "method": "POST",
  "url": "https://store.uat.sunmi.com/openapi/face/group/delete",
  "headers": {
    "Content-Type": "application/x-www-form-urlencoded"
  },
  formData: {
    "shop_id": "10096",
    "group_id": "578968814328",
    "app_id": "LMWWQVTW4QGCC",
    "timestamp": 1581383983,
    "random": "5dsf6698",
    "sign": "33C18A18282733A71F998BB5A5E4319D"
  }

Return value:

{
    "code": 0,  /* Please refer to the error list for other errors */
    "msg": "succeed",
    "data": {}
}

Error codes:

Error code Description
5000Database error
5013No data found
5041No shop_id parameter found in the request
5506The data has not been found
5524The default face library is not allowed to be modified
5509Non-empty face library

5.3.6 Acquire the Face List of a Specified Face Group

Interface description: users can acquire the face list of a specified face group by calling this interface.

Interface request: /fact/group/getFaceList

Interface parameters:

ParametersRequiredTypeDescriptionExample
shop_idYesstringThe ID of the store to be interfaced with on SaaS platform, which should be provided by the SaaS supplier.7948
group_idYesstringThe unique ID of a face group578968813726
page_numNo (1 by default)intThe current page number1
page_sizeNo (10 by default)intThe number of entries on the current page10

Sample request :

  "method": "POST",
  "url": "https://store.uat.sunmi.com/openapi/face/group/getFaceList",
  "headers": {
    "Content-Type": "application/x-www-form-urlencoded"
  },
  formData: {
    "shop_id": "7948",
    "group_id": "578968813726",
    "app_id": "LMWWQVTW4QGCC",
    "timestamp": 1581383983,
    "random": "5dsf6698",
    "sign": "33C18A18282733A71F998BB5A5E4319D"
  }

Return value:

{
    "data": {
        "face_list": [
            {
                "face_id": "578968751459",
                "group_id": "578968813726",
                "group_name": "",
                "gender": 1,
                "age_range": 6,
                "arrival_count": 0,
                "create_time": 1579591542,
                "last_arrival_time": 0,
                "name": "lll",
                "customer_key1": "",
                "customer_key2": "",
                "customer_key3": "",
                "customer_key4": "",
                "customer_key5": ""
            }
        ],
        "total_num": 1
    },
    "code": 0,  /* Please refer to the error list for other errors */
    "msg": "succeed"
}

Return field description: gender

gender valueDescription
0Unknown
1Male
2Female

Return field description: age_range

age_range valueDescription
1Age 0~6
2Age 7~12
3Age 13~18
4Age 19~28
5Age 29~35
6Age 36~45
7Age 46~55
8Age 56 and the above

Error codes:

Error code Description
5000Database error
5506The data has not been found
5013No data found
5041No shop_id parameter found in the request

5.3.7 Acquire the Detailed Information of a Specified Face

Interface description: users can acquire the detailed information of a specified face by calling this interface.

Request link: /face/getInfo

Interface parameters:

ParameterrequiredTypeDescriptionExample
shop_idYesstringThe ID of the store to be interfaced with on SaaS platform, which should be provided by the SaaS supplier.7948
face_idYesstringThe unique ID of a face group578968740430

Sample request :

  "method": "POST",
  "url": "https://store.uat.sunmi.com/openapi/face/getInfo",
  "headers": {
    "Content-Type": "application/x-www-form-urlencoded"
  },
  formData: {
    "shop_id": "7948",
    "face_id": "578968751459",
    "app_id": "LMWWQVTW4QGCC",
    "timestamp": 1581383983,
    "random": "5dsf6698",
    "sign": "33C18A18282733A71F998BB5A5E4319D"
  }

Return value:

{
    "data": {
        "age_range": 6,
        "arrival_count": 0,
        "create_time": 1579591542,
        "face_id": "578968751459",
        "gender": 1,
        "group_id": "578968813726",
        "group_name": "stranger",
        "last_arrival_time": 0,
        "name": "lll"
    },
    "code": 0,  /* Please refer to the error list for other errors */
    "msg": "succeed"
}

Error codes:

Error codeDescription
5000Database error
5506No data found
5013No data found
5041No shop_id parameter found in the request

5.3.8 Add Face Information to a Specified Face Group

Interface description: users can add face information to a specified face group by calling this interface.

Request link: /face/add

Interface parameters:

Content-Type:application/form-data

ParameterRequiredTypeDescriptionExample
shop_idYesstringThe ID of the store to be interfaced with on SaaS platform, which should be provided by the SaaS supplier.7948
group_idYesstringThe unique ID of a face group578968813726
nameYesstringThe name of the face ownerMike
picYesfileThe corresponding image (≤1M) of a faceface.png
genderNointThe gender of a face owner (1: male, 2: female)1
age_rangeNointThe age range a face corresponds to4
customer_value1NostringFace group customized extended field 1 content1
customer_value2NostringFace group customized extended field 2 contentsing
customer_value3NostringFace group customized extended field 3 contentamericans
customer_value4NostringFace group customized extended field 4 contentfat
customer_value5NostringFace group customized extended field 5 contentshort hair

Sample request :

  "method": "POST",
  "url": "https://store.uat.sunmi.com/openapi/face/add",
  "headers": {
    "Content-Type": "application/x-www-form-urlencoded"
  },
  formData: {
    "shop_id": "7948",
    "app_id": "LMWWQVTW4QGCC",
    "group_id": "578968813726",
    "name": "Mike",
    "pic": {
      "value": fs.createReadStream("/D:/image/face.png"),
      "options": {
        "filename": "/D:/image/face.png",
        "contentType": null
      }
    "timestamp": 1581383983,
    "random": "5dsf6698",
    "sign": "33C18A18282733A71F998BB5A5E4319D"
  }

Return value:

{
    "code": 0, /* Please refer to the error list for other errors */
    "msg": "succeed",
    "data": {
        "face_id": "578968740430"
    }
}

Error codes:

Error codeDescription
5000Database error
5013No data found
5041No shop_id parameter found in the request
5520The number of face groups or the face capacity reaches the upper limit

Note: SUNMI Store will process the images added to the face library and generate the corresponding face_id. The process result will be noticed asynchronously for it takes some time to process images.

For details, please refer to Notification Push Center.

The synchronous process and return method are being developed.

5.3.9 Modify the Attribute Information of a Specified Face

Interface description: users can modify the attribute information of a specified face by calling this interface.

Request link: /face/update

Interface parameters:

ParameterRequiredTypeDescriptionExample
shop_idYesstringThe ID of the store to be interfaced with on SaaS platform, which should be provided by the SaaS supplier.7948
group_idYesstringThe unique ID of a face group578968813726
face_idYesstringThe unique ID of a face578968751459
nameNostringThe name of the face ownerMike
genderNointThe gender of a face owner (1: male, 2: female)1
age_rangeNointThe age range a face corresponds4
customer_value1NostringFace group customized extended field 1 content1
customer_value2NostringFace group customized extended field 2 contentsing
customer_value3NostringFace group customized extended field 3 contentamericans
customer_value4NostringFace group customized extended field 4 contentfat
customer_value5NostringFace group customized extended field 5 contentshort hair

Field description: age_range

age_range valueDescription
1Age 0~6
2Age 7~12
3Age 13~18
4Age 19~28
5Age 29~35
6Age 36~45
7Age 46~55
8Age 56 and the above

Sample request :

  "method": "POST",
  "url": "https://store.uat.sunmi.com/openapi/face/update",
  "headers": {
    "Content-Type": "application/x-www-form-urlencoded"
  },
  formData: {
    "shop_id": "7948",
    "app_id": "LMWWQVTW4QGCC",
    "group_id": "578968813726",
    "face_id": "578968751459",
    "timestamp": 1581383983,
    "random": "5dsf6698",
    "sign": "33C18A18282733A71F998BB5A5E4319D"
  }

Return value:

{
    "code": 0,  /* 
Please refer to the error list for other errors */
    "msg": "succeed",
    "data": {}
}

Error codes:

Error codeDescription
5000Database error
5013No data found
5041No shop_id parameter found in the request
5520The number of face groups or the face capacity reaches the upper limit
5521The face information is not in the specified face group

5.3.10 Delete Face Information from the Specified Face Group

Interface description: users can delete face information from the specified face group by calling this interface.

Request link: /face/delete

Interface parameters:

ParameterRequiredTypeDescriptionExample
shop_idYesstringThe ID of the store to be interfaced with on SaaS platform, which should be provided by the SaaS supplier.7948
group_idYesstringThe unique ID of a face group578968813726
face_id_listYesarray[string]The unique ID of a face[578968751459]

Sample request :

  "method": "POST",
  "url": "https://store.uat.sunmi.com/openapi/face/delete",
  "headers": {
    "Content-Type": "application/x-www-form-urlencoded"
  },
  formData: {
    "shop_id": "7948",
    "app_id": "LMWWQVTW4QGCC",
    "group_id": "578968813726",
    "face_id_list": ["578968751459"],
    "timestamp": 1581383983,
    "random": "5dsf6698",
    "sign": "33C18A18282733A71F998BB5A5E4319D"
  }

Return value:

{
    "code": 0,  /* Please refer to the error list for other errors */
    "msg": "succeed",
    "data": {}
}

Error codes:

Error codeDescription
5000Database error
5013No data found
5041No shop_id parameter found in the request

5.3.11 Move a Specified Face Among Face Groups

Interface description: users can move a specified face among face groups by calling this interface.

Request link: /face/group/move

Interface parameters:

ParameterRequiredTypeDescriptionExample
shop_idYesstringThe store ID which should be provided by the SaaS supplier7948
source_group_idYesstringThe unique ID of an original face group578968813726
target_group_idYesstringThe unique ID of a target face group578968813727
face_id_listYesarray[string]The face ID arrays to be moved[578968751459]

Sample request :

  "method": "POST",
  "url": "https://store.uat.sunmi.com/openapi/face/group/move",
  "headers": {
    "Content-Type": "application/x-www-form-urlencoded"
  },
  formData: {
    "shop_id": "7948",
    "app_id": "LMWWQVTW4QGCC",
    "source_group_id": "578968813726",
    "target_group_id": "578968813727",
    "face_id_list": ["578968751459"],
    "timestamp": 1581383983,
    "random": "5dsf6698",
    "sign": "33C18A18282733A71F998BB5A5E4319D"
  }

Return value:

{
    "code": 0,  /* Please refer to the error list for other errors */
    "msg": "succeed",
    "data": {}
}

Error codes:

Error codeDescription
5000Database error
5013No data found
5041No shop_id parameter found in the request
5520The number of face groups or the face capacity reaches the upper limit
5521The face information is not in the specified face group
5522The face library does not exist

5.3.12 Change the Strategy of Moving a New Customer to Other Groups

Interface description: users can change the strategy of moving new customer groups by calling this interface.

Request link: /face/group/updateMoveStrategy

Interface parameters:

ParameterRequiredTypeDescriptionExample
shop_idYesstringThe ID of the store to be interfaced with on SaaS platform, which should be provided by the SaaS supplier.7948
target_group_idYesstringThe unique ID of a target face group578968813727
thresholdYesintThe threshold (the times a customer visits the store in a certain period time) of moving a new customer to other groups4
periodYesintThe certain period of time (in seconds) that reaches the condition of moving a new customer to other groups604800

Sample request :

  "method": "POST",
  "url": "https://store.uat.sunmi.com/openapi/face/group/updateMoveStrategy",
  "headers": {
    "Content-Type": "application/x-www-form-urlencoded"
  },
  formData: {
    "shop_id": "7948",
    "app_id": "LMWWQVTW4QGCC",
    "target_group_id": "578968813727",
    "threshold": 4,
    "period": 604800,
    "timestamp": 1581383983,
    "random": "5dsf6698",
    "sign": "33C18A18282733A71F998BB5A5E4319D"
  }

Return value:

{
    "code": 0,  /* Please refer to the error list for other errors */
    "msg": "succeed",
    "data": {}
}

Error codes:

Error codeDescription
5000Database error
5013No data found
5041No shop_id parameter found in the request
5506The data has not been found
5520The number of face groups or the face capacity reaches the upper limit
5525The information of the default face group cannot be changed

6 The Interface for Customer Flow Statistics

6.1 Interface Description

This interface is used to inquire the customer flow and history monitored and saved by the IPC. Three statistical dimensions are included – historical customer flow data (T+1), the customer flow data of the current day (T+0), real-time customer flow data.

The historical customer flow data (T+1) and the customer flow data of the current day (T+0) are provided by HTTP interface. SaaS suppliers can obtain the data by initiating request and the frequency of updating statistical data of the current day is smaller 15s/update, and the real-time customer flow data will be obtained by receiving notifications. For details, please refer to Notification Push Center.

6.2 Interface List

InterfaceDescription
/passengerFlow/stat/today/getLatestAcquire the real-time customer flow of the current day (real-time total customer flow)
/passengerFlow/stat/today/groupByTagAcquire the customer flow data of the current day (according to the age and new/repeat face groups)
/passengerFlow/stat/today/groupByGenderAcquire the customer flow data of the current day (according to the age and gender group)
/passengerFlow/stat/today/getTrendByHourAcquire the customer flow trend of the current day (total customer flow, the time granularity is hour)
/passengerFlow/stat/history/groupByTagAcquire historical customer flow data (total customer flow/new and repeat customer/member)
/passengerFlow/stat/history/groupByGenderAcquire the details on historical customer group (age and gender)
/passengerFlow/stat/history/getTrendByHourAcquire the historical customer flow trend (total customer flow/new and repeat customers, the time granularity is hour)
/passengerFlow/stat/history/getTrendByDayAcquire the historical customer flow trend (total customer flow/new and repeat customer, the time granularity is day)
/passengerFlow/stat/history/getTrendByWeekAcquire the historical customer flow trend (total customer flow/new and repeat customer, the time granularity is week) (developing)
/passengerFlow/stat/history/getTrendByMonthAcquire the historical customer flow trend (total customer flow/new or repeat customer, the time granularity is month) (developing)

6.3 Interface Details

6.3.1 Acquire the Real-Time Customer Flow of the Current Day

Interface description: users can acquire the customer flow of the current day by calling this interface.

Interface link: /passengerFlow/stat/today/getLatest

Interface parameter:

ParameterRequiredTypeDescriptionExample
shop_idYesstringThe ID of the store to be interfaced with on SaaS platform, which should be provided by the SaaS supplier.7948

Sample request :

  "method": "POST",
  "url": "https://store.uat.sunmi.com/openapi/passengerFlow/stat/today/getLatest",
  "headers": {
    "Content-Type": "application/x-www-form-urlencoded"
  },
  formData: {
    "shop_id": "7948",
    "app_id": "LMWWQVTW4QGCC",
    "timestamp": 1581383983,
    "random": "5dsf6698",
    "sign": "33C18A18282733A71F998BB5A5E4319D"
  }

Return value:

{
    "code": 0, /* Please refer to the error list for other errors*/
    "msg": "succeed",
    "data": {
	"count": "123"
        "unexposed_count": 0
    }
}

Error codes:

Error codeDescription
5000Database error
5013No data found
5041No shop_id parameter found in the request

6.3.2 Acquire the Customer Flow Data of the Current Day (According to the Group of New and Repeat Customer and Age Range)

Interface description: users can acquire the data of new/repeat customer flow data according to the age range of the current day by calling this interface.

Request link: /passengerFlow/stat/today/groupByTag

Interface parameter:

ParameterRequiredTypeDescriptionExample
shop_idYesstringThe ID of the store to be interfaced with on SaaS platform, which should be provided by the SaaS supplier.7948

Sample request :

  "method": "POST",
  "url": "https://store.uat.sunmi.com/openapi/passengerFlow/stat/today/groupByTag",
  "headers": {
    "Content-Type": "application/x-www-form-urlencoded"
  },
  formData: {
    "shop_id": "7948",
    "app_id": "LMWWQVTW4QGCC",
    "timestamp": 1581383983,
    "random": "5dsf6698",
    "sign": "33C18A18282733A71F998BB5A5E4319D"
  }

Return value:

{
    "data": {
        "count_list": [
            {
                "age_range": 1,
                "stranger_count": 0,  
                "regular_count": 0, 
                "member_count": 0  
            },
            {
                "age_range": 2,
                "stranger_count": 0,
                "regular_count": 0,
                "member_count": 0
            },
            {
                "age_range": 3,
                "stranger_count": 0,
                "regular_count": 0,
                "member_count": 0
            },
            {
                "age_range": 4,
                "stranger_count": 0,
                "regular_count": 0,
                "member_count": 0
            },
            {
                "age_range": 5,
                "stranger_count": 0,
                "regular_count": 0,
                "member_count": 0
            },
            {
                "age_range": 6,
                "stranger_count": 0,
                "regular_count": 0,
                "member_count": 0
            },
            {
                "age_range": 7,
                "stranger_count": 0,
                "regular_count": 0,
                "member_count": 0
            },
            {
                "age_range": 8,
                "stranger_count": 0,
                "regular_count": 0,
                "member_count": 0
            }
        ]
    },
    "code": 0,  /* Please refer to the error list for other errors*/
    "msg": "succeed"
}

Field description: age_range

age_range valueDescription
1Age 0~6
2Age 7~12
3Age 13~18
4Age 19~28
5Age 29~35
6Age 36~45
7Age 46~55
8Age 56 and the above

Error codes:

Error codeDescription
5000Database error
5013No data found
5041No shop_id parameter found in the request

6.3.3 Acquire the Customer Flow Data of the Current Day (According to the Gender and Age)

Request link: /passengerFlow/stat/today/groupByGender

Interface description: users can acquire the customer flow data of different age range and different gender by calling this interface.

Interface parameter:

ParameterRequiredTypeDescriptionExample
shop_idYesstringThe ID of the store to be interfaced with on SaaS platform, which should be provided by the SaaS supplier7948

Sample request :

  "method": "POST",
  "url": "https://store.uat.sunmi.com/openapi/passengerFlow/stat/today/groupByGender",
  "headers": {
    "Content-Type": "application/x-www-form-urlencoded"
  },
  formData: {
    "shop_id": "7948",
    "app_id": "LMWWQVTW4QGCC",
    "timestamp": 1581383983,
    "random": "5dsf6698",
    "sign": "33C18A18282733A71F998BB5A5E4319D"
  }

Return value:

{
    "data": {
        "count_list": [
            {
                "age_range": 1,
                "male_count": 0, 
                "male_regular_count": 0, 
                "male_member_count": 0,
                "female_count": 0,
                "female_regular_count": 0,
                "female_member_count": 0 
            },
            {
                "age_range": 2,
                "male_count": 0,
                "male_regular_count": 0,
                "male_member_count": 0,
                "female_count": 0,
                "female_regular_count": 0,
                "female_member_count": 0
            },
            {
                "age_range": 3,
                "male_count": 0,
                "male_regular_count": 0,
                "male_member_count": 0,
                "female_count": 0,
                "female_regular_count": 0,
                "female_member_count": 0
            },
            {
                "age_range": 4,
                "male_count": 0,
                "male_regular_count": 0,
                "male_member_count": 0,
                "female_count": 0,
                "female_regular_count": 0,
                "female_member_count": 0
            },
            {
                "age_range": 5,
                "male_count": 0,
                "male_regular_count": 0,
                "male_member_count": 0,
                "female_count": 0,
                "female_regular_count": 0,
                "female_member_count": 0
            },
            {
                "age_range": 6,
                "male_count": 0,
                "male_regular_count": 0,
                "male_member_count": 0,
                "female_count": 0,
                "female_regular_count": 0,
                "female_member_count": 0
            },
            {
                "age_range": 7,
                "male_count": 0,
                "male_regular_count": 0,
                "male_member_count": 0,
                "female_count": 0,
                "female_regular_count": 0,
                "female_member_count": 0
            },
            {
                "age_range": 8,
                "male_count": 0,
                "male_regular_count": 0,
                "male_member_count": 0,
                "female_count": 0,
                "female_regular_count": 0,
                "female_member_count": 0
            }
        ]
    },
    "code": 0,  /* Please refer to the error list for other errors*/
    "msg": "succeed"
}

Field description: age_range

age_range valueDescription
1Age 0~6
2Age 7~12
3Age 13~18
4Age 19~28
5Age 29~35
6Age 36~45
7Age 46~55
8Age 56 and the above

Error codes:

Error codeDescription
5000Database error
5013No data found
5041No shop_id parameter found in the request

6.3.4 Acquire the Customer Flow Data of the Current Day (Total Customer Flow, the Time Granularity is Hour)

Request link: /passengerFlow/stat/today/getTrendByHour

Interface description: users can acquire the customer flow data of different time period the current day by calling this interface.

Interface parameter:

ParameterRequiredTypeDescriptionExample
shop_idYesstringThe ID of the store to be interfaced with on SaaS platform, which should be provided by the SaaS supplier.7948

Sample request :

  "method": "POST",
  "url": "https://store.uat.sunmi.com/openapi/passengerFlow/stat/today/getTrendByHour",
  "headers": {
    "Content-Type": "application/x-www-form-urlencoded"
  },
  formData: {
    "shop_id": "7948",
    "app_id": "LMWWQVTW4QGCC",
    "timestamp": 1581383983,
    "random": "5dsf6698",
    "sign": "33C18A18282733A71F998BB5A5E4319D"
  }

Return value:

{
    "data": {
        "count_list": [
            {
                "time": "2020-02-11 00:00",
                "total_count": 0,
                "unexposed_count": 0
            },
            {
                "time": "2020-02-11 01:00",
                "total_count": 0,
                "unexposed_count": 0
            },
            {
                "time": "2020-02-11 02:00",
                "total_count": 0,
                "unexposed_count": 0
            },
            {
                "time": "2020-02-11 03:00",
                "total_count": 0,
                "unexposed_count": 0
            },
            {
                "time": "2020-02-11 04:00",
                "total_count": 0,
                "unexposed_count": 0
            },
            {
                "time": "2020-02-11 05:00",
                "total_count": 0,
                "unexposed_count": 0
            },
            {
                "time": "2020-02-11 06:00",
                "total_count": 0,
                "unexposed_count": 0
            },
            {
                "time": "2020-02-11 07:00",
                "total_count": 0,
                "unexposed_count": 0
            },
            {
                "time": "2020-02-11 08:00",
                "total_count": 0,
                "unexposed_count": 0
            },
            {
                "time": "2020-02-11 09:00",
                "total_count": 0,
                "unexposed_count": 0
            },
            {
                "time": "2020-02-11 10:00",
                "total_count": 0,
                "unexposed_count": 0
            },
            {
                "time": "2020-02-11 11:00",
                "total_count": 0,
                "unexposed_count": 0
            },
            {
                "time": "2020-02-11 12:00",
                "total_count": 0,
                "unexposed_count": 0
            },
            {
                "time": "2020-02-11 13:00",
                "total_count": 0,
                "unexposed_count": 0
            },
            {
                "time": "2020-02-11 14:00",
                "total_count": 0,
                "unexposed_count": 0
            },
            {
                "time": "2020-02-11 15:00",
                "total_count": 0,
                "unexposed_count": 0
            },
            {
                "time": "2020-02-11 16:00",
                "total_count": 0,
                "unexposed_count": 0
            }
        ]
    },
    "code": 0, /* Please refer to the error list for other errors*/
    "msg": "succeed",
}

Field description: age_range

age_range valueDescription
1Age 0~6
2Age 7~12
3Age 13~18
4Age 19~28
5Age 29~35
6Age 36~45
7Age 46~55
8Age 56 and the above

Error codes:

Error codeDescription
5000Database error
5013No data found
5041No shop_id parameter found in the request

6.3.5 Acquire the Historical Customer Flow Data (Total/New and Repeat Customer/Member)

Interface description: users can acquire the customer flow data of the three main face group in historical data by calling this interface.

Request link: /passengerFlow/stat/history/groupByTag

Interface parameters:

ParameterRequiredTypeDescriptionExample
shop_idYesstringThe ID of the store to be interfaced with on SaaS platform, which should be provided by the SaaS supplier.7948
start_timeYesstring The start (YYYY-MM-DD) of the time interval to be filtered (if you want to acquire the data of one day, the start time is the end time)2020-01-01
end_timeYesstringThe end (YYYY-MM-DD) of the time interval to be filtered (if you want to acquire the data of one day, the start time is the end time)2020-01-16

Note:

For each time you call the interface, the interval between start time and end time is limited to 30 days.

Sample request :

  "method": "POST",
  "url": "https://store.uat.sunmi.com/openapi/passengerFlow/stat/history/groupByTag",
  "headers": {
    "Content-Type": "application/x-www-form-urlencoded"
  },
  formData: {
    "shop_id": "7948",
    "app_id": "LMWWQVTW4QGCC",
    "start_time": "2020-01-01",
    "end_time": "2020-01-16",
    "timestamp": 1581383983,
    "random": "5dsf6698",
    "sign": "33C18A18282733A71F998BB5A5E4319D"
  }

Return value:

{
    "data": {
        "total_count": 0,   
        "regular_count": 0,   
        "stranger_count": 0,  
        "member_count": 0,   
        "unexposed_count": 0 
    },
    "code": 0,   /* Please refer to the error list for other errors*/
    "msg": "succeed"
}

Error codes:

Error codeDescription
5000Database error
5013No data found
5041No shop_id parameter found in the request

6.3.6 Acquire the Historical Customer Group Data (According to Age and Gender)

Request link: /passengerFlow/stat/history/groupByGender

Interface description: users can acquire the customer data the current day of different age range and gender by calling the interface.

Interface parameters:

ParameterRequiredTypeDescriptionExample
shop_idYesstringThe ID of the store to be interfaced with on SaaS platform, which should be provided by the SaaS supplier.7948
start_timeYesstringThe start (YYYY-MM-DD) of the time interval to be filtered (if you want to acquire the data of one day, the start time is the end time) 2020-01-01
end_time YesstringThe end (YYYY-MM-DD) of the time interval to be filtered (if you want to acquire the data of one day, the start time is the end time) 2020-01-01

Note:

For each time you call the interface, the interval between start time and end time is limited to 30 days.

Sample request :

  "method": "POST",
  "url": "https://store.uat.sunmi.com/openapi/passengerFlow/stat/history/groupByGender",
  "headers": {
    "Content-Type": "application/x-www-form-urlencoded"
  },
  formData: {
    "shop_id": "7948",
    "app_id": "LMWWQVTW4QGCC",
    "start_time": "2020-01-01",
    "end_time": "2020-01-01",
    "timestamp": 1581383983,
    "random": "5dsf6698",
    "sign": "33C18A18282733A71F998BB5A5E4319D"
  }

Return value:

{
    "data": {
        "count_list": [
            {
                "age_range": 1,
                "male_count": 0, 
                "male_regular_count": 0, 
                "male_member_count": 0, 
                "female_count": 0,
                "female_regular_count": 0, 
                "female_member_count": 0 
            },
            {
                "age_range": 2,
                "male_count": 0,
                "male_regular_count": 0,
                "male_member_count": 0,
                "female_count": 0,
                "female_regular_count": 0,
                "female_member_count": 0
            },
            {
                "age_range": 3,
                "male_count": 0,
                "male_regular_count": 0,
                "male_member_count": 0,
                "female_count": 0,
                "female_regular_count": 0,
                "female_member_count": 0
            },
            {
                "age_range": 4,
                "male_count": 0,
                "male_regular_count": 0,
                "male_member_count": 0,
                "female_count": 0,
                "female_regular_count": 0,
                "female_member_count": 0
            },
            {
                "age_range": 5,
                "male_count": 0,
                "male_regular_count": 0,
                "male_member_count": 0,
                "female_count": 0,
                "female_regular_count": 0,
                "female_member_count": 0
            },
            {
                "age_range": 6,
                "male_count": 0,
                "male_regular_count": 0,
                "male_member_count": 0,
                "female_count": 0,
                "female_regular_count": 0,
                "female_member_count": 0
            },
            {
                "age_range": 7,
                "male_count": 0,
                "male_regular_count": 0,
                "male_member_count": 0,
                "female_count": 0,
                "female_regular_count": 0,
                "female_member_count": 0
            },
            {
                "age_range": 8,
                "male_count": 0,
                "male_regular_count": 0,
                "male_member_count": 0,
                "female_count": 0,
                "female_regular_count": 0,
                "female_member_count": 0
            }
        ]
    },
    "code": 0,  /* Please refer to the error list for other errors*/
    "msg": "succeed"
}

Field description: age_range

age_range valueExample
1Age 0~6
2Age 7~12
3Age 13~18
4Age 19~28
5Age 29~35
6Age 36~45
7Age 46~55
8Age 56 and the above

Error codes:

Error codeDescription
5000Database error
5013No data found
5041No shop_id parameter found in the request

6.3.7 Acquire the Historical Customer Flow Trend (Total/New and Repeat Customer, and the time granularity Is Hour)

Request link: /passengerFlow/stat/history/getTrendByHour

Interface description: users can acquire the customer flow trend of a period of time by calling this interface.

Interface parameters:

ParameterRequiredTypeDescriptionExample
shop_idYesstringThe ID of the store to be interfaced with on SaaS platform, which should be provided by the SaaS supplier.7948
start_timeYesstringThe start (YYYY-MM-DD) of the time interval to be filtered (if you want to acquire the data of one day, the start time is the end time) 2020-01-01
end_time YesstringThe end (YYYY-MM-DD) of the time interval to be filtered (if you want to acquire the data of one day, the start time is the end time) 2020-01-01

Notes:

For each time you call the interface, the interval between start time and end time is limited to 24 hours.

Sample request :

  "method": "POST",
  "url": "https://store.uat.sunmi.com/openapi/passengerFlow/stat/history/getTrendByHour",
  "headers": {
    "Content-Type": "application/x-www-form-urlencoded"
  },
  formData: {
    "shop_id": "7948",
    "app_id": "LMWWQVTW4QGCC",
    "start_time": "2020-01-01",
    "end_time": "2020-01-01",
    "timestamp": 1581383983,
    "random": "5dsf6698",
    "sign": "33C18A18282733A71F998BB5A5E4319D"
  }

Return value:

{
    "data": {
        "count_list": [
            {
                "time": "2019-12-01 0:00",
                "total_count": 0, 
                "regular_count": 0, 
                "stranger_count": 0, 
                "member_count": 0, 
                "unexposed_count": 0 
            },
            {
                "time": "2019-12-01 1:00",
                "total_count": 0,
                "regular_count": 0,
                "stranger_count": 0,
                "member_count": 0,
                "unexposed_count": 0
            },
            {
                "time": "2019-12-01 2:00",
                "total_count": 0,
                "regular_count": 0,
                "stranger_count": 0,
                "member_count": 0,
                "unexposed_count": 0
            },
            {
                "time": "2019-12-01 3:00",
                "total_count": 0,
                "regular_count": 0,
                "stranger_count": 0,
                "member_count": 0,
                "unexposed_count": 0
            },
            {
                "time": "2019-12-01 4:00",
                "total_count": 0,
                "regular_count": 0,
                "stranger_count": 0,
                "member_count": 0,
                "unexposed_count": 0
            },
            {
                "time": "2019-12-01 5:00",
                "total_count": 0,
                "regular_count": 0,
                "stranger_count": 0,
                "member_count": 0,
                "unexposed_count": 0
            },
            {
                "time": "2019-12-01 6:00",
                "total_count": 0,
                "regular_count": 0,
                "stranger_count": 0,
                "member_count": 0,
                "unexposed_count": 0
            },
            {
                "time": "2019-12-01 7:00",
                "total_count": 0,
                "regular_count": 0,
                "stranger_count": 0,
                "member_count": 0,
                "unexposed_count": 0
            },
            {
                "time": "2019-12-01 8:00",
                "total_count": 0,
                "regular_count": 0,
                "stranger_count": 0,
                "member_count": 0,
                "unexposed_count": 0
            },
            {
                "time": "2019-12-01 9:00",
                "total_count": 0,
                "regular_count": 0,
                "stranger_count": 0,
                "member_count": 0,
                "unexposed_count": 0
            },
            {
                "time": "2019-12-01 10:00",
                "total_count": 0,
                "regular_count": 0,
                "stranger_count": 0,
                "member_count": 0,
                "unexposed_count": 0
            },
            {
                "time": "2019-12-01 11:00",
                "total_count": 0,
                "regular_count": 0,
                "stranger_count": 0,
                "member_count": 0,
                "unexposed_count": 0
            },
            {
                "time": "2019-12-01 12:00",
                "total_count": 0,
                "regular_count": 0,
                "stranger_count": 0,
                "member_count": 0,
                "unexposed_count": 0
            },
            {
                "time": "2019-12-01 13:00",
                "total_count": 0,
                "regular_count": 0,
                "stranger_count": 0,
                "member_count": 0,
                "unexposed_count": 0
            },
            {
                "time": "2019-12-01 14:00",
                "total_count": 0,
                "regular_count": 0,
                "stranger_count": 0,
                "member_count": 0,
                "unexposed_count": 0
            },
            {
                "time": "2019-12-01 15:00",
                "total_count": 0,
                "regular_count": 0,
                "stranger_count": 0,
                "member_count": 0,
                "unexposed_count": 0
            },
            {
                "time": "2019-12-01 16:00",
                "total_count": 0,
                "regular_count": 0,
                "stranger_count": 0,
                "member_count": 0,
                "unexposed_count": 0
            },
            {
                "time": "2019-12-01 17:00",
                "total_count": 0,
                "regular_count": 0,
                "stranger_count": 0,
                "member_count": 0,
                "unexposed_count": 0
            },
            {
                "time": "2019-12-01 18:00",
                "total_count": 0,
                "regular_count": 0,
                "stranger_count": 0,
                "member_count": 0,
                "unexposed_count": 0
            },
            {
                "time": "2019-12-01 19:00",
                "total_count": 0,
                "regular_count": 0,
                "stranger_count": 0,
                "member_count": 0,
                "unexposed_count": 0
            },
            {
                "time": "2019-12-01 20:00",
                "total_count": 0,
                "regular_count": 0,
                "stranger_count": 0,
                "member_count": 0,
                "unexposed_count": 0
            },
            {
                "time": "2019-12-01 21:00",
                "total_count": 0,
                "regular_count": 0,
                "stranger_count": 0,
                "member_count": 0,
                "unexposed_count": 0
            },
            {
                "time": "2019-12-01 22:00",
                "total_count": 0,
                "regular_count": 0,
                "stranger_count": 0,
                "member_count": 0,
                "unexposed_count": 0
            },
            {
                "time": "2019-12-01 23:00",
                "total_count": 0,
                "regular_count": 0,
                "stranger_count": 0,
                "member_count": 0,
                "unexposed_count": 0
            }
        ]
    },
    "code": 0, /* Please refer to the error list for other errors*/
    "msg": "succeed"
}

Error codes:

Error codeDescription
5000Database error
5013No data found
5041No shop_id parameter found in the request

6.3.8 Acquire the Historical Customer Flow Trend (Total/New and Repeat Customer, the Time Granularity Is Day)

Request link: /passengerFlow/stat/history/getTrendByDay

Interface description: users can acquire the customer flow trend of a period of time by calling this interface.

Interface parameters:

ParameterRequiredTypeDescriptionExample
shop_idYesstringThe ID of the store to be interfaced with on SaaS platform, which should be provided by the SaaS supplier.15220
start_timeYesstringThe start (YYYY-MM-DD) of the time interval to be filtered 2020-01-01
end_time YesstringThe end (YYYY-MM-DD) of the time interval to be filtered 2020-01-03

Note:

For each time you call the interface, the interval between start time and end time is limited to 30 days.

Sample request :

  "method": "POST",
  "url": "https://store.uat.sunmi.com/openapi/passengerFlow/stat/history/getTrendByDay",
  "headers": {
    "Content-Type": "application/x-www-form-urlencoded"
  },
  formData: {
    "shop_id": "7948",
    "app_id": "LMWWQVTW4QGCC",
    "start_time": "2020-01-01",
    "end_time": "2020-01-03",
    "timestamp": 1581383983,
    "random": "5dsf6698",
    "sign": "33C18A18282733A71F998BB5A5E4319D"
  }

Return value:

{
    "data": {
        "count_list": [
            {
                "time": "2020-01-01",
                "total_count": 0,
                "regular_count": 0, 
                "stranger_count": 0, 
                "member_count": 0, 
                "unexposed_count": 0 
            },
            {
                "time": "2020-01-02",
                "total_count": 0,
                "regular_count": 0,
                "stranger_count": 0,
                "member_count": 0,
                "unexposed_count": 0
            },
            {
                "time": "2020-01-03",
                "total_count": 0,
                "regular_count": 0,
                "stranger_count": 0,
                "member_count": 0,
                "unexposed_count": 0
            }
        ]
    },
    "code": 0, /* Please refer to the error list for other errors*/
    "msg": "succeed"
}

Error codes:

Error codeDescription
5000Database error
5013No data found
5041No shop_id parameter found in the request

6.3.9 Acquire the Historical Customer Flow Trend (Total/New and Repeat Customer, the Time Granularity Is Week) (Developing)

Request link: /passengerFlow/stat/history/getTrendByWeek

Interface description: users can acquire the customer flow trend in a period of time by calling this interface.

Interface parameters:

ParameterRequiredTypeDescription
shop_idYesstringThe ID of the store to be interfaced with on SaaS platform, which should be provided by the SaaS supplier.
start_timeYesstringThe start (YYYY-MM-DD) of the time interval to be filtered
end_time YesstringThe end (YYYY-MM-DD) of the time interval to be filtered

Note:

For each time you call the interface, the interval between start time and end time is limited to 12 weeks.

Return value:

{
    "code": 0, /* 其他错误参考错误列表 */
    "msg": "succeed",
    "data": {
        "count_list": [
            {
                "time": "2019-09-11",
                "total_count": 0, 
                "regular_count": 0, 
                "stranger_count": 0, 
                "member_count": 0 
            },
            {
                "time": "2019-09-17",
                "total_count": 0,
                "regular_count": 0,
                "stranger_count": 0,
                "member_count": 0
            }
        ]
    }
}

Error codes:

Error codeDescription
5000Database error
5013No data found
5041No shop_id parameter found in the request

6.3.10 1.1.1 Acquire the Historical Customer Flow Trend (Total/New and Repeat Customer, the Time Granularity Is Month)

Request link: /passengerFlow/stat/history/getTrendByMonth

Interface description: users can acquire the customer flow trend in a period of time by calling this interface.

Interface parameters:

ParameterRequiredTypeDescription
shop_idYesstringThe ID of the store to be interfaced with on SaaS platform, which should be provided by the SaaS supplier.
start_timeYesstringThe start (YYYY-MM-DD) of the time interval to be filtered
end_time YesstringThe end (YYYY-MM-DD) of the time interval to be filtered

Note:

For each time you call the interface, the interval between start time and end time is limited to 12 months.

Return value:

{
    "code": 0, /* refer to the blew table for more errcode description */
    "msg": "succeed",
    "data": {
        "count_list": [
            {
                "time": "2019-01",
                "total_count": 0, 
                "regular_count": 0, 
                "stranger_count": 0, 
                "member_count": 0 
            },
            {
                "time": "2019-12",
                "total_count": 0,
                "regular_count": 0,
                "stranger_count": 0,
                "member_count": 0
            }
        ]
    }
}

Error codes:

Error codeDescription
5000Database error
5013No data found
5041No shop_id parameter found in the request

7 The Interface to Playback the Live Video

7.1 1.1 Interface Description

This interface is used to check the real-time and historical video data.

7.2 Interface List

InterfaceDescription
/media/live/startStart remote live video
/media/live/stopEnd remote live video
/media/playback/startStart remote video playback (developing)
/media/playback/stopEnd remote video playback (developing)
/media/video/getListAcquire the list of video playback
/media/motionDetection/getListAcquire the list of motion detection videos
/media/playback/getSnapshotAcquire the snapshots of a specified period of time
/media/live/getSnapshotAcquire the snapshots of real-time monitor

7.3 Interface Details

InterfaceDescription
/media/live/startStart remote live video
/media/live/stopEnd remote live video
/media/playback/startStart remote video playback (developing)
/media/playback/stopEnd remote video playback (developing)
/media/video/getListAcquire the list of video playback
/media/motionDetection/getListAcquire the list of motion detection videos
/media/playback/getSnapshotAcquire the snapshots of a specified period of time
/media/live/getSnapshotAcquire the snapshots of real-time monitor

7.3.1  Enable Remote Live-Broadcasting

Interface description: users can enable remote live-broadcasting by calling this interface.

Request link: /media/live/start

Interface parameters:

ParameterRequiredTypeDescriptionExample
shop_idYesstringThe ID of the store to be interfaced with on SaaS platform, which should be provided by the SaaS supplier.10087
ipc_idYesstringThe unique ID of an IPC549755805835
resolutionYesintResolution0

Sample request :

  "method": "POST",
  "url": "https://store.uat.sunmi.com/openapi/media/live/start",
  "headers": {
    "Content-Type": "application/x-www-form-urlencoded"
  },
  formData: {
    "shop_id": "10087",
    "app_id": "LMWWQVTW4QGCC",
    "ipc_id": "549755805835",
    "resolution": 0,
    "timestamp": 1581383983,
    "random": "5dsf6698",
    "sign": "33C18A18282733A71F998BB5A5E4319D"
  }

Return value:

{
    "code": 0, /* Please refer to the error list for other errors*/
    "msg": "succeed"
    "data": {
        "url": "https://xxxxxxxx/C101P98200023/1219130724381102080.flv?auth_key=1579501989-729716105000265001016467621435-0-",
        "hls_url": "https://xxxxxxxx/C101P98200023/1219130724381102080.m3u8?auth_key=1579501989-729716105000265001016467621435-0-"
    }
}

Field description: resolution

resolution valueDescription
0Super high definition
1High definition

Error codes:

Error codeDescription
5000Database error
5011Error in communication with the device
5013No data found
5041No shop_id parameter found in the request
5501The IPC does not exist
5510Unbound device

7.3.2  End Live

Interface description: users can end the remote live by calling this interface.

Request link: /media/live/stop

Interface parameters:

ParameterRequiredTypeDescriptionExample
shop_idYesstringThe ID of the store to be interfaced with on SaaS platform, which should be provided by the SaaS supplier.10087
ipc_idYesstringThe unique ID of an IPC549755805835
resolutionYesintResolution0

Sample request :

  "method": "POST",
  "url": "https://store.uat.sunmi.com/openapi/media/live/stop",
  "headers": {
    "Content-Type": "application/x-www-form-urlencoded"
  },
  formData: {
    "shop_id": "10087",
    "app_id": "LMWWQVTW4QGCC",
    "ipc_id": "549755805835",
    "resolution": 0,
    "timestamp": 1581383983,
    "random": "5dsf6698",
    "sign": "33C18A18282733A71F998BB5A5E4319D"
  }

Return value:

{
    "code": 0,  /* 其他错误参考错误列表 */
    "msg": "succeed",
    "data": {}
}

Field description: resolution

resolution valueDescription
0Super high definition
1High definition

错误码:

Error CodeDescription
5000Database error
5013No data found
5011Error in communication with the device
5041No shop_id parameter found in the request
5501The IPC does not exist
5510Unbound device

7.3.4  Acquire the List of Video for Playback

Interface description: users can acquire the list of video playback by calling this interface.

Request link: /media/video/getList

Interface parameters:

ParameterRequiredTypeDescriptionExample
shop_idYesstringThe ID of the store to be interfaced with on SaaS platform, which should be provided by the SaaS supplier.10087
ipc_idYesstringThe unique ID of an IPC549755805835
start_timeYesintThe Unix timestamp (accurate to second) which indicates the start time of the inquiry1578969264
end_timeYesintThe Unix timestamp (accurate to second) which indicates the end time of the inquiry1578972864

Note:

The time interval between start_time and end_time shall be within 3600s

Sample request :

  "method": "POST",
  "url": "https://store.uat.sunmi.com/openapi/media/video/getList",
  "headers": {
    "Content-Type": "application/x-www-form-urlencoded"
  },
  formData: {
    "shop_id": "10087",
    "app_id": "LMWWQVTW4QGCC",
    "ipc_id": "549755805835",
    "start_time": 1578969264,
    "end_time": 1578969264,
    "timestamp": 1578972864,
    "random": "5dsf6698",
    "sign": "33C18A18282733A71F998BB5A5E4319D"
  }

Return value:

{
    "code": 0, /* Please refer to the error list for other errors*/
    "msg": "succeed",
    "data": {
	"total_count": 1,
	"video_list": [{
            "ipc_id": "549755812970",
	    "url": "http: //xxxxxxxx/VIDEO/IPC/SS101D8BS00087/39C1045AF2EA34B0CEA528FB228C8EDA",
	    "start_time": 1551854897,
	    "end_time": 1551854958
	}]
	}
}

Error codes:

Error codeDescription
5000Database error
5013No data found
5021Invalid parameter (the time interval overruns the limit)
5041No shop_id parameter found in the request

7.3.5 Acquire the List of Motion Detection Videos

Interface description: users can acquire the list of motion detection videos

Request link: /media/motionDetection/getList

Interface parameters:

ParameterRequiredTypeDescriptionExample
shop_idYesstringThe ID of the store to be interfaced with on SaaS platform, which should be provided by the SaaS supplier.10087
ipc_idYesstringThe unique ID of an IPC549755805835
start_timeYesintThe Unix timestamp (accurate to second) which indicates the start time of the inquiry1578969264
end_timeYesintThe Unix timestamp (accurate to second) which indicates the end time of the inquiry1579055640
page_numNo (1 by default)intThe current page number1
page_sizeNo (10 by default)intThe number of entries (100 maximum) on the current page10

Sample request :

  "method": "POST",
  "url": "https://store.uat.sunmi.com/openapi/media/motionDetection/getList",
  "headers": {
    "Content-Type": "application/x-www-form-urlencoded"
  },
  formData: {
    "shop_id": "10087",
    "app_id": "LMWWQVTW4QGCC",
    "ipc_id": "549755805835",
    "start_time": 1578969264,
    "end_time": 1579055640,
    "timestamp": 1578972864,
    "random": "5dsf6698",
    "sign": "33C18A18282733A71F998BB5A5E4319D"
  }

Return value:

{   
    "code": 0, /* Please refer to the error list for other errors*/
    "msg": "succeed",
    "data": {
	"total_num": 1,
	"video_list": [{
            "source": "1",
	    "detect_time": 1551854897,
	    "url": "http: //xxxxxxxx/VIDEO/IPC/SS101D8BS00087/39C1045AF2EA34B0CEA528FB228C8EDA"
	}]
    }
}

Field description: source

source valueDescription
1Image
2Sound
3Image and sound

Error codes:

Error codeDescription
5000Database error
5013No data found
5041No shop_id parameter found in the request

7.3.6 Acquire the Monitoring Images in a Specified Time Range

Interface description: users can acquire the monitoring images in a specified time range by calling this interface.

Request link: /media/playback/getSnapshot

Interface parameters:

ParameterRequiredTypeDescriptionExample
shop_idYesstringThe ID of the store to be interfaced with on SaaS platform, which should be provided by the SaaS supplier.15220
ipc_idYesstringThe unique ID of an IPC549755812970
timeYesintThe Unix timestamp (accurate to second) which indicates the screenshot time1579055640

Sample request :

  "method": "POST",
  "url": "https://store.uat.sunmi.com/openapi/media/playback/getSnapshot",
  "headers": {
    "Content-Type": "application/x-www-form-urlencoded"
  },
  formData: {
    "shop_id": "10087",
    "app_id": "LMWWQVTW4QGCC",
    "ipc_id": "549755805835",
    "time": 1579055640,
    "timestamp": 1578972864,
    "random": "5dsf6698",
    "sign": "33C18A18282733A71F998BB5A5E4319D"
  }

Return value:

{
    "code": 0,  /* Please refer to the error list for other errors*/
    "msg": "succeed",
    "data": {
        "snapshot_url":"http://xxxxxxxx/VIDEO/IPC/SS101D8BS00087/39C1045AF2EA34B0CEA528FB228C8EDA"
    }
}

Error codes:

Error codeDescription
5000Database error
5013No data found
5041No shop_id parameter found in the request

7.3.7 Acquire the Real-Time Monitoring Image

Interface description: users can acquire the real-time monitoring images by calling this interface, and the validity of the images is one day.

Request link: /media/live/getSnapshot

Interface parameters:

ParameterRequiredTypeDescriptionExample
shop_idYesstringThe ID of the store to be interfaced with on SaaS platform, which should be provided by the SaaS supplier.10087
ipc_idYesstringThe unique ID of an IPC549755805835

Sample request :

  "method": "POST",
  "url": "https://store.uat.sunmi.com/openapi/media/live/getSnapshot",
  "headers": {
    "Content-Type": "application/x-www-form-urlencoded"
  },
  formData: {
    "shop_id": "10087",
    "app_id": "LMWWQVTW4QGCC",
    "ipc_id": "549755805835",
    "timestamp": 1578972864,
    "random": "5dsf6698",
    "sign": "33C18A18282733A71F998BB5A5E4319D"
  }

Return value:

{
    "code": 0,  /* Please refer to the error list for other errors*/
    "msg": "succeed",
    "data":{  
        "snapshot_url":"http://xxxxxxxx/VIDEO/IPC/SS101D8BS00087/39C1045AF2EA34B0CEA528FB228C8EDA"
    }
}

Error codes:

Error codeDescription
5000Database error
5011Error in communication with the device
5013No data found
5041No shop_id parameter found in the request
5501IPC does not exist
5510The device is unbound
5515The screenshot time overrun the limit


7.3.8
Start remote playback

Interface description: Through this interface call, the user can start remote playback.

Request link: /media/playback/start

Interface parameters:

ParameterRequiredTypeDescriptionExample
shop_idYesstringThe ID of the store to be interfaced with on SaaS platform, which should be provided by the SaaS supplier.10087
ipc_idYesstringThe unique ID of an IPC549755805835
start_timeYesint开始查询时间,Unix时间戳,秒级别1578969264
end_timeYesint结束查询时间,Unix时间戳,秒级别1579055640

Sample request :

  "method": "POST",
  "url": "https://store.uat.sunmi.com/openapi/media/playback/start",
  "headers": {
    "Content-Type": "application/x-www-form-urlencoded"
  },
  formData: {
    "shop_id": "10087",
    "app_id": "LMWWQVTW4QGCC",
    "ipc_id": "549755805835",
    "start_time": 1578969264,
    "end_time": 1579055640,
    "timestamp": 1578972864,
    "random": "5dsf6698",
    "sign": "33C18A18282733A71F998BB5A5E4319D"
  }

Return value:

{
    "code": 0,  /* Please refer to the error list for other errors*/
    "msg": "succeed",
    "data": {
        "url": "https://xxxxxxxx/SAAS-OpenAPI_1211497245552152576/1577092646.flv?auth_key=1577096246-57626095498907571693914212321441-0-",
        "hls_url": "https://xxxxxxxx/SAAS-OpenAPI_1211497245552152576/1577092646.flv?auth_key=1577096246-57626095498907571693914212321441-0-",
        "client_id": "SAAS-OpenAPI_1211497245552152576"
    }
}

Error codes:

Error codeDescription
5021Illegal parameter (time interval exceeding limit)
5041 No shop_id parameter found in the request
5087Unmatched data
5088Database error
5506No data found


7.3.9
End remote playback

Interface description: Through this interface call, the user can start remote playback.

Request link: /media/playback/stop

Interface parameters:

ParameterRequiredType Description Example
client_id Yesstring user client id SAAS-OpenAPI_1211497245552152576

Sample request :

  "method": "POST",
  "url": "https://store.uat.sunmi.com/openapi/media/playback/stop",
  "headers": {
    "Content-Type": "application/x-www-form-urlencoded"
  },
  formData: {
    "client_id": "SAAS-OpenAPI_1211497245552152576",
    "app_id": "LMWWQVTW4QGCC",
    "timestamp": 1578972864,
    "random": "5dsf6698",
    "sign": "33C18A18282733A71F998BB5A5E4319D"
  }

Return value:

{
    "code": 0,  /* Please refer to the error list for other errors*/
    "msg": "succeed",
    "data": {}
}

Error codes:

Error codeDescription
5020Invalid parameter

8  Notifications Center

8.1 Interface description

SUNMI Store platform can push notifications to the cooperative SaaS parties according to the notification type subscribed by the cooperative platforms

8.2 Interface List

Please refer to Notification Center.

9 docking demonstration

9.1 Shop lignment

Please refer to Sunmi Store Open Platform -> Shop APIs, it is introduce how to set up the mapping relationship between sunmi’s shop and saas’ shop. All subsequent operations are based on the devices and data in the stop

9.2 Configuration Network For Device

If your device is connected to the Internet through cable, please skip this step.

If your device is connected to the Internet through a wireless network, please follow the steps below to use the Android SDK for network configration (for other operating systems or devices, you can also directly call the device API for network configration).

If the blue light on the device is always on which inndicates that the device is connected to Internet successful

If the green light on the device is always on which inndicates that the device is connected to Internet abnormal

9.3 Bind Device

9.3.1 Bind Device by API(under development)

After the IPC device is connected to the network successful, call the device binding interface /device/ipc/bind to bind the device to the specified stop.

demo case:

  "method": "POST",
  "url": "https://store.uat.sunmi.com/openapi/device/ipc/bind",
  "headers": {
    "Content-Type": "application/x-www-form-urlencoded"
  },
  formData: {
    "shop_id": "10087",
    "ipc_sn": "C201D8BS00089",
    "app_id": "LMWWQVTW4QGCC",
    "timestamp": 1578972864,
    "random": "5dsf6698",
    "sign": "33C18A18282733A71F998BB5A5E4319D"
  }

9.3.2 bind device on sunmi store web

Open the Sunmi assistant APP which can be downloaded from Android or IOS market, login with your own username and password which has been set up relationship with saas’ shop.
In the shop, please click the Device to choose a type device added, at the same time, turn on the camera power. After the power is turned on, wait for about 20 seconds. When the camera’s green light is flashing , then click next.

There are two mode for connecting Internet: Wired and wireless

  • For cable network connection, need to plug in the cable for the camera, at the same time, keep the sunmi assistant app in the same network; after the camera ‘s  blue light is always on, then click next, and find the corresponding IPC device to bind.
  • For wireless network connection, need to connect your mobile phone which has been installed sunmi assistant app to the camera’s wireless network [Sunmi XXXX] (you can find the network name on the camera body or the box), then click next to find the corresponding IPC device to bind

After adding successfully, the newly added IPC devices can be seen on mobile phones and the web

9.4 Device configration

9.4.1 Adjust Camera Focus By API (under development)

After the device is bound, the API can be called to adjust camera focus

9.4.2 Setting Incoming Line On Store Web

The first thing for face sense camera is set incoming line for the shop.

Step1: open the sunmi assistant app, login the corresponding shop with right username and password, click the Device, then click the three small icons in the upper right of the screen to enter the camera settings, then start to adjust the screen to get the best picture
Step2: the screen will prompt “please guide the customer to face to the IPC and stand at the right place for face reorganization”, and then click next in the upper right corner of the screen

Step3: the screen will prompt ” Please fit the face into the facial recognition box by adjusting the size of the image and moving the box “. At the same time, the camera will automatically adjust the screen, and prompt ” To ensure the recognition accuracy, you can move the store doorsill line you set or drag the ends of the doorsill line to change doorsill length “, which is that you can manually mark the line on the mobile screen to set the position of the entrance threshold, and then click finish

9.5 Watch Living Video

Interface List

Detailed info can be read in chapter 7: playbace living video

InterfaceDescription
/media/live/startStart remote live video
/media/live/stopEnd remote live video
/media/playback/startStart remote video playback (developing)
/media/playback/stopEnd remote video playback (developing)
/media/video/getListAcquire the list of video playback
/media/motionDetection/getListAcquire the list of motion detection videos
/media/playback/getSnapshotAcquire the snapshots of a specified period of time
/media/live/getSnapshotAcquire the snapshots of real-time monitor

9.6 Customer Flow Statistics

Interface list

Detailed info can be read in chapter 6: customer flow statistics

InterfaceDescription
/passengerFlow/stat/today/getLatestAcquire the real-time customer flow of the current day (real-time total customer flow)
/passengerFlow/stat/today/groupByTagAcquire the customer flow data of the current day (according to the age and new/repeat face groups)
/passengerFlow/stat/today/groupByGenderAcquire the customer flow data of the current day (according to the age and gender group)
/passengerFlow/stat/today/getTrendByHourAcquire the customer flow trend of the current day (total customer flow, the time granularity is hour)
/passengerFlow/stat/history/groupByTagAcquire historical customer flow data (total customer flow/new and repeat customer/member)
/passengerFlow/stat/history/groupByGenderAcquire the details on historical customer group (age and gender)
/passengerFlow/stat/history/getTrendByHourAcquire the historical customer flow trend (total customer flow/new and repeat customers, the time granularity is hour)
/passengerFlow/stat/history/getTrendByDayAcquire the historical customer flow trend (total customer flow/new and repeat customer, the time granularity is day)
/passengerFlow/stat/history/getTrendByWeekAcquire the historical customer flow trend (total customer flow/new and repeat customer, the time granularity is week) (developing)
/passengerFlow/stat/history/getTrendByMonthAcquire the historical customer flow trend (total customer flow/new or repeat customer, the time granularity is month) (developing)

9.7 Real-time To Get face_id

Please refer to Sunmi Store Open Platform ->Notification Center: hook/add. First, hook the monitored event with the callback HTTP address and function to sunmi store open platform

Second, when IPC get the related face will report to sunmi cloud backend system, sunmi will push the face info to saas’ hooked http address.

9.7.1 Add an event monitoring

Description:

By requesting this API, User could set up an http callback for a set of events of their choice on the SUNMI store open platform.

When the specified events happened, open platform will request the given HTTP API.

The authorization of this HTTP API must be the same as the SUNMI store open platform API method.

Following parameters must be included in the callback API:

parameter required type description
shop_id yesstring the identifier of the saas shop which applied by saas
event yesint the type of event to monitor
payload yes string the specific structure of message in JSON

API address: /hook/add

Parameters

parametersreqired type decription example
shop_id yes string the identifier of the saas shop which applied by saas 15220
http_callback yes string the http call back API http://xxxxxxxx/api/testHook
event_list yesarray[int] the list of event to be monitored [2001]

demo case:

  "method": "POST",
  "url": "https://store.uat.sunmi.com/openapi/hook/add",
  "headers": {
    "Content-Type": "application/x-www-form-urlencoded"
  },
  formData: {
    "shop_id": "15220",
    "http_callback": "http://xxxxxxxx/api/testHook",
    "event_list": [2001],
    "app_id": "LMWWQVTW4QGCC",
    "timestamp": 1578972864,
    "random": "5dsf6698",
    "sign": "33C18A18282733A71F998BB5A5E4319D"
  }

return value :

{
    code:0,    
    msg: "succeed",
    data: {}               
}

parameter event

event value description
2001 IPC real time face recognition message

payload(event=2001):

{
    ipc_id: "928",
    face_id: "29195",
    gender: 1,
    age_range: 4,
    group_id: "8927",
    group_name: "stranger",
    group_type": 2
}

parameter : gender

gender valuedescrption
0 unkown
1male
2female

parameter : age_range

age_range valuedescription
1 age 0~6
2age 7~12
3age 13~18
4age 19~28
5age 29~35
6age 36~45
7age 46~55
8age 56~

parameter: group_type

group_type value description
1 stranger face library
2 familiar face library
3 shop assistant face library
5 custom face library

Appendix

Update record

update dateupdate content
2019-07-07draft
2019-07-17Simplified interface, keep the shop_id as the only indentifer for saas
2019-08-08adjust some return value
2019-08-23update notification center