Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/GaelCeballos/Smart_Enviro_Backend/llms.txt

Use this file to discover all available pages before exploring further.

Returns a paginated list of all sensor readings, ordered from newest to oldest (50 per page). Supports optional filtering by device or sensor type. Each reading includes the device name and sensor type name and unit via eager-loaded relationships.

Endpoint

GET /api/sensor-data Auth: None required. This is a public apiResource route.

Query Parameters

device_id
integer
Filter readings to a specific device by its integer database ID. When omitted, readings from all devices are returned.
sensor_type_id
integer
Filter readings to a specific sensor type by its integer database ID. When omitted, all sensor types are included in the results.
page
integer
Page number for pagination. Defaults to 1. Each page contains up to 50 records ordered by recorded_at descending.

Example Requests

# All readings (first page)
curl -X GET http://localhost/api/sensor-data

# Filter by device
curl -X GET "http://localhost/api/sensor-data?device_id=3"

# Filter by sensor type and device
curl -X GET "http://localhost/api/sensor-data?device_id=3&sensor_type_id=2"

Response

200 OK

Returns a standard Laravel paginated response envelope. The data array contains the reading records for the current page.
{
  "current_page": 1,
  "data": [
    {
      "id": 42,
      "device_id": 3,
      "sensor_type_id": 2,
      "reading_value": 73.5,
      "recorded_at": "2024-01-15T10:30:00.000000Z",
      "device": {"id": 3, "name": "Invernadero A"},
      "sensor_type": {"id": 2, "name": "Humedad del suelo", "unit": "%"}
    }
  ],
  "first_page_url": "http://localhost/api/sensor-data?page=1",
  "from": 1,
  "last_page": 5,
  "last_page_url": "http://localhost/api/sensor-data?page=5",
  "next_page_url": "http://localhost/api/sensor-data?page=2",
  "path": "http://localhost/api/sensor-data",
  "per_page": 50,
  "prev_page_url": null,
  "to": 50,
  "total": 243
}
current_page
integer
The current page number being returned.
data
array
Array of sensor reading objects for the current page, ordered newest-first by recorded_at.
per_page
integer
Number of records per page. Fixed at 50.
total
integer
Total number of records matching the applied filters across all pages.
last_page
integer
The last available page number, calculated as ceil(total / per_page).
next_page_url
string
Full URL to the next page of results. null when on the last page.
prev_page_url
string
Full URL to the previous page of results. null when on the first page.
The sensor_type_id query parameter here expects the integer database ID (from the sensor_types table), not the metric_key string. The POST /api/sensor-data store endpoint is the exception where metric_key strings are accepted.

Build docs developers (and LLMs) love