/
Pivoted Value Select

Pivoted Value Select

Tag ID별로 정렬된 센서 데이터를 Tag ID를 칼럼으로 설정한 ROW형태로 변환하는 API이다.

HTTP Request

GET https://${CloudVendor}.${CountryCode}.machlake.com/lakes/${lake_id}/values/pivoted Content-Type: application/json; charset=utf8 x-api-key: {API Key}

Parameters

Optional

Type

Description

Example

Optional

Type

Description

Example

tag_name

string

Tag의 이름. 여러개를 명시하려면 ',' 문자를 이용하여 나열할 수 있다.

&tag_name=tag1,tag2,tag3

calc_mode

string

min,max,cnt,avg,sum

&calc_mode=min (default : avg)

date_format

string

Time값의 포멧 지정 DATE_FORMAT 혹은 timestamp 단위("SECOND", "MILLISECOND", "MICROSECOND", "NANOSECOND")

&date_format=YYYY-MM-DD HH24:MI:SS
or
&date_format=MILLISECOND

(default : YYYY-MM-DD HH24:MI:SS)

start_time

string

검색 시작 시간 (종료시간보다 적은 값이어야 함)

아래의 두가지 중 하나의 방법으로 설정

type 1 : 시간 문자열

start_time=2018-01-16 14:40:05 000
or

start_time=2018-01-16 14:40:05.000

type 2 : 밀리초 혹은 마이크로초 기반 타임스탬프

start_time=1618813188
or

start_time=1618813188123

&start_time=2018-01-16 14:40:05 000
or
&start_time=2018-01-16 14:40:05.000
or
&start_time=1618813188
or
&start_time=1618813188123

  • datetime of parameter supports up to millisecond.

end_time

string

검색 종료 시간 (start_time보다 커야 함)

same as start_time

same as start_time

interval_type

string

sec,min,hour,day (or s,m,h,d)

&interval_type=hour (default : sec)

interval_value

int

interval_type의 정수배로 표현하는 interval 설정

&interval_value=10 (default : 1)

limit

int

출력할 데이터의 수

&limit=1000 (default : Restricted by 'lake tier' by lake tier)

offset

int

검색후 건너뛸 데이터의 수

&offset=500

direction

int

오름차순 혹은 내림차순 설정

&direction=0
0 : ascend (default)
1 : descend

value_return_form

int

결과 출력 방법


차트 라이브러리에서 입력받는 방식에 따라 변경하여 사용함

0 : separate standard (default)

1 : merged standard

Request Example

GET https://aws1.us.machlake.com/lakes/xbacd1234/values/pivoted?tag_name=tag_01,tag_02&calc_mode=avg&date_format=YYYY-MM-DD HH24:MI:SS&start_time=2021-06-16 11:35:00&end_time=2021-07-06 12:12:28&interval_type=min&limit=1000&value_return_form=0 Content-Type: application/json; charset=utf8 x-api-key: {API Key}

Response Example

Status 200 // return format = 0 { "status": "success", "data": { "calc_mode": "AVG", "columns": [ {"name": "TIME", "type": 5, "length": 4096}, {"name": "tag_01", "type": 20, "length": 17}, {"name": "tag_02", "type": 20, "length": 17} ], "samples": [ { "data": [ { "TIME": "2021-06-16 11:36:00", "tag_01": 1515.4806, "tag_02": 1524.3684 }, { "TIME": "2021-06-16 11:37:00", "tag_01": 1513.4624, "tag_02": 1490.107 }, { "TIME": "2021-06-17 15:42:00", "tag_01": 1499.028979191633, "tag_02": null }, { "TIME": "2021-06-17 15:43:00", "tag_01": 1470.2225841476657, "tag_02": null }, { "TIME": "2021-06-17 15:44:00", "tag_01": 1487.0528, "tag_02": 1508.5176 }, { "TIME": "2021-07-06 12:12:00", "tag_01": 1887.5, "tag_02": 1628 } ] } ] } } // return format = 1 { "status": "success", "data": { "calc_mode": "AVG", "columns": [ {"name": "TIME", "type": 5, "length": 4096}, {"name": "tag_01", "type": 20, "length": 17}, {"name": "tag_02", "type": 20, "length": 17} ], "samples": [ { "data": { "TIME": [ "2021-06-16 11:36:00", "2021-06-16 11:37:00", "2021-06-17 15:42:00", "2021-06-17 15:43:00", "2021-06-17 15:44:00", "2021-07-06 12:12:00" ], "tag_01": [ 1515.4806, 1513.4624, 1499.028979191633, 1470.2225841476657, 1487.0528, 1887.5 ], "tag_02": [ 1524.3684, 1490.107, null, null, 1508.5176, 1628 ] } } ] } }

Sample Code