# Wia API Quickstart Guide Welcome to Wia! This quickstart guide will help you get started with Wia's energy API, allowing you to make your first API call. ## Step 1: Get Your API Key 1. Create your account and log in. 2. Navigate to your dashboard to retrieve your API key or, depending on your representative, you may have been sent a key. 3. If you don't have an API key, please contact your representative. Your API key is required to authenticate all API requests. ## Step 2: List All Spaces The first step in using the API is to retrieve a list of all spaces. ### Example Request Use the following `curl` command to retrieve all spaces: ```bash curl -X GET https://api.wia.io/v1/spaces \ -H "Authorization: Bearer YOUR_API_KEY" ``` ### Response Example ```json [ { "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. ## Step 3: List Devices in a Space Once you have the space `id`, you can list all devices within that space. ### Example Request Use the following `curl` command to retrieve devices in a specific space: ```bash curl -X GET "https://api.wia.io/v1/devices?space.id=spc_abc123" \ -H "Authorization: Bearer YOUR_API_KEY" ``` ### Response Example ```json [ { "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. ## Step 4: Retrieve Electricity Consumption for a Space With the space `id`, you can retrieve electricity consumption data. ### Example Request Use the following `curl` command to retrieve electricity consumption data: ```bash 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. ### Response Example ```json { "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.