- Created by machlake (Unlicensed) , last modified on Feb 20, 2023
You are viewing an old version of this content. View the current version.
Compare with Current View Version History
« Previous Version 24 Next »
This API is used to extract raw sensor data stored in the data lake with various options. For more detailed usage, refer to the Parameter section below.
HTTP Request
Parameters
Optional | Type | Description | Example |
---|---|---|---|
type | string | select type | &type=raw |
tag_name | string | tag name with , separator | &tag_name=tag1,tag2,tag3 |
start_time | string | start time of select (MUST be eralier than end_time) type 1 : time string format
type 2 : timestamp (second or millisecond)
| &start_time=2018-01-16 14:40:05 000
|
separator | string | separator for tag_name, columns, and_condition | &separator=| (default : ,) |
and_condition | string | filtering condition (need escape sequence)
| &and_condition=”value” > 345,”name” = 'sjkim' |
end_time | string | end time of select (MUST be later than start_time)
| same as start_time |
date_format | string | date format of select time | &date_format=YYYY-MM-DD HH24:MI:SS (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) |
columns | string | columns to filter out | &columns=value,value2 (default : value) |
aliases | string | columns to be aliased (Must be blank or equal to columns,) | &aliases=myvalue,myvalue2 |
direction | int | ascend or descent by time | &direction=0 : ascend (default) |
Request Example
Response Example
Sample Code
In this sample, try to show variety parameter combination, but can’t show all combination, but should find parameter option from using this sample
chcp 65001 :: Text Encoding to UTF-8 in CMD :: Example For Select Raw 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=raw :: ------------------------------------------------------------------------------------------------- :: :: CASE - DATA GET with date format YYYY-MM-DD HH24:MI:SS mmm:uuu:nnn set TAG_NAME=sensor1 set DATE_FORMAT=YYYY-MM-DD HH24:MI:SS mmm:uuu:nnn set START_TIME=2021-01-06 17:00:00 000:000:000 set END_TIME=2021-01-06 21:00:00 000:000:000 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%" \ --data-urlencode "start_time=%START_TIME%" \ --data-urlencode "end_time=%END_TIME%" :: Return Format :: { :: "success":true, :: "reason":"success", :: "data":{ :: "columns":[ :: {"name":"NAME","type":5,"length":80}, :: {"name":"TIME","type":5,"length":4096}, :: {"name":"VALUE","type":20,"length":17} :: ], :: "rows":[ :: ["sensor1","2021-01-06 17:00:00 001:000:000",1], :: ["sensor1","2021-01-06 17:00:00 002:000:000",1.5], :: ["sensor1","2021-01-06 17:00:00 003:000:000",2], :: ["sensor1","2021-01-06 17:00:00 004:000:000",1], :: ["sensor1","2021-01-06 17:00:00 005:000:000",1.5], :: ["sensor1","2021-01-06 17:00:00 006:000:000",2], :: ["sensor1","2021-01-06 17:00:00 007:000:000",1], :: ["sensor1","2021-01-06 17:00:00 008:000:000",1.5], :: ["sensor1","2021-01-06 17:00:00 009:000:000",2], :: ["sensor1","2021-01-06 18:00:00 001:000:000",2], :: ["sensor1","2021-01-06 18:00:00 002:000:000",2.5], :: ["sensor1","2021-01-06 18:00:00 003:000:000",2] :: ] :: } :: } :: ------------------------------------------------------------------------------------------------- :: :: CASE - DATA GET with date format YYYY-MM-DD HH24:MI:SS set DATE_FORMAT=YYYY-MM-DD HH24:MI:SS set TAG_NAME=sensor1 set DATE_FORMAT=YYYY-MM-DD HH24:MI:SS set START_TIME=2021-01-06 17:00:00 set END_TIME=2021-01-06 21:00:00 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%" \ --data-urlencode "start_time=%START_TIME%" \ --data-urlencode "end_time=%END_TIME%" :: Return Format :: { :: "success":true, :: "reason":"success", :: "data":{ :: "columns":[ :: {"name":"NAME","type":5,"length":80}, :: {"name":"TIME","type":5,"length":4096}, :: {"name":"VALUE","type":20,"length":17} :: ], :: "rows":[ :: ["sensor1","2021-01-06 17:00:00",1], :: ["sensor1","2021-01-06 17:00:00",1.5], :: ["sensor1","2021-01-06 17:00:00",2], :: ["sensor1","2021-01-06 17:00:00",1], :: ["sensor1","2021-01-06 17:00:00",1.5], :: ["sensor1","2021-01-06 17:00:00",2], :: ["sensor1","2021-01-06 17:00:00",1], :: ["sensor1","2021-01-06 17:00:00",1.5], :: ["sensor1","2021-01-06 17:00:00",2], :: ["sensor1","2021-01-06 18:00:00",2], :: ["sensor1","2021-01-06 18:00:00",2.5], :: ["sensor1","2021-01-06 18:00:00",2] :: ] :: } :: } :: ------------------------------------------------------------------------------------------------- :: :: CASE - DATA GET with date format YYYY-MM-DD HH24:MI:SS, data inserted with date skip mmm:uuu:nnn set TAG_NAME=sensor2 set DATE_FORMAT=YYYY-MM-DD HH24:MI:SS mmm:uuu:nnn set START_TIME=2021-01-06 17:00:00 000:000:000 set END_TIME=2021-01-06 21:00:00 000:000:000 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%" \ --data-urlencode "start_time=%START_TIME%" \ --data-urlencode "end_time=%END_TIME%" :: Return Format :: { :: "success":true, :: "reason":"success", :: "data":{ :: "columns":[ :: {"name":"NAME","type":5,"length":80}, :: {"name":"TIME","type":5,"length":4096}, :: {"name":"VALUE","type":20,"length":17} :: ], :: "rows":[ :: ["sensor2","2021-01-06 17:00:00 000:000:000",1], :: ["sensor2","2021-01-06 17:00:01 000:000:000",1.5], :: ["sensor2","2021-01-06 17:00:02 000:000:000",2], :: ["sensor2","2021-01-06 17:00:03 000:000:000",1], :: ["sensor2","2021-01-06 17:00:04 000:000:000",1.5], :: ["sensor2","2021-01-06 17:00:05 000:000:000",2], :: ["sensor2","2021-01-06 18:00:00 001:000:000",2], :: ["sensor2","2021-01-06 18:00:00 002:000:000",2.5], :: ["sensor2","2021-01-06 18:00:00 003:000:000",2], :: ["sensor2","2021-01-06 20:00:04 000:000:000",2], :: ["sensor2","2021-01-06 20:00:05 000:000:000",2.5], :: ["sensor2","2021-01-06 20:00:06 000:000:000",2] :: ] :: } :: } :: ------------------------------------------------------------------------------------------------- :: :: CASE - DATA GET with UTC-0 timezone set TZ=Africa/Abidjan set TAG_NAME=sensor2 set DATE_FORMAT=YYYY-MM-DD HH24:MI:SS mmm:uuu:nnn set START_TIME=2021-01-06 17:00:00 000:000:000 set END_TIME=2021-01-06 21:00:00 000:000:000 curl -k -G %URL% -H %CONTENT_HEADER% -H %API_HEADER% \ --data-urlencode "type=%SELECT_TYPE%" \ --data-urlencode "timezone=%TZ%" \ --data-urlencode "tag_name=%TAG_NAME%" \ --data-urlencode "date_format=%DATE_FORMAT%" \ --data-urlencode "start_time=%START_TIME%" \ --data-urlencode "end_time=%END_TIME%" :: Return Format :: { :: "success":true, :: "reason":"success", :: "data":{ :: "columns":[ :: {"name":"NAME","type":5,"length":80}, :: {"name":"TIME","type":5,"length":4096}, :: {"name":"VALUE","type":20,"length":17} :: ], :: "rows":[ :: ["sensor2","2021-01-06 17:00:00 007:000:000",1], :: ["sensor2","2021-01-06 17:00:00 008:000:000",1.5], :: ["sensor2","2021-01-06 17:00:00 009:000:000",2] :: ] :: } :: } :: ------------------------------------------------------------------------------------------------- :: :: CASE - DATA GET with local timezone, data inserted UTC-0 timezone setting set TAG_NAME=sensor2 set DATE_FORMAT=YYYY-MM-DD HH24:MI:SS mmm:uuu:nnn set START_TIME=2021-01-07 02:00:00 000:000:000 set END_TIME=2021-01-07 12:00:00 000:000:000 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%" \ --data-urlencode "start_time=%START_TIME%" \ --data-urlencode "end_time=%END_TIME%" :: Return Format :: { :: "success":true, :: "reason":"success", :: "data":{ :: "columns":[ :: {"name":"NAME","type":5,"length":80}, :: {"name":"TIME","type":5,"length":4096}, :: {"name":"VALUE","type":20,"length":17} :: ], :: "rows":[ :: ["sensor2","2021-01-07 02:00:00 007:000:000",1], :: ["sensor2","2021-01-07 02:00:00 008:000:000",1.5], :: ["sensor2","2021-01-07 02:00:00 009:000:000",2] :: ] :: } :: } :: ------------------------------------------------------------------------------------------------- :: :: CASE - DATA GET with limit and offset set TAG_NAME=sensor1,sensor2 set DATE_FORMAT=YYYY-MM-DD HH24:MI:SS mmm:uuu:nnn set START_TIME=2021-01-06 17:00:00 000:000:000 set END_TIME=2021-01-06 21:00:00 000:000:000 set LIMIT=10 set OFFSET=5 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%" \ --data-urlencode "start_time=%START_TIME%" \ --data-urlencode "end_time=%END_TIME%" \ --data-urlencode "limit=%LIMIT%" \ --data-urlencode "offset=%OFFSET%" :: Return Format :: { :: "success":true, :: "reason":"success", :: "data":{ :: "columns":[ :: {"name":"NAME","type":5,"length":80}, :: {"name":"TIME","type":5,"length":4096}, :: {"name":"VALUE","type":20,"length":17} :: ], :: "rows":[ :: ["sensor1","2021-01-06 17:00:00 006:000:000",2], :: ["sensor1","2021-01-06 17:00:00 007:000:000",1], :: ["sensor1","2021-01-06 17:00:00 008:000:000",1.5], :: ["sensor1","2021-01-06 17:00:00 009:000:000",2], :: ["sensor1","2021-01-06 18:00:00 001:000:000",2], :: ["sensor1","2021-01-06 18:00:00 002:000:000",2.5], :: ["sensor1","2021-01-06 18:00:00 003:000:000",2], :: ["sensor1","2021-01-06 20:00:04 000:000:000",2], :: ["sensor1","2021-01-06 20:00:05 000:000:000",2.5], :: ["sensor1","2021-01-06 20:00:06 000:000:000",2] :: ] :: } :: } :: ------------------------------------------------------------------------------------------------- :: :: CASE - DATA GET with descent by time set TAG_NAME=sensor1,sensor2 set DATE_FORMAT=YYYY-MM-DD HH24:MI:SS mmm:uuu:nnn set START_TIME=2021-01-06 17:00:00 000:000:000 set END_TIME=2021-01-06 21:00:00 000:000:000 set DIRECTION=1 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%" \ --data-urlencode "start_time=%START_TIME%" \ --data-urlencode "end_time=%END_TIME%" \ --data-urlencode "direction=%DIRECTION%" :: Return Format :: { :: "success":true, :: "reason":"success", :: "data":{ :: "columns":[ :: {"name":"NAME","type":5,"length":80}, :: {"name":"TIME","type":5,"length":4096}, :: {"name":"VALUE","type":20,"length":17} :: ], :: "rows":[ :: ["sensor2","2021-01-06 20:00:06 000:000:000",2], :: ["sensor1","2021-01-06 20:00:06 000:000:000",2], :: ["sensor2","2021-01-06 20:00:05 000:000:000",2.5], :: ["sensor1","2021-01-06 20:00:05 000:000:000",2.5], :: ["sensor2","2021-01-06 20:00:04 000:000:000",2], :: ["sensor1","2021-01-06 20:00:04 000:000:000",2], :: ["sensor2","2021-01-06 18:00:00 003:000:000",2], :: ["sensor1","2021-01-06 18:00:00 003:000:000",2], :: ["sensor2","2021-01-06 18:00:00 002:000:000",2.5], :: ["sensor1","2021-01-06 18:00:00 002:000:000",2.5], :: ["sensor2","2021-01-06 18:00:00 001:000:000",2], :: ["sensor1","2021-01-06 18:00:00 001:000:000",2], :: ["sensor2","2021-01-06 17:00:05 000:000:000",2], :: ["sensor2","2021-01-06 17:00:04 000:000:000",1.5], :: ["sensor2","2021-01-06 17:00:03 000:000:000",1], :: ["sensor2","2021-01-06 17:00:02 000:000:000",2], :: ["sensor2","2021-01-06 17:00:01 000:000:000",1.5], :: ["sensor1","2021-01-06 17:00:00 009:000:000",2], :: ["sensor1","2021-01-06 17:00:00 008:000:000",1.5], :: ["sensor1","2021-01-06 17:00:00 007:000:000",1], :: ["sensor1","2021-01-06 17:00:00 006:000:000",2], :: ["sensor1","2021-01-06 17:00:00 005:000:000",1.5], :: ["sensor1","2021-01-06 17:00:00 004:000:000",1], :: ["sensor1","2021-01-06 17:00:00 003:000:000",2], :: ["sensor1","2021-01-06 17:00:00 002:000:000",1.5], :: ["sensor1","2021-01-06 17:00:00 001:000:000",1], :: ["sensor2","2021-01-06 17:00:00 000:000:000",1] :: ] :: } :: }
# Text Encoding to UTF-8 in CMD # Example For Select Raw 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 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=raw # ------------------------------------------------------------------------------------------------- # # CASE - DATA GET with date format YYYY-MM-DD HH24:MI:SS mmm:uuu:nnn TAG_NAME=sensor1 DATE_FORMAT="YYYY-MM-DD HH24:MI:SS mmm:uuu:nnn" START_TIME="2021-01-06 17:00:00 000:000:000" END_TIME="2021-01-06 21:00:00 000:000:000" 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" \ --data-urlencode "start_time=$START_TIME" \ --data-urlencode "end_time=$END_TIME" # Return Format # { # "success":true, # "reason":"success", # "data":{ # "columns":[ # {"name":"NAME","type":5,"length":80}, # {"name":"TIME","type":5,"length":4096}, # {"name":"VALUE","type":20,"length":17} # ], # "rows":[ # ["sensor1","2021-01-06 17:00:00 001:000:000",1], # ["sensor1","2021-01-06 17:00:00 002:000:000",1.5], # ["sensor1","2021-01-06 17:00:00 003:000:000",2], # ["sensor1","2021-01-06 17:00:00 004:000:000",1], # ["sensor1","2021-01-06 17:00:00 005:000:000",1.5], # ["sensor1","2021-01-06 17:00:00 006:000:000",2], # ["sensor1","2021-01-06 17:00:00 007:000:000",1], # ["sensor1","2021-01-06 17:00:00 008:000:000",1.5], # ["sensor1","2021-01-06 17:00:00 009:000:000",2], # ["sensor1","2021-01-06 18:00:00 001:000:000",2], # ["sensor1","2021-01-06 18:00:00 002:000:000",2.5], # ["sensor1","2021-01-06 18:00:00 003:000:000",2] # ] # } # } # ------------------------------------------------------------------------------------------------- # # CASE - DATA GET with date format YYYY-MM-DD HH24:MI:SS TAG_NAME=sensor1 DATE_FORMAT="YYYY-MM-DD HH24:MI:SS" START_TIME="2021-01-06 17:00:00" END_TIME="2021-01-06 21:00:00" 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" \ --data-urlencode "start_time=$START_TIME" \ --data-urlencode "end_time=$END_TIME" # Return Format # { # "success":true, # "reason":"success", # "data":{ # "columns":[ # {"name":"NAME","type":5,"length":80}, # {"name":"TIME","type":5,"length":4096}, # {"name":"VALUE","type":20,"length":17} # ], # "rows":[ # ["sensor1","2021-01-06 17:00:00",1], # ["sensor1","2021-01-06 17:00:00",1.5], # ["sensor1","2021-01-06 17:00:00",2], # ["sensor1","2021-01-06 17:00:00",1], # ["sensor1","2021-01-06 17:00:00",1.5], # ["sensor1","2021-01-06 17:00:00",2], # ["sensor1","2021-01-06 17:00:00",1], # ["sensor1","2021-01-06 17:00:00",1.5], # ["sensor1","2021-01-06 17:00:00",2], # ["sensor1","2021-01-06 18:00:00",2], # ["sensor1","2021-01-06 18:00:00",2.5], # ["sensor1","2021-01-06 18:00:00",2] # ] # } # } # ------------------------------------------------------------------------------------------------- # # CASE - DATA GET with date format YYYY-MM-DD HH24:MI:SS, data inserted with date skip mmm:uuu:nnn TAG_NAME=sensor2 DATE_FORMAT="YYYY-MM-DD HH24:MI:SS mmm:uuu:nnn" START_TIME="2021-01-06 17:00:00 000:000:000" END_TIME="2021-01-06 21:00:00 000:000:000" 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" \ --data-urlencode "start_time=$START_TIME" \ --data-urlencode "end_time=$END_TIME" # Return Format # { # "success":true, # "reason":"success", # "data":{ # "columns":[ # {"name":"NAME","type":5,"length":80}, # {"name":"TIME","type":5,"length":4096}, # {"name":"VALUE","type":20,"length":17} # ], # "rows":[ # ["sensor2","2021-01-06 17:00:00 000:000:000",1], # ["sensor2","2021-01-06 17:00:01 000:000:000",1.5], # ["sensor2","2021-01-06 17:00:02 000:000:000",2], # ["sensor2","2021-01-06 17:00:03 000:000:000",1], # ["sensor2","2021-01-06 17:00:04 000:000:000",1.5], # ["sensor2","2021-01-06 17:00:05 000:000:000",2], # ["sensor2","2021-01-06 18:00:00 001:000:000",2], # ["sensor2","2021-01-06 18:00:00 002:000:000",2.5], # ["sensor2","2021-01-06 18:00:00 003:000:000",2], # ["sensor2","2021-01-06 20:00:04 000:000:000",2], # ["sensor2","2021-01-06 20:00:05 000:000:000",2.5], # ["sensor2","2021-01-06 20:00:06 000:000:000",2] # ] # } # } # ------------------------------------------------------------------------------------------------- # # CASE - DATA GET with UTC-0 timezone TZ="Africa/Abidjan" TAG_NAME=sensor2 DATE_FORMAT="YYYY-MM-DD HH24:MI:SS mmm:uuu:nnn" START_TIME="2021-01-06 17:00:00 000:000:000" END_TIME="2021-01-06 21:00:00 000:000:000" curl -k -G $URL -H $CONTENT_HEADER -H $API_HEADER \ --data-urlencode "type=$SELECT_TYPE" \ --data-urlencode "timezone=$TZ" \ --data-urlencode "tag_name=$TAG_NAME" \ --data-urlencode "date_format=$DATE_FORMAT" \ --data-urlencode "start_time=$START_TIME" \ --data-urlencode "end_time=$END_TIME" # Return Format # { # "success":true, # "reason":"success", # "data":{ # "columns":[ # {"name":"NAME","type":5,"length":80}, # {"name":"TIME","type":5,"length":4096}, # {"name":"VALUE","type":20,"length":17} # ], # "rows":[ # ["sensor2","2021-01-06 17:00:00 007:000:000",1], # ["sensor2","2021-01-06 17:00:00 008:000:000",1.5], # ["sensor2","2021-01-06 17:00:00 009:000:000",2] # ] # } # } # ------------------------------------------------------------------------------------------------- # # CASE - DATA GET with local timezone, data inserted UTC-0 timezone setting TAG_NAME=sensor2 DATE_FORMAT="YYYY-MM-DD HH24:MI:SS mmm:uuu:nnn" START_TIME="2021-01-07 02:00:00 000:000:000" END_TIME="2021-01-07 12:00:00 000:000:000" 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" \ --data-urlencode "start_time=$START_TIME" \ --data-urlencode "end_time=$END_TIME" # Return Format # { # "success":true, # "reason":"success", # "data":{ # "columns":[ # {"name":"NAME","type":5,"length":80}, # {"name":"TIME","type":5,"length":4096}, # {"name":"VALUE","type":20,"length":17} # ], # "rows":[ # ["sensor2","2021-01-07 02:00:00 007:000:000",1], # ["sensor2","2021-01-07 02:00:00 008:000:000",1.5], # ["sensor2","2021-01-07 02:00:00 009:000:000",2] # ] # } # } # ------------------------------------------------------------------------------------------------- # # CASE - DATA GET with limit and offset TAG_NAME=sensor1 DATE_FORMAT="YYYY-MM-DD HH24:MI:SS mmm:uuu:nnn" START_TIME="2021-01-06 17:00:00 000:000:000" END_TIME="2021-01-06 21:00:00 000:000:000" LIMIT=10 OFFSET=5 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" \ --data-urlencode "start_time=$START_TIME" \ --data-urlencode "end_time=$END_TIME" \ --data-urlencode "limit=$LIMIT" \ --data-urlencode "offset=$OFFSET" # Return Format # { # "success":true, # "reason":"success", # "data":{ # "columns":[ # {"name":"NAME","type":5,"length":80}, # {"name":"TIME","type":5,"length":4096}, # {"name":"VALUE","type":20,"length":17} # ], # "rows":[ # ["sensor1","2021-01-06 17:00:00 006:000:000",2], # ["sensor1","2021-01-06 17:00:00 007:000:000",1], # ["sensor1","2021-01-06 17:00:00 008:000:000",1.5], # ["sensor1","2021-01-06 17:00:00 009:000:000",2], # ["sensor1","2021-01-06 18:00:00 001:000:000",2], # ["sensor1","2021-01-06 18:00:00 002:000:000",2.5], # ["sensor1","2021-01-06 18:00:00 003:000:000",2], # ["sensor1","2021-01-06 20:00:04 000:000:000",2], # ["sensor1","2021-01-06 20:00:05 000:000:000",2.5], # ["sensor1","2021-01-06 20:00:06 000:000:000",2] # ] # } # } # ------------------------------------------------------------------------------------------------- # # CASE - DATA GET with descent by time TAG_NAME=sensor1,sensor2 DATE_FORMAT="YYYY-MM-DD HH24:MI:SS mmm:uuu:nnn" START_TIME="2021-01-06 17:00:00 000:000:000" END_TIME="2021-01-06 21:00:00 000:000:000" DIRECTION=1 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" \ --data-urlencode "start_time=$START_TIME" \ --data-urlencode "end_time=$END_TIME" \ --data-urlencode "direction=$DIRECTION" # Return Format # { # "success":true, # "reason":"success", # "data":{ # "columns":[ # {"name":"NAME","type":5,"length":80}, # {"name":"TIME","type":5,"length":4096}, # {"name":"VALUE","type":20,"length":17} # ], # "rows":[ # ["sensor2","2021-01-06 20:00:06 000:000:000",2], # ["sensor1","2021-01-06 20:00:06 000:000:000",2], # ["sensor2","2021-01-06 20:00:05 000:000:000",2.5], # ["sensor1","2021-01-06 20:00:05 000:000:000",2.5], # ["sensor2","2021-01-06 20:00:04 000:000:000",2], # ["sensor1","2021-01-06 20:00:04 000:000:000",2], # ["sensor2","2021-01-06 18:00:00 003:000:000",2], # ["sensor1","2021-01-06 18:00:00 003:000:000",2], # ["sensor2","2021-01-06 18:00:00 002:000:000",2.5], # ["sensor1","2021-01-06 18:00:00 002:000:000",2.5], # ["sensor2","2021-01-06 18:00:00 001:000:000",2], # ["sensor1","2021-01-06 18:00:00 001:000:000",2], # ["sensor2","2021-01-06 17:00:05 000:000:000",2], # ["sensor2","2021-01-06 17:00:04 000:000:000",1.5], # ["sensor2","2021-01-06 17:00:03 000:000:000",1], # ["sensor2","2021-01-06 17:00:02 000:000:000",2], # ["sensor2","2021-01-06 17:00:01 000:000:000",1.5], # ["sensor1","2021-01-06 17:00:00 009:000:000",2], # ["sensor1","2021-01-06 17:00:00 008:000:000",1.5], # ["sensor1","2021-01-06 17:00:00 007:000:000",1], # ["sensor1","2021-01-06 17:00:00 006:000:000",2], # ["sensor1","2021-01-06 17:00:00 005:000:000",1.5], # ["sensor1","2021-01-06 17:00:00 004:000:000",1], # ["sensor1","2021-01-06 17:00:00 003:000:000",2], # ["sensor1","2021-01-06 17:00:00 002:000:000",1.5], # ["sensor1","2021-01-06 17:00:00 001:000:000",1], # ["sensor2","2021-01-06 17:00:00 000:000:000",1] # ] # } # }
// Example For Select Raw 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 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/raw"; // CASE - DATA GET with date format YYYY-MM-DD HH24:MI:SS mmm:uuu:nnn app.get( '/select_raw_with_nano_date_time_string', function(req, res) { var request = require('request'); const QueryParams = new URLSearchParams() QueryParams.set('tag_name', 'sensor1') QueryParams.set('date_format', 'YYYY-MM-DD HH24:MI:SS mmm:uuu:nnn') QueryParams.set('start_time', '2021-01-06 17:00:00 000:000:000') QueryParams.set('end_time', '2021-01-06 21:00:00 000:000:000') 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":{"calc_mode":"raw","columns":[{"name":"TIME","type":5,"length":4096},{"name":"VALUE","type":20,"length":17}],"samples":[{"tag_name":"sensor1","data":[{"TIME":"2021-01-06 17:00:00 001:000:000","VALUE":1},{"TIME":"2021-01-06 17:00:00 002:000:000","VALUE":1.5},{"TIME":"2021-01-06 17:00:00 003:000:000","VALUE":2},{"TIME":"2021-01-06 17:00:00 004:000:000","VALUE":1},{"TIME":"2021-01-06 17:00:00 005:000:000","VALUE":1.5},{"TIME":"2021-01-06 17:00:00 006:000:000","VALUE":2},{"TIME":"2021-01-06 17:00:00 007:000:000","VALUE":1},{"TIME":"2021-01-06 17:00:00 008:000:000","VALUE":1.5},{"TIME":"2021-01-06 17:00:00 009:000:000","VALUE":2},{"TIME":"2021-01-06 18:00:00 001:000:000","VALUE":2},{"TIME":"2021-01-06 18:00:00 002:000:000","VALUE":2.5},{"TIME":"2021-01-06 18:00:00 003:000:000","VALUE":2},{"TIME":"2021-01-06 20:00:04 000:000:000","VALUE":2},{"TIME":"2021-01-06 20:00:05 000:000:000","VALUE":2.5},{"TIME":"2021-01-06 20:00:06 000:000:000","VALUE":2}]}]},"status":"success"} } else { console.log(error) } }) } ) // CASE - DATA GET with date format YYYY-MM-DD HH24:MI:SS app.get( '/select_raw_with_date_time_string', function(req, res) { var request = require('request'); const QueryParams = new URLSearchParams() QueryParams.set('tag_name', 'sensor1') QueryParams.set('date_format', 'YYYY-MM-DD HH24:MI:SS') QueryParams.set('start_time', '2021-01-06 17:00:00 000:000:000') QueryParams.set('end_time', '2021-01-06 21:00:00 000:000:000') 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":{"calc_mode":"raw","columns":[{"name":"TIME","type":5,"length":4096},{"name":"VALUE","type":20,"length":17}],"samples":[{"tag_name":"sensor1","data":[{"TIME":"2021-01-06 17:00:00","VALUE":1},{"TIME":"2021-01-06 17:00:00","VALUE":1.5},{"TIME":"2021-01-06 17:00:00","VALUE":2},{"TIME":"2021-01-06 17:00:00","VALUE":1},{"TIME":"2021-01-06 17:00:00","VALUE":1.5},{"TIME":"2021-01-06 17:00:00","VALUE":2},{"TIME":"2021-01-06 17:00:00","VALUE":1},{"TIME":"2021-01-06 17:00:00","VALUE":1.5},{"TIME":"2021-01-06 17:00:00","VALUE":2},{"TIME":"2021-01-06 18:00:00","VALUE":2},{"TIME":"2021-01-06 18:00:00","VALUE":2.5},{"TIME":"2021-01-06 18:00:00","VALUE":2},{"TIME":"2021-01-06 20:00:04","VALUE":2},{"TIME":"2021-01-06 20:00:05","VALUE":2.5},{"TIME":"2021-01-06 20:00:06","VALUE":2}]}]},"status":"success"} } else { console.log(error) } }) } ) // CASE - DATA GET with date format YYYY-MM-DD HH24:MI:SS, data inserted with date skip mmm:uuu:nnn app.get( '/select_raw_with_date_time_string_skip_under', function(req, res) { var request = require('request'); const QueryParams = new URLSearchParams() QueryParams.set('tag_name', 'sensor2') QueryParams.set('date_format', 'YYYY-MM-DD HH24:MI:SS mmm:uuu:nnn') QueryParams.set('start_time', '2021-01-06 17:00:00 000:000:000') QueryParams.set('end_time', '2021-01-06 21:00:00 000:000:000') 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":{"calc_mode":"raw","columns":[{"name":"TIME","type":5,"length":4096},{"name":"VALUE","type":20,"length":17}],"samples":[{"tag_name":"sensor2","data":[{"TIME":"2021-01-06 17:00:00 000:000:000","VALUE":1},{"TIME":"2021-01-06 17:00:01 000:000:000","VALUE":1.5},{"TIME":"2021-01-06 17:00:02 000:000:000","VALUE":2},{"TIME":"2021-01-06 17:00:03 000:000:000","VALUE":1},{"TIME":"2021-01-06 17:00:04 000:000:000","VALUE":1.5},{"TIME":"2021-01-06 17:00:05 000:000:000","VALUE":2},{"TIME":"2021-01-06 18:00:00 001:000:000","VALUE":2},{"TIME":"2021-01-06 18:00:00 002:000:000","VALUE":2.5},{"TIME":"2021-01-06 18:00:00 003:000:000","VALUE":2},{"TIME":"2021-01-06 20:00:04 000:000:000","VALUE":2},{"TIME":"2021-01-06 20:00:05 000:000:000","VALUE":2.5},{"TIME":"2021-01-06 20:00:06 000:000:000","VALUE":2}]}]},"status":"success"} } else { console.log(error) } }) } ) // CASE - DATA GET with date format YYYY-MM-DD HH24:MI:SS and with UTC-0 timezone app.get( '/select_raw_with_date_time_string_with_utc0', function(req, res) { var request = require('request'); const QueryParams = new URLSearchParams() QueryParams.set('tag_name', 'sensor2') QueryParams.set('date_format', 'YYYY-MM-DD HH24:MI:SS mmm:uuu:nnn') QueryParams.set('start_time', '2021-01-06 17:00:00 000:000:000') QueryParams.set('end_time', '2021-01-06 21:00:00 000:000:000') var option = { url: URL + "?" + QueryParams.toString(), headers: { 'Content-Type': 'application/json', 'x-api-key': API_KEY, "Use-Timezone": "Africa/Abidjan" }, }; request.get( option, function(error, response, body) { if (!error) { res.writeHead(200); res.end(body); console.log(body) // {"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-06 17:00:00 007:000:000","VALUE":1},{"TIME":"2021-01-06 17:00:00 008:000:000","VALUE":1.5},{"TIME":"2021-01-06 17:00:00 009:000:000","VALUE":2}]}]},"status":"success"} } else { console.log(error) } }) } ) // CASE - DATA GET with date format YYYY-MM-DD HH24:MI:SS mmm:uuu:nnn and limit / offset / direction / value_retrun_form=0 app.get( '/select_raw_with_date_time_string_with_variety_setting', 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') QueryParams.set('start_time', '2021-01-06 17:00:00 000:000:000') QueryParams.set('end_time', '2021-01-06 21:00:00 000:000:000') QueryParams.set('limit', 10) QueryParams.set('offset', 5) QueryParams.set('direction', 0) QueryParams.set('value_return_form', 0) 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":{"calc_mode":"raw","columns":[{"name":"TIME","type":5,"length":4096},{"name":"VALUE","type":20,"length":17}],"samples":[{"tag_name":"sensor1","data":[{"TIME":"2021-01-06 17:00:00 006:000:000","VALUE":2},{"TIME":"2021-01-06 17:00:00 007:000:000","VALUE":1},{"TIME":"2021-01-06 17:00:00 008:000:000","VALUE":1.5},{"TIME":"2021-01-06 17:00:00 009:000:000","VALUE":2},{"TIME":"2021-01-06 18:00:00 001:000:000","VALUE":2},{"TIME":"2021-01-06 18:00:00 002:000:000","VALUE":2.5},{"TIME":"2021-01-06 18:00:00 003:000:000","VALUE":2},{"TIME":"2021-01-06 20:00:04 000:000:000","VALUE":2},{"TIME":"2021-01-06 20:00:05 000:000:000","VALUE":2.5},{"TIME":"2021-01-06 20:00:06 000:000:000","VALUE":2}]}]},"status":"success"} } else { console.log(error) } }) } ) // CASE - DATA GET with date format YYYY-MM-DD HH24:MI:SS mmm:uuu:nnn and limit / offset / direction / value_retrun_form=0 app.get( '/select_raw_with_date_time_string_with_other_variety_setting', 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') QueryParams.set('start_time', '2021-01-06 17:00:00 000:000:000') QueryParams.set('end_time', '2021-01-06 21:00:00 000:000:000') QueryParams.set('direction', 1) QueryParams.set('value_return_form', 1) 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":{"calc_mode":"raw","columns":[{"name":"TIME","type":5,"length":4096},{"name":"VALUE","type":20,"length":17}],"samples":[{"tag_name":"sensor2","data":{"TIME":["2021-01-06 20:00:06 000:000:000","2021-01-06 20:00:05 000:000:000","2021-01-06 20:00:04 000:000:000","2021-01-06 18:00:00 003:000:000","2021-01-06 18:00:00 002:000:000","2021-01-06 18:00:00 001:000:000","2021-01-06 17:00:05 000:000:000","2021-01-06 17:00:04 000:000:000","2021-01-06 17:00:03 000:000:000","2021-01-06 17:00:02 000:000:000","2021-01-06 17:00:01 000:000:000","2021-01-06 17:00:00 000:000:000"],"VALUE":[2,2.5,2,2,2.5,2,2,1.5,1,2,1.5,1]}},{"tag_name":"sensor1","data":{"TIME":["2021-01-06 20:00:06 000:000:000","2021-01-06 20:00:05 000:000:000","2021-01-06 20:00:04 000:000:000","2021-01-06 18:00:00 003:000:000","2021-01-06 18:00:00 002:000:000","2021-01-06 18:00:00 001:000:000","2021-01-06 17:00:00 009:000:000","2021-01-06 17:00:00 008:000:000","2021-01-06 17:00:00 007:000:000","2021-01-06 17:00:00 006:000:000","2021-01-06 17:00:00 005:000:000","2021-01-06 17:00:00 004:000:000","2021-01-06 17:00:00 003:000:000","2021-01-06 17:00:00 002:000:000","2021-01-06 17:00:00 001:000:000"],"VALUE":[2,2.5,2,2,2.5,2,2,1.5,1,2,1.5,1,2,1.5,1]}}]},"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 raw data with nano date time string') console.log('http://127.0.0.1:8888/select_raw_with_date_time_string is result for select raw data with date time string') console.log('http://127.0.0.1:8888/select_raw_with_date_time_string_skip_under is result for select raw data with nano date time string but instered unly date time string that does not contain under second') console.log('http://127.0.0.1:8888/select_raw_with_date_time_string_with_utc0 is result for select raw data with nano date time string and utc-0') console.log('http://127.0.0.1:8888/select_raw_with_date_time_string_with_variety_setting is result for select raw data with nano date time string and limit=10, offset=0, direction=0, value_return_form=0') console.log('http://127.0.0.1:8888/select_raw_with_date_time_string_with_variety_setting is result for select raw data with nano date time string and limit=10, offset=0, direction=0, value_return_form=0') console.log('http://127.0.0.1:8888/select_raw_with_date_time_string_with_other_variety_setting is result for select raw data with nano date time string and direction=1, value_return_form=1') })
""" Example For Select Raw Data for tag API by using request in python written by yeony kim sensor1, sensor2 is applied in lake """ import requests API_KEY = "YOUR_API_TOKEN" LAKE_ID = "YOUR_LAKE_ID" URL = f"https://{LAKE_ID}.machlake.com/lakes/values/raw" headers = { 'Content-Type': 'application/json', 'x-api-key': API_KEY } # CASE - DATA GET with date format YYYY-MM-DD HH24:MI:SS mmm:uuu:nnn params = { 'tag_name': 'sensor1', 'date_format': 'YYYY-MM-DD HH24:MI:SS mmm:uuu:nnn', 'start_time': '2021-01-06 17:00:00 000:000:000', 'end_time': '2021-01-06 21:00:00 000:000:000' } response = requests.get(URL, headers=headers, params=params, verify=False) print(response.content.decode('utf-8')) # {"data":{"calc_mode":"raw","columns":[{"name":"TIME","type":5,"length":4096},{"name":"VALUE","type":20,"length":17}],"samples":[{"tag_name":"sensor1","data":[{"TIME":"2021-01-06 17:00:00 001:000:000","VALUE":1},{"TIME":"2021-01-06 17:00:00 002:000:000","VALUE":1.5},{"TIME":"2021-01-06 17:00:00 003:000:000","VALUE":2},{"TIME":"2021-01-06 17:00:00 004:000:000","VALUE":1},{"TIME":"2021-01-06 17:00:00 005:000:000","VALUE":1.5},{"TIME":"2021-01-06 17:00:00 006:000:000","VALUE":2},{"TIME":"2021-01-06 17:00:00 007:000:000","VALUE":1},{"TIME":"2021-01-06 17:00:00 008:000:000","VALUE":1.5},{"TIME":"2021-01-06 17:00:00 009:000:000","VALUE":2},{"TIME":"2021-01-06 18:00:00 001:000:000","VALUE":2},{"TIME":"2021-01-06 18:00:00 002:000:000","VALUE":2.5},{"TIME":"2021-01-06 18:00:00 003:000:000","VALUE":2},{"TIME":"2021-01-06 20:00:04 000:000:000","VALUE":2},{"TIME":"2021-01-06 20:00:05 000:000:000","VALUE":2.5},{"TIME":"2021-01-06 20:00:06 000:000:000","VALUE":2}]}]},"status":"success"} # CASE - DATA GET with date format YYYY-MM-DD HH24:MI:SS params = { 'tag_name': 'sensor1', 'date_format': 'YYYY-MM-DD HH24:MI:SS', 'start_time': '2021-01-06 17:00:00 000:000:000', 'end_time': '2021-01-06 21:00:00 000:000:000' } response = requests.get(URL, headers=headers, params=params, verify=False) print(response.content.decode('utf-8')) # {"data":{"calc_mode":"raw","columns":[{"name":"TIME","type":5,"length":4096},{"name":"VALUE","type":20,"length":17}],"samples":[{"tag_name":"sensor1","data":[{"TIME":"2021-01-06 17:00:00","VALUE":1},{"TIME":"2021-01-06 17:00:00","VALUE":1.5},{"TIME":"2021-01-06 17:00:00","VALUE":2},{"TIME":"2021-01-06 17:00:00","VALUE":1},{"TIME":"2021-01-06 17:00:00","VALUE":1.5},{"TIME":"2021-01-06 17:00:00","VALUE":2},{"TIME":"2021-01-06 17:00:00","VALUE":1},{"TIME":"2021-01-06 17:00:00","VALUE":1.5},{"TIME":"2021-01-06 17:00:00","VALUE":2},{"TIME":"2021-01-06 18:00:00","VALUE":2},{"TIME":"2021-01-06 18:00:00","VALUE":2.5},{"TIME":"2021-01-06 18:00:00","VALUE":2},{"TIME":"2021-01-06 20:00:04","VALUE":2},{"TIME":"2021-01-06 20:00:05","VALUE":2.5},{"TIME":"2021-01-06 20:00:06","VALUE":2}]}]},"status":"success"} # CASE - DATA GET with date format YYYY-MM-DD HH24:MI:SS, data inserted with date skip mmm:uuu:nnn params = { 'tag_name': 'sensor1', 'date_format': 'YYYY-MM-DD HH24:MI:SS mmm:uuu:nnn', 'start_time': '2021-01-06 17:00:00 000:000:000', 'end_time': '2021-01-06 21:00:00 000:000:000' } response = requests.get(URL, headers=headers, params=params, verify=False) print(response.content.decode('utf-8')) # {"data":{"calc_mode":"raw","columns":[{"name":"TIME","type":5,"length":4096},{"name":"VALUE","type":20,"length":17}],"samples":[{"tag_name":"sensor1","data":[{"TIME":"2021-01-06 17:00:00 001:000:000","VALUE":1},{"TIME":"2021-01-06 17:00:00 002:000:000","VALUE":1.5},{"TIME":"2021-01-06 17:00:00 003:000:000","VALUE":2},{"TIME":"2021-01-06 17:00:00 004:000:000","VALUE":1},{"TIME":"2021-01-06 17:00:00 005:000:000","VALUE":1.5},{"TIME":"2021-01-06 17:00:00 006:000:000","VALUE":2},{"TIME":"2021-01-06 17:00:00 007:000:000","VALUE":1},{"TIME":"2021-01-06 17:00:00 008:000:000","VALUE":1.5},{"TIME":"2021-01-06 17:00:00 009:000:000","VALUE":2},{"TIME":"2021-01-06 18:00:00 001:000:000","VALUE":2},{"TIME":"2021-01-06 18:00:00 002:000:000","VALUE":2.5},{"TIME":"2021-01-06 18:00:00 003:000:000","VALUE":2},{"TIME":"2021-01-06 20:00:04 000:000:000","VALUE":2},{"TIME":"2021-01-06 20:00:05 000:000:000","VALUE":2.5},{"TIME":"2021-01-06 20:00:06 000:000:000","VALUE":2}]}]},"status":"success"} # CASE - DATA GET with date format YYYY-MM-DD HH24:MI:SS and with UTC-0 timezone headers = { 'Content-Type': 'application/json', 'x-api-key': API_KEY, "Use-Timezone": "Africa/Abidjan" } params = { 'tag_name': 'sensor1', 'date_format': 'YYYY-MM-DD HH24:MI:SS mmm:uuu:nnn', 'start_time': '2021-01-06 17:00:00 000:000:000', 'end_time': '2021-01-06 21:00:00 000:000:000' } response = requests.get(URL, headers=headers, params=params, verify=False) print(response.content.decode('utf-8')) # {"data":{"calc_mode":"raw","columns":[{"name":"TIME","type":5,"length":4096},{"name":"VALUE","type":20,"length":17}],"samples":null},"status":"success"} # CASE - DATA GET with date format YYYY-MM-DD HH24:MI:SS mmm:uuu:nnn and limit / offset / direction / value_retrun_form=0 headers = { 'Content-Type': 'application/json', 'x-api-key': API_KEY, } params = { 'tag_name': 'sensor1,sensor2', 'date_format': 'YYYY-MM-DD HH24:MI:SS mmm:uuu:nnn', 'start_time': '2021-01-06 17:00:00 000:000:000', 'end_time': '2021-01-06 21:00:00 000:000:000', 'limit': 10, 'offset': 5, 'direction': 0, 'value_return_form': 0 } response = requests.get(URL, headers=headers, params=params, verify=False) print(response.content.decode('utf-8')) # {"data":{"calc_mode":"raw","columns":[{"name":"TIME","type":5,"length":4096},{"name":"VALUE","type":20,"length":17}],"samples":[{"tag_name":"sensor1","data":[{"TIME":"2021-01-06 17:00:00 006:000:000","VALUE":2},{"TIME":"2021-01-06 17:00:00 007:000:000","VALUE":1},{"TIME":"2021-01-06 17:00:00 008:000:000","VALUE":1.5},{"TIME":"2021-01-06 17:00:00 009:000:000","VALUE":2},{"TIME":"2021-01-06 18:00:00 001:000:000","VALUE":2},{"TIME":"2021-01-06 18:00:00 002:000:000","VALUE":2.5},{"TIME":"2021-01-06 18:00:00 003:000:000","VALUE":2},{"TIME":"2021-01-06 20:00:04 000:000:000","VALUE":2},{"TIME":"2021-01-06 20:00:05 000:000:000","VALUE":2.5},{"TIME":"2021-01-06 20:00:06 000:000:000","VALUE":2}]}]},"status":"success"} # CASE - DATA GET with date format YYYY-MM-DD HH24:MI:SS mmm:uuu:nnn and limit / offset / direction / value_retrun_form=0 headers = { 'Content-Type': 'application/json', 'x-api-key': API_KEY, } params = { 'tag_name': 'sensor1,sensor2', 'date_format': 'YYYY-MM-DD HH24:MI:SS mmm:uuu:nnn', 'start_time': '2021-01-06 17:00:00 000:000:000', 'end_time': '2021-01-06 21:00:00 000:000:000', 'direction': 1, 'value_return_form': 1 } response = requests.get(URL, headers=headers, params=params, verify=False) print(response.content.decode('utf-8')) # {"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-06 20:00:06 000:000:000","2021-01-06 20:00:05 000:000:000","2021-01-06 20:00:04 000:000:000","2021-01-06 18:00:00 003:000:000","2021-01-06 18:00:00 002:000:000","2021-01-06 18:00:00 001:000:000","2021-01-06 17:00:05 000:000:000","2021-01-06 17:00:04 000:000:000","2021-01-06 17:00:03 000:000:000","2021-01-06 17:00:02 000:000:000","2021-01-06 17:00:01 000:000:000","2021-01-06 17:00:00 000:000:000"],"VALUE":[2,2.5,2,2,2.5,2,2,1.5,1,2,1.5,1]}},{"tag_name":"sensor1","data":{"TIME":["2021-01-06 20:00:06 000:000:000","2021-01-06 20:00:05 000:000:000","2021-01-06 20:00:04 000:000:000","2021-01-06 18:00:00 003:000:000","2021-01-06 18:00:00 002:000:000","2021-01-06 18:00:00 001:000:000","2021-01-06 17:00:00 009:000:000","2021-01-06 17:00:00 008:000:000","2021-01-06 17:00:00 007:000:000","2021-01-06 17:00:00 006:000:000","2021-01-06 17:00:00 005:000:000","2021-01-06 17:00:00 004:000:000","2021-01-06 17:00:00 003:000:000","2021-01-06 17:00:00 002:000:000","2021-01-06 17:00:00 001:000:000"],"VALUE":[2,2.5,2,2,2.5,2,2,1.5,1,2,1.5,1,2,1.5,1]}}]},"status":"success"}
- No labels