Search Specific Devices

Search specific devices from all the devices that are associated with the current Application.

Request URL

POST {base_url}/device/openapi/v1/devices/search

Request Parameters

Table 1. Header Parameters
Parameter Required Type Description
Authorization Yes String The valid access token for making API calls.

The format should be Bearer {access_token}.

Table 2. Body Parameters
Parameter Required Type Description
pageSize Yes Integer Define how many records per page.
pageNumber Yes Integer

Define which page is displayed.

sorts No Array<Object> Define the sorting field and display order.
direction No String Define the display order.

Valid value:

  • asc: Ascending order.
  • desc: Descending order.
property No String Define the sorting field.

Valid value: Existing fields of the device details.

sn No String Specify the devices' SN (Serial Number) to search for.
devEUI No String Specify the devices' EUI (Extended Unique Identifier) to search for.
imei No String Specify the devices' IMEI (International Mobile Equipment Identity) to search for.
autopStatus No Array<String> Specify the devices' auto provisioning status to search for.

Valid value:

  • SUCCESS: Successfully auto-provisioned devices.
  • WAITING: Devices awaiting auto-provisioning.
  • DISABLE: Devices with auto provisioning disabled.
connectStatus No Array<String> Specify the devices' connectivity status to search for.

Valid value:

  • ONLINE: Devices actively connected to Milesight Development Platform.
  • OFFLINE: Devices NOT currently connected Milesight Development Platform.
  • DISCONNECT: Devices disconnected from Milesight Development Platform.
name No String Specify the device name to search for.
model No String Specify the device model to search for.
hardwareVersion No String Specify the hardware version of the device to search for.
firmwareVersion No String Specify the firmware version of the device to search for.
electricityMin No Integer Specify the minimum battery level to search for.

For example, if you set this parameter to 80, then devices with over 80% battery will be displayed.

electricityMax No Integer Specify the maximum battery level to search for.
For example, if you set this parameter to 5, then devices with less than 5% battery will be displayed.
Tip: You can set a low battery threshold, then use this parameter to filter out devices with low battery levels.
project No String Specify the device's project tag to search for.
description No String Specify the device description to search for.
tag No Array<String> Specify the device's tags to search for.
deviceType No Array<String> Specify the device's types to search for.

Valid value:

  • GATEWAY: The gateway device to set up communication between sub devices and Milesight Development Platform.
  • SUB_DEVICE: The Internet inaccessible device which needs gateway to connect to Milesight Development Platform.
  • COMMON: The Internet accessible device which is able to connect to Milesight Development Platform directly.
licenseStatus No Array<String> Specify the device's license status to search for.

Valid value:

  • VALID: The device can be used.
  • INVALID: The device is banned after the pro plan expires.

Response Parameters

Parameter Type Description
data Object<Search_Result> The search result.
status String The result of the API request.
  • Success
  • Failed
requestId String The unique ID of the request, which can be used to quickly locate the request.
Search_Result
Parameter Type Description
pageSize Integer The number of records displayed on each page.
pageNumber Integer Which page is displayed.
total Integer The total number of records.
content Array<Device_Details> Details of devices that match the search criteria.
Device_Details
Parameter Type Description
sn String The SN (Serial Number) of this device.
imei String The IMEI (International Mobile Equipment Identity) of this device.
autopStatus String The auto provisioning status of the device.
  • SUCCESS: The device has been auto-provisioned successfully.
  • WAITING: The device is waiting to be auto-provisioned.
  • DISABLE: Auto provisioning is disabled for this device.
name String The device name.
model String The device model.
hardwareVersion String The hardware version of the device.
firmwareVersion String The firmware version of the device.
electricity Integer The battery level of the device.
lastUpdateTime Long The timestamp of the device's most recent report.
application Object Information of the device's associated Application.
applicationId Long The unique ID of this Application.
applicationName String Name of this Application.
project String The device's project tag.
description String The device description.
deviceId Long The unique ID of this device.
devEUI String The EUI (Extended Unique Identifier) of this device.
connectStatus String The connectivity status of the device.
  • ONLINE: The device is actively connected to Milesight Development Platform.
  • OFFLINE: The device is NOT currently connected to Milesight Development Platform.
  • DISCONNECT: The device is disconnected from Milesight Development Platform.
licenseStatus String The license status of the device.
  • VALID: The device can be used.
  • INVALID: The device is banned after the pro plan expires.
deviceType String The type of this device.
  • GATEWAY: The gateway device to set up communication between sub devices and Milesight Development Platform.
  • SUB_DEVICE: The Internet inaccessible device which needs gateway to connect to Milesight Development Platform.
  • COMMON: The Internet accessible device which is able to connect to Milesight Development Platform directly.
tag Array<String> The tags of this device.

Examples

Request example
Search for devices with the auto-provision status disabled.
POST /device/openapi/v1/devices/search HTTP/1.1
Host: demo.milesight.com
Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6InllYXN0b25lLWRlZmF1bHQta2V5LWlkIn0.eyJncmFudF90eXBlIjoiY2xpZW50X2NyZWRlbnRpYWxzIiwic2NvcGUiOlsib3BlbmFwaSJdLCJjbGllbnRfZXh0Ijp7ImFwcF9pZCI6IjE3MzY5NTQ4MDE3MTMzMjgxMzAifSwiZXhwIjoxNzAzMjEzMDk4LCJhdXRob3JpdGllcyI6WyJST0xFX0NMSUVOVCJdLCJqdGkiOiJiYjJjN2U4Yy03NGQwLTQ4NjEtODE3MS1iYTc0NWRlMGY0NmQiLCJjbGllbnRfaWQiOiI4OTNkNzdjNy1mMGNiLTRmMzQtOWNhMS03YzJhNGNmMTEzNDgiLCJ0cyI6MTcwMzIwOTQ5ODMzNH0
Content-Type: application/json

{
    "pageSize": 2,
    "pageNumber": 1,
    "autopStatus": [
        "DISABLE"
    ]
}
Response example
HTTP/1.1 200 OK
{
    "data": {
        "pageSize": 2,
        "pageNumber": 1,
        "total": 2,
        "content": [
            {
                "sn": "6785C3807364xxxx",
                "autopStatus": "DISABLE",
                "name": "Comfort Sensor Room-3D",
                "model": "AM308",
                "application": {
                    "applicationId": "1734475086466600962",
                    "applicationName": "Demo"
                },
                "project": "Workplace",
                "description": "Comfort Sensor of Room-3D",
                "deviceId": "1742010610312101890",
                "devEUI": "24E124785C38xxxx",
                "connectStatus": "DISCONNECT"
            },
            {
                "sn": "6791D1970467xxxx",
                "autopStatus": "DISABLE",
                "name": "Demo Device",
                "model": "TH-Motion Sensor",
                "hardwareVersion": "v1.0",
                "firmwareVersion": "v1.1",
                "electricity": 97,
                "lastUpdateTime": 1704180118083,
                "application": {
                    "applicationId": "1734475086466600962",
                    "applicationName": "Demo"
                },
                "project": "Workspace",
                "description": "TH-Motion Sensor of Room 4A",
                "deviceId": "1739930666380779522",
                "devEUI": "24E124791D19xxxx",
                "connectStatus": "ONLINE"
            }
        ]
    },
    "status": "Success",
    "requestId": "63abfe424fa8c7d273e36d74d87b56b0"
}