Skip to content

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/gate

Authentication

Gate devices authenticate using device-specific API keys.

Headers

x-api-key: YOUR_DEVICE_API_KEY
Content-Type: application/json

Endpoints

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

TypeDescription
INStudent entering
OUTStudent exiting

Status Codes

CodeMeaning
ON_TIMEWithin expected time
LATEAfter cutoff time
EARLY_OUTLeft before dismissal
ABSENTNo record for day

Error Responses

json
{
  "success": false,
  "error": "INVALID_STUDENT",
  "message": "Student ID not found"
}

Error Codes

CodeMeaning
INVALID_STUDENTStudent not found
INVALID_DEVICEDevice not registered
DUPLICATE_SCANAlready scanned recently
UNAUTHORIZEDInvalid 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

💡 Note: Contact your system administrator to obtain device API keys.

Released under the MIT License.