Versions Compared

Key

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

...

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

...

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://aws1.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
{
    "statussuccess": "success"true,
    "datareason": "success",
    "data": {
        "calc_modecolumns": "raw",[
            "columns{"name": "NAME", "type": 5, "length": [80},
            {"name": "TIME", "type": 5, "length": 4096},
            {"name": "MyVal", "type": 20, "length": 17}
        ],
        "samples": [
            {
 ["tag_01","2021-07-06 12:12:27", 1629],
              "tag_name": "["tag_02",
                "data": [{"MyVal": 1629,"TIME": "2021-07-06 12:12:27"}]
            },
25", 1625]
        ]
  {  }
              "tag_name": "tag_01",
                "data": [{"MyVal": 1625,"TIME": "2021-07-06 12:12:25"}]
            }
        ]
    }
}
 
// return format = 1
{
    "status": "success",
    "data": {
        "calc_mode": "raw",
        "columns": [
            {"name": "TIME", "type": 5, "length": 4096},
            {"name": "MyVal", "type": 20, "length": 17}
        ],
        "samples": [
            {
                "tag_name": "tag_02",
                "data": {
                    "MyVal": [1629],
                    "TIME": ["2021-07-06 12:12:27"]
                }
            },
            {
                "tag_name": "tag_01",
                "data": {
                    "MyVal": [1625],
                    "TIME": ["2021-07-06 12:12:25"]
                }
            }
        ]
    }
}}
 

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_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/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 "tag_name=%TAG_NAME%" --data-urlencode "date_format=%DATE_FORMAT%"

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

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

:: 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
set VALUE_RETURN_FORM=1

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

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

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

...