API Endpoint: aggregate_sensor_data

API Endpoint: aggregate_sensor_data

aggregate_sensor_data

Returns sensor data aggregated over time for a given data_source or sensor. The aggregate_sensor_data endpoint can be used to retrieve data from power meters and environmental sensors in SiteWorx Sense.
Parameters
Example Call
Example Response
Parameters
FieldTypeDescription
data_source_idstringUnique id of DataSource
sensor_idstringUnique id of Sensor
start_timeintegerStart time for report (Unix Epoch format)
end_timeintegerEnd time for report (Unix Epoch format)
intervalstring,optional15minhour, or day (defaults to 15min if not specified)
include_minuteboolean,optionalAnnotate each record with the interval start minute-of-hour (0-59)
include_hourboolean,optionalAnnotate each record with the interval start hour-of-day (0-23)
include_dowboolean,optionalAnnotate each record with the interval start day-of-week (0-6)
Example Call
Return the daily (interval=day) energy usage (interval_type=1) for sensor (data_source_id=4Wkcm4CW8cJ) from 18 June 2018 (start_time=1560830400) through 21 June 2018 (end_time=1561435200). Both times are aligned with local midnight.

GET https://example-backend.siteworx.io/api/v1/aggregate_sensor_data?data_source_id=4Wkcm4CW8cJ&interval=day&interval_type=1&start_time=1560830400&end_time=1561089600
Example Response
{
"data": [
{
"data_source_id": "4Wkcm4CW8cJ",
"data_type": 7,
"interval_start": 1538366400,
"max_adj_value": 609.5796934962273,
"max_value": 1451,
"mean_adj_value": 604.0453392913786,
"mean_value": 1443.7627118644068,
"min_adj_value": 601.1679935455322,
"min_value": 1440,
"sample_count": 59
},
{
"data_source_id": "4Wkcm4CW8cJ",
"data_type": 7,
"interval_start": 1538370000,
"max_adj_value": 606.5208935141563,
"max_value": 1447,
"mean_adj_value": 602.9954969246509,
"mean_value": 1442.3898305084747,
"min_adj_value": 600.4032935500145,
"min_value": 1439,
"sample_count": 59
},
"NOTE: 21 records removed...",
{
"data_source_id": "4Wkcm4CW8cJ",
"data_type": 7,
"interval_start": 1538449200,
"max_adj_value": 589.6974936127663,
"max_value": 1425,
"mean_adj_value": 586.0684088882754,
"mean_value": 1420.2542372881355,
"min_adj_value": 583.5798936486244,
"min_value": 1417,
"sample_count": 59
}
],
"meta": {
"count": 24
}
}
 

    • Related Articles

    • API Terms

      Overview This article provides definitions of terms that are critical to understand when using the SiteWorx API. Terms ID All resources in SiteWorx are identified by a unique ID. They are represented as alpha-numeric strings (e.g. 3EVHgjWw46E.) ...
    • How to Use the API

      Overview SiteWorx offers a web-based REST API to authenticate, make requests, and retrieve data from both lighting nodes in SiteWorx Tune and sensor nodes in SiteWorx Sense. The following data types are available: Lighting nodes Lighting energy usage ...
    • API Endpoint: aggregate_tag_interval_facts

      aggregate_tag_interval_facts Returns an array of interval facts for a specific Tag over a given span of time. Parameters Example Call Example Response Parameters field type description tag_id string Unique id of Tag start_time integer Start time for ...
    • API Endpoint: aggregate_site_interval_facts

      aggregate_site_interval_facts Returns an array of interval facts for a site over a given span of time. Parameters Example Call (Energy Usage) Example Response (Energy Usage) Example Call (Occupancy) Example Response (Occupancy) Parameters Field Type ...
    • SiteWorx Sense data

      The method for querying SiteWorx Sense data via the API varies based on the sensor and data type: For power meters, cumulative energy usage (Wh) is queried via Tags and instantaneous data such as voltage, current, power factor, etc is queried via ...