# CLEVERON API v1

You can also call up all the details of the buildings and their various rooms in which you have placed CLEVERON devices.

To use the API you will need the appropriate username and password.

With the CLEVERON API, it is possible to read out data in real-time to help you integrate your preferred external systems. If you would like more functions, please contact CLEVERON Support at <support@cleveron.ch>.

### Instruction Manual for the API

1. Start the login function and add the appropriate username and password to the URL. Warning: we stronghly suggest calling this API endpoint on a backend to avoid exposing your username and password on a publicly accessible web portal.
2. After logging in request, you receive a **sessionToken** in an object. This must be used for the next requests.
3. In the *Get Rooms* and *Get Devices* functions, you also need an additional **objectId**. Take these from the respective previous requests and insert them together with the **sessionToken.**

## Get Login

<mark style="color:blue;">`GET`</mark> `https://server.cleveron.ch/apiv1/login?username=<username>&password=<password>`

The first step for logging in and check the API.

#### Query Parameters

| Name     | Type   | Description |
| -------- | ------ | ----------- |
| username | string | username    |
| password | string | password    |

{% tabs %}
{% tab title="200 Response frame returning result object after successful request:" %}

```
{
    "username": "xxx",
    "email": "xxx",
    "lastName": "",
    "name": "",
    "objectId": "wGiGWonFT",
    "sessionToken": "r:253429453837245478920845"
}
```

{% endtab %}

{% tab title="404 Response from returning result object after unsuccessful request:" %}

```
    "code": 101,
    "message": "Invalid username/password."
}
```

{% endtab %}
{% endtabs %}

## Get Me

<mark style="color:blue;">`GET`</mark> `https://server.cleveron.ch/apiv1/me?sessionToken=<sessionToken>`

Return the login data from the user. e.g. for checking that everything is correct.

#### Query Parameters

| Name         | Type   | Description                                                                     |
| ------------ | ------ | ------------------------------------------------------------------------------- |
| sessionToken | string | Token you got from the login request which is used for retrieveing the session. |

{% tabs %}
{% tab title="200 Response frame object after successful returning request:" %}

```
{
    "username": "Cleveron Demo",
    "email": "info@cleveron.ch",
    "lastName": "",
    "name": "",
    "objectId": "AxA3LXX6xd"
}
```

{% endtab %}
{% endtabs %}

## Get Building

<mark style="color:blue;">`GET`</mark> `https://server.cleveron.ch/apiv1/building?sessionToken=<sessionToken>`

Get a list of all the buildings linked to your account.

#### Query Parameters

| Name         | Type   | Description                                                                     |
| ------------ | ------ | ------------------------------------------------------------------------------- |
| sessionToken | string | Token you got from the login request which is used for retrieveing the session. |

{% tabs %}
{% tab title="200 " %}

```
[
    {
        "objectId": "K3HK0HuMo6",
        "homeName": "Cleveron Demo",
        "address": "bernstrasse 1, 3066 Stettlen",
        "city": "Stettlen",
        "area": 75,
        "canton": "BE"
    }
]
```

{% endtab %}
{% endtabs %}

## Get Rooms

<mark style="color:blue;">`GET`</mark> `https://server.cleveron.ch/apiv1/building/<buildingId>/room?sessionToken=<sessionTokenId>`

Get all information and details about the rooms in a building.

#### Path Parameters

| Name       | Type   | Description                                                                                                       |
| ---------- | ------ | ----------------------------------------------------------------------------------------------------------------- |
| buildingId | string | To request a list of the rooms you have to enter the specific **"objectId"** from the building after *building/*. |

#### Query Parameters

| Name           | Type   | Description                                                                     |
| -------------- | ------ | ------------------------------------------------------------------------------- |
| sessionTokenId | string | Token you got from the login request which is used for retrieveing the session. |

{% tabs %}
{% tab title="200 " %}

```
[
    {
        "objectId": "EZaaxz63NA",
        "roomName": "Schulzimmer",
        "floor": 1,
        "tempMin": 18,
        "tempMax": 22,
        "area": 25,
        "height": 3,
        "avgTempLastHour": 22.94,
        "avgHumLastHour": 66.96,
        "co2": 551
    },
    {
        "objectId": "ILqx506p4C",
        "roomName": "Büro Schulleiter",
        "floor": 0,
        "tempMin": 18,
        "tempMax": 22,
        "area": 20,
        "height": 2.5,
        "avgTempLastHour": 21.94,
        "avgHumLastHour": 60.96,
        "co2": 445
    },
    {
        "objectId": "3q2XgFucGI",
        "roomName": "Aula",
        "floor": 0,
        "tempMin": 18,
        "tempMax": 22,
        "area": 30,
        "height": 2.5,
        "avgTempLastHour": 20.94,
        "avgHumLastHour": 62.96,
        "co2": 631
    }
]
```

{% endtab %}
{% endtabs %}

## Get Devices

<mark style="color:blue;">`GET`</mark> `https://server.cleveron.ch/apiv1/room/<roomId>/devices?sessionToken=<sessionTokenId>`

Get temperature, humidity, co2 from the devices of the room. This endpoint can also be used to check the status of the devices.

#### Path Parameters

| Name   | Type   | Description                                                                                                 |
| ------ | ------ | ----------------------------------------------------------------------------------------------------------- |
| roomId | string | To request a list of the devices you have to enter the specific **"objectId"** from the room after *room/*. |

#### Query Parameters

| Name           | Type   | Description                                                                     |
| -------------- | ------ | ------------------------------------------------------------------------------- |
| sessionTokenId | string | Token you got from the login request which is used for retrieveing the session. |

{% tabs %}
{% tab title="200 deviceType can be "CLEVER\_Thermo" or "CLEVER\_Sense" depending of the product you own." %}

```
[
    {
        "objectId": "ReXMceCFOd",
        "serialNumber": 2000739,
        "macAddress": "CC:50:E3:E3:D7:B1",
        "batteryVoltage": 3.6,
        "co2": 345,
        "lastMeasurementDate": {
            "__type": "Date",
            "iso": "2021-09-20T11:54:30.923Z"
        },
        "temperature": 22.253043631987403,
        "humidity": 49.99,
        "wifiStrength": -78,
        "presence": 0.47,
        "deviceType": "CLEVER_Thermo"
    }
]
```

{% endtab %}
{% endtabs %}

Do you need further functionality for your businesss or do you have suggestions? Please let us know by sending us a request at <support@cleveron.ch>. Thanks!

![Thanks to be a part of CLEVERON.](/files/-Mk1Tti6TllfeuJhwIOb)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.cleveron.ch/cleveron-api.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
