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 data (energy usage in Wh, available in 15-minute buckets)
- Motion sensor occupancy data (occupancy percentage)
Sensor nodes
- For power meters, energy usage data in Wh as well as other electrical parameters reported by the meter.
- For other sensor types, the API will return the environmental data (temperature, relative humidity, pressure, flow rate, etc.) that the deployed sensor is measuring.
All API requests must be made over HTTPS using an API key that will be provided by the SiteWorx Operations team.
How to Use the API
- Get a SiteWorx Software API key
- Contact siteworxops@siteworx.io to request a key. Please include your full contact information and Organization Name or URL.
- Once you have your key, you can access the API in the following manner:
- Header: X-Siteworx-Api-Key: <api-key>
- Base URL: https://<orgname>-backend.siteworx.io/api/v1
- Example: curl -H 'X-Siteworx-Api-Key: <api-key>' https://<orgname>-backend.siteworx.io/api/v1/version
- Response: {"api_rev":"1.83.0","commit_hash":"b2c430adca6c5959572c35d818c3a634d518e8a1"}
Data Output
By default, the API endpoints return data in JSON format. Most endpoints also support the option to return the data in CSV format. This is enabled by setting the Accept header to text/csv. This returns a URL pointing to a remote temporary file containing the result. You must then fetch this URL. Note that the temporary file expires after 24 hours.
Time Representation
The API uses "Unix Epoch Time" to represent all times as integers. Most programming languages and spreadsheet applications have functions to convert between other time formats and Unix Epoch Time.