Welcome to Wia! This quickstart guide will help you get started with Wia's energy API, allowing you to make your first API call.
- 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.
The first step in using the API is to retrieve a list of all spaces.
Use the following curl command to retrieve all spaces:
curl -X GET https://api.wia.io/v1/spaces \
-H "Authorization: Bearer YOUR_API_KEY"[
{
"id": "spc_abc123",
"name": "Main Office",
"isPublic": false
},
{
"id": "spc_def456",
"name": "Warehouse",
"isPublic": true
}
]This response lists all spaces available to your account. Each space has an id, name, and other details.
Once you have the space id, you can list all devices within that space.
Use the following curl command to retrieve devices in a specific space:
curl -X GET "https://api.wia.io/v1/devices?space.id=spc_abc123" \
-H "Authorization: Bearer YOUR_API_KEY"[
{
"id": "dev_abc123",
"name": "Temperature Sensor",
"isMain": true
},
{
"id": "dev_def456",
"name": "Smart Meter",
"isMain": false
}
]This response lists all devices in the specified space. Each device has an id, name, and additional details.
With the space id, you can retrieve electricity consumption data.
Use the following curl command to retrieve electricity consumption data:
curl -X GET "https://api.wia.io/v1/energy/electricity?space.id=spc_abc123&since=1704067200000&until=1704153600000" \
-H "Authorization: Bearer YOUR_API_KEY"since: The start of the time range for the data in ISO 8601 format.until: The end of the time range for the data in ISO 8601 format.
{
"result": [
{
"energy": "1000",
"timestamp": 1631707200000
},
{
"energy": "1200",
"timestamp": 1631710800000
}
],
"continuationToken": null
}This response provides the electricity consumption data for the specified space and time range.