This can be used to get the current readings graph data from compatible devices that are being managed with T&D WebStorage Service.
By specifying the number of data readings or the time period it is possible to get only the specific data that you request.
https://api.webstorage-service.com/v1/devices/data
Read-Only ID is also possible
20 requests per allotted 1-minute span, or 160,000 readings per 60 minutes per device
This interval for this API has been designed to be relatively long so as to allow for retrieval of data on a set regular interval. Since the number of retrieved data readings is large and the load is intense, an upper limit for the number of data readings per device has been included.
This will help alleviate duplicate data acquisition for the same device. Further, to reduce short-term load the maximum number of accesses has been limited. Please be aware of this before using.
If you wish to get the latest current readings at a shorter interval, use the following API.
Item Name | Measurement Value |
---|---|
HTTP Method | POST |
X-HTTP-Method-Override | GET |
Host | api.webstorage-service.com:443 |
Content-Type: | application/json |
Parameter Name | Format | Required | Default Value | Details |
---|---|---|---|---|
api-key | string(45 characters) | Yes | --- | Already acquired API Key |
login-id | string(8 characters) | Yes | --- | User ID Read-Only ID is also possible |
login-pass | string(4-16 characters) | Yes | --- | The password for the above User ID. |
remote-serial | string(8 characters) | Yes | --- | Device Serial Number of the device from which graph data will be retrieved. Not possible to select more than one unit at a time. |
unixtime-from | number | --- | unixtime at the start time of retrieving graph data (*1) Only newer data that comes after the specified time will be retrieved. | |
unixtime-to | number | Time at which API was accessed | unixtime at the finish time of retrieving graph data (*1) Only older data that comes before the specified time will be retrieved. | |
number | number | 16000 | This can be used when you wish to specify the number of graph data readings to be retrieved. The default is 16,000 readings and the upper limit is 65,535. (*1) | |
type | string( json/csv/csv2 ) | json | These are format types for the received graph data. Select either json format or csv format.(*2) | |
temperature-unit | string(device/C/F) | device | This 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) About Settings for unixtime-from / unixtime-to / number
・Even if the set number is larger than 65,535, it will be limited to 65,535.
・“unixtime-from/unixtime-to” is designed with an AND condition included whereby the number of readings can be specified. If specified, then that number of data readings will be retrieved in sequence from the data at the latest time specified.
・If no specifications are made for unixtime-from, unixtime-to or number then the most recent 16,000 reading will be retrieved.
・If the number of data readings in the period specified by “unixtime-from” and “unixtime-to” is more than that specified by “number”, then not all data in the time period will be retrieved, but only the the number of data readings specified by “number” will be retrieved with the most recent data first.
(EX: If in the period specified by “unixtime-from” and ”unixtime-to” there are 20,000 data readings, but 16,000 readings was specified by “number”, then only the most recent 16,000 readings from the time specified in “unixtime-to” as a starting point. The oldest 4,000 readings will not be retrieved. )
・If the number of data readings in the period specified by “unixtime-from” and “unixtime-to” is less than that specified by “number”, then all of the data in the specified time period (from “unixtime-from” to “unixtime-to”) will be retrieved.
(EX: If in the period specified by “unixtime-from” and ”unixtime-to” there are 10,000 data readings, but 16,000 readings was specified by “number”, then all 10,000 readings included in the specified period will be retrieved. )
(*2) 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 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
[1. If you wish to get the most recent readings (maximum 16,000 readings) from TR-71wf [sn:52120001] in current readings graph data JSON format] { "api-key":"73pfobnche8d1p6laqnemsbnpkght3bjv047oid6p2sg3", "login-id":"tbzz9999", "login-pass":"ppaasswwoorrdd", "remote-serial":"52120001" } [2.If you wish to get readings over a time period (maximum 16,000 readings), August 1, 2017 00:00:00 to September 1, 2017 00:00:00 (for August 2017) from TR-71wf [sn:52120001] in current readings graph data JSON format] { "api-key":"73pfobnche8d1p6laqnemsbnpkght3bjv047oid6p2sg3", "login-id":"tbzz9999", "login-pass":"ppaasswwoorrdd", "remote-serial":"52120001", "unixtime-from":1504191600, "unixtime-to":1504191600 }
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.
[1. If you wish to get the most recent readings (maximum 16,000 readings) from TR-71wf [sn:52120001] in current readings graph data JSON format] 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 EX2: [2.If you wish to get readings over a time period (maximum 16,000 readings), August 1, 2017 00:00:00 to September 1, 2017 00:00:00 (for August 2017) from TR-71wf [sn:52120001] in current readings graph data JSON format] 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","unixtime-from":1504191600,"unixtime-to":1504191600}' \ https://api.webstorage-service.com:443/v1/devices/latest-data
Item Name | Value | Details |
---|---|---|
HTTP status code | (**) | HTTP Status Code |
Content-Type | application/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 |
X-RateLimit-Remaining-DataCount | (integer) | Remaining number of accessible data readings |
(**) 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 X-RateLimit-Remaining-DataCount: 0 { "error":{ "code": error code, "message": "error details" } }
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 |
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. |
name | string | Device Name of Selected Device |
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 for the above unixtime. |
data.ch2 | string(*1)(*4) | The value for ch2 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.
*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 X-RateLimit-Remaining-DataCount: 87654 { "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 } ] }
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 for 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 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) 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.
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 X-RateLimit-Remaining-DataCount: 87654 "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" .....