2023.04.22 | admin | 223次围观
返回值为JSON格式,如下:
{
"status": "succ",
"head": ["ts","current", …],
"column_meta": [["ts",9,8],["current",6,4], …],
"data": [
["2018-10-03 14:38:05.000", 10.3, …],
["2018-10-03 14:38:15.000", 12.6, …]
],
"rows": 2
}
说明:
column_meta 中的列类型说明:
自定义授权码
HTTP请求中需要带有授权码,用于身份识别。授权码通常由管理员提供,可简单的通过发送HTTP GET请求来获取授权码,操作如下:
curl http://
:6041/rest/login/ /
其中,ip是TDengine数据库的IP地址url加上时间戳,username为数据库用户名,password为数据库密码,返回值为JSON格式url加上时间戳,各字段含义如下:
获取授权码示例:
curl http://192.168.0.1:6041/rest/login/root/taosdata
返回值:
{
"status": "succ",
"code": 0,
"desc": "/KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04"
}
使用示例
curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d 'select * from demo.d1001' 192.168.0.1:6041/rest/sql
返回值:
{
"status": "succ",
"head": ["ts","current","voltage","phase"],
"column_meta": [["ts",9,8],["current",6,4],["voltage",4,4],["phase",6,4]],
"data": [
["2018-10-03 14:38:05.000",10.3,219,0.31],
["2018-10-03 14:38:15.000",12.6,218,0.33]
],
"rows": 2
}
curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d 'create database demo' 192.168.0.1:6041/rest/sql
返回值:
{
"status": "succ",
"head": ["affected_rows"],
"column_meta": [["affected_rows",4,4]],
"data": [[1]],
"rows": 1
}
其他用法结果集采用Unix时间戳
HTTP请求URL采用sqlt时,返回结果集的时间戳将采用Unix时间戳格式表示,例如
curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d 'select * from demo.d1001' 192.168.0.1:6041/rest/sqlt
返回值:
{
"status": "succ",
"head": ["ts","current","voltage","phase"],
"column_meta": [["ts",9,8],["current",6,4],["voltage",4,4],["phase",6,4]],
"data": [
[1538548685000,10.3,219,0.31],
[1538548695000,12.6,218,0.33]
],
"rows": 2
}
结果集采用UTC时间字符串
HTTP请求URL采用sqlutc时,返回结果集的时间戳将采用UTC时间字符串表示,例如
curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d 'select * from demo.t1' 192.168.0.1:6041/rest/sqlutc
返回值:
{
"status": "succ",
"head": ["ts","current","voltage","phase"],
"column_meta": [["ts",9,8],["current",6,4],["voltage",4,4],["phase",6,4]],
"data": [
["2018-10-03T14:38:05.000+0800",10.3,219,0.31],
["2018-10-03T14:38:15.000+0800",12.6,218,0.33]
],
"rows": 2
}
重要配置项
下面仅列出一些与RESTful接口有关的配置参数,其他系统参数请看配置文件里的说明。注意:配置修改后,需要重启taosd服务才能生效
版权声明
本文仅代表作者观点。
本文系作者授权发表,未经许可,不得转载。
发表评论