第三方平台接入指南
更新时间:2019-04-19
配置信息
1、第三方平台用户在配置页面上填写自己服务器的URL和token,以HTTP开头,用来接收极动云平台的 验证信息和推送信息,同时还需选择数据加密方式(明文或者密文)。
2、提交配置信息后,极动云平台会发http get请求到用户填写的URL中,参数包括signature、nonce、
timestamp(nonce:随机字符串,timestamp:当前时间戳,signature:签名),第三方平台用户收到后对token、
nonce和timestamp进行校验,若确认,就返回nonce,接入生效。
signature = MD5(SHA1(token+nonce+timestamp))
接口说明
1、获取平台token(GET)
URL | https://api.expeedos.cn/v1/platform/token?platform_key=xxx&secret_key=yyy |
http头部 | |
Request | |
Responese |
{ “result_code”:0, “access_token”:”zzz”, “expires_in”:7200, “result_message”:”ok” } |
注意事项 | 该接口每日调用次数不能超过200次 |
参数说明
标签 | 类型 | 是否必填 | 含义 |
---|---|---|---|
platform_key | String | Y | 平台识别码 |
secret_key | String | Y | 密钥 |
token | String | 调用接口凭证 | |
expires_in | int | 凭证有效时间(秒) | |
result_code/result_message | int | 0代表成功,对应"result_message"为"ok"; 1代表失败,对应"result_message"为"验证失败"; |
2、设备上下线状态查询(GET)
URL | https://api.expeedos.cn/v1/devices/device_status/{device_id} |
http头部 | access_token:xxx; device_key:xxx |
Request | |
Responese |
{ “result_code”:0, “device_status”:1, “result_message”:”ok” } |
注意事项 |
参数说明
标签 | 类型 | 是否必填 | 含义 |
---|---|---|---|
token | String | Y | 调用接口凭证 |
device_id | String | Y | 设备ID |
device_key | String | ||
result_code/result_message | int | 0代表成功,对应"result_message"为"ok"; 1 代表token过期,对应"result_message"为"token过期"; 2 代表设备不存在,对应"result_message"为"设备不存在"; … |
|
device_status | int | 设备状态,0为离线,1为上线; |
3、查询设备当前状态(GET)
URL | https://api.expeedos.cn/v1/devices/{device_id}/currentDatapoints?id=xxx,yyy |
http头部 | access_token:xxx; device_key=xxx |
Request(JSON) | |
Responese |
{ "result_code":0; "result_message":"ok" "data":{ "xxx":0, "yyy":2 } } |
注意事项 |
参数说明
标签 | 类型 | 是否必填 | 含义 |
---|---|---|---|
access_token | String | Y | 调用接口凭证 |
device_id | String | Y | 设备ID |
device_key | String | ||
id | String | 状态属性名称,查询所有属性填“all” |
4、查询设备历史记录(GET)
URL | https://api.expeedos.cn/v1/devices/{device_id}/datapoints?id=xxx,yyy&start=xxx&end=xxx&limit=8&cursor=ZZZ&first=0 |
http头部 | access_token:xxx; device_key=xxx |
Request(JSON) | |
Responese |
{ “result_code”:0; “result_message”:”ok” “cursor”: 1486958400000, “data”:[{ “timestamp”:”2017-02-13T12-00-00-000”, ”xxx”:0; ”yyy”:2; }, { “timestamp”:”2017-02-13T12-00-01-000”, ”xxx”:2 }, … ] } |
注意事项 |
参数说明
标签 | 类型 | 是否必填 | 含义 |
---|---|---|---|
access_token | String | Y | 调用接口凭证 |
device_id | String | Y | 设备ID |
device_key | String | Y | |
id | String | N | 要查询的数据点名,多个查询以“,”隔开,不传则默认传该设备下所有数据点 |
start | String | N | 起始时间,传时间格式,例2017-02-13T12-00-00-000;start与end必须成对出现 |
end | String | N | 截止时间,传时间格式,例2017-02-13T12-00-00-000;start与end必须成对出现 |
first | int | N | 0表示按最近时间排序,1表示按最早时间排序,默认不填为0; |
limit | int | N | 限定本次请求最多返回的数据点的数量,取值1-6000,不传则默认查询100; |
cursor | long | N | 指定本次请求继续从cursor位置开始提取数据 |
cursor | long | N | 指定本次请求继续从cursor位置开始提取数据 |
result_code/result_message | int/String | 0代表成功,对应“result_message”为”ok”; 1 代表token过期,对应“result_message”为“token过期”; 2 代表设备不存在,对应“result_message”为“设备不存在”; 3 代表查询参数非法,对应”result_message”为“查询参数非法”; … |
5、设备上下线通知(POST)
URL | 用户注册URL |
http头部 | |
Request(JSON) | { “msg_type”:”1”, “device_id”:xxx, “device_key”:xxx, “device_sn”:xxx, “device_status”:0 } |
Responese | { “result_code”:0, “result_msg”:”ok” } |
参数说明
标签 | 类型 | 是否必填 | 含义 |
---|---|---|---|
msg_type | String | Y | 1为设备上下线通知;2为设备数据上送通知;3为设置信息返回通知 |
device_id | String | Y | 设备ID |
device_status | String | 设备状态,0为上线,1为离线; | |
device_sn | String | 设备SN | |
result_code | String | 0代表成功;... | |
result_message | String | 返回信息; |
6、设备数据上送通知(POST)
URL | 用户注册URL |
http头部 | |
Request(JSON) | { “device_id”:xxx “device_key”:xxx “msg_type”:”2” data:[{ “timestamp”:”2017-02-13T12-00-00-000”, “value1”:xx, “value2”:yy … }, { “timestamp”:”2017-02-13T12-00-00-000”, “value1”:xx, “value2”:yy … }, .. ] } |
Responese | { “result_code”:0, “result_message”:”ok” } |
参数说明
标签 | 类型 | 是否必填 | 含义 |
---|---|---|---|
msg_type | String | Y | 1为设备上下线通知;2为设备数据上送通知;3为设置信息返回通知 |
device_id | String | Y | 设备ID |
data | JSON数组 | 具体数据 | |
result_message | String | 返回信息; |
7、应用端发送设置信息(POST)
URL | https://api.expeedos.cn/v1/devices/{device_id}/device_setting |
http头部 | access_token:xxx; device_key=xxx |
Request(JSON) | { “temp”:xxx; “switch”:xxx; } |
Responese | { “result_code”:0, “result_message”:”ok”, “message_id”:xxxxx } |
参数说明
标签 | 类型 | 是否必填 | 含义 |
---|---|---|---|
token | String | Y | 调用接口凭证 |
device_id | String | Y | 设备ID |
device_key | String | Y | |
data | Y | 设置信息 | |
result_code/result_message | int/String | 0代表成功,对应“result_message”为”ok”; 1 代表token过期,对应“result_message”为“token过期”; 2 代表设备不存在,对应“result_message”为“设备不存在”; 3 代表设备不在线,对应“result_message”为“设备不在线” … | |
message_id | String | 用于标识设置返回信息 | 设置信息 |
8、服务器返回设置信息(POST)
URL | 用户注册URL |
http头部 | access_token:xxx; device_key=xxx |
Request(JSON) | { “msg_type”:3; “message_id”: xxx “device_id”:xxx “set_result”:0 } |
Responese | { “result_code”:0; “result_message”:”ok” } |
参数说明
标签 | 类型 | 是否必填 | 含义 |
---|---|---|---|
msg_type | String | Y | 1为设备上下线通知;2为设备数据上送通知;3为设置信息返回通知 |
message_id | String | Y | 用于标识设置返回信息 |
device_id | String | Y | 设备ID |
set_result | String | Y | 0为设置成功;1为设置失败; |
result_code | int | Y | 0代表成功;… |
result_message | String | Y | 返回信息; |
错误代码
错误代码(resul_code) | 错误信息(result_message) | 注释 |
---|---|---|
0 | ok | 成功 |
1 | token过期 | token过期 |
2 | 设备不存在 | 设备不存在 |
3 | Device_key不存在 | |
4 | URL参数非法 | |
5 | BODY参数非法 |