1. Home
  2. Documenti
  3. API
  4. Supported API

Supported API

Supported API 

  1. API REST (HTTP/HTTPS)

    • Based on HTTP GET, POST, PUT, DELETE requests

    • Anwers in JSON

    • Usable by any application with network access
      Example:

      http
      GET https://api.example.com/devices/LM123456/data
      
  2. API MQTT (Pub/Sub)

    • Based on MQTT (Message Queuing Telemetry Transport) protocol

    • Ideals for real time communications with a low bandwidth consumption

    • The device publishes data to a topic, and other clients can subscribe to receive it

    • Example:

      plaintext
      Topic: levelmeter/LM123456/data
      Payload: {"temperature": 23.4, "motion_detected": true}

Authentication and Security

APIs use authentication tokens to ensure security and controlled access.
Example of authentication with Bearer token:

http
GET https://api.example.com/devices/LM123456/data
Authorization: Bearer YOUR_ACCESS_TOKEN

Examples of Endpoint API REST

1. Get the latest device data

http
GET /devices/{device_id}/data

Answer JSON

json
{
"device_id": "LM123456",
"timestamp": 1711532400,
"temperature": 23.4,
"motion": true,
"battery_level": 78
}

2. Set a Threshold Alarm

http
POST /devices/{device_id}/alerts
Content-Type: application/json

Body JSON

json
{
"type": "temperature",
"threshold": 50,
"action": "send_alert"
}

3. Check Battery Status

http
GET /devices/{device_id}/battery

Answer

json
{
"battery_level": 78,
"status": "OK"
}

Articoli