Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Optional

Type

Description

Example

tag_name

String

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

&tag_name=tag1,tag2,tag3

separator

string

separator for 매개변수의 tag_name, columns, and_conditioncondition들을 구분하는 구분자

&separator=

value_return_form

int

result set format

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

0 : separate standard (default) or 1 : merged standard

date_format

string

date format of select time or timestamp type 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)

offset

int

count of skip검색후 건너뛸 데이터의 수

&offset=500

limit

int

count of display출력할 데이터의 수

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

...

Name of Value

Value Description

MAX_TIMEMaximum time value among records of the tag

같은 tag값을 갖는 결과 중 가장 큰 시간값

MAX_VALUEMaximum value among records in that tag

같은 tag값을 갖는 결과 중 가장 큰 값

MAX_VALUE_TIMEThe time value of the record with the maximum value entered

같은 tag값을 갖는 결과 중 가장 큰 값이 입력되었을 때의 시간값

MIN_TIMEMinimum time value among records of that tag

같은 tag값을 갖는 결과 중 시간이 가장 작은 시간

MIN_VALUEMinimum value among records in that tag

같은 tag값을 갖는 결과 중 가장 작은 값

MIN_VALUE_TIMEThe time value of the record with the minimum value entered

같은 tag값을 갖는 결과 중 가장 작은 값이 입력되었을 때의 시간값

RECENT_ROW_TIME

Time value of the most recently entered data가장 최근에 입력된 시간 값

ROW_COUNT

Number of records레코드의 수

Sample Code

...

Expand
titlelinux(shell)

github

Code Block
# Text Encoding to UTF-8 in CMD
# Example For Select Data by Time Range for tag API by using curl in ubuntu
# written by yeony kim

API_KEY=YOUR_API_TOKEN

CONTENT_HEADER=Content-Type:application/json
API_HEADER=x-api-key:$API_KEY
LAKE_ID=YOUR_LAKE_ID
URL=https://$LAKE_ID.machlake.com/lakes/values/time_range

# ------------------------------------------------------------------------------------------------- #

# CASE - Current DATA GET with date format YYYY-MM-DD HH24:MI:SS mmm:uuu:nnn
TAG_NAME=sensor1,sensor2
DATE_FORMAT="YYYY-MM-DD HH24:MI:SS mmm:uuu:nnn"

curl -k -G $URL -H $CONTENT_HEADER -H $API_HEADER --data-urlencode "tag_name=$TAG_NAME" --data-urlencode "date_format=$DATE_FORMAT"

# Return Format
# {"data":{"columns":[{"length":4096,"name":"MIN","type":5},{"length":4096,"name":"MAX","type":5}],"samples":[{"data":[{"MAX":"2021-01-07 02:00:00 009:000:000","MIN":"2021-01-06 17:00:00 000:000:000"}],"tag_name":"sensor2"},{"data":[{"MAX":"2021-01-06 20:00:06 000:000:000","MIN":"2021-01-06 17:00:00 001:000:000"}],"tag_name":"sensor1"}]},"status":"success"}

# ------------------------------------------------------------------------------------------------- #
# ------------------------------------------------------------------------------------------------- #

# CASE - Current DATA GET with date format nanosecond timestamp
TAG_NAME=sensor1,sensor2
DATE_FORMAT=NANOSECOND

curl -k -G $URL -H $CONTENT_HEADER -H $API_HEADER --data-urlencode "tag_name=$TAG_NAME" --data-urlencode "date_format=$DATE_FORMAT"

# Return Format
# {"data":{"columns":[{"length":20,"name":"MIN","type":12},{"length":20,"name":"MAX","type":12}],"samples":[{"data":[{"MAX":1609952400009000000,"MIN":1609920000000000000}],"tag_name":"sensor2"},{"data":[{"MAX":1609930806000000000,"MIN":1609920000001000000}],"tag_name":"sensor1"}]},"status":"success"}

# ------------------------------------------------------------------------------------------------- #
Expand
titlejavascript

github

Code Block
// Example For Select Data by Time Range for tag API by using request in node js
// written by yeony kim
// sensor1, sensor2 is applied in lake

process.env.NODE_TLS_REJECT_UNAUTHORIZED ="0";

const express = require('express');
const app = express();
const API_KEY ="YOUR_API_TOKEN";
const LAKE_ID ="YOUR_LAKE_ID"
const URL ="https://" + LAKE_ID +".machlake.com/lakes/values/time_range";

// CASE - Current DATA GET with date format YYYY-MM-DD HH24:MI:SS mmm:uuu:nnn

app.get(
    '/select_time_range_with_nano_time_date_string', function(req, res) {
        var request = require('request');

        const QueryParams = new URLSearchParams()
        
        QueryParams.set('tag_name', 'sensor1,sensor2')
        QueryParams.set('date_format', 'YYYY-MM-DD HH24:MI:SS mmm:uuu:nnn')

        var option = {
            url: URL + "?" + QueryParams.toString(),
            headers: {
                'Content-Type': 'application/json',
                'x-api-key': API_KEY
            },
        };
        request.get( option, function(error, response, body) {
            if (!error) {
                res.writeHead(200);
                res.end(body);
                console.log(body) // {"data":{"columns":[{"length":4096,"name":"MIN","type":5},{"length":4096,"name":"MAX","type":5}],"samples":[{"data":[{"MAX":"2021-01-07 02:00:00 009:000:000","MIN":"2021-01-06 17:00:00 000:000:000"}],"tag_name":"sensor2"},{"data":[{"MAX":"2021-01-06 20:00:06 000:000:000","MIN":"2021-01-06 17:00:00 001:000:000"}],"tag_name":"sensor1"}]},"status":"success"}
            } else {
                console.log(error)
            }
        })
    }
)

// CASE - Current DATA GET with date format nanosecond timestamp

app.get(
    '/select_time_range_with_nano_timestamp_string', function(req, res) {
        var request = require('request');

        const QueryParams = new URLSearchParams()
        
        QueryParams.set('tag_name', 'sensor1,sensor2')
        QueryParams.set('date_format', 'NANOSECOND')

        var option = {
            url: URL + "?" + QueryParams.toString(),
            headers: {
                'Content-Type': 'application/json',
                'x-api-key': API_KEY
            },
        };
        request.get( option, function(error, response, body) {
            if (!error) {
                res.writeHead(200);
                res.end(body);
                console.log(body) // {"data":{"columns":[{"length":20,"name":"MIN","type":12},{"length":20,"name":"MAX","type":12}],"samples":[{"data":[{"MAX":1609952400009000000,"MIN":1609920000000000000}],"tag_name":"sensor2"},{"data":[{"MAX":1609930806000000000,"MIN":1609920000001000000}],"tag_name":"sensor1"}]},"status":"success"}
            } else {
                console.log(error)
            }
        })
    }
)

app.listen(8888, function() {
    console.log('http://127.0.0.1:8888/select_raw_with_nano_date_time_string is result for select time range data with nano date time string')
    console.log('http://127.0.0.1:8888/select_time_range_with_nano_timestamp_string is result for select time range data with nano timestamp string')
})

...

titlepython

github

...

Type

...

titlewindow(batch)

...

github

Code Block
chcp 65001 
:: Text Encoding to UTF-8 in CMD
:: Example For Select Data by Time Range for tag API by using curl in window script
:: written by yeony kim

set API_KEY=YOUR_API_TOKEN

set CONTENT_HEADER="Content-Type: application/json"
set API_HEADER="x-api-key: %API_KEY%"
set LAKE_ID=YOUR_LAKE_ID
set URL="https://%LAKE_ID%.machlake.com/lakes/values/time_range"

:: ------------------------------------------------------------------------------------------------- ::

:: CASE - Current DATA GET with date format YYYY-MM-DD HH24:MI:SS mmm:uuu:nnn
set TAG_NAME=sensor1,sensor2
set DATE_FORMAT=YYYY-MM-DD HH24:MI:SS mmm:uuu:nnn

curl -k -G %URL% -H %CONTENT_HEADER% -H %API_HEADER% --data-urlencode "tag_name=%TAG_NAME%" --data-urlencode "date_format=%DATE_FORMAT%"

:: Return Format
:: {"data":{"columns":[{"length":4096,"name":"MIN","type":5},{"length":4096,"name":"MAX","type":5}],"samples":[{"data":[{"MAX":"2021-01-07 02:00:00 009:000:000","MIN":"2021-01-06 17:00:00 000:000:000"}],"tag_name":"sensor2"},{"data":[{"MAX":"2021-01-06 20:00:06 000:000:000","MIN":"2021-01-06 17:00:00 001:000:000"}],"tag_name":"sensor1"}]},"status":"success"}

:: ------------------------------------------------------------------------------------------------- ::
:: ------------------------------------------------------------------------------------------------- ::

:: CASE - Current DATA GET with date format nanosecond timestamp
set TAG_NAME=sensor1,sensor2
set DATE_FORMAT=NANOSECOND

curl -k -G %URL% -H %CONTENT_HEADER% -H %API_HEADER% --data-urlencode "tag_name=%TAG_NAME%" --data-urlencode "date_format=%DATE_FORMAT%"

:: Return Format
:: {"data":{"columns":[{"length":20,"name":"MIN","type":12},{"length":20,"name":"MAX","type":12}],"samples":[{"data":[{"MAX":1609952400009000000,"MIN":1609920000000000000}],"tag_name":"sensor2"},{"data":[{"MAX":1609930806000000000,"MIN":1609920000001000000}],"tag_name":"sensor1"}]},"status":"success"}

:: ------------------------------------------------------------------------------------------------- ::