[小 迪 导读]
随着大数据技术和智能显示技术的倒退,数字可视化大屏设计曾经成为IT信息畛域一种广泛的数据展现利用场景。从政府的宏观政务决策,到企业的生产治理,从环保数据的实时监控,到电商平台的流量监控,都离不开数据大屏的身影。可视化数据大屏承载着各种组织对内信息共享、决策分析,对外信息颁布、行业交换、会议现场展现等重任,被越来越宽泛的利用。在数字化转型潮流中,dgiot可能提供海量的数据采集并通过dgiot对立接口为第三方提供设施信息的数据生产。

1.0 获取Token

1.1登录接口

接口名称:登录接口
接口地址:https://prod.dgiotcloud.cn/io...
申请办法:POST

申请参数

参数参数名称类型参数阐明是否必填项
username用户名String零碎账户
password明码String零碎账户明码
Json 示例:{"password": "dgiot\_admin","username": "dgiot\_admin"}

返回参数

参数参数名称类型参数阐明是否必填项
username用户名String零碎账户
sessionToken会话标识String零碎申请惟一验证

Json 示例:{"sessionToken": "r:b2567201abe12b1581ebf5dd16839edd","username": "dgiot\_admin"}

1.2 获取token

接口名称:取得Token
接口地址:https://prod.dgiotcloud.cn/io...
申请办法:POST

申请参数

参数参数名称类型参数阐明是否必填项
appid利用名称String在SDK调用过程中惟一的一个利用标识
secret利用密钥String调用API时的Token,用来验证申请合法性,请留神窃密

返回参数

参数参数名称类型参数阐明是否必填项
name用户名String零碎账户
access\_token会话标识String零碎申请惟一验证
expires\_inToken过期工夫IntToken过期工夫单位:秒
desc形容String形容

2.0查问Device parse数据

简要形容:

  • 获取以后设施parse数据

申请URL:

  • https://prod.dgiotcloud.cn/iotapi/classes/Device

申请形式:

  • GET

参数:

参数名必选类型阐明
orderstring排序形式, 负为降序, eg: score,-name
limitintegerlimit, 显示多少条记录,显示100条记录 eg:100
skipintegerskip, 从第几条记录开始
keysstring须要显示的字段,加count(*)则后果外面会显示总记录数, last_row为获取最初一条记录, eg: devaddr,status
includestringinclude
whereinteger过滤条件,eg: {"devaddr":{"$in":["842500EE"]}}
curl -X GET "https://prod.dgiotcloud.cn/iotapi/classes/Device?order=createdAt&limit=10&skip=0&keys=devaddr%2Cstatus&where=%7B%22devaddr%22%3A%7B%22%24in%22%3A%5B%22842500EE%22%5D%7D%7D" -H "accept: application/json" -H "authorization: Basic bGl1c2hvdXhpbjpsaXVzaG91eGlu"

返回示例

  {    "results": [      {        "devaddr": "842500EE",        "status": "ONLINE",        "objectId": "7f484ee521",        "createdAt": "2021-04-18T11:06:53.878Z",        "updatedAt": "2021-04-19T05:43:14.419Z",        "ACL": {          "role:admin": {            "read": true,            "write": true          }        }      }    ]  }

返回参数阐明

备注

  • 更多返回错误代码请看首页的错误代码形容

3.0查问单个Device时序数据

简要形容:

  • 获取以后设施时序数据

申请URL:

  • https://prod.dgiotcloud.cn/iotapi/device

申请形式:

  • GET

参数:

参数名必选类型阐明
deviceidstring设施ID
orderstring排序形式, 负为降序, eg: score,-name
limitintegerlimit, 显示多少条记录,显示100条记录 eg:100
skipintegerskip, 从第几条记录开始
keysstring须要显示的字段,加count(*)则后果外面会显示总记录数, last_row为获取最初一条记录, eg: username,email
whereinteger过滤条件,eg: {"createdat": {"$gte":"now - 10d"}}
curl -X GET "https://prod.dgiotcloud.cn/iotapi/device/69c7f9e376?order=createdAt&limit=10&skip=10&where=%7B%22createdat%22%3A%20%7B%22%24gte%22%3A%22now%20-%2010d%22%7D%7D" -H "accept: application/json" -H "authorization: Basic YWRtaW46c3dTV2lvdG4ybi5jb20="

返回示例

  {    "results": [      {        "activetotalenergy": 0,        "createdat": "2021-04-14 03:27:02.577"      },      {        "activetotalenergy": 0,        "createdat": "2021-04-14 03:27:12.582"      },      {        "activetotalenergy": 0,        "createdat": "2021-04-14 03:27:22.512"      },      {        "activetotalenergy": 0,        "createdat": "2021-04-14 03:27:32.451"      },      {        "activetotalenergy": 0,        "createdat": "2021-04-14 03:27:42.515"      },      {        "activetotalenergy": 0,        "createdat": "2021-04-14 03:27:52.389"      },      {        "activetotalenergy": 0,        "createdat": "2021-04-14 03:28:02.390"      },      {        "activetotalenergy": 0,        "createdat": "2021-04-14 03:28:12.454"      },      {        "activetotalenergy": 0,        "createdat": "2021-04-14 03:28:22.360"      },      {        "activetotalenergy": 0,        "createdat": "2021-04-14 03:28:32.279"      }    ]  }

返回参数阐明

备注

  • 更多返回错误代码请看首页的错误代码形容

RESTful接口应用帮忙

反复登录问题解决方案:

curl 是罕用的命令行工具,用来申请 Web 服务器。它的名字就是客户端(client)的 URL 工具的意思。

它的性能十分弱小,命令行参数多达几十种。其中 -u 参数能够用来设置服务器认证的用户名和明码。

  • $ curl -u 'demo:123456'

下面命令设置用户名为demo,明码为123456。

以上文curl为例:

原:curl -X GET "https://prod.dgiotcloud.cn/iotapi/device/a47072cd8b?order=createdAt&limit=10&skip=10&where=%7B%22createdat%22%3A%20%7B%22%24gte%22%3A%22now%20-%2010d%22%7D%7D" -H "accept: application/json" 现:curl -u 'demo:123456' -X GET "https://prod.dgiotcloud.cn/iotapi/device/a47072cd8b?order=createdAt&limit=10&skip=10&where=%7B%22createdat%22%3A%20%7B%22%24gte%22%3A%22now%20-%2010d%22%7D%7D" -H "accept: application/json" 

TDengine反对SQL语句:

为反对各种不同类型平台的开发,TDengine提供合乎REST设计标准的API,即RESTful API。为最大水平升高学习老本,不同于其余数据库RESTful API的设计办法,TDengine间接通过HTTP POST 申请BODY中蕴含的SQL语句来操作数据库,仅须要一个URL。

http://<ip>:<PORT>/rest/sql

curl语法如下:

curl -u username:password -d '<SQL>' <ip>:<PORT>/rest/sql

留神:SQL语句中的数据表应提供数据库前缀

上面以查问最近十条记录为例

curl -H "accept: application/json" -u root:taosdata -d 'SELECT createdat FROM _3ea14b556a._d46d4340d9   order by createdat desc limit 10 ' http://prod.dgiotcloud.cn:6041/rest/sql

返回示例

  {      "status":"succ",      "head":[          "createdat"      ],      "data":[          [              "2021-04-20 03:09:42.737"          ],          [              "2021-04-20 03:09:17.726"          ],          [              "2021-04-20 03:08:51.004"          ],          [              "2021-04-20 03:08:14.428"          ],          [              "2021-04-20 03:07:48.258"          ],          [              "2021-04-20 03:07:13.028"          ],          [              "2021-04-20 03:06:47.026"          ],          [              "2021-04-20 03:06:20.609"          ],          [              "2021-04-20 03:05:44.695"          ],          [              "2021-04-20 03:05:18.560"          ]      ],      "rows":10  }

[小 迪 点评]

  • dgiot反对对接第三方平台,为数字可视化大屏等第三方利用提供无力的数据保障。

想理解更多 dgiot 的具体细节,欢送大家在GitHub上查看相干源代码。