API - raw-data-batch


Overview

Add raw data in batch. The operation is a single transaction. Either all data has been added or all data failed. And all the data in one epoch should be uploaded in one go.

There are several validations in place to make the batch upload as seamless as possible:

  1. If you have uploaded data in a given epoch range already, any attempt to add more data in the same range will generate an error.
  2. If you try to add data that falls outside of the given from and to date ranges you will see an error.
  3. If you try to add data where the given data stream type doesn't exist, you will see an error.
  4. An incorrect timestamp will cause an error.
  5. A missing entity reference will cause an error.

Prerequisites

  • the data stream type as {dst}, for example, “Electricity”;
  • the entity as{entity}, for example, “care-home-01”;
  • a data stream code (less than 50 chars) as {ds};
  • the epoch {from} and {to}in ISO 8601 format, it should be aligned with epoch setting of the data stream type, for example, if the epoch length is 5 min, the possible {from} and {to} could be "2019-04-04T10:20:00+00:00" and "2019-04-04T10:25:00+00:00"
  • the {rows} array contains all data and each data has below properties:
  • the {ts} in ISO 8601 format;
  • number or string as {value}

Method

POST

URI

/api/v1/raw-data-batch

Request Body

{
    "dst": "Electricity",
    "entity": "care-home-01",
    "ds": "care_home_01_elec_usage",
    "from": "2019-04-04T10:20:00+00:00",
    "to": "2019-04-04T10:25:00+00:00",
    "rows": [
        {"ts": "2019-04-04T10:20:34.123+00:00", "value": 11},
        {"ts": "2019-04-04T10:23:34.123+00:00", "value": 12}
    ]
}

Response Sample

201 Created
[
    {
        "uri": "http://sbyongphp7.global-initiative.com/sbyongphp7_careai_ws_20190327115905/public/api/v1/raw-data/31"
    },
    {
        "uri": "http://sbyongphp7.global-initiative.com/sbyongphp7_careai_ws_20190327115905/public/api/v1/raw-data/32"
    }
]

The above example data relies on the:

  • Data Stream Type (DST) already existing
  • The entity must already exist
  • From and to timestamps being formatting correctly
  • Timestamps in the rows being formatted correctly

The id, for example 31 and 31, of the raw data will be return accordingly with the same order and index of the input data.