Attendance Report API
Simple attendance summary API with date range filtering and per-user activity logs.
v1
|
Single Endpoint
1. Attendance Summary Endpoint
Single endpoint that returns attendance summary with date range filtering, per-user first-in/last-out times, and full activity logs.
GET /api/v1/attendance/summary
2. Authentication
Include your API key in the request header:
X-API-Key: your_api_key_here
API keys are generated from the CCTVOffice desktop application.
3. Query Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| start_date | string | Yes | Start date (YYYY-MM-DD format) |
| end_date | string | Yes | End date (YYYY-MM-DD format) |
| user_id | string | No | Filter by auto-generated user ID. Use custom_id as alternative filter. |
| custom_id | string | No | Filter by custom user ID (optional, nullable). Use instead of user_id. |
| page | integer | No | Page number (default: 1) |
| limit | integer | No | Records per page (default: 20, max: 100) |
4. Response Format
The response includes:
- date_range - The queried date range
- pagination - Page info with has_next/has_prev flags
- users - Array of user attendance records with:
- user_id, custom_id (optional, nullable), user_name, user_type
- date (daily record)
- first_in (full datetime)
- last_out (full datetime)
- working_hours (calculated)
- activities (array of all events for that day)
Success Response
{
"success": true,
"data": {
"date_range": {
"start": "2025-04-20",
"end": "2025-04-27"
},
"pagination": {
"current_page": 1,
"per_page": 20,
"total_records": 45,
"total_pages": 3,
"has_next": true,
"has_prev": false
},
"users": [
{
"user_id": 56,
"custom_id": "STU-001",
"user_name": "Rahul Sharma",
"user_type": "Student",
"date": "2025-04-27",
"first_in": "2025-04-27 08:15:30",
"last_out": "2025-04-27 17:45:00",
"working_hours": "9h 29m",
"activities": [
{
"time": "2025-04-27 08:15:30",
"event": "entry",
"camera": "Main Gate",
"details": null
},
{
"time": "2025-04-27 12:30:00",
"event": "exit",
"camera": "Cafeteria",
"details": null
},
{
"time": "2025-04-27 13:00:00",
"event": "entry",
"camera": "Cafeteria",
"details": null
},
{
"time": "2025-04-27 17:45:00",
"event": "exit",
"camera": "Main Gate",
"details": null
}
]
}
]
}
}
Single User Response (when user_id is provided)
{
"success": true,
"data": {
"date_range": {
"start": "2025-04-20",
"end": "2025-04-27"
},
"pagination": {
"current_page": 1,
"per_page": 20,
"total_records": 7,
"total_pages": 1,
"has_next": false,
"has_prev": false
},
"users": [
{
"user_id": 56,
"user_name": "Rahul Sharma",
"user_type": "Student",
"date": "2025-04-27",
"first_in": "2025-04-27 08:15:30",
"last_out": "2025-04-27 17:45:00",
"working_hours": "9h 29m",
"activities": [
{ "time": "2025-04-27 08:15:30", "event": "entry", "camera": "Main Gate", "details": null },
{ "time": "2025-04-27 17:45:00", "event": "exit", "camera": "Main Gate", "details": null }
]
},
{
"user_id": 56,
"user_name": "Rahul Sharma",
"user_type": "Student",
"date": "2025-04-26",
"first_in": "2025-04-26 08:20:00",
"last_out": "2025-04-26 18:00:00",
"working_hours": "9h 40m",
"activities": [
{ "time": "2025-04-26 08:20:00", "event": "entry", "camera": "Main Gate", "details": null },
{ "time": "2025-04-26 18:00:00", "event": "exit", "camera": "Main Gate", "details": null }
]
}
]
}
}
5. Usage Examples
Get all users attendance for a date range (paginated)
GET /api/v1/attendance/summary?start_date=2025-04-20&end_date=2025-04-27&page=1&limit=20
Get specific user attendance for a date range
GET /api/v1/attendance/summary?start_date=2025-04-01&end_date=2025-04-30&user_id=56
Get user by custom_id instead of user_id
GET /api/v1/attendance/summary?start_date=2025-04-01&end_date=2025-04-30&custom_id=STU-001
cURL Example
curl -X GET "https://cctvoffice.com/api/v1/attendance/summary?start_date=2025-04-20&end_date=2025-04-27" \
-H "X-API-Key: your_api_key_here"
6. Error Codes
| Code | Meaning | Description |
|---|---|---|
| 400 | Bad Request | Missing or invalid parameters (e.g., invalid date format) |
| 401 | Unauthorized | Missing or invalid API key |
| 429 | Too Many Requests | Rate limit exceeded (100 requests/hour) |
Error Response Format
{
"success": false,
"error": "Error message description",
"code": 400
}
Event Types
| Event | Description |
|---|---|
| entry | Person entered through a camera/gate |
| exit | Person exited through a camera/gate |
| general | Other detection event |