Search Suggestions
IOT API Reference

IOT API Reference

TONYLABS 24 Aug, 2014
  • 13
  • 0

相关参考

HTTP 协议参考 常用 RESETFUL 错误代码

API

下面的表列出一套完整的操作可以执行与 TONYLABS IoT API。产品,设备,钥匙,触发器,数据流和数据。每个资源都有特定的属性。 注意:如果不指定格式/媒体类型 JSON或XML 与 IoT API进行交互时,默认的格式接受/返回 JSON。 

iot-service-structure

用户注册

用户注册时,App 开发者需要注意密码需要通过 MD5 或 SHA 先将密码加密后,再发送,性别(Gender)字段为字符串类型,可接受如 Male|Female 或 '男'|'女',亦可 0|1 区分,生日日期格式为 YYYY-mm-dd 

Parameters
MethodPUT
Base URLhttp://iot.swiftio.cc/beta
API Endpoint/rest/user/register.json
Headers
  

PUT http://iot.swiftio.cc/beta/rest/user/register.json

{ "version":"1.0.0", "username":"", "email":"", "passwd":"MD5()", "phone":"", "idcard":"", "gender":"Male|Female", "birthday":"YYYY-mm-dd" }

 Return JSON 

{"status":"200"}

用户登录

Parameters
MethodPOST
Base URLhttp://121.40.153.169
API Endpoint/api/user/login.json
Headers
  

POST http://iot.swiftio.cc/beta/rest/user/login.json

{ "version":"1.0.0", "username":"", "email":"", "passwd":"" }

 Return JSON

{ "uid":"47", "username":"USERNAME", "password":"PASSWRD", "email":"EMAIL", "email_verified":"0", "uuid":null, "role":"citizen", "city":null, "country":null, "website":null, "idcard":"IDCARD_NUMBER", "gender":"MALE", "phone":"PHONE_NUMBER", "birthday":"1999-08-14", "last_login_time":null, "last_login_ip":null, "login_count":"0", "lock":"0", "ctime":"2014-10-24 10:58:58", "mtime":null }

 用户信息查询 (JSON) 

Parameters
MethodGET
Base URLhttp://121.40.153.169
API Endpoint/api/user/UID_HERE.json
Headers
  

GET http://iot.swiftio.cc/beta/rest/user/UID_HERE.json

{ "version":"1.0.0", "username":"", "email":"", "passwd":"" }

 Return JSON

{ "uid":"47", "username":"USERNAME", "password":"PASSWRD", "email":"EMAIL", "email_verified":"0", "uuid":null, "role":"citizen", "city":null, "country":null, "website":null, "idcard":"IDCARD_NUMBER", "gender":"MALE", "phone":"PHONE_NUMBER", "birthday":"1999-08-14", "last_login_time":null, "last_login_ip":null, "login_count":"0", "lock":"0", "ctime":"2014-10-24 10:58:58", "mtime":null }

  

 

用户信息查询 (HTML)

Parameters
MethodGET
Base URLhttp://121.40.153.169
API Endpoint/api/user_login
Headers
  

GET http://121.40.153.169/api/user_login?version=1.0.0&username=xxx&email=xxx@xxx.com&passwd=md5(xxx)

NO BODY

Return JSON

{ "uid":"47", "username":"USERNAME", "password":"PASSWRD", "email":"EMAIL", "email_verified":"0", "uuid":null, "role":"citizen", "city":null, "country":null, "website":null, "idcard":"IDCARD_NUMBER", "gender":"MALE", "phone":"PHONE_NUMBER", "birthday":"1999-08-14", "last_login_time":null, "last_login_ip":null, "login_count":"0", "lock":"0", "cTime":"2014-10-24 10:58:58", "mTime":null }

 用户节点设备列表 (JSON)

Parameters
MethodGET
Base URLhttp://121.40.153.169
API Endpoint/api/node/UID_HERE.json
Headers
  

GET http://iot.swiftio.cc/beta/rest/node/user/UID_HERE.json

[javascript] { "version":"1.0.0", "username":"", "email":"", "passwd":"" } [/javascript]

Return JSON

[javascript] [ { "uid":"5", "user_device_name":"My Living Room Power Jack", "user_device_mac":"843A4B0DAA20", "user_device_lock":"1", "device_id":"13", "device_machine_name":"5_channels_jack", "device_description":"Manufactory Warning Message for User" }, { "uid":"5", "user_device_name":"My Bedroom Power Jack", "user_device_mac":"843A4B0DAA11", "user_device_lock":"0", "device_id":"13", "device_machine_name":"5_channels_jack", "device_description":"Manufactory Warning Message for User" } ] [/javascript]

 

用户节点设备列表 (HTML)

Parameters
MethodGET
Base URLhttp://iot.swiftio.cc/beta
API Endpoint/api/node_list
Headers
  

GET http://iot.swiftio.cc/beta/rest/node/list?username=xxx&email=xxx&passwd=md5(xxx)

[javascript] NO BODY [/javascript]

Return JSON

[javascript] [ { "uid":"5", "user_device_name":"My Living Room Power Jack", "user_device_mac":"843A4B0DAA20", "user_device_lock":"1", "device_id":"13", "device_machine_name":"5_channels_jack", "device_description":"Manufactory Warning Message for User" }, { "uid":"5", "user_device_name":"My Bedroom Power Jack", "user_device_mac":"843A4B0DAA11", "user_device_lock":"0", "device_id":"13", "device_machine_name":"5_channels_jack", "device_description":"Manufactory Warning Message for User" } ] [/javascript]

 

节点设备绑定/更新

当用户完成注册并登录后,用户通过手机 App 与智能设备通过 SmartConfig 配对,配对成功后,智能设备把该设备的 UUID、 machine_name 和 MAC 地址传回 App, 并通过该节点设备绑定/更新API登记。已登记绑定的设备,如需更新用户自定义设备名称,或锁定该设备,仍使用此方法更新,程序将自动判断。 

Parameters
MethodPOST
Base URLhttp://iot.swiftio.cc/beta
API Endpoint/rest/device/MAC_ADDRESS_HERE.json
Headers
  

POST http://iot.swiftio.cc/beta/rest/device/MAC_ADDRESS_HERE.json

[javascript] { "version":"1.0.0", "uid":"USER_ID_FROM_USER_LOGIN_STEP", "uuid":"MANUFACTORY_OR_DEVELOPER_UUID", "machine_name":"MACHINE_NAME_FROM_MCU", "name":"USER_DEFINED_DEVICE_NAME", "lock":"1||0" } [/javascript]

Return JSON

[javascript] { "status": 200, "msg": "Node updated." } [/javascript] [javascript] { "status": 200, "msg": "Node bound." } [/javascript]

 

用户节点设备删除

用户通过App删除节点设备,App 只需要将用户设备中的 UUID、MAC 地址和当前用户ID 通过 DELETE 请求即可。 

Parameters
MethodDELETE
Base URLhttp://121.40.153.169
API Endpoint/api/node/MAC_ADDRESS_HERE.json
Headers
  

DELETE http://121.40.153.169/api/channel/MAC_ADDRESS_HERE.json

[javascript] { "version" : "1.0.0", "username" : "xxxx", "passwd" : "md5(xxxxxx)" } [/javascript]

Return JSON

{"status":"200"}

 

心跳发送  (设备端) (HTML)

Parameters
MethodPUT
Base URLhttp://121.40.153.169
API Endpoint/api/node_heartbeat
Headers
  

PUT http://121.40.153.169/api/node_heartbeat?version=1.0.0&mac=xxxxxxxx

[javascript] {"version:"1.0.0", "mac":"AABBCCDDEEFF"} [/javascript]

Return JSON

 

心跳检测  (App 端) (HTML)

Parameters
MethodGET
Base URLhttp://121.40.153.169
API Endpoint/api/node_heartbeat
Headers
  

GET http://121.40.153.169/api/node_heartbeat?version=1.0.0&mac=xxxxxxxx

No body

Return JSON

[javascript] { {"status":200} } [/javascript]

 

节点设备通道数据读取(JSON)

Parameters
MethodGET
Base URLhttp://iot.swiftio.cc/beta
API Endpoint/rest/channel/MAC_ADDRESS_HERE.json
Headers
  

GET http://iot.swiftio.cc/beta/rest/channel/MAC_ADDRESS_HERE.json

{ "version":"1.0.0", "uuid":"xxx-xxxx-xxxxx-xxxxxx", "device_alt":"1415196715" (Optional) }

Return JSON

{ "device_machine_name":"xx_xxx_xx", "device_description":"xxxxxxxx", "device_alt":"1415196715", "channel": { "channel1": { "channel_value":"100", "channel_alt":"1414206622" }, "channel2": { "channel_value":"200", "channel_alt":"1414206622" }, } }

节点设备通道数据读取(HTML)

Parameters
MethodGET
Base URLhttp://iot.swiftio.cc/beta
API Endpoint/rest/channel/data
Headers
  

GET http://iot.swiftio.cc/beta/rest/channel/data?version=1.0.0&mac=xxxxxxxx&uuid=xxxx-xxxx-xxx-xxxx&device_alt=1415196715(Optional)

NO Body

Return JSON

{ "device_machine_name":"xxx_xxx_xx", "device_description":"xxxxxxxxxx", "device_alt":"1415196715", "channel": { "channel1": { "channel_value":"100", "channel_alt":"1414206622" }, "channel2": { "channel_value":"200", "channel_alt":"1414206622" }, } }

节点设备通道数据发送

Parameters
MethodPUT
Base URLhttp://iot.swiftio.cc/beta
API Endpoint/rest/channel/MAC_ADDRESS_HERE.json
Headers
  

PUT http://iot.swiftio.cc/beta/rest/channel/MAC_ADDRESS_HERE.json

{ "version" : "1.0.0", "uuid" : "xxx-xxxx-xxx-xxxx-xxx", "datastreams" : [ { "channel" : "channel1", "value" : "1" }, { "channel" : "channel2", "value" : "2" } ] }

  


相关商品

高性能 IoT 物联网开发板 SONY Spresense

SPRESENSE套件配备了六核心的Cortex-M4F处理器,内置有1.5MB的SRAM和8MB的存储空间,支持GNSS和GPS全球定位。其可通过连接器将主板的I / O电压从1.8V提升至3.3V

335.00

订阅并保持联系

输入您的电子邮箱即可在第一时间获得 TONYLABS 资讯