Basic Configurations

  1. Set WIFI Configurations
  2. Set WIFI Configurations (without authentication)
  3. Get WIFI Configurations
  4. Get AP List
  5. Get AP List (without authentication)
  6. Set Zoom
  7. Manual Focus
  8. Automatic Focus
  9. Reset Zoom and Focus
  10. Get Zoom and Focus Configurations
  11. Set IR Mode
  12. Get IR Mode
  13. Set Dynamic Detect
  14. Get Dynamic Detect
  15. Set IPC Name
  16. Get IPC Name
  17. Set LED
  18. Get LED
  19. Set Rotation
  20. Get Rotation
  21. Get Rotation Angles
  22. Format SD-card
  23. Get SD-card Status

1. Set WIFI Configurations

Description

Set the SSID and password for Internet connection.

Request Link

https://192.168.0.1/openapi/config/setWifiConf, 192.168.0.1 should be replaced by the IP address of the IPC.

Request Parameters

Below are private parameters for this API, please refer to Public Parameters for more details.

ParameterTypeDescriptionRequiredExample
ssid stringThe name of wireless network or “SSID” to connect, maximum 32 charactersY WeWork
password stringThe password of the AP to connect, left blank if no password is required, WEP is not supported, maximum 64 charactersY

Response Parameters

ParameterTypeDescription
code int Return code, represent the request result,
possible return codes are 0, 1, 2, 3, 5, 7, 100, 101, see Error Code for further details.

Request Example

POST /openapi/config/setWifiConf HTTP/1.1
Host: 192.168.0.1
Content-Type: application/x-www-form-urlencoded

app_id=mdk923idkf&random=289192&timestamp=15930292837&sign=IDKNFLK392038KDS932K& ssid=sunmi_ipc&password=1234567890

Response Example

{
    “code”: 0
}

2. Set WIFI Configurations (without authentication)

Description

Set the SSID and password for Internet connection before activation, invalid after activation.

Request Link

https://192.168.0.1/openapi/config/setWifiConfWithoutAuth, 192.168.0.1 should be replaced by the IP address of the IPC.

Request Parameters

This API requires no public parameter.

ParameterTypeDescriptionRequiredExample
ssid stringThe name of wireless network or “SSID” to connect, maximum 32 charactersY WeWork
password stringThe password of the AP to connect, left blank if no password is required, WEP is not supported, maximum 64 charactersY

Response Parameters

ParameterTypeDescription
code int Return code, represent the request result,
possible return codes are 0, 1, 2, 3, 5, 7, 12, 100, 101, see Error Code for further details.

Request Example

POST /openapi/config/setWifiConfWithoutAuth HTTP/1.1
Host: 192.168.0.1
Content-Type: application/x-www-form-urlencoded

ssid=sunmi_ipc&password=1234567890

Response Example

{
    “code”: 0
}

3. Get WIFI Configurations

Description

Get the WIFI configurations.

Request Link

https://192.168.0.1/openapi/config/getWifiConf, 192.168.0.1 should be replaced by the IP address of the IPC.

Request Parameters

No private parameter for this API, please refer to Public Parameters for more details.

Response Parameters

ParameterTypeDescription
code int Return code, represent the request result,
possible return codes are 0, 1, 3, 5, 7, see Error Code for further details.
ssid string SSID
password string Password

Request Example

POST /openapi/config/getWifiConf HTTP/1.1
Host: 192.168.0.1
Content-Type: application/x-www-form-urlencoded

app_id=mdk923idkf&random=289192×tamp=15930292837&sign=IDKNFLK392038KDS932K

Response Example

{
    “code”: 0,
    “data”: {
        “ssid”: “SUNMI_IPC”,
        “password”: “1234567890”
    }
}

4. Get AP List

Description

Get the AP list discovered by the IPC.

Request Link

https://192.168.0.1/openapi/config/getApList, 192.168.0.1 should be replaced by the IP address of the IPC.

Request Parameters

No private parameter for this API, please refer to Public Parameters for more details.

Response Parameters

ParameterTypeDescription
code int Return code, represent the request result,
possible return codes are 0, 1, 3, 5, 7, see Error Code for further details.
num int Number of AP discovered
ssid string SSID
key_mgmt string Encryption method

Request Example

POST /openapi/config/getApList HTTP/1.1
Host: 192.168.0.1
Content-Type: application/x-www-form-urlencoded

app_id=mdk923idkf&random=289192&timestamp=15930292837&sign=IDKNFLK392038KDS932K

Response Example

{
    “code”:0,
    “data”: 
    {
        “num”: 3,
        “ap_list”:[
            {
                “ssid”: “TP-LINK_3475”,
                “key_mgmt”: “WPA-PSK”
            },
            {
                “ssid”: “WeWork”,
                “key_mgmt”: “WPA-PSK”
            },
            {
                “ssid”: “WeWorkCorp”,
                “key_mgmt”: “WPA-PSK”
            }
        ]
    }
}

5. Get AP List (without authentication)

Description

Get the AP list discovered by the IPC before activation, invalid after activation.

Request Link

https://192.168.0.1/openapi/config/getApListWithoutAuth, 192.168.0.1 should be replaced by the IP address of the IPC.

Request Parameters

No private parameter for this API, please refer to Public Parameters for more details.

Response Parameters

ParameterTypeDescription
code int Return code, represent the request result,
possible return codes are 0, 1, 3, 5, 7, see Error Code for further details.
num int Number of AP discovered
ssid string SSID
key_mgmt string Encryption method

Request Example

POST /openapi/config/getApListWithoutAuth HTTP/1.1
Host: 192.168.0.1
Content-Type: application/x-www-form-urlencoded

app_id=mdk923idkf&random=289192&timestamp=15930292837&sign=IDKNFLK392038KDS932K

Response Example

{
    “code”:0,
    “data”: 
    {
        “num”: 3,
        “ap_list”:[
            {
                “ssid”: “TP-LINK_3475”,
                “key_mgmt”: “WPA-PSK”
            },
            {
                “ssid”: “WeWork”,
                “key_mgmt”: “WPA-PSK”
            },
            {
                “ssid”: “WeWorkCorp”,
                “key_mgmt”: “WPA-PSK”
            }
        ]
    }
}

6. Set Zoom

Description

Set the zoom level of the lens.

Request Link

https://192.168.0.1/openapi/config/setZoom, 192.168.0.1 should be replaced by the IP address of the IPC.

Request Parameters

Below are private parameters for this API, please refer to Public Parameters for more details.

ParameterTypeDescriptionRequiredExample
zoom int Zoom level, range is [0, 500]. Y 200

Response Parameters

ParameterTypeDescription
code int Return code, represent the request result,
possible return codes are 0, 1, 3, 5, 7, 110, see Error Code for further details.

Request Example

POST /openapi/config/setZoom HTTP/1.1
Host: 192.168.0.1
Content-Type: application/x-www-form-urlencoded

app_id=mdk923idkf&random=289192&timestamp=15930292837&sign=IDKNFLK392038KDS932K& zoom=100

Response Example

{
    “code”: 0
}

7. Manual Focus

Description

Set the focus level of the lens. This is used to manually adjust the focus level if automatic focus after zooming is not satisfying.

Request Link

https://192.168.0.1/openapi/config/manualFocus, 192.168.0.1 should be replaced by the IP address of the IPC.

Request Parameters

Below are private parameters for this API, please refer to Public Parameters for more details.

ParameterTypeDescriptionRequiredExample
focus int Focus level, range is [0, 780]. Y 200

Response Parameters

ParameterTypeDescription
code int Return code, represent the request result,
possible return codes are 0, 1, 3, 5, 7, 111, see Error Code for further details.

Request Example

POST /openapi/config/manualFocus HTTP/1.1
Host: 192.168.0.1
Content-Type: application/x-www-form-urlencoded

app_id=mdk923idkf&random=289192&timestamp=15930292837&sign=IDKNFLK392038KDS932K& focus=100

Response Example

{
    “code”: 0
}

8. Automatic Focus

Description

Set to automatically focus to a given focus point.

Request Link

https://192.168.0.1/openapi/config/autoFocus, 192.168.0.1 should be replaced by the IP address of the IPC.

Request Parameters

Below are private parameters for this API, please refer to Public Parameters for more details.

ParameterTypeDescriptionRequiredExample
focus_x int X-axis percentage of the focus point, range is [0, 100]. Y 50
focus_y int Y-axis percentage of the focus point, range is [0, 100]. Y 50

Response Parameters

ParameterTypeDescription
code int Return code, represent the request result,
possible return codes are 0, 1, 3, 5, 7, 112, see Error Code for further details.

Request Example

POST /openapi/config/autoFocus HTTP/1.1
Host: 192.168.0.1
Content-Type: application/x-www-form-urlencoded

app_id=mdk923idkf&random=289192&timestamp=15930292837&sign=IDKNFLK392038KDS932K& focus_x=50&focus_y=50

Response Example

{
    “code”: 0
}

9. Reset Zoom and Focus

Description

Reset zoom and focus levels to defaults.

Request Link

https://192.168.0.1/openapi/config/resetZoomFocus, 192.168.0.1 should be replaced by the IP address of the IPC.

Request Parameters

No private parameter for this API, please refer to Public Parameters for more details.

Response Parameters

ParameterTypeDescription
code int Return code, represent the request result,
possible return codes are 0, 1, 3, 5, 7, see Error Code for further details.

Request Example

POST /openapi/config/resetZoomFocus HTTP/1.1
Host: 192.168.0.1
Content-Type: application/x-www-form-urlencoded

app_id=mdk923idkf&random=289192&timestamp=15930292837&sign=IDKNFLK392038KDS932K

Response Example

{
    “code”: 0
}

10. Get Zoom and Focus Configurations

Description

Get zoom and focus configurations.

Request Link

https://192.168.0.1/openapi/config/getZoomFocusConf, 192.168.0.1 should be replaced by the IP address of the IPC.

Request Parameters

No private parameter for this API, please refer to Public Parameters for more details.

Response Parameters

ParameterTypeDescription
code int Return code, represent the request result,
possible return codes are 0, 1, 3, 5, 7, see Error Code for further details.
max_zoom int Maximum zoom level
max_focus int Maximum focus level
zoom int Current zoom level
focus int Current focus level
focus_x int X-axis percentage of the focus point
focus_y int Y-axis percentage of the focus point

Request Example

POST /openapi/config/getZoomFocusConf HTTP/1.1
Host: 192.168.0.1
Content-Type: application/x-www-form-urlencoded

app_id=mdk923idkf&random=289192&timestamp=15930292837&sign=IDKNFLK392038KDS932K

Response Example

{
    “code”: 0,
    “data”: {
        “zoom”: 0,
        “max_zoom”: 500,
        “max_focus”: 780,
        “focus”: 0,
        “focused_x”: 50,
        “focused_y”: 50
    }
}

11. Set IR Mode

Description

Set IR mode of the lens.

Request Link

https://192.168.0.1/openapi/config/setIrMode, 192.168.0.1 should be replaced by the IP address of the IPC.

Request Parameters

Below are private parameters for this API, please refer to Public Parameters for more details.

ParameterTypeDescriptionRequiredExample
irmode int 0: off; 1: on; 2: auto. 2 is recommended. Y 2

Response Parameters

ParameterTypeDescription
code int Return code, represent the request result,
possible return codes are 0, 1, 3, 5, 7, 113, see Error Code for further details.

Request Example

POST /openapi/config/setIrMode HTTP/1.1
Host: 192.168.0.1
Content-Type: application/x-www-form-urlencoded

app_id=mdk923idkf&random=289192&timestamp=15930292837&sign=IDKNFLK392038KDS932K& irmode=1

Response Example

{
    “code”: 0
}

12. Get IR Mode

Description

Get IR mode of the lens.

Request Link

https://192.168.0.1/openapi/config/getIrMode, 192.168.0.1 should be replaced by the IP address of the IPC.

Request Parameters

No private parameter for this API, please refer to Public Parameters for more details.

Response Parameters

ParameterTypeDescription
code int Return code, represent the request result,
possible return codes are 0, 1, 3, 5, 7, see Error Code for further details.
irmode int Current IR mode of the lens

Request Example

POST /openapi/config/getIrMode HTTP/1.1
Host: 192.168.0.1
Content-Type: application/x-www-form-urlencoded

app_id=mdk923idkf&random=289192&timestamp=15930292837&sign=IDKNFLK392038KDS932K

Response Example

{
    “code”: 0,
    “data”: {
          “irmode”: 1
    }
}

13. Set Dynamic Detect

Description

Dynamic detection on the IPC supports detection and alarm motional and audio events. This API is used to set dynamic detection thresholds and period.

Request Link

https://192.168.0.1/openapi/config/setDynamicDetect, 192.168.0.1 should be replaced by the IP address of the IPC.

Request Parameters

Below are private parameters for this API, please refer to Public Parameters for more details.

Parameter TypeDescriptionRequiredExample
motion_level int Motion detection level, range is [0, 3] where 3 is most sensitive. Y 2
audio_level int Audio detection level, range is [0, 3] where 3 is most sensitive. Y 2
weekday int Detection period in a week. Bits are used to represent the weekdays:
bit 0 is for Monday, bit 1 is for Tuesday, bit 2 is for Wednesday,
bit 3 is for Thursday, bit 4 is for Friday, bit 5 is for Saturday,
bit 6 is for Sunday and bit 7 is for 7 x 24 hours. For example,
0b00001111 means detection is on from Monday to Thursday,
0b00010101 means detection is on at Monday, Wednesday and Friday.
Y 128 (decimal value of 0b10000000),
21 (decimal value of 0b00010101)
start_time long Start time of the day in minute, range is [0, 1440]. For example, 60 is
01:00, 121 is 02:01.
Y 200
stop_time long Stop time of the day in minute, range is [0, 1440]. For example, 60 is
01:00, 121 is 02:01.
Y 400

Response Parameters

ParameterTypeDescription
code int Return code, represent the request result,
possible return codes are 0, 1, 3, 5, 7, 114, 115, 116, 117, see Error Code for further details.

Request Example

POST /openapi/config/setDynamicDetect HTTP/1.1
Host: 192.168.0.1
Content-Type: application/x-www-form-urlencoded

app_id=mdk923idkf&random=289192&timestamp=15930292837&sign=IDKNFLK392038KDS932K motion_level=1&audio_level=1&weekday=128&start_time=1260&stop_time=540

Response Example

{
    “code”: 0
}

14. Get Dynamic Detect

Description

Get configurations of the dynamic detection.

Request Link

https://192.168.0.1/openapi/config/getDynamicDetect, 192.168.0.1 should be replaced by the IP address of the IPC.

Request Parameters

No private parameter for this API, please refer to Public Parameters for more details.

Response Parameters

ParameterTypeDescription
code int Return code, represent the request result,
possible return codes are 0, 1, 3, 5, 7, see Error Code for further details.
motion_level int Motion detection level, range is [0, 3] where 3 is most sensitive.
audio_level int Audio detection level, range is [0, 3] where 3 is most sensitive.
weekday int Detection period in a week. Bits are used to represent the weekdays:
bit 0 is for Monday, bit 1 is for Tuesday, bit 2 is for Wednesday,
bit 3 is for Thursday, bit 4 is for Friday, bit 5 is for Saturday,
bit 6 is for Sunday and bit 7 is for 7 x 24 hours. For example,
0b00001111 means detection is on from Monday to Thursday,
0b00010101 means detection is on at Monday, Wednesday and Friday.
start_time long Start time of the day in minute, range is [0, 1440]. For example, 60 is
01:00, 121 is 02:01.
stop_time long Stop time of the day in minute, range is [0, 1440]. For example, 60 is
01:00, 121 is 02:01.

Request Example

POST /openapi/config/getDynamicDetect HTTP/1.1
Host: 192.168.0.1
Content-Type: application/x-www-form-urlencoded


app_id=mdk923idkf&random=289192×tamp=15930292837&sign=IDKNFLK392038KDS932K

Response Example

{
    “code”: 0,
    “data”: {
          “motion_level”: 1,
         “audio_level”: 1,
         “weekday”: 7,
         “start_time”: 120
         “stop_time”: 240,
    }
}

15. Set IPC Name

Description

Set the name of the IPC.

Request Link

https://192.168.0.1/openapi/config/updateName, 192.168.0.1 should be replaced by the IP address of the IPC.

Request Parameters

Below are private parameters for this API, please refer to Public Parameters for more details.

ParameterTypeDescriptionRequiredExample
name string Name, maximum 36 characters Y Camera1

Response Parameters

ParameterTypeDescription
code int Return code, represent the request result,
possible return codes are 0, 1, 3, 5, 7, 118, see Error Code for further details.

Request Example

POST /openapi/config/updateName HTTP/1.1
Host: 192.168.0.1
Content-Type: application/x-www-form-urlencoded

app_id=mdk923idkf&random=289192&timestamp=15930292837&sign=IDKNFLK392038KDS932K&
name=front_door

Response Example

{
    “code”: 0
}

16. Get IPC Name

Description

Get the name of the IPC.

Request Link

https://192.168.0.1/openapi/config/getName, 192.168.0.1 should be replaced by the IP address of the IPC.

Request Parameters

No private parameter for this API, please refer to Public Parameters for more details.

Response Parameters

ParameterTypeDescription
code int Return code, represent the request result,
possible return codes are 0, 1, 3, 5, 7, see Error Code for further details.
name int Name

Request Example

POST /openapi/config/getName HTTP/1.1
Host: 192.168.0.1
Content-Type: application/x-www-form-urlencoded

app_id=mdk923idkf&random=289192&timestamp=15930292837&sign=IDKNFLK392038KDS932K

Response Example

{
    “code”: 0,
    “data”: {
         “name”: “front_door”
    }
}

17. Set LED

Description

Set the LED on the IPC.

Request Link

https://192.168.0.1/openapi/config/setLedSwitch, 192.168.0.1 should be replaced by the IP address of the IPC.

Request Parameters

Below are private parameters for this API, please refer to Public Parameters for more details.

ParameterTypeDescriptionRequiredExample
led_switch int 0: disable, 1: enable Y 1

Response Parameters

ParameterTypeDescription
code int Return code, represent the request result,
possible return codes are 0, 1, 3, 5, 7, 119, see Error Code for further details.

Request Example

POST /openapi/config/setLedSwitch HTTP/1.1
Host: 192.168.0.1
Content-Type: application/x-www-form-urlencoded

app_id=mdk923idkf&random=289192&timestamp=15930292837&sign=IDKNFLK392038KDS932K& led_switch=1

Response Example

{
    “code”: 0
}

18. Get LED

Description

Get the setting of the LED on the IPC.

Request Link

https://192.168.0.1/openapi/config/getLedSwitch, 192.168.0.1 should be replaced by the IP address of the IPC.

Request Parameters

No private parameter for this API, please refer to Public Parameters for more details.

Response Parameters

ParameterTypeDescription
code int Return code, represent the request result,
possible return codes are 0, 1, 3, 5, 7, see Error Code for further details.
led_switch int 0: disable, 1: enable

Request Example

POST /openapi/config/getLedSwitch HTTP/1.1
Host: 192.168.0.1
Content-Type: application/x-www-form-urlencoded

app_id=mdk923idkf&random=289192&timestamp=15930292837&sign=IDKNFLK392038KDS932K

Response Example

{
    “code”: 0,
    “data”: {
         “led_switch”: 1
    }
}

19. Set Rotation

Description

Set the orientation of image, use Get Rotation Angles to get available angles.

Request Link

https://192.168.0.1/openapi/config/setRotation, 192.168.0.1 should be replaced by the IP address of the IPC.

Request Parameters

Below are private parameters for this API, please refer to Public Parameters for more details.

ParameterTypeDescriptionRequiredExample
rotation int The orientation of image Y 180

Response Parameters

ParameterTypeDescription
code int Return code, represent the request result,
possible return codes are 0, 1, 3, 5, 7, 120, see Error Code for further details.

Request Example

POST /openapi/config/setRotation HTTP/1.1
Host: 192.168.0.1
Content-Type: application/x-www-form-urlencoded

app_id=mdk923idkf&random=289192&timestamp=15930292837&sign=IDKNFLK392038KDS932K& rotation=180

Response Example

{
    “code”: 0
}

20. Get Rotation

Description

Get the orientation of image,.

Request Link

https://192.168.0.1/openapi/config/getRotation, 192.168.0.1 should be replaced by the IP address of the IPC.

Request Parameters

No private parameter for this API, please refer to Public Parameters for more details.

Response Parameters

ParameterTypeDescription
code int Return code, represent the request result,
possible return codes are 0, 1, 3, 5, 7, see Error Code for further details.
rotation int The orientation of image

Request Example

POST /openapi/config/getRotation HTTP/1.1
Host: 192.168.0.1
Content-Type: application/x-www-form-urlencoded

app_id=mdk923idkf&random=289192&timestamp=15930292837&sign=IDKNFLK392038KDS932K

Response Example

{
    “code”: 0,
    “data”: {
        “rotation”: 180
    }

21. Get Rotation Angles

Description

Get supported rotation angles of image.

Request Link

https://192.168.0.1/openapi/config/getRotationAngles, 192.168.0.1 should be replaced by the IP address of the IPC.

Request Parameters

No private parameter for this API, please refer to Public Parameters for more details.

Response Parameters

ParameterTypeDescription
code int Return code, represent the request result,
possible return codes are 0, 1, 3, 5, 7, see Error Code for further details.
angles string list List of supported rotation angles of image

Request Example

POST /openapi/config/getRotation HTTP/1.1
Host: 192.168.0.1
Content-Type: application/x-www-form-urlencoded

app_id=mdk923idkf&random=289192&timestamp=15930292837&sign=IDKNFLK392038KDS932K

Response Example

{
    “code”: 0,
    “data”: {
        “angles”: [
            “0”,
            “90”,
            “180”,
            “270”
        ]
    }
}

22. Format SD-card

Description

Format the SD-card in the IPC.

Request Link

https://192.168.0.1/openapi/config/formatMemoryCard, 192.168.0.1 should be replaced by the IP address of the IPC.

Request Parameters

No private parameter for this API, please refer to Public Parameters for more details.

Response Parameters

ParameterTypeDescription
code int Return code, represent the request result,
possible return codes are 0, 1, 3, 5, 7, 220, 221, see Error Code for further details.

Request Example

POST /openapi/config/formatMemoryCard HTTP/1.1
Host: 192.168.0.1
Content-Type: application/x-www-form-urlencoded

app_id=mdk923idkf&random=289192&timestamp=15930292837&sign=IDKNFLK392038KDS932K

Response Example

{
    “code”: 0
}

23. Get SD-card Status

Description

Get the status of the SD-card in the IPC.

Request Link

https://192.168.0.1/openapi/config/getMemoryCardStatus, 192.168.0.1 should be replaced by the IP address of the IPC.

Request Parameters

No private parameter for this API, please refer to Public Parameters for more details.

Response Parameters

ParameterTypeDescription
code int Return code, represent the request result,
possible return codes are 0, 1, 3, 5, 7, see Error Code for further details.
status int 0: unplugged, 1: unformatted, 2: working;3: unknown

Request Example

POST /openapi/config/getMemoryCardStatus HTTP/1.1
Host: 192.168.0.1
Content-Type: application/x-www-form-urlencoded

app_id=mdk923idkf&random=289192&timestamp=15930292837&sign=IDKNFLK392038KDS932K

Response Example

{
    “code”: 0,
    “data”: {
         “status”: 2
    }
}

Device Management

1.Activation

Description

This API is used to activate the IPC, connected to the Internet is required.

All of the existing groups and records will be deleted after the activation and two default groups will be created: stranger and regulart.

Request link

https://192.168.0.1/openapi/device/activate, 192.168.0.1 should be replaced by the IP address of the IPC.

Request Parameters

ParameterTypeDescriptionRequired
app_idstringUser application ID, used as public parameterY
timestamplongUnix timestamp in secondY
randomlongA 6-10 digits random numberY
snstringDevice SNY
signstringSignature of the requestY

Please refer to 1.5.4 Signature Rules and replace the Secret Key with the OpenAPI Activation Number to generate the signature.

For example, if you have the following parameters:

app_id: JO83UNV983U9OR
random: 289192
sn: FS101D8BS00106
timestamp: 1593029283

The OpenAPI Activation Number is 12345678

Then the signature is:

str1=”app_id=JO83UNV983U9OR&random=289192&sn=FS101D8BS00106&timestamp=1593029283″
str2 = str1 + “&key=12345678”
sign = MD5(str2).upper()

The parameters in the final HTTP request are:

app_id:JO83UNV983U9OR
random:289192
sn:FS101D8BS00106
timestamp:1593029283
sign:72CB1C1031D3BA103D2FA1A57E171C2D

Response Parameters

ParameterTypeDescription
codeintReturn code, represent the request result,
possible return codes are 0, 1, 2, 3, 4, 8, 9, 10, 11, see Error Code for further details.

Request Example

POST /openapi/device/activate HTTP/1.1
Host: 192.168.0.1
Content-Type: application/x-www-form-urlencoded
app_id=JO83UNV983U9OR&random=289192&sn=FS101D8BS00106&timestamp=1593029283&sign=72CB1C1031D3BA103D2FA1A57E171C2D

Response Example

{
    “code”:          0,
}

2.Get Basic Informations

Description

This API is used to get basic informations of the IPC.

Request link

https://192.168.0.1/openapi/device/getInfo, 192.168.0.1 should be replaced by the IP address of the IPC.

Request Parameters

No private parameter for this API, please refer to Public Parameters for more details.

Response Parameters

ParameterTypeDescription
codeintReturn code, represent the request result,
possible return codes are 0, 1, 2, 3, 5, 7, see Error Code for further details.
snstringDevice SN
model_namestringModel name
namestringDevice name
software_versionstringSoftware version
hardware_versionstringHardware version
ipstringIP address
macstringMAC address

Request Example

POST /openapi/device/getInfo HTTP/1.1
Host: 192.168.0.1
Content-Type: application/x-www-form-urlencoded
app_id=mdk923idkf&random=289192&timestamp=15930292837&sign=IDKNFLK392038KDS932K&

Response Example

{
    “code”: 0,
    “data”: {
        “sn”: “SS101D8BS00083”,
        “model_name”: “FS”,
        “name”: “My FS”,
        “software_version”: “1.1.0”,
        “hardware_version”: “1.0.0”,
        “ip”: “192.168.0.1”,
        “mac”: “04:12:24:E3:45:12 “
    }
}

3.Restore Factory Settings

Description

This API is used to restore the IPC to factory settings.

Request link

https://192.168.0.1/openapi/device/reset, 192.168.0.1 should be replaced by the IP address of the IPC.

Request Parameters

No private parameter for this API, please refer to Public Parameters for more details.

Response Parameters

ParameterTypeDescription
codeintReturn code, represent the request result,
possible return codes are 0, 1, 2, 3, 5, 7, see Error Code for further details.

Request Example

POST /openapi/device/reset HTTP/1.1
Host: 192.168.0.1
Content-Type: application/x-www-form-urlencoded
app_id=mdk923idkf&random=289192&timestamp=15930292837&sign=IDKNFLK392038KDS932K

Response Example

{
    “code”:          0,
}

4.Reboot

Description

This API is used to reboot the IPC.

Request link

https://192.168.0.1/openapi/device/reboot, 192.168.0.1 should be replaced by the IP address of the IPC.

Request Parameters

No private parameter for this API, please refer to Public Parameters for more details.

Response Parameters

ParameterTypeDescription
codeintReturn code, represent the request result,
possible return codes are 0, 1, 2, 3, 5, 7, see Error Code for further details.

Request Example

POST /openapi/device/reset HTTP/1.1
Host: 192.168.0.1
Content-Type: application/x-www-form-urlencoded
app_id=mdk923idkf&random=289192&timestamp=15930292837&sign=IDKNFLK392038KDS932K

Response Example

{
    “code”:          0,
}

Update to UAT Firmware

1 Introduction

This document is intended to help users manually update the IPC firmware to the UAT version for deployment and debugging in the UAT environment.

2 Get Firmware

Please consult Sunmi Technology Customer Service for the latest firmware of your devices and do not use any third-party firmware which may cause malfunctions.

  • UAT firmware for the Face Sense Camera (or FS & FM020): Part1, Part2.
  • UAT firmware for the Store Sense Camera (or SS & FM010): Download here.

3 Notes

  1. Firmware is not interchangeable and you should use correct firmware for your device.
  2. The versioning convention of IPC firmware is like 1.2.0-release for release environment and 1.2.0-uat for UAT environment. The device can only be updated to a different version.
  3. Verification will be performed to ensure the firmware is correctly signed before actually updating. Please make sure the firmware comes from Sunmi Technology to prevent malfunctions or bricks after updating.

4 Update Procedure

4.1 Copy the firmware to the SD-card

  1. Plug the SD-card into a computer, format the SD-card with EXFAT file system and set the volume label to “SUNMI-XXXX” where “XXXX” is the last four digits of the MAC address which is on the label of the device.
  2. Create a “firmware” directory in the SD-card’s root directory, copy the firmware file here and rename it to “ip-up.bin”.

4.2 Update

  1. Insert the SD-card with firmware inside into the IPC.
  2. Power on the IPC.
  3. Wait for around 1 min until the red LED blinks, indicating it is updating.
  4. Wait for around 1 min, if the red LED is off and green LED is on that means the device is going to reboot. The updating procedure completes when the green LED is flashing or the blue LED is on.

4.3 Setup

  1. After rebooting, hold the Reset button for a few seconds to restore the factory settings.
  2. Follow  the procedures in the User Manual to setup your device and bind it to your account.
  3. If the SD-card is unformatted, use the Sunmi Assistant App or go to https://store.uat.sunmi.com and follow steps in 4.2 to format the SD-card.
  4. Remember to delete the “ipc-up.bin” file under the firmware directory in the SD-card, preventing any accidently update.

Update to Release Firmware

1 Introduction

This document is intended to help users manually update the IPC firmware to the release version after deployment and debugging in the UAT environment.

2 Get Firmware

Please consult Sunmi Technology Customer Service for the latest firmware of your devices and do not use any third-party firmware which may cause malfunctions.

  • Release firmware for the Face Sense Camera (or FS & FM020): Part1, Part2.
  • Release firmware for the Store Sense Camera (or SS & FM010): Download here.

3 Notes

  1. Firmware is not interchangeable and you should use correct firmware for your device.
  2. The versioning convention of IPC firmware is like 1.2.0-release for release environment and 1.2.0-uat for UAT environment. The device can only be updated to a different version.
  3. Verification will be performed to ensure the firmware is correctly signed before actually updating. Please make sure the firmware comes from Sunmi Technology to prevent malfunctions or bricks after updating.

4 Update Procedure

4.1 Copy the firmware to the SD-card

  1. Plug the SD-card into a computer, format the SD-card with EXFAT file system and set the volume label to “SUNMI-XXXX” where “XXXX” is the last four digits of the MAC address which is on the label of the device.
  2. Create a “firmware” directory in the SD-card’s root directory, copy the firmware file here and rename it to “ipc-up.bin”.

4.2 Update

  1. Insert the SD-card with firmware inside into the IPC.
  2. Power on the IPC.
  3. Wait for around 1 min until the red LED blinks, indicating it is updating.
  4. Wait for around 1 min, if the red LED is off and green LED is on that means the device is going to reboot. The updating procedure completes when the green LED is flashing or the blue LED is on.

4.3 Setup

  1. After rebooting, hold the Reset button for a few seconds to restore the factory settings.
  2. Follow  the procedures in the User Manual to setup your device and bind it to your account.
  3. If the SD-card is unformatted, use the Sunmi Assistant App or go to https://store.sunmi.com and format the SD-card.
  4. Remember to delete the “ipc-up.bin” file under the firmware directory in the SD-card, preventing any accidently update.

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

Order APIs

1. Background

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

As an open platform, SUNMI Store can do data interchange for third-party SaaS providers, including the interchange of product information, transaction information and membership system.

Multiple SUNMI IOT device can help the user to digitize their shop. Based on the data from their shop such as face recognition and customer statistics along with the order info from saas provider, user could analyze their shops better.

This document describes how to exchange data with the third party saas provider to make sure SUNMI store open platform can get the order information from saas provider as soon as possible to do analysis.

2. API Specification

2.1 Protocol

All APIs use HTTPS Protocol with POST method

Note: The size of the request body should be no more than 1 MB. If this size is exceeded, open platform will deny it.

Content-Typeapplication/x-www-form-urlencoded
return typeJSON
encodingUTF-8
signing algorithmMD5
signing rulessee chapter 2.2

2.2 Signing rules

see Authentication

2.3 Common parameter

parameterrequiredtypedescription
app_idyesstringunique identifier provided by SUNMI store open platform
randomyesstring6-10 digit random string with number and alphabets
timestampyesint10 digit current unix timestamp
signyesstringsee chapter 2.2

3 APIs

3.1 Order APIs

3.1.1 Parameters

The following parameters are all for SUNMI store open platform and is used to explain APIs. Saas providers must provide the parameter of their own to make sure the order can be synced to open platform.

The parameters in the order below are the basics properties of an order, there will be more properties in real orders.

Order
parametertyperequireduniquedescription
order_nostringthe unique identifier of an order
order_typeinttype of an order(1- normal order、 2- canceled, 3-exchanged for new product, 4- suspend,5-报表)
order_timeintorder timestamp
order_start_timeintthe start time of an order
purchase_amountdouble (2 digit precision)
discount_amountdouble (2 digit precision)
received_amountdouble (2 digit precision)
payment_typeint1-cash、2-alipay、3-wechat pay、4-QQpay、5-JD wallet、6-credit card、7-unionpay QR code、8-other
customer_countintdefault 1
device_snstring
software_namestring
software_specstring
hardware_namestring
hardware_specstring
cashier_nostring
cashier_diskstring
shop_assistant_nostring
order_sourceint1-offline、 2-online (default offline)
member_nostring
ali_idstring
wechat_open_idstring
member_pointsdouble
coupon_nostring
coupon_source int1-shop,2-alipay, 3-wechat pay, 4-other
receipt_nostring
sunmi_receipt_nostring
product_listarray[product]
see the list below
product
parametertypedescriptionrequired
namestringname of the product
seq_numstringsequence number of the product
bar_codestringbar code of the product
specstringspec of the product
unitstringunit of the product
quantitydouble (3 digit precision)sell quantity
stock_quantity double (3 digit precision) stock quantity
original_pricedouble (2 digit precision) original price
present_pricedouble (2 digit precision) current price
promote_amountdouble (2 digit precision) promotion price
subtotal_amountdouble (2 digit precision) subtotal of this product
product additional properties for specific product
parametertypedescriptionrequired
colorstringcode for color
sizestringcode for size

3.1.2 Update order 

API description: By requesting this API, the saas provider can notify the SUNMI store open platform that there is a new order in their system.

API address:/order/update(this is for reference, the detail of this API for each saas provider will be different and needed to be discussed)

Parameters

parameterrequiredtypedescription
shop_idyesstringThe identifier of the shop in open platform
order_listyesarraythe list of order needed to be update

Return value: 

{
  code: 0,
  msg: "succeed",
  data: {
    "invalid_list": [
      "CN0000938",
      "CN0000939"
    ]
  }
}

Errors:

Error codeDescription
5041invalid saas provider
5047invalid order

4 Return value

4.1 Error type

Error types will be returned in HTTP response. If the sign is invalid, then the http status code 401 will be returned.

If the sign is valid, then it will return HTTP status code 200 whatsoever, the error will be returned in the HTTP response body. The structure of our response body is normally:

{
    code:0
    msg: "success"
    data: {}
} 

4.2 Error list

see Error List

5 Examples

Error Codes

1. Background

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

As an open platform, SUNMI Store can do data interchange for third-party SaaS providers, including the interchange of product information, transaction information and membership system.

ESL and other IoT devices are directly attached to the store’s products, prices and strategies, thus a basic product database framework is preserved in SUNMI Store. For data sources, users can choose either to edit on the page of SUNMI Store or to deal with the data on the third-party SaaS provider.

This document describes the error codes user might encounter and the description of that error.

2. Return value

Error types will be returned in HTTP response. If the sign is invalid, then the http status code 401 will be returned.

If the sign is valid, then it will return HTTP status code 200 whatsoever, the error will be returned in the HTTP response body. The structure of our response body is normally:

{
    code:0
    msg: "success"
    data: {}
} 

3. Error list

Error codedescription
5090invalid sign
5091invalid timestamp
5092invalid random value
5000database error
5013invalid saas provider or shop
5015invalid product
5022invalid parameter
5041invalid saas provider
5047invalid order

Notification Center

1. Background

The data flow between the SUNMI store open platform and the Saas provider could be bidirectional and real-time. The Saas provider can pass its data to the open platform and remote control SUNMI’s IOT device.

Meanwhile, SUNMI store open platform could push the data in its system to the saas provider through the data center on their need

2. API specification

2.1 protocol

All Open APIs are HTTPS request with POST method only.

Content-Typeapplication/x-www-form-urlencoded
data typeJSON
encodingUTF-8
signatureMD5
sign rule see chapter 2.2

2.2 Sign rule

See authentication

2.3 Common parameter

parameterrequiredtypedescription
app_idyesstringunique identifier provided by SUNMI store open platform
randomyesstring6-10 digits random string with numbers and alphabets.
timestampyesintcurrent 10 digit unix timestamp
signyesstringsee 2.2

3. Event Monitor APIs

3.1 API list

API addressdescription
/hook/addadd the HTTP callback address for a set of events
/hook/deletedelete the HTTP callback address for a set of events

3.2 API detail

8.3.1 Add an event monitoring

API 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:

parameterrequiredtypedescription
shop_idyesstringthe identifier of the shop in open platform
eventyesintThe type of event to monitor
payloadyesstringthe specific structure of message in JSON

API address: /hook/add

Parameters

parameterrequiredtypedescription
shop_idstringthe identifier of the shop in open platform
http_callbackstringthe http call back API
event_listarray[int]the list of event to be monitored

return value: 

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

parameter event

event valuedescription
1010IPC FM010 motion detecting message
1100add a face to a group result message
2001IPC real time face recognition message
4100price change message (currently unavailable)

payload(event=1010): 

{
  ipc_id: 029388
  sn: "FS101D8BS00080",
  name: "设备1",
 video_url:"http://xxx.xxx.xxx.xxx/xxx/xxx/41b061f6f10dbd6fe1aaf469fb0ab012d9193d9655816af31cdfbcsdfe71a5fe1",
  model_name: "FM020",
  motion_type: 0,
}

Parameter motion_type:

motion_type valuedescription
1motion detection event
2voice detection event

payload(event=1100): 

{
  code: 0,
  msg: "",
  face_id:195
}

Parameter code

code valuedescription
5527bad face image
5000database error

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 valuedescription
0unknown
1male
2female

parameter 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~

Parameter group_type

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

8.3.2 Cancel event monitoring

API description: By requesting this API, the user can cancel the monitor on given events

API address:/hook/delete

Parameters

parameterrequiredtypedescription
shop_idyesstringthe identifier of the shop in open platform
event_listyesarray[int]the list of events that need to be canceled

Return value: 

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

Parameter event:

event valuedescription
1010IPC FM010 motion detecting message
1100add a face to a group result message
2001IPC real time face recognition message
4100price change message (currently unavailable)

Electronic Shelf Label(ESL)

1. Background

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

As an open platform, SUNMI Store can do data interchange for third-party SaaS providers, including the interchange of product information, transaction information and membership system.

2. API Specifications

2.1 Protocol

All APIs use HTTPS Protocol with POST method.

Note: The size of the request body should be no more than 1 MB. If this size is exceeded, open platform will deny it.

Content-Typeapplication/x-www-form-urlencoded
return type JSON
encodingUTF-8
signing algorithmsMD5
signing rules see chapter 2.2

2.2 Signing rules

see Authentication

2.3 common parameter

parameterrequiredtypedescription
app_idyesstring unique identifier provided by SUNMI store open platform
randomyesstring 6-10 digit random string with number and alphabets
timestampyesint 10 digit current unix timestamp
signyesstring see chapter 2.2

3. Shop design

See Shop section

4. ESL APIs

4.1 Description

This set of APIs are used to manage the basic properties of the ESL.

4.2 API List

API addressDescription
/device/esl/bindbind an ESL to a shop
/device/esl/unbindunbind an ESL from a shop
/device/esl/getListget the list of ESLs from a shop
/device/esl/getInfoget the detail info of a given ESL
/device/esl/pushImagepush an image to the ESL
/device/esl/flashLedorder the given ESL to flash its LED light
/device/esl/setRefreshTimeset the refresh rate of a given esl (unavailable yet)
/device/getOverviewget the overview of both a shop’s ESL and its AP

4.3 API detail

4.3.1 Bind an ESL to a shop

API description:By calling this API, user can bind his ESL to a given shop

API address:/device/esl/bind

Parameters

parameterrequiredtypedescription
shop_idyesstring The identifier of the shop in open platform
esl_codeno (either esl_code or esl_sn must be provided)string8-digit ID of the ESL
esl_snno (either esl_code or esl_sn must be provided)stringSerial number of the ESL

Return Value: 

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

Errors:

Error codeDescription
5000database error
5301invalid ESL
5338ESL already bounded

4.3.2  Unbind an ESL from a shop

API description:By calling this API, user can bind his ESL to a given shop

API address:/device/esl/unbind

Parameters

parameterrequiredtypedescription
shop_idyesstringThe identifier of the shop in open platform
esl_idyesstringThe unique ID from bind API

Return value: 

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

Errors:

Error codeDescription
5000database error
5301invalid ESL

4.3.3 Get the list of ESLs from a shop

API description:By calling this API, user can get the list of ESLs from a shop

API address:/device/esl/getList

Parameters

parametersrequiredtypedescription
shop_idyesstringThe identifier of the shop in open platform
page_numno (default 1)intcurrent page
page_sizeno (default 10)intThe number of items per page

Return value: 

{
  code: 0,
  msg: "succeed",
  data: {
    "total_count": 100,
    "esl_list": [{
      "esl_id": "129200",
      "esl_code": "SKDI39DN",
      "esl_sn": "B101194N00002",
      "model_name": "SL121+",
      "status": 2
    }, 
    .......
    ]
  }
}

Parameter Status:

status valuedescription
0Not activated
1Not binded
2Waiting For Data
3Push success
4Push Failed

Errors:

Error CodeDescription
5000database error
5020invalid parameter

4.3.4 Get the detail info of a given ESL

API description:By calling this API, user can get the detail info of a given ESL

API address:/device/esl/getInfo

Parameters:

parameterrequiredtypedescription
shop_idyesstringThe identifier of the shop in open platform
esl_code
no (either esl_code or esl_sn must be provided)string8-digit ID of the ESL
esl_idno (either esl_code or esl_sn must be provided)stringunique ID of the ESL

Return value: 

{
  code: 0,
  msg: "succeed",
  data: {
    "esl_id": "1000",
    "esl_code": "SKDI39DN",
    "esl_sn": "B101194N00002",
    "model_name": "SL121+",
    "status": 2,
    "screen_size_name": "2.13寸",
    "software_version": "1.0.1",
    "battery": 90,
    "rssi": -23,
    "connect_time": 15683920394,
    "ap_id":  "10200",
    "ap_sn": "B201E95D00001",
     "ap_sn": "B201E95D00001",
  }
}

Parameter status

status valuedescription
0Not activated
1Not binded
2Waiting For Data
3Push Success
4Push Failed

Errors:

error codedescription
5000database error
5023parameter missing
5502invalid ESL

4.3.5 Push an image to the ESL

API description:By calling this API, user can push an image to a given ESL

API address:/device/esl/pushImage

Parameters:

parameterrequiredtypedescription
shop_idyesstringThe identifier of the shop in open platform
esl_idyesstringThe ID of the given ESL
picyesfileThe picture to be pushed

Note:

The color and the resolusion of the picture must meet the standard below, otherwise the ESL won’t be able to display that.

ESL typecolor supportedpicture size(px)
SL121black, white, red212 * 104
SL126black, white, red296 * 152
SL126+black, white296 * 152
SL142black, white, red400 * 300
SL142+black, white, red400 * 300

Return value: 

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

Errors:

Error codedescription
5004system error
5005invalid file
5020invalid parameter
5300invalid AP
5301invalid ESL

4.3.6 Order the given ESL to flash its LED light

API description:By calling this API, user can order the given ESL to flash its LED light

API address:/device/esl/flashLed

Parameters

parameterrequiredtypedescription
shop_idyesstringThe identifier of the shop in open platform
esl_idyesstringThe ID of the given ESL
channelnointLED color: 1-white, 2-blue, 4-green, 8- red, 512-cyan, 1024-purple, 2048-yellow(default 4)
cyclenointThe duration of a single flash, 1 cycle = 10ms. (default 100)
durationnointThe total flash times (default 8)

Return value: 

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

Errors:

Error codedescription
5000database error
5301invalid ESL

4.3.7 Set the refresh rate of a given esl

API description:By calling this API, user can set the refresh rate of a given esl. Currently this API is not available.

API address:/device/esl/setRefreshTime (unavailable yet)

Parameters

parameterrequiredtypedescription
shop_idyesstringThe identifier of the shop in open platform
esl_code
no (either esl_code or esl_id must be provided)string8-digit ID of the ESL
esl_idno (either esl_code or esl_id must be provided)intThe unique ID of a given ESL
refresh_timeyesintrefresh time in second

Return value: 

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

4.3.8 Get the overview of both a shop’s ESL and its AP

API description:By calling this API, user can set the refresh rate of a given esl. Currently this API is not available.

API address:/device/getOverview

Parameters:

parameterrequiredtypedescription
shop_idyesstringThe identifier of the shop in open platform

Return value:

{
  code: 0,
  msg: "succeed",
  data: {
    "ap_total_count":24,
    "esl_total_count":55,
    "esl_pending_count":54,
    "esl_failed_count":3
  }
}

5. Access Point APIs

5.1 Description

The set of APIs used to manage the basic properties of the Access Points(AP)

5.2 API lists

API addressdescription
/device/ap/bindbind an AP to a shop
/device/ap/unbindunbind an AP from a shop
/device/ap/getListget the List of APs from a shop
/device/ap/getInfoget the info about a given AP
/device/ap/updateNameupdate the name of an AP
/device/ap/rebootreboot a given AP
/device/ap/setScanTimeset the scan time of a given AP (currently unavailable)

5.3 API detail

5.3.1 Bind an AP to a shop

API description:By calling this API, user can bind an AP to a shop.

API address:/device/ap/bind

Parameters:

parameterrequiredtypedescription
shop_idyesstringThe identifier of the shop in open platform
ap_snyesstringThe serial number of an AP
ap_namenostringThe name of an AP
ap_macnostringThe MAC Address of an AP

Return value: 

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

Errors:

Error codeDescription
5000database error
5023invalid parameter
5300invalid AP
5339AP already bound to a shop

5.3.2 Unbind an AP from a shop

API description:By calling this API, user can unbind an AP from a shop.

API address:/device/ap/unbind

Parameters

parameterrequiredtypedescription
shop_idyesstringThe identifier of the shop in open platform
ap_idyesstringThe ID of an AP

Return value: 

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

Errors:

Error codeDescription
5000database error
5300invalid AP

5.3.3 Get the List of APs from a shop

API description:By calling this API, user can get the List of APs of a shop.

API address:/device/ap/getList

Parameters:

parameterrequiredtypedescription
shop_idyesstringThe identifier of the shop in open platform
page_numnointcurrent page (default 1)
page_sizenointcurrent items per page (default 10)

返回值: 

{
  code: 0,
  msg: "succeed", 
  data: {
    "total_count": 100,
    "ap_list": [{
      "ap_id": “1000”,
      "ap_sn": "B201E96500001",
      "ap_name": "Gate 5", 
      "esl_count": 1920,
      "status": 2
    },
    ......
  ]}
}

Return parameter status

status valuedescription
0not activated
1online
2offline

Errors:

Error codedescription
5000database error
5020invalid parameter

5.3.4 Get the info about a given AP

API description:By calling this API, user can get the info about a given AP.

API address:/device/ap/getInfo

Parameters

parameterrequiredtypedescription
shop_idyesstringThe identifier of the shop in open platform
ap_idyesstring The ID of an AP

Return value: 

{
  code: 0,
  msg: "succeed",
  data: {
    "ap_id": “1000”,
    "ap_sn": "B201E96500001",
    "ap_name": "Gate 5",
    "model_name": "SLAP1",
    "status": 2,
    "esl_count": 1920,
    "software_version": "1.0.1",
    "connect_time": 15683920394,
  }
}

Return parameter status

status valuedescription
0not activated
1online
2offline

Errors:

Error codedescription
5000database error
5011invalid model type
5300invalid AP

5.3.5 Update the name of an AP

API description:By calling this API, user can update the name of an AP.

API address:/device/ap/updateName

Parameters

parameterrequiredtypedescription
shop_idyesstringThe identifier of the shop in open platform
ap_idyesstringThe id of an AP
ap_nameyesstringThe new name of this AP

Return value: 

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

Errors:

Error codeDescription
5000database error
5300invalid AP

5.3.6 Reboot the given AP

API description:By calling this API, user can reboot the given AP.

API address:/device/ap/reboot

Parameters

parameterrequiredtypedescription
shop_idyesstringThe identifier of the shop in open platform
ap_idyesstringThe ID of an AP

Return value: 

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

Errors:

Error codeDescriptions
5000database error
5300invalid AP

5.3.7 Set the scan time of a given AP

API description:By calling this API, user can set the scan time of a given AP.

API address:/device/ap/setScanTime (temporary unavailableq)

Parameters

parameterrequiredtypedescription
shop_idyesstringThe identifier of the shop in open platform
ap_idyesstringThe ID of an AP
scan_timeyesintThe new scan time of the given AP

Return value: 

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

6. Device update APIs

6.1 Description

This set of APIs are used to manage and update the firmware of ESL and AP.

6.2 API List

API addressdescription
/device/ap/firmware/getListget the firmware info of APs by model
/device/ap/firmware/upgradeupdate the firmware of APs
/device/esl/firmware/getListget the firmware info of ESLs by model
/device/esl/firmware/upgradeudpate the firmware of ESLs

6.3 API detail

6.3.1 Get the firmware info of APs by model

API description:By calling this API, user can get the firmware info of APs by model. If multiple versions of firmware are running on differents APs with same model type, only the latest version of firmware will be returned

API address:/device/ap/firmware/getList

Parameters:

parameterrequiredtypedescription
shop_idyesstringThe identifier of the shop in open platform
page_numnointCurrent page (default 1) (currently unavailable)
page_sizenointCurrent items per page (default 10) (currently unavailable)

Return value: 

{
  code: 0,
  msg: "succeed",
  data: {
    "total_count": 10,
    "ap_firmware_list": [{
      "model_name": "SLAP1",
      "software_version": "1.0.2",
      },
      ......
    ],
  }
}

Errors:

Error codeDescription
5000database error

6.3.2 Update the firmware of APs

API description:By calling this API, user can update the firmware of APs by model. This API is currently not available.

API address:/device/ap/firmware/upgrade (暂未开放)

Parameters

parameterrequiredtypedescription
shop_idyesstringThe identifier of the shop in open platform

返回值: 

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

6.3.3 Get the firmware info of ESLs by model

API description:By calling this API, user can Get the firmware info of ESLs by model. If multiple versions of firmware are running on differents ESLs with same model type, only the latest version of firmware will be returned

API address:/device/esl/firmware/getList

Parameters

parameterrequiredtypedescription
shop_idyesstringThe identifier of the shop in open platform
page_numnointcurrent page (default 1) (currently not available)
page_sizenointcurrent items per page (default 10) (currently not available)

Return value: 

{
  code: 0,
  msg: "succeed",
  data: {
    "total_count": 10,
    "ap_firmware_list": [{
      "model_name": "SLAP1",
      "software_version": "1.0.2",
      },
      ......
    ],
  }
}

Errors:

Error codeDescription
5000database error

6.3.4 Update the firmware of ESLs

API description:By calling this API, user can update the firmware of ESLs by model. This API is currently not available.

API address:/device/esl/firmware/upgrade (currently unavailable)

Parameters

parameterrequiredtypedescription
shop_idyesstringThe identifier of the shop in open platform

Return value: 

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

7. Template management API

7.1 Description

The set of APIs used to manage the template

7.2 API list

API addressdescription
/template/createcreate a new template
/template/updateupdate an existing template
/template/getListget all template
/template/getInfoget the detail of a given template
/template/deletedelete a template

7.3 API detail

7.3.1 Create a new template

API description:By calling this API, user can upload json and create a new template.

API address:/template/create

Parameters

parameterrequiredtypedescription
shop_idyesstringThe identifier of the shop in open platform
template_nameyesstringThe name of the template
template_coloryesintThe color type that the templates support: 1-black and white, 2- black white and red.
template_screenyesintThe screen size this template support (1 – 2.13 inch,2 – 2.6 inch,3 – 4.2 inch)
template_jsonyesstringThe template JSON

Return value: 

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

Errors:

Error codeDescription
5000database error
5005file error
5343invalid template
5346template name already exists

7.3.2 Update a given template

API description:By calling this API, user can upload json and create a new template.

API address:/template/update

Parameters

parameterrequiredtypedescription
shop_idyesstringThe identifier of the shop in open platform
template_idyesstring
The ID of a template
template_namenostringThe name of a template
template_jsonnostringTemplate JSON

Return value: 

}

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

Errors:

Error codeDescription
5000database error
5005file error
5343invalid template
5346template name already exists

7.3.3 Get all template

API description:By calling this API, user can get all templates.

API address:/template/getList

Parameters

parameterrequiredtypedescription
shop_idyesstringThe identifier of the shop in open platform
page_numnointcurrent page
page_sizenointcurrent items per page

Return value: 

{
  code: 0,
  msg: "succeed",
  data: {
    "total_count": 15,
    "template_list":[{
      "template_id": "100",
      "template_name": "sample",
      "template_color": 1,  /* currently not available*/
      "template_screen": 1
    },
    .......
    ]
  }
}

Errors:

Error codeDescription
5000database error
5020invalid parameters

Return parameter color:

color valuedescription
1black and white
2black, white and red

Return parameter screen:

screen valuedescription
12.13 inch
22.6 inch
34.2 inch

7.3.4 Get the detail of a given template

API description:By calling this API, user can get the detail of a given template.

API address:/template/getInfo

Parameters

parameterrequiredtypedescription
shop_idyesstringThe identifier of the shop in open platform
template_idyesstringThe unique ID of a template

Rerturn value: 

{
  code: 0,
  msg: "succeed",
  data: {
    "template_name": "sample",
    "template_color_name": "BW",
    "template_screen_type_name": "2.6",
    "template_json": "...",
    "template_color:": 1, /* currently unavailable */
    "template _screen": 1, /* currently unavailable */
  }
}

Errors:

Error codeDescription
5000database error
5005file error
5343invalid template

Return parameter color:

color valuedescription
1black and white
2black white and red

Return parameter screen:

screen valuedescription
12.13 inch
22.6 inch
34.2 inch

7.3.5 Delete a template

API description:By calling this API, user can delete a given template.

API address:/template/delete

Parameters

parameterrequiredtypedescription
shop_idyesstring The identifier of the shop in open platform
template_id_listyesarrayThe unique ID of a template

Return value: 

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

Errors:

Error codeDescription
5000database error

8. Product Management APIs

8.1 Description

This set of APIs is used to manage the price of the product and its relationship to the ESLs. After the relationship is set up, SUNMI store open platform will automatically update the changes of a product to the ESLs.

8.2 API list

API addressdescription
/product/bindEslbind a product to an ESL
/product/unbindEslunbind a product from an ESL
/product/getBindEslListget the list of ESLs a product is bound to
/product/updateTemplateupdate the template of a product
/product/getInfoget the info of a product
/product/getListget the list of all product

8.3 API detail

8.3.1 Bind a product to an ESL

API description:By calling this API, user can bind a product to an ESL

API address:/product/bindEsl

Parameters

parameterrequiredtypedescription
shop_idyesstringThe identifier of the shop in open platform
product_idyesstringThe unique ID of a product
esl_codeno (either esl_code or esl_sn must be provided)string8-digit ID of the ESL
esl_idno (either esl_code or esl_sn must be provided)stringThe unique ID of a given ESL
template_idyesstringThe unique ID of a template

Return value: 

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

Errors:

Error codeDescription
5000database error
5020invalid parameters
5015invalid products
5343invalid template
5300invalid AP
5301invalid ESL
5338ESL already bounded to another shop
5342invalid ESL image
5006oss error

8.3.2 Unbind a product from an ESL

API description:By calling this API, user can unbind a product from an ESL

API address:/product/unbindEsl

Parameters

parameterrequiredtypedescription
shop_idyesstringThe identifier of the shop in open platform
esl_codeno (either esl_code or esl_sn must be provided)string 8-digit ID of the ESL
esl_idno (either esl_code or esl_sn must be provided)stringThe unique ID of a given ESL

}

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

Errors:

Error codeDescription
5000database error
5020invalid parameters
5301invalid ESL
5320ESL not bounded
5336ESL bound to another shop   
5342invalid ESL image
5006oss error

8.3.3 Get the list of ESLs

API description:By calling this API, user can unbind a product from an ESL

API address:/product/getBindEslList

Parameters

parameterrequiredtypedescription
shop_idyesstringThe identifier of the shop in open platform
product_idyesstringThe unique ID of a product

Return value: 

{
  code: 0,
  msg: "succeed",
  data: {
    "esl_list": [{
      "esl_id": ”1000“,
      "esl_code": "DJKS90EN",
      "template_id": ”10002“,
      "status": 1,
      },
      .......
      ]
    }
  }
}

Errors:

Error codedescription
5000database error
5020invalid parameters
5301invalid ESL
5015invalid product

8.3.4 Update the template of a product

API description:By calling this API, user can update the template of a product

API address:/product/updateTemplate

Parameters

parameterrequiredtypedescription
shop_idyesstringThe identifier of the shop in open platform
product_idyesstringThe unique id of the product
template_idyesstring
The unique id of a template

Return value: 

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

Errors:

Error codedescription
5000database error
5020invalid parameter
5005file error
5006oss error
5343invalid template
5015invalid product
5342invalid ESL image

8.3.5 Get product info

API description:By calling this API, user can get the product info of a specific product

API address:/product/getInfo

Parameters

parameterrequiredtypedescription
shop_idyesstringThe identifier of the shop in open platform
product_idyesstringThe unique ID of a product

Return value: 

{
  code: 0,
  msg: "succeed",
  data: {
    "id":,
    "name":,
    "alias":,
    "seq_num":,
    "bar_code":,
    "qr_code":,
    "unit":,
    "spec":,
    "area":,
    "level":,
    "brand":, 
    "expire_time":,
    "price":,
    "promote_price":,
    "member_price":,
  }
}

Errors:

Error codedescription
5000database error
5015invalid product id

8.3.6 Get product list

API description:By calling this API, user can get the product list of a given shop

API address:/product/getList

Parameters

parameterrequiredtypedescription
shop_idyesstringThe identifier of the shop in open platform
keywordnostringsearching keywords
page_numnointpage number
page_sizenointnumber of items per page

Return value: 

{
  code: 0,
  msg: "succeed",
  data: {
    "total_count": 1,
    "product_list": [{
      "id": ,
      "name": ,
      "seq_num": ,
      "bar_code": ,
      "category_id": ,
      "price": ,
      "modified_time":
    }]
  }
}

Errors:

Error codeDescription
5000database error
5020invalid parameters

9. Notifications

9.1 Description

After receiving the message from the device, SUNMI store open platform can push notification to the saas providers based on their need.

9.2 API specification

具体接口和实现标准,参考 015.消息推送中心

Product APIs

1 Background

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

As an open platform, SUNMI Store can do data interchange for third-party SaaS providers, including the interchange of product information, transaction information and membership system.

ESL and other IoT devices are directly attached to the store’s products, prices and strategies, thus a basic product database framework is preserved in SUNMI Store. For data sources, users can choose either to edit on the page of SUNMI Store or to deal with the data on the third-party SaaS provider.

This document describes how to interchange the product information of the third-party SaaS provider, including how to synchronize the information (the merchant’s products and prices) between SaaS system and SUNMI Store in real-time after the initial interchange of product data.

2 API Specifications

2.1 Protocol

All APIs use HTTPS Protocol with POST method

Note: The size of the request body should be no more than 1 MB. If this size is exceeded, open platform will deny it.

Content-Typeapplication/x-www-form-urlencoded
return typeJSON
encodingUTF-8
signing algorithmsMD5
signing rulessee chapter 2.2

2.2 Signing rules

see Authentication

2.3 common parameter

parameterrequiredtypedescription
app_idyesstringunique identifier provided by SUNMI store open platform
randomyesstring6-10 digit random string with number and alphabets
timestampyesint10 digit current unix timestamp
signyesstringsee chapter 2.2

3 APIs

3.1 Product mapping

3.1.1 Parameters

The following parameters are for open platform APIs. The saas providers will need to provide their product properties list to create a mapping between their system and open platform’s system

parametertypedescriptionrequiredsaas system parameters
idstringthe id in sunmi databaseyes
seq_numstringproduct sequence numberno
bar_codestringproduct bar codeno
namestringproduct nameyes
aliasstringproduct aliasno
pricedoublecurrent product priceyes
promote_pricedoubleproduct promotion priceno
member_pricedoublemembership priceno
specstringspecs for the productno
unitstringunit for the productno
levelstringlevel of the productno
areastringarea of the productno
brandstringbrand of the productno
qr_codestringqr code url for the productno
expire_timeintproduct expire timeno

3.1.2 Create New Product

API description:This API is used after a saas system had created a new product to inform the open platform system about the change.

This API is for creating new products only, if the product ID exists, then this ID will be added into the exist_list. If the required parameter is not passed, then the id will be put into invalid_list and returned.

API address:/product/create (just for reference)

parameters:

parameterrequiredtypedescription
shop_idyesstringthe identifier of the shop in open platform
product_listyesarray array of product

product parameter:

parameterrequiredtypedescription
idyesstringunique identifier of the product
seq_numnostringproduct sequence number
bar_codenostringproduct bar code
nameyesstringproduct name
aliasnostringproduct alias
pricenodouble(non-negative ,2digit precision)current selling price
promote_pricenodouble( non-negative ,2digit precision )promote price
member_pricenodouble( non-negative ,2digit precision )membership price
specnostringproduct specs
unitnostringproduct unit
levelnostringproduct level
areanostringproduct area
brandnostringproduct brand
qr_codenostringproduct qr code url
expire_timenointproduct expire time

Return value: 

{
    "code": 0,
    "msg": "succeed",
    "data": {
        "exist_list": [
            "1"
        ],
        "invalid_list": [
            "400"
        ],
    }
}

Error list

Error codedescription
5000database error
5041invalid saas provider
5015invalid product

3.2.3 Update New Product

API description : This API is used after a saas system had udpate a new product to inform the open platform system about the change.

Note that the update API will only update the existing product. If there are no such product, the product id will be returned in the not_exist_list.

Update API will only modify the existing properties of a product, if there are no such property in the system, then it will do nothing.

API address:/product/update(for reference only)

Parameter

parameterrequiredtypedescription
shop_idyesstringthe identifier of a shop
product_listyesarraythe list of product to be updated

product parameter

parameterrequiredtypedescription
idyesstringID of the product
seq_numnostringsequence number of the product
bar_codenostringbar code of the product
namenostringname of the product
aliasnostringalias of the product
pricenodouble( non-negative ,2digit precision )current price
promote_pricenodouble( non-negative ,2digit precision )promotion price
member_pricenodouble( non-negative ,2digit precision )membership price
specnostringspec of the product
unitnostringunit of the product
levelnostringlevel of the product
areanostringarea of the product
brandnostringbrand of the product
qr_codenostringQR code url of the product
expire_timenointexpiration time of the product

Return value:

{
    "code": 0,
    "msg": "succeed",
    "data": {
        "not_exist_list": [
            "5"
        ],
        "invalid_list": []
    }
}

Errors:

error codedescription
5000database error
5041invalid saas provider
5015invalid product

3.2.4 Delete Product

API description : This API is used after a saas system had udpate a new product to inform the open platform system about the change.

The delete API will only delete the existing product in the open platform, if the open platform cannot match the product id, it will add this id to the not_exist_list and return.

API address:/product/delete(for reference only)

Parameters

parameterrequiredtypedescription
shop_idyesstringid of the shop
product_key_listyeslist list of product id to be deleted

Return value: 

{
    "code": 0,
    "msg": "succeed",
    "data": {
        "not_exist_list": [
            "100"
        ]
    }
}

Error:

Error codeDescription
5000database error
5041invalid saas provider
5015invalid product

4 Return Value

4.1 Error Type

Error types will be returned in HTTP response. If the sign is invalid, then the http status code 401 will be returned.
If the sign is valid, then it will return HTTP status code 200 whatsoever, the error will be returned in the HTTP response body. The structure of our response body is normally:

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

4.2 Error Code List

Please Refer to the Error Code List

5 Open API from the saas provider

In the process of creating product mapping, SUNMI store open platform might request the saas provider to provide the following API:

5.1 Get all products Information List

API description : This API is used for SUNMI store open platform to get all product information from the saas provider. Note that for different saas provider the return data structure can be different.

API addresshttps://example.SaaS.com/api/getProductList(for reference only)

Parameters

parameterrequiredtypedescription
shop_idyesstringid of the shop
page_numyesintcurrent page number
page_sizeyesintnumber of items returned per request

Return value:

{
    "code": 0,
    "msg": "succeed",
    "data": {
        "total": 2,
        "product_list": [
            {
                "name": "example_product",
                "seq_num": "28929380903",
                "price": 10.00,
            }, ...
        ]
    }
}

6 Examples

This chapter offers some examples for creating the product mapping.

The API below requires the shop mapping done to work. For shop mappings please see shop API

The sample paramater we use (we have skipped the sign, random, etc. parameters for reader’s convenience):

app_idsecret_keyshop_id
APPID6917LTYtokenlty1237948

As shown below, after the initial shop mapping, there are not products in the list.

6.1 Example to create new product

6.1.1 Success example

After successfulling creating the shop binding, user will need to call product/create to create product on open platform

Parameters:

app_idAPPID6917LTY
shop_id7948
product_list[{“name”:”\u53ef\u53e3\u53ef\u4e50\/\u704c\u88c5″,”id”:”1″,”seq_num”:”cola58476″,”bar_code”:”6958644000259″,”unit”:”\u7f50″,”price”:”3.2″,”member_price”:”3″,”spec”:”250ml”,”level”:””,”brand”:”\u53ef\u4e50″}]

Return value:

{
    "code": 0,
    "msg": "succeed",
    "data": {
        "exist_list": [],
        "invalid_list": []
    }
}

After refreshing the page, we can see that we successfully created a product.

Click Details for the product detail.

6.1.2 Failed Example: product already existed

Resend the same request in 6.1.1, we can find the product_id in the exist list, telling us this product already existed

Parameters:

app_idAPPID6917LTY
shop_id7948
product_list[{“name”:”\u53ef\u53e3\u53ef\u4e50\/\u704c\u88c5″,”id”:”1″,”seq_num”:”cola58476″,”bar_code”:”6958644000259″,”unit”:”\u7f50″,”price”:”3.2″,”member_price”:”3″,”spec”:”250ml”,”level”:””,”brand”:”\u53ef\u4e50″}]

Return value:

{
    "data": {
        "exist_list": [
            "1"
        ],
        "invalid_list": []
    },
    "code": 0,
    "msg": "succeed"
}

6.1.3 Failed Example: invalid JSON

In this example we put an invalid JSON in the request body

Parameter:

app_idAPPID6917LTY
shop_id7948
product_list[{“name”:”\u53ef\u53e3\u53ef\u4e50\/\u704c\u88c5″,,,”id”:”1″,”seq_num”:”cola58476″,”bar_code”:”6958644000259″,”unit”:”\u7f50″,”price”:”3.2″,”member_price”:”3″,”spec”:”250ml”,”level”:””,”brand”:”\u53ef\u4e50″}]

Return value:

{
    "code": 1,
    "msg": "product_list: JSON.parse error"
}

6.1.4 Failed Example: missing required field

In this request, the request body is missing parameter id

Parameters:

app_idAPPID6917LTY
shop_id7948
product_list[{“name”:”\u53ef\u53e3\u53ef\u4e50\/\u704c\u88c5″,”id”:”1″,”seq_num”:”cola58476″,”bar_code”:”6958644000259″,”unit”:”\u7f50″,”price”:”3.2″,”member_price”:”3″,”spec”:”250ml”,”level”:””,”brand”:”\u53ef\u4e50″}]

Return value:

{
    "code": 1,
    "msg": "invalid saas product info"
}

6.2 Example to update an existing product

6.2.1 Success example – update the existing product

Requesting the product/update API to update the price of a product

Parameters:

app_idAPPID6917LTY
shop_id7948
product_list[{“id”:1, “price”:”3.5″}]

Return value:

{
    "data": {
        "not_exist_list": [],
        "invalid_list": []
    },
    "code": 0,
    "msg": "succeed"
}

In the sunmi store page, we can see that the price has already been changed and the update time is recorded.

before

after

6.2.2 Success example – create a new product

The update API can also be used to create a product that doesn’t exist.

Parameters:

app_idAPPID6917LTY
shop_id7948
product_list[{“id”:2, “name”:”Non-Exist Product”,”seq_num”:”nonexist1″,”price”:”58.2″}]

Return value:

{
    "data": {
        "not_exist_list": [
            "2"
        ],
        "invalid_list": []
    },
    "code": 0,
    "msg": "succeed"
}

The return value shows that the product with id “2” does not exist, so it created an item with product id 2.

before

after

6.2.3 Failed Example: invalid JSON

In this example we put an invalid JSON in the request body

Parameters:

app_idAPPID6917LTY
shop_id7948
product_list[{“name”:”\u53ef\u53e3\u53ef\u4e50\/\u704c\u88c5″,,,”id”:”1″,”seq_num”:”cola58476″,”bar_code”:”6958644000259″,”unit”:”\u7f50″,”price”:”3.2″,”member_price”:”3″,”spec”:”250ml”,”level”:””,”brand”:”\u53ef\u4e50″}]

Return value:

{
    "code": 1,
    "msg": "product_list: JSON.parse error"
}

6.2.4 Failed Example: missing required field

In this request, the request body is missing parameter id

Parameters:

app_idAPPID6917LTY
shop_id7948
product_list[{“name”:”\u53ef\u53e3\u53ef\u4e50\/\u704c\u88c5″,”id”:”1″,”seq_num”:”cola58476″,”bar_code”:”6958644000259″,”unit”:”\u7f50″,”price”:”3.2″,”member_price”:”3″,”spec”:”250ml”,”level”:””,”brand”:”\u53ef\u4e50″}]

Return value:

{
    "code": 1,
    "msg": "invalid saas product info"
}

6.3 Example to delete an existing product

6.3.1 Success example

Requesting product/delete API to delete an existing product.

Parameters:

app_idAPPID6917LTY
shop_id7948
product_key_list[2]

Return value:

{
    "data": {
        "not_exist_list": []
    },
    "code": 0,
    "msg": "succeed"
}

In the product list, we can see that the product has already been deleted.

before

after

6.3.2 Failed Example: invalid product

In this request we tried to delete a product that does not exist

Parameters:

app_idAPPID6917LTY
shop_id7948
product_key_list[3]

Return value:

{
    "data": {
        "not_exist_list": [
            "3"
        ]
    },
    "code": 0,
    "msg": "succeed"
}