Gate API Documentation
The Gate API provides endpoints for gate devices to record student attendance through QR code scanning or RFID.
Overview
Gate devices use this API to send attendance data to the system when students enter or exit school premises.
Base URL
https://your-domain.com/api/public/gateAuthentication
Gate devices authenticate using device-specific API keys.
Headers
x-api-key: YOUR_DEVICE_API_KEY
Content-Type: application/jsonEndpoints
Record Attendance
POST /api/public/gate/attendance
Records a student entry or exit.
Request Body:
json
{
"studentId": "STU-2024-0001",
"timestamp": "2024-01-15T07:30:00Z",
"type": "IN",
"gateId": "GATE-001"
}Response:
json
{
"success": true,
"message": "Attendance recorded",
"data": {
"studentName": "Juan Dela Cruz",
"grade": "Grade 6",
"section": "Section A",
"time": "7:30 AM",
"status": "ON_TIME"
}
}Verify Student
GET /api/public/gate/verify/{studentId}
Verifies if a student ID is valid.
Response:
json
{
"valid": true,
"student": {
"id": "STU-2024-0001",
"name": "Juan Dela Cruz",
"photo": "https://...",
"grade": "Grade 6",
"section": "Section A"
}
}Get Gate Status
GET /api/public/gate/status/{gateId}
Gets current gate device status.
Response:
json
{
"gateId": "GATE-001",
"name": "Main Entrance",
"status": "ONLINE",
"lastPing": "2024-01-15T07:29:00Z"
}Attendance Types
| Type | Description |
|---|---|
| IN | Student entering |
| OUT | Student exiting |
Status Codes
| Code | Meaning |
|---|---|
| ON_TIME | Within expected time |
| LATE | After cutoff time |
| EARLY_OUT | Left before dismissal |
| ABSENT | No record for day |
Error Responses
json
{
"success": false,
"error": "INVALID_STUDENT",
"message": "Student ID not found"
}Error Codes
| Code | Meaning |
|---|---|
| INVALID_STUDENT | Student not found |
| INVALID_DEVICE | Device not registered |
| DUPLICATE_SCAN | Already scanned recently |
| UNAUTHORIZED | Invalid API key |
Rate Limiting
- 100 requests per minute per device
- 429 response when exceeded
Tips
- Handle Errors - Implement proper error handling
- Retry Logic - Retry failed requests
- Offline Mode - Queue if connection lost
- Sync Time - Keep device time accurate
Related Pages
- Device Management - Manage gate devices
- Attendance Management - View attendance
- Guardian API - Parent app API
💡 Note: Contact your system administrator to obtain device API keys.
