API Documentation

Details for interacting with the Zellig API to send sensor data.

Sensor Data API Endpoint
POST to /api/sensor-data with a JSON body.

Expected JSON Payload Format:

The timestamp should be a Unix timestamp (seconds since epoch).

The homeId is the unique ID of your home document in Firestore.

The apiKey is a secret key associated with your home, found within its Firestore document. This key is used by your devices to authenticate when sending data.

temperature, humidity, and pressure are common optional fields within the data object. You can add any other custom key-value pairs to the data object.

{
  "homeId": "your-home-id-from-dashboard-or-db",
  "apiKey": "your-home-api-key-from-db",
  "deviceId": "sensor-esp32-001",
  "deviceName": "Living Room Sensor",
  "timestamp": 1749382546,
  "location": "Living Room",
  "tag": "Primary Sensor",
  "data": {
    "temperature": 22.5,
    "humidity": 45.2,
    "pressure": 1012.5
  }
}

Field Descriptions:

  • homeId (string, required): The unique ID of your Home document in Firestore.
  • apiKey (string, required): Your Home's secret API Key for device authentication.
  • deviceId (string, required): A unique identifier for the physical device sending data.
  • deviceName (string, required): A human-readable name for the device.
  • timestamp (number, required): Unix timestamp in seconds representing when the reading was taken.
  • location (string, optional): A descriptive location for the sensor (e.g., "Bedroom", "Kitchen").
  • tag (string, optional): An optional tag for categorizing or grouping sensor data.
  • data (object, required): An object containing the actual sensor readings.
    • temperature (number, optional): Temperature in Celsius.
    • humidity (number, optional): Relative humidity in percent.
    • pressure (number, optional): Atmospheric pressure in hPa.
    • ...any other custom fields (any, optional): You can include other sensor readings as key-value pairs.

Important Security Note:

The apiKey is sensitive. It should only be embedded in your trusted sensor devices. Do not expose it in client-side browser code or public repositories. The backend API route /api/sensor-data uses this key along with the homeId to validate incoming data.