多協議接入 產品介紹 快速入門 用戶指南 開發指南
EDP TCP透傳 MQTT Modbus HTTP
常見問題

批量查詢設備信息

請求方式:GET

URL: http://api.onenet.hk.chinamobile.com/devices

URL參數

參數名稱 格式 是否必須 說明
key_words string 匹配關鍵字,從id和title欄位中左匹配
auth_info string 鑒權信息
tag array-string 設備標籤
online bool 設備在線狀態
private bool 設備私密性
page int 指定頁碼,最大頁數為10000
per_page int 指定每頁輸出設備個數,預設30,最多100
device_id string 指定設備ID,多個用逗號分隔,最多100個
begin string 起始時間,北京時間,示例:6/20/2016
end string 結束時間,北京時間,示例:6/20/2016

返回參數

參數名稱 格式 說明
errno int 調用錯誤碼,為0表示調用成功
error string 錯誤描述,為“succ”表示調用成功
data json 介面調用成功之後返回的設備相關信息,見data描述表

data描述表

參數名稱 格式 說明
total_count int 查詢結果中設備的數量
page int 當前頁
per_page int 每頁設備數量
devices array-json 設備信息的json陣列,見devices描述表

devices描述表

參數名稱 格式 說明
protocol string 設備接入協議
create_time string 設備創建時間,北京時間
online bool 設備在線狀態
id string 設備ID
auth_info string 設備鑒權信息,對應設備註冊介面中的“sn”或者“mac”參數
title string 設備名
desc string 設備描述
tags array-string 設備標籤
location json 設備位置座標信息,以經緯度鍵值對表示:{“lon”:xx,”lat”:xx}
other json 其他設備自訂信息,以鍵值對格式表示,見示例

請求示例1

查詢創建時間為2017-02-04至2017-06-04的標籤為china的在線設備

GET http://api.onenet.hk.chinamobile.com/devices?begin=2017-02-04&end=2017-06-04&online=true&tag=ch

請求示例2

查詢設備ID為35282992,35271941的兩個設備

GET http://api.onenet.hk.chinamobile.com/devices?device_id=35282992,35271941 HTTP/1.1

請求示例3

查詢該產品下所有的設備

GET http://api.onenet.hk.chinamobile.com/devices HTTP/1.1

返回示例

{
    "errno": 0,
    "data": {
        "per_page": 30,
        "devices": [{
            "protocol": "EDP",
            "other": {
                "version": "1.0.0",
                "manufacturer": "china mobile"
            },
            "create_time": "2018-06-04 17:43:11",
            "online": true,
            "location": {
                "lat": 23.54,
                "lon": 109
            },
            "id": "35282992",
            "auth_info": "tes01235n82105",
            "title": "test_device",
            "desc": "test_desc",
            "tags": ["china", "mobile"]
        }, {
            "protocol": "EDP",
            "create_time": "2018-06-04 11:15:38",
            "online": true,
            "id": "35271941",
            "auth_info": "tes810372105",
            "title": "test_device",
            "tags": ["china"]
        }],
        "total_count": 2,
        "page": 1
    },
    "error": "succ"
}

个搜索结果,搜索内容 “

    0 个搜索结果,搜索内容 “