Energy Guide
This guide provides insights into retrieving and analyzing energy, gas, and water consumption data using the Wia API. You will learn how to configure the flow of data (consumption vs. production), filter data by device properties, and handle timestamps effectively.
Step 1: Get Your API Key
- Create your account and log in.
- Navigate to your dashboard to retrieve your API key or, depending on your representative, you may have been sent a key.
- If you don't have an API key, please contact your representative.
Your API key is required to authenticate all API requests.
Step 2: Retrieve Energy Data
The Wia API allows you to retrieve energy, gas, and water consumption data. These data points can be grouped by devices, spaces, or countries.
Example Request for Electricity Consumption
curl -X GET "https://api.wia.io/v1/energy/electricity?space.id=spc_abc123&since=2024-01-01T00:00:00Z&until=2024-01-02T00:00:00Z&flow=consumption" \
-H "Authorization: Bearer YOUR_API_KEY"
space.id
: Specify the space for which you want data.since
: Start of the time range timestamp.until
: End of the time range timestamp.flow
: Set toconsumption
for energy used orproduction
for energy generated.
Response Example
{
"result": [
{
"energy": "1000",
"timestamp": 1631707200000
},
{
"energy": "1200",
"timestamp": 1631710800000
}
],
"continuationToken": null
}
Step 3: Retrieve Gas and Water Data
The process is similar for gas and water data.
Example Request for Gas Consumption
curl -X GET "https://api.wia.io/v1/energy/gas?space.id=spc_abc123&since=2024-01-01T00:00:00Z&until=2024-01-02T00:00:00Z&flow=consumption" \
-H "Authorization: Bearer YOUR_API_KEY"
Example Request for Water Consumption
curl -X GET "https://api.wia.io/v1/energy/water?space.id=spc_abc123&since=2024-01-01T00:00:00Z&until=2024-01-02T00:00:00Z&flow=consumption" \
-H "Authorization: Bearer YOUR_API_KEY"
Step 4: Group Data by Devices or Countries
You can group data by devices or countries for more granular analysis.
Example Request for Device-level Breakdown
curl -X GET "https://api.wia.io/v1/energy/electricity?space.id=spc_abc123&since=2024-01-01T00:00:00Z&until=2024-01-02T00:00:00Z&breakdown=device" \
-H "Authorization: Bearer YOUR_API_KEY"
Response Example
{
"devices": {
"dev_abc123": [
{
"energy": "1000",
"timestamp": 1631707200000
}
],
"dev_def456": [
{
"energy": "1200",
"timestamp": 1631707200000
}
]
}
}
Example Request for Country-level Breakdown
curl -X GET "https://api.wia.io/v1/energy/electricity?since=2024-01-01T00:00:00Z&until=2024-01-02T00:00:00Z&breakdown=country" \
-H "Authorization: Bearer YOUR_API_KEY"
Response Example
{
"countries": {
"IRL": [
{
"energy": "2000",
"timestamp": 1631707200000
}
],
"DEU": [
{
"energy": "1500",
"timestamp": 1631707200000
}
]
}
}
Step 5: Handling Timestamps
All timestamps in the API are in UTC. Use the timezone
parameter to adjust data for your local timezone.
Example Request with Timezone
curl -X GET "https://api.wia.io/v1/energy/electricity?space.id=spc_abc123&since=2024-01-01T00:00:00Z&until=2024-01-02T00:00:00Z&timezone=Europe/London" \
-H "Authorization: Bearer YOUR_API_KEY"
Interval Aggregation
You can specify the data aggregation interval using the interval
parameter (e.g., 15 minutes
, 1 hour
, 1 day
).
Example Request with Interval
curl -X GET "https://api.wia.io/v1/energy/electricity?space.id=spc_abc123&since=2024-01-01T00:00:00Z&until=2024-01-02T00:00:00Z&interval=1 hour" \
-H "Authorization: Bearer YOUR_API_KEY"
Summary
The Wia API provides robust options to retrieve and analyze energy, gas, and water consumption data. You can:
- Choose between
consumption
orproduction
flow. - Group data by
device
orcountry
. - Handle timestamps effectively with
timezone
andinterval
parameters.
Use these features to monitor usage trends, optimize energy management, and make data-driven decisions.