API for getting preserved data


Get the log data in JSON format of tags that have been enabled the logger configuration.

The following parameters are used to getting the log data.

HTTP request method POST
URL http://ortopiaj.jp/php/trend_api.php
BODY Set in JSON format
JSON Data key Required / Optional Description
CID Required Company ID (default value: "con")
PID Required Project ID
UID Required User ID(Must be Device Privilege)
PWD Required Hash the password string [sha256]
DTYPE Required Graph Type
0:Real-time (raw data: data_native_device_data_[device ID]_[cloud key])
1:Historical (minute data: data_calc_minute_data_[device ID]_[cloud key])
ST Required Acquisition start date
DTYPE=0:"YYYYMMDDHHMMSS"
DTYPE=1:"YYYYMMDDHHMM"
ET Required Acquisition end date and time
DTYPE=0:"YYYYMMDDHHMMSS"
DTYPE=1:"YYYYMMDDHHMM"
PARAM Required Specify up to 8 tags to retrieve data in an array format.
DID:Device ID
CKEY:Cloud Key
TAG:Tag Name
OTYPE Optional Data thinning methods. 0:average 1:maximum 2:minimum 3:direct value If there are no items, no thinning
OPERIOD Required when setting data thinning. Time interval for data thinning Specify the value of seconds as an integer.
When DTYPE=1, Specify the period in seconds in minute unit (For example,60,120,180...)
TS Optional 1:Add timestamp (UNIX time) for each data in response
Other or no item: do not add

For the parameter that specifies the date and time, specify the time recorded in the log data (device time).

Please refer to the help of Historical Trend for the guideline of the parameter specification value such as the time interval of extracting data.

For extracting the direct value, the number of data is calculated from the time range and interval.

Example of the request:

{"CID":"con","PID":"XXX","UID":"XXX","PWD":"XXX","DTYPE":1,"ST":"202110040000","ET":"202110070000","OTYPE":0,"OPERIOD":120,"TS":1,
"PARAM":[{"DID":"XXX","CKEY":"XXX","TAG":"XXX"},{"DID":"XXX","CKEY":"XXX","TAG":"XXX"}]}

The time range of the data that can be acquired at one time is from 1 second to 30 days; if it exceeds 30 days, it will be limited to 30 days.

In addition, the number of data that can be acquired at one time is limited as follows.

Number of tags Number of data that can be acquired per tag
1 80,000
2 70,000
3 60,000
4 50,000
5 40,000
6 30,000
7 20,000
8 10,000

The response is as follows.

HTTP status code Details
200 For details of the data, please refer to the description of the DATA section.
400 The company or project you specified does not exist.
401 Could not log in due to incorrect user, password, or permissions.
404 All tag names do not exist.
500 Internal server error
JSON Data Key Description
DATA Respose data is in the following format.
[
[[Data array of the first tag],[Data array of the second tag],[Data array of the third tag]・・・]
]
TS If 1 is specified for TS in the request, the response will be an array of timestamps (UNIX time) for each data.
ET The time of the last data.
If you want to get data that exceeds the limit number, this can be done by specifying the start time (ST) with the end time returned from the previous time and getting the data again.
DTYPE=0:"YYYYMMDDHHMMSS"
DTYPE=1:"YYYYMMDDHHMM"
OPERIOD When data extracting period is set, the value of the time interval (in seconds) is responded.
ERROR Responds when there is an error in the response content. For details, please refer to the following "The contents of the ERROR".

Example of a response:

{"DATA":[[],[]],"TS":[],"ET":"202110070000","OPERIOD":120}

The contents of the ERROR:

ERROR message Description
No json The request is not in JSON format. Please check the format of your request.
No (key name) Key The request does not have a key with a valid value. Please check the format and value of the request.
Tags request over The number of tags specified in the request is over than 8, please make it less than 8.
PARAM key contents error There is no device ID, cloud key, or tag name set. Please check the format of your request.
Empty data: (Device ID).(Cloud Key):(Tag Name) If the acquired data does not exist for one or more tags, the last tag name will be displayed. Please check the tag name of your request.
Empty data All acquired data does not exist.

Example of PowerShell:

$response = Invoke-WebRequest -Method POST -Uri "http://localhost/php/trend_api.php" -Body "{`"CID`":`"con`",`"PID`":`"XXX`",`"UID`":`"XXX`",`"PWD`":`"XXX`",`"DTYPE`":1,`"ST`":`"202110040000`",`"ET`":`"202110070000`",`"OTYPE`":0,`"OPERIOD`":120,`"TS`":1,`"PARAM`":[{`"DID`":`"XXX`",`"CKEY`":`"XXX`",`"TAG`":`"XXX`"},{`"DID`":`"XXX`",`"CKEY`":`"XXX`",`"TAG`":`"XXX`"}]}"