Skip to main content
GET
/
devices
/
{device_id}
/
attendance
curl -X GET "https://your-server:5000/devices/principal/attendance"
{
  "success": true,
  "total": 2,
  "data": [
    {
      "user_id": "5",
      "timestamp": "2026-03-06 09:15:23",
      "status": 1,
      "punch": 0,
      "device_id": "principal",
      "device_name": "Entrada Principal"
    },
    {
      "user_id": "5",
      "timestamp": "2026-03-05 17:30:45",
      "status": 0,
      "punch": 1,
      "device_id": "principal",
      "device_name": "Entrada Principal"
    }
  ]
}
Fetch attendance records from a specific device. This endpoint queries a single device and returns its attendance records with optional filtering.

Path Parameters

device_id
string
required
The unique identifier of the device to query. Must be a registered device ID.

Query Parameters

user_id
string
Filter attendance records by a specific user ID. Only records matching this exact user ID will be returned.
date
string
Filter attendance records by date in YYYY-MM-DD format (e.g., 2026-03-03). Only records where the timestamp starts with this date will be returned.

Response Format

The response includes attendance records from the specified device, sorted by timestamp.

Response Fields

success
boolean
required
Indicates whether the operation completed successfully.
total
integer
required
Total number of attendance records returned from the device.
data
array
required
Array of attendance records sorted by timestamp in descending order (newest first).

Device Locking

This endpoint uses device-level locking to ensure safe concurrent access:
  • Each device has its own threading lock
  • Only one request can query a specific device at a time
  • The device is temporarily disabled during data retrieval
  • The device is re-enabled after the query completes (even if an error occurs)
  • Multiple requests can query different devices simultaneously

Error Responses

The endpoint returns appropriate HTTP error codes for different failure scenarios.

Device Not Found (404)

Returned when the specified device_id does not exist in the system.
{
  "success": false,
  "error": "Dispositivo 'invalid_id' no encontrado.",
  "disponibles": ["principal", "bodega"]
}

Device Connection Error (500)

Returned when the server cannot connect to the device or an error occurs during data retrieval.
{
  "success": false,
  "error": "Connection timeout"
}
curl -X GET "https://your-server:5000/devices/principal/attendance"
{
  "success": true,
  "total": 2,
  "data": [
    {
      "user_id": "5",
      "timestamp": "2026-03-06 09:15:23",
      "status": 1,
      "punch": 0,
      "device_id": "principal",
      "device_name": "Entrada Principal"
    },
    {
      "user_id": "5",
      "timestamp": "2026-03-05 17:30:45",
      "status": 0,
      "punch": 1,
      "device_id": "principal",
      "device_name": "Entrada Principal"
    }
  ]
}

Notes

  • The endpoint queries a single device specified by device_id
  • Results are sorted by timestamp in descending order (newest first)
  • Filters are applied after fetching data from the device (server-side filtering)
  • The device is temporarily disabled during query to prevent interference
  • The device lock ensures only one request can access the device at a time
  • The device is always re-enabled, even if an error occurs during the query
  • If the device is unavailable or returns an error, the endpoint returns a 500 status code

Build docs developers (and LLMs) love