API列表
请求方式 |
API |
描述 |
GET |
/v1.0/osaas/functions/{category} |
获取功能集(按品类) |
GET |
/v1.0/osaas/devices/{device_id}/functions |
获取功能集(按设备) |
GET |
/v1.0/osaas/devices/{device_id}/specifications |
获取规格属性(按设备) |
GET |
/v1.0/osaas/devices/{device_id}/status |
获取设备最新状态 |
POST |
/v1.0/osaas/devices/{device_id}/commands |
下发设备指令 |
获取功能集(按品类)
接口描述
调用该接口获取功能集(按品类)
接口地址
GET {url}/v1.0/osaas/functions/{category}
请求参数
参数名 |
类型 |
参数类型 |
说明 |
是否必需 |
category |
String |
URI |
产品品类编码 |
是 |
响应参数
参数名 |
类型 |
说明 |
code |
Integer |
响应码(详情见错误码章节),成功时为空 |
success |
Boolean |
是否成功:(true:成功,false:失败) |
msg |
String |
请求失败的信息,成功时为空 |
t |
Long |
返回时间戳,13位 |
result |
Object |
返回结果 |
result参数说明
参数名 |
类型 |
说明 |
category |
String |
产品品类编码 |
functions |
Arrays |
功能集 |
functions 参数说明
参数名 |
类型 |
说明 |
code |
String |
功能码 |
type |
String |
功能类型 |
values |
String |
参数范围 |
name |
String |
功能名称 |
desc |
String |
功能描述 |
请求示例
GET {url}/v1.0/osaas/functions/kg
响应成功示例
{
"success": true,
"t": 1571293776551,
"result": {
"category": "kg",
"functions": [
{
"name": "开关",
"desc": "开关",
"code": "switch_1",
"type": "Boolean",
"values": "{}"
}
]
}
}
响应失败示例
{
"code": 500,
"msg": "system error,please contact the admin",
"success": false,
"t": 1561378856383
}
获取功能集(按设备)
接口描述
调用该接口获取功能集(按设备)
接口地址
GET /v1.0/osaas/devices/{device_id}/functions
请求参数
参数名 |
类型 |
参数类型 |
说明 |
是否必需 |
device_id |
String |
URI |
设备唯一标识 |
是 |
响应参数
参数名 |
类型 |
说明 |
code |
Integer |
响应码(详情见错误码章节),成功时为空 |
success |
Boolean |
是否成功:(true:成功,false:失败) |
msg |
String |
请求失败的信息,成功时为空 |
t |
Long |
返回时间戳,13位 |
result |
Object |
返回结果 |
result 参数说明
参数名 |
类型 |
说明 |
category |
String |
产品类别 |
functions |
Arrays |
功能集 |
functions 参数说明
参数名 |
类型 |
说明 |
code |
String |
功能码 |
type |
String |
功能类型 |
values |
String |
参数范围 |
name |
String |
功能名称 |
desc |
String |
功能描述 |
请求示例
GET {url}/v1.0/osaas/devices/6c5cc1ce9718d******/functions
响应成功示例
{
"success": true,
"t": 1571293776551,
"result": {
"category": "cz",
"functions": [
{
"name": "开关",
"desc": "开关",
"code": "switch_1",
"type": "Boolean",
"values": "{}"
}
]
}
}
响应失败示例
{
"code": 500,
"msg": "system error,please contact the admin",
"success": false,
"t": 1561378856383
}
获取规格属性(按设备)
接口描述
调用该接口根据设备唯一标识获取设备规格属性(包含功能集、状态集)
接口地址
GET /v1.0/osaas/devices/{device_id}/specifications
请求参数
参数名 |
类型 |
参数类型 |
说明 |
是否必需 |
device_id |
String |
URI |
设备唯一标识 |
是 |
响应参数
参数名 |
类型 |
说明 |
code |
Integer |
响应码(详情见错误码章节),成功时为空 |
success |
Boolean |
是否成功:(true:成功,false:失败) |
msg |
String |
请求失败的信息,成功时为空 |
t |
Long |
返回时间戳,13位 |
result |
Object |
返回结果 |
result参数说明
参数名 |
类型 |
说明 |
category |
String |
产品类别 |
functions |
Arrays |
功能集 |
status |
Arrays |
状态集 |
functions参数说明
参数名 |
类型 |
说明 |
code |
String |
功能码 |
type |
String |
功能类型 |
values |
String |
参数范围 |
name |
String |
功能名称 |
desc |
String |
功能描述 |
status参数说明
参数名 |
类型 |
说明 |
code |
String |
状态码 |
type |
String |
状态类型 |
values |
String |
参数范围 |
请求示例
GET {url}/v1.0/osaas/devices/6c5cc1ce9718******/specifications
响应成功示例
{
"success": true,
"t": 1571201730542,
"result": {
"category": "dj",
"functions": [
{
"name": "开关",
"desc": "开关",
"code": "switch_1",
"type": "Boolean",
"values": "{}"
}
],
"status": [
{
"code": "switch_led",
"type": "Boolean",
"values": "{}"
},
{
"code": "work_mode",
"type": "Enum",
"values": "{\"range\":[\"colour\"]}"
}
]
}
}
响应失败示例
{
"code": 500,
"msg": "system error,please contact the admin",
"success": false,
"t": 1561378856383
}
获取设备最新状态
接口描述
调用该接口获取设备最新状态
接口地址
GET /v1.0/osaas/devices/{device_id}/status
请求参数
参数名 |
类型 |
参数类型 |
说明 |
是否必需 |
device_id |
String |
URI |
设备唯一标识 |
是 |
响应参数
参数名 |
类型 |
说明 |
code |
Integer |
响应码(详情见错误码章节),成功时为空 |
success |
Boolean |
是否成功:(true:成功,false:失败) |
msg |
String |
请求失败的信息,成功时为空 |
t |
Long |
返回时间戳,13位 |
result |
Arrays |
返回结果 |
result参数说明
参数名 |
类型 |
说明 |
code |
String |
状态编码 |
value |
String |
状态值 |
请求示例
GET {url}/v1.0/osaas/devices/6c5cc1ce9718******/status
响应成功示例
{
"success": true,
"t": 1545447665981,
"result": [
{
"code": "switch_led",
"value": "true"
},
{
"code": "work_mode",
"value": "scene_2"
}
]
}
响应失败示例
{
"code": 500,
"msg": "system error,please contact the admin",
"success": false,
"t": 1561378856383
}
下发设备指令
接口描述
调用该接口下发设备指令
接口地址
POST /v1.0/osaas/devices/{device_id}/commands
请求参数
参数名 |
类型 |
参数类型 |
说明 |
是否必需 |
device_id |
String |
URI |
设备唯一标识 |
是 |
commands |
Arrays |
BODY |
功能集 |
是 |
commands参数说明
参数名 |
类型 |
参数类型 |
说明 |
是否必需 |
code |
String |
BODY |
功能码 |
是 |
value |
Object |
BODY |
功能值 |
是 |
响应参数
参数名 |
类型 |
说明 |
code |
Integer |
响应码(详情见错误码章节),成功时为空 |
success |
Boolean |
是否成功:(true:成功,false:失败) |
msg |
String |
请求失败的信息,成功时为空 |
t |
Long |
返回时间戳,13位 |
result |
Boolean |
返回结果 |
请求示例
POST {url}/v1.0/osaas/devices/6c5cc1ce9718dxxxxxxx/commands
{
"commands": [
{
"code": "switch_led",
"value": true
},
{
"code": "bright",
"value": 30
}
]
}
响应成功示例
{
"success": true,
"result": true,
"t": 1566053034624
}
响应失败示例
{
"code": 500,
"msg": "system error,please contact the admin",
"success": false,
"t": 1561378856383
}
错误码
以下为该接口常见的业务异常,更多的异常错误,请参见全局错误码。