Get Latest Data (300 most recent readings) [TR7A2/7A, TR-7wb/nw/wf, TR4A, TR32B]

Overview

This can be used to get the 300 most recent readings of current readings graph data from compatible devices that are being managed with T&D WebStorage Service.

Request

URI

https://api.webstorage-service.com/v1/devices/latest-data

Access Restrictions

Read-Only ID is also possible.

Compatible Models for this API

TR7A2/7A, TR-7wb/nw/wf series, TR4A series, TR32B

Rate Limit

60 requests per allotted 1-minute span

We set this rate limit to allow for the retrieval of the most recent few minutes of recorded data when the auto-upload interval is set at one minute for around ten devices set to measure at the shortest possible recording interval of 1 second.
Note that if the number of registered devices is more than 60, data cannot be received from all of them every minute without a loss of data. On the other hand, it is possible to issue the API every second to a maximum of 300 devices without data loss. This will take 5 minutes to complete one cycle during which each device set at a recording interval of 1 sec will record 5 minutes worth of readings or the maximum amount of 300 readings which can be received with this API. Therefore even with this rate limit it is still possible to get the latest 300 readings from up to 300 devices without any loss of data.

The rate limit itself is designed to avoid concentrated access during a short period of time and balance out the load. Please be aware of this before using.

Request Header

Item NameValue
HTTP MethodPOST
X-HTTP-Method-OverrideGET
Hostapi.webstorage-service.com:443
Content-Typeapplication/json

Request Parameter

Parameter NameFormatRequiredDefault ValueDetails
api-keystring(45 characters)Yes---Already acquired API Key
login-idstring(8 characters)Yes---User ID Read-Only ID is also possible.
login-passstring(4-16 characters)Yes---The password for the above User ID.
remote-serialstring(8 characters)Yes---Device Serial Number of the device from which graph data will be extracted. Not possible to select more than one unit at a time.
typestring( json/csv/csv2 )jsonThese are the formats in which graph data can be received. Select either json format or csv format.(*1)
temperature-unitstring(device/C/F)deviceThis can be used to specify the temperature units used when retrieving recorded data.
[device] : Values will be returned as per the units set in the device. (default)
[C] : Values will be returned in Celsius.
[F] : Values will be returned in Fahrenheit.

(*1) Set type=csv or type=csv2 to get the response in the same format as the Response Example (CSV format). Note that "type=csv" will be deprecated on Nov. 1, 2024.

Request Example

Request Header

POST /v1/devices/latest-data HTTP/1.1
Host: api.webstorage-service.com:443
Content-Type: application/json
X-HTTP-Method-Override: GET

Request Body

{
"api-key":"73pfobnche8d1p6laqnemsbnpkght3bjv047oid6p2sg3",
"login-id":"tbzz9999",
"login-pass":"ppaasswwoorrdd",
"remote-serial":"52120001"
}

*In this example, 300 readings of current readings graph data are being retrieved in json format from TR-71wf[52120001].

Request Example using Curl

This is an example of request using the curl command, which is available from the command line on Windows and Mac devices.
The example command includes request header and request body.

curl -X POST \
  -H "Content-Type: application/json" \
  -H "X-HTTP-Method-Override: GET" \
  -d '{"api-key":"73pfobnche8d1p6laqnemsbnpkght3bjv047oid6p2sg3","login-id":"tbzz9999","login-pass":"ppaasswwoorrdd","remote-serial":"52120001"}' \
  https://api.webstorage-service.com:443/v1/devices/latest-data

Response

Response Header

Item NameValueDetails
HTTP status code(**)HTTP Status Code
Content-Typeapplication/json; charset=utf-8
text/csv; charset=utf-8
The format will be changed according to the specified format, either JSON or CSV. (Character code is UTF-8)
X-RateLimit-Limit(integer)Maximum number of requests per allotted time span
X-RateLimit-Reset(integer)Number of seconds in the allotted time span
X-RateLimit-Remaining(integer)Remaining number of requests per allotted time span

(**) If the HTTP status code is “200”, then the process has been completed successfully. If any other HTTP status code is returned, then an error has occurred and processing was not completed. As shown below, if an error does occur, JSON data with the error info included will be returned.

HTTP/1.1 400 Bad Request
Server: api.webstorage-service.com
Content-Type: application/json; charset=utf-8
X-RateLimit-Limit: 60
X-RateLimit-Reset: 60
X-RateLimit-Remaining: 57

{
	"error":{
		"code": error code,
		"message": "error details"
	}
}

Response Parameter (JSON format)

In the following, when an item name includes a period (.) as in “channel.name”, this indicates that the elements of the array are included in the item, in this case “channel”.

Item Name Format Details
serial string Serial Number of Selected Device
model string Model Name of Selected Device
name string Device Name of Selected Device
time_diff string(*1) Device Time Difference Info [in units of minutes] shown here. If it is a Remote Unit, then the time difference info will be that set in Base Unit to which it is registered.
std_bias string(*1) Device Time Difference from Standard [in units of minutes] shown here. If it is a Remote Unit, then the time difference from standard info will be that set in Base Unit to which it is registered.
dst_bias string(*1) Device Time Difference during Daylight Savings Time [in units of minutes] shown here. If it is a Remote Unit, then the time difference during daylight savings time info will be that set in Base Unit to which it is registered.
channel Array Measurement Channel Info shown here. If the device selected does not include sufficient data, it may result in an empty array.
  channel.name string Channel Name
  channel.num string(*1) Channel Number (0~)
  channel.unit string Unit of Measurement for Channel(*2)
data Array If the number of data readings is "0”, then the array is blank.
  data.unixtime string(*1) unixtime of graph data
  data.data-id string(*1) data-id(*3) of graph data
  data.ch1 string(*1)(*4) The value for ch1(*5) for the above unixtime.
  data.ch2 string(*1)(*4) The value for ch2(*5) for the above unixtime. This will not exist, if the device has no ch2 measurement.

(*1) The value is a number, but the type is character-based.
(*2)When Celsius or Fahrenheit is specified in "temperature-unit" in Request Parameter, the specified unit will be used instead of the unit set in the device.
(*3) The data-id will increment from 0 to 65535 and then return to 0. The continuity of data can be confirmed by looking at the continuity of this value and unixtime. If there is a period during which current readings data could not be received, the data-id for that period may be missing. However, note that monitoring data for TR41/TR42/TR45 is always "data-id": 0.
(*4) If the measured value is obtained, a numeric value of character type is returned, but if an error occurs, an error value starting with E is returned.
(*5) This value will reflect the data value, or an error code if no valid data is available. Refer to the "Error Code List (Recorded Data)" below to see the error code list.

Response Example(JSON format)

*Please note that actual responses may not be in such clear understandable form as shown in the example below.

HTTP/1.1 200 OK
Server: api.webstorage-service.com
Content-Type: application/json; charset=utf-8
X-RateLimit-Limit: 60
X-RateLimit-Reset: 60
X-RateLimit-Remaining: 57

{
	"serial":"52140001",
	"model":"TR-72wf",
	"name":"outside window on east side",
        "time_diff": "540",
        "std_bias": "0",
        "dst_bias": "60",
	"channel":[
		{
			"name":"temp",
			"num":0,
			"unit":"C"
		},{
			"name":"humid",
			"num":1,
			"unit":"%"
		}],
	"data":[
		{
			"unixtime": 123456789,
                        "data-id": "123",
			"ch1":23.5,
			"ch2":65
		},{
			"unixtime": 123456800,
                        "data-id": "124",
			"ch1":25.5,
			"ch2":68
		}, ... ,{
			"unixtime": 123456999,
                        "data-id": "324",
			"ch1":21.5,
			"ch2":60
		}
	]
}

Response Parameter (CSV format)

The following explains data formatting for when data is received in CSV format. This is the same format as when data is output in CSV format in T&D Graph.

Line 1 (Header row) Date/Time (Fixed value) Date/Time (Fixed value) No. 1 (Fixed value) No. 2 (fixed Value) (Increases or decreases depending on number of channels)
Line 2 (Header row) Time Difference:GMT**:**/Daylight Savings Time:on/off (*1) (Device Time Difference Settings) Serial Value for Date (Excel) (fixed value) Channel Name of channel 1 Channel Name of channel 2 (Increases or decreases depending on number of channels)
Line 3 (Header row) (fixed value of blank data) (fixed value of blank data) Ch 1 Unit of Measurement(*4) Ch 2 Unit of Measurement (*4)(Increases or decreases depending on number of channels)
Line 4 and after (data rows) Time at Measurement (*2) Serial value in Excel for Time at Measurement (*3) Ch 1 Measurement Reading(*5) Ch 2 Measurement Reading(*5) (Increases or decreases depending on number of channels)

(*1) Both the time difference info set in the device and the “On/Off” for the daylight savings time setting in the WebStorage management screen will be displayed here.
(*2) The time at measurement will be calculated using the time difference info of the device and the time adjustment, if any, for daylight savings time and will be displayed in the following format: "yyyy-mm-dd HH:mm:ss".
(*3) This is will be the date and time after adjustments carried out in (*2) and converted into a serial value for use in Excel.
(*4) When Celsius or Fahrenheit is specified in "temperature-unit" in Request Parameter, the specified unit will be used instead of the unit set in the device.
(*5) This value will reflect the data value, or an error code if no valid data is available. Refer to the "Error Code List (Recorded Data)" below to see the error code list.

Response Example (CSV format)

HTTP/1.1 200 OK
Server: api.webstorage-service.com
Content-Type: text/csv; charset=utf-8
X-RateLimit-Limit: 60
X-RateLimit-Reset: 60
X-RateLimit-Remaining: 57

"Date/Time","Date/Time","No.1"
"time difference:GMT+9:00/daylight savings time:off","date as serial value(Excel)","Temp"
"","","C"
"2016-12-14 15:46:14","42718.657106481","24.1"
"2016-12-14 15:46:24","42718.657222222","24.0"
"2016-12-14 15:46:34","42718.657337963","24.0"
"2016-12-14 15:46:44","42718.657453704","24.1"
"2016-12-14 15:46:54","42718.657569444","24.1"
"2016-12-14 15:47:04","42718.657685185","24.0"
"2016-12-14 15:47:14","42718.657800926","24.0"
"2016-12-14 15:47:24","42718.657916667","24.0"
"2016-12-14 15:47:34","42718.658032407","24.0"
"2016-12-14 15:47:44","42718.658148148","24.1"
"2016-12-14 15:47:54","42718.658263889","24.2"
"2016-12-14 15:48:04","42718.65837963","24.2"
.....

MENU