Versions Compared

Key

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

...

Paste code macro
languagehttp
themeSunburst
GET https://{lake_id${CloudVendor}.${CountryCode}.machlake.com/v1/lakes/${lake_id}/values/current
Content-Type: application/json; charset=utf8
x-api-key: {API Key}

Parameters

Optional

Type

Description

Example

type

string

select type

&type=current

tag_name

string

tag name with , separator

&tag_name=tag1,tag2,tag3

date_format

string

date format of select time
or
timestamp type ("SECOND", "MILLISECOND", "MICROSECOND", "NANOSECOND")

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

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

columns

string

columns to filter out

&columns=value,value2 (default : value)

separator

string

separator for tag_name, columns, and_condition

&separator=| (default : ,)

aliases

string

columns to be aliased (If Empty orthe columns is incorrect, an error will occur)

&aliases=myvalue,myvalu2

value_return_form

int

result set format

Optimized for various chart libraries and configured to return

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

Request Example

Paste code macro
languagehttp
themeSunburst
GET https://lake01aws1.us.machlake.com/v1/lakes/xbacd1234/values/?type=current?&tag_name=tag_01,tag_02&columns=VALUE&aliases=MyVal&value_return_form=0
Content-Type: application/json; charset=utf8
x-api-key: {API Key}

...

Paste code macro
languagejson
themeSunburst
Status 200

// return format = 0
{
    "status"success": true,
    "reason": "success",
    "data": {
        "calc_modecolumns": "raw", [
            {"name": "NAME", "type": 5, "columnslength": [80},
            {"name": "TIME", "type": 5, "length": 4096},
            {"name": "MyVal", "type": 20, "length": 17}
        ],
        "samplesrows": [
            ["tag_01","2021-07-06  {
                "tag_name": "tag_02",
                "data": [{"MyVal": 1629,"TIME": "2021-07-06 12:12:27"}]12:12:27", 1629],
            ["tag_02","2021-07-06 12:12:25", 1625]
        ]
    }
}
 

Sample Code

Expand
titlewindow(batch)

github

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

set API_KEY=YOUR_API_KEY
set LAKE_ID=YOUR_LAKE_ID
set CLOUD_VENDOR=YOUR_CLOUD_VENDOR
set CLOUD_REGION=YOUR_CLOUD_REGION

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

set SELECT_TYPE=current

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

:: 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 "type=%SELECT_TYPE%" \
    --data-urlencode "tag_name=%TAG_NAME%" \
    --data-urlencode "date_format=%DATE_FORMAT%"

:: Return Format
:: {
::     "success": true,
::     "reason": "success",
::     "data":{
::         "columns":[
::             {"name":"NAME","type":5,"length":80},
::             {"name":"TIME","type":5,"length":4096},
::             
{"
tag_
name":
"tag_01",
"VALUE","type":20,"length":17}
::         ],
::         "
data
rows":[
::             [
{
"sensor2"
MyVal": 1625,"TIME": "2021-07-06 12:12:25"}]
,"2021-01-07 02:00:00 009:000:000",2],
::             ["sensor1","2021-01-06 20:00:06 000:000:000",2]
::         ]
::     }
:: }
Expand
titlelinux(shell)

github

Code Block
languagebash
# Text Encoding to UTF-8 in CMD
# Example 
] } } // return format = 1 {
For Select Current Data for tag API by using curl in ubuntu

LAKE_ID=$YOUR_LAKE_ID
API_KEY=$YOUR_API_KEY
CLOUD_VENDOR=$YOUR_CLOUD_VENDOR
CLOUD_REGION=$YOUR_CLOUD_REGION
TAG_NAME=$YOUR_TAG_NAME

CONTENT_HEADER=Content-Type:application/json
API_HEADER=x-api-key:$API_KEY
URL=https://${CLOUD_VENDOR}.${CLOUD_REGION}.machlake.com/v1/lakes/${LAKE_ID}/values

SELECT_TYPE=current

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

# 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 "type=$SELECT_TYPE" \
    --data-urlencode "tag_name=$TAG_NAME" \
    --data-urlencode "date_format=$DATE_FORMAT"

# Return Format
# {
#     "success": true,
#     "
status
reason": "success",
#     "data":{
{
#         "
calc_mode
columns":
"raw",
[
#             
"columns": [
{"name":"NAME","type":5,"length":80},
#             {"name":
"TIME",
"type":
5,
"length":
4096},
#             {"name":
"
MyVal
VALUE",
"type":
20,
"length":
17}
#         ],
#         "rows":[
#             ["sensor2"
samples": [
,"2021-01-07 02:00:00 009:000:000",2],
#             ["sensor1","2021-01-06 20:00:06 000:000:000",2]
#         ]
#     }
# }
Expand
titlejavascript

github

Code Block
languagejs
// Example For Select Current Data 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 API_KEY ="YOUR_API_TOKEN";
const LAKE_ID ="YOUR_LAKE_ID";
const CLOUD_VENDOR="CLOUD_VENDOR";
const CLOUD_REGION="CLOUD_REGION";
const URL = `https://${CLOUD_VENDOR}.${CLOUD_REGION}.machlake.com/v1/lakes/${LAKE_ID}/values`;

var request = require('request');

const TAG_NAME = "sensor1,sensor2";
const SELECT_TYPE="current";


/* ------------------------------------------------------------------------------------------------- */

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

request.get({
    url: URL, 
    qs: {
        type: SELECT_TYPE,
        
"
tag_name: TAG_NAME,
        date_format: "YYYY-MM-DD HH24:MI:SS mmm:uuu:nnn"
    },
    headers: {
        
"tag_02",
"x-api-key": API_KEY
    }}, 
    function(error, response, body) {
        console.log(body);
        // Return Format
        // {
        //     "success": true,
        //     "reason": "success",
        //     "data":{
        //         "columns":[
        //             {"name":"NAME","type":5,"length":80},
        //             {"name":"TIME","type":5,"length":4096},
        //            
"MyVal": [1629
 {"name":"VALUE","type":20,"length":17}
        //         ],
        //         "rows":[
        //             ["sensor2"
TIME": ["2021-07-06 12:12:27"]
,"2021-01-07 02:00:00 009:000:000",2],
        //             ["sensor1","2021-01-06 20:00:06 000:000:000",2]
        //         ]
        //     }
        // }
    })
Expand
titlepython

gitgub

Code Block
languagepy
"""
Example For Select Current Data for tag API by using request in python
written by yeony kim
"""

import requests

API_KEY = "YOUR_API_TOKEN"
LAKE_ID = "YOUR_LAKE_ID"
CLOUD_VENDOR="CLOUD_VENDOR"
CLOUD_REGION="CLOUD_REGION"

URL = f"https://{CLOUD_VENDOR}.{CLOUD_REGION}.machlake.com/v1/lakes/{LAKE_ID}/values"

SELECT_TYPE="current"
TAG_NAME="sensor1,sensor2"

headers = {
    "Content-Type": "application/json",
    "x-api-key": API_KEY
}


{ "tag_name": "tag_01", "data": {
# ------------------------------------------------------------------------------------------------- #

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

params = {
    "type": SELECT_TYPE,
    "tag_name": TAG_NAME,
    "date_format": "YYYY-MM-DD HH24:MI:SS mmm:uuu:nnn",
}

response = requests.get(URL, headers=headers,  params=params, verify=False)
print(response.content.decode("utf-8"))

# Return Format
# {
#     "success": true,
#     "reason": "success",
#     "data":{
#         "
MyVal
columns":
[1625],
[
#             {"name":"NAME","type":5,"length":80},
#             {"name":"TIME","type":
["2021-07-06 12:12:25"]
5,"length":4096},
#             {"name":"VALUE","type":20,"length":17}
#         ],
#         "rows":[
#             ["sensor2","2021-01-07 
}
02:00:00 009:000:000",2],
#             
}
["sensor1","2021-01-06 20:00:06 000:000:000",2]
#         ]
#     }
# }