EduPulse Smart Schools
EduPulse Africa API Specification

Developer REST API Explorer & Interactive Reference

📚 School Librarian & Library Management REST API

Librarian Mobile App REST API

Official API reference for the EduPulse School Librarian and Library Management Mobile Application. Supports camera barcode & ISBN scanning, book catalog management, book checkout/issuing (temporary borrowing vs permanent copy issue), return inspection, overdue alerts with SMS reminders, book hold reservations, member lookup, digital e-books, and GPS shift attendance.

Base URL http://localhost/edupulse/index.php?api=librarian
Payload Format application/json (UTF-8)
Auth Header Authorization: Bearer <TOKEN>

Authentication & Security

Protected librarian endpoints require the Authorization: Bearer <API_TOKEN> HTTP header. Tokens are issued upon authenticating with phone/email and PIN.

// Example Librarian API Request Header
Authorization: Bearer 34f8a92b7c61029e8d475a1c2b3e4f5061728394a5b6c7d8e9f0123456789abc
Content-Type: application/json

Standard Response Envelope

Success Response (200 OK / 201 Created)
{
  "success": true,
  "status_code": 200,
  "message": "Operation completed successfully",
  "data": { ... },
  "errors": null
}
Error Response (422 Unprocessable / 404 Not Found)
{
  "success": false,
  "status_code": 422,
  "message": "book_id and borrower_name are required.",
  "data": null,
  "errors": null
}
Module 1

Authentication & Librarian Profile

POST ?action=auth_login /auth/login
Public

Authenticates school librarian or bursar using phone/email and PIN or password.

Request Payload:

{
  "login": "moses.musoke@stjulian.edu.ug",
  "password": "1234"
}

Sample Response (`200 OK`):

{
  "success": true,
  "status_code": 200,
  "message": "Librarian login successful. Welcome to the library management portal!",
  "data": {
    "token": "34f8a92b7c61029e8d475a1c2b3e4f5061728394a5b6c7d8e9f0123456789abc",
    "user": {
      "id": 20,
      "name": "Tr. Moses Musoke",
      "email": "moses.musoke@stjulian.edu.ug",
      "phone": "+256755575803",
      "role_id": 8,
      "role_name": "librarian",
      "role_display": "School Librarian",
      "school_id": 1,
      "school_name": "St. Julian High School",
      "school_logo": "uploads/logos/school_logo_1.png"
    }
  }
}
POST ?action=auth_forgot_password /auth/forgot-password
Public

Request Payload:

{ "login": "+256755575803" }

Sample Response (`200 OK`):

{
  "success": true,
  "status_code": 200,
  "message": "Password reset verification code dispatched.",
  "data": { "login": "+256755575803", "sms_sent": true, "step": "verify_reset_code" }
}
POST ?action=auth_reset_password /auth/reset-password
Public

Request Payload:

{ "login": "+256755575803", "otp_code": "8419", "new_password": "4321" }

Sample Response (`200 OK`):

{
  "success": true,
  "status_code": 200,
  "message": "Password reset successfully! You are now logged in.",
  "data": { "token": "34f8a92b7c61029e8d475a1c2b3e4f5061728394a5b6c7d8e9f0123456789abc", "user": { "id": 20, "name": "Tr. Moses Musoke" } }
}
POST ?action=auth_logout /auth/logout
Bearer Token

Sample Response (`200 OK`):

{
  "success": true,
  "status_code": 200,
  "message": "Logged out successfully.",
  "data": null,
  "errors": null
}
GET ?action=profile /profile
Bearer Token

Sample Response (`200 OK`):

{
  "success": true,
  "status_code": 200,
  "message": "Librarian profile retrieved",
  "data": {
    "user": {
      "id": 20,
      "name": "Tr. Moses Musoke",
      "email": "moses.musoke@stjulian.edu.ug",
      "phone": "+256755575803",
      "role_name": "librarian",
      "role_display": "School Librarian"
    },
    "school": {
      "name": "St. Julian High School",
      "logo_url": "uploads/logos/school_logo_1.png"
    },
    "stats": {
      "total_titles": 4,
      "total_copies": 160,
      "available_copies": 129,
      "active_loans": 1
    }
  }
}
POST ?action=profile_update /profile/update
Bearer Token

Request Payload:

{
  "name": "Tr. Moses Musoke",
  "phone": "+256755575803",
  "email": "moses.musoke@stjulian.edu.ug"
}

Sample Response (`200 OK`):

{
  "success": true,
  "status_code": 200,
  "message": "Profile updated successfully!",
  "data": {
    "user": {
      "id": 20,
      "name": "Tr. Moses Musoke",
      "email": "moses.musoke@stjulian.edu.ug",
      "phone": "+256755575803",
      "photo_url": "uploads/librarians/lib_1786948211.jpg"
    }
  }
}
GET ?action=librarian_badge /librarian-badge
Bearer Token

Sample Response (`200 OK`):

{
  "success": true,
  "status_code": 200,
  "message": "Librarian digital badge retrieved",
  "data": {
    "staff": {
      "id": 20,
      "staff_code": "LIB-0020",
      "name": "Tr. Moses Musoke",
      "role": "Chief Librarian & Resource Manager",
      "phone": "+256755575803"
    },
    "school": {
      "name": "St. Julian High School",
      "logo_url": "uploads/logos/school_logo_1.png"
    },
    "barcode_data": "LIB-0020",
    "qr_string": "EDUPULSE-LIBRARY:20:LIB-0020:SCH-1"
  }
}
Module 2

Library Dashboard & Live Census

GET ?action=dashboard /dashboard
Bearer Token

Sample Response (`200 OK`):

{
  "success": true,
  "status_code": 200,
  "message": "Library dashboard overview retrieved",
  "data": {
    "metrics": {
      "total_titles": 4,
      "total_copies": 160,
      "available_copies": 129,
      "borrowed_copies": 1,
      "overdue_loans": 1,
      "today_issued": 0,
      "today_returned": 0,
      "pending_holds": 0
    },
    "recent_loans": [
      {
        "id": 1,
        "book_title": "Advanced Level Pure Mathematics P1 & P2",
        "borrower_name": "Brian Kimuli (Senior 4 (UCE))",
        "issue_date": "2026-07-22",
        "due_date": "2026-07-25",
        "status": "issued"
      }
    ],
    "categories": [
      { "category": "Literature in English", "title_count": 1, "total_copies": "60", "available_copies": "50" },
      { "category": "Mathematics", "title_count": 1, "total_copies": "30", "available_copies": "21" },
      { "category": "Sciences", "title_count": 1, "total_copies": "45", "available_copies": "38" }
    ]
  }
}
Module 3

Universal Library Barcode / QR Scanner

POST ?action=scan_barcode /scan/barcode
Bearer Token

Multi-entity scanning: Book ISBNs, Student IDs, Staff Cards, and Loan references.

Scenario A: Request Payload (Book ISBN):

{
  "scanned_code": "ISBN-978-0435"
}

Sample Response (`200 OK`):

{
  "success": true,
  "status_code": 200,
  "message": "Book identified: Advanced Level Pure Mathematics P1 & P2",
  "data": {
    "entity_type": "book",
    "book": {
      "id": 2,
      "school_id": 1,
      "book_title": "Advanced Level Pure Mathematics P1 & P2",
      "author": "J. K. Backhouse",
      "isbn_code": "ISBN-978-0435",
      "category": "Mathematics",
      "total_copies": 30,
      "available_copies": 21,
      "shelf_location": "Shelf B-01",
      "condition_status": "Good"
    },
    "active_loans": [
      {
        "id": 1,
        "borrower_name": "Brian Kimuli (Senior 4 (UCE))",
        "issue_date": "2026-07-22",
        "due_date": "2026-07-25",
        "status": "issued"
      }
    ]
  }
}

Scenario B: Request Payload (Student ID Card):

{
  "scanned_code": "STU-2026-008"
}

Sample Response (`200 OK`):

{
  "success": true,
  "status_code": 200,
  "message": "Student borrower identified: mukibi hr",
  "data": {
    "entity_type": "student",
    "student": {
      "id": 8,
      "student_code": "STU-2026-008",
      "admission_no": "ADM/2026/875",
      "full_name": "mukibi hr",
      "class_name": "Primary 1",
      "parent_phone": "0755575803"
    },
    "borrowed_books": [],
    "overdue_count": 0
  }
}
Module 4

Book Catalog & Inventory Management

GET ?action=books&category=Sciences /books/list
Bearer Token

Sample Response (`200 OK`):

{
  "success": true,
  "status_code": 200,
  "message": "Book catalog list retrieved",
  "data": [
    {
      "id": 1,
      "school_id": 1,
      "book_title": "Longman Secondary Chemistry Book 4",
      "author": "A. Atkinson",
      "isbn_code": "ISBN-978-0582",
      "category": "Sciences",
      "total_copies": 45,
      "available_copies": 38,
      "shelf_location": "Shelf A-02",
      "condition_status": "Good"
    }
  ]
}
GET ?action=book_details&book_id=1 /books/details
Bearer Token

Sample Response (`200 OK`):

{
  "success": true,
  "status_code": 200,
  "message": "Book details retrieved",
  "data": {
    "book": {
      "id": 1,
      "book_title": "Longman Secondary Chemistry Book 4",
      "author": "A. Atkinson",
      "isbn_code": "ISBN-978-0582",
      "category": "Sciences",
      "total_copies": 45,
      "available_copies": 38,
      "shelf_location": "Shelf A-02",
      "condition_status": "Good"
    },
    "recent_loans": []
  }
}
POST ?action=book_add /books/add
Bearer Token

Request Payload:

{
  "book_title": "Macbeth (Cambridge School Shakespeare)",
  "author": "William Shakespeare",
  "isbn_code": "ISBN-978-1107615495",
  "category": "Literature in English",
  "shelf_location": "Shelf C-02",
  "total_copies": 40,
  "condition_status": "New"
}

Sample Response (`201 Created`):

{
  "success": true,
  "status_code": 201,
  "message": "New library book 'Macbeth (Cambridge School Shakespeare)' added to catalog!",
  "data": {
    "id": 5,
    "book_title": "Macbeth (Cambridge School Shakespeare)",
    "total_copies": 40,
    "available_copies": 40
  }
}
POST ?action=book_update /books/update
Bearer Token

Request Payload:

{
  "book_id": 5,
  "shelf_location": "Shelf C-03",
  "total_copies": 45
}

Sample Response (`200 OK`):

{
  "success": true,
  "status_code": 200,
  "message": "Library book 'Macbeth (Cambridge School Shakespeare)' updated successfully!",
  "data": { "id": 5, "total_copies": 45, "shelf_location": "Shelf C-03" }
}
POST ?action=book_delete /books/delete
Bearer Token

Request Payload:

{ "book_id": 5 }

Sample Response (`200 OK`):

{
  "success": true,
  "status_code": 200,
  "message": "Book removed from library catalog.",
  "data": null
}
GET ?action=book_categories /books/categories
Bearer Token

Sample Response (`200 OK`):

{
  "success": true,
  "status_code": 200,
  "message": "Book categories retrieved",
  "data": [
    { "category": "Literature in English", "titles_count": 2, "copies_count": "100", "available_count": "90" },
    { "category": "Mathematics", "titles_count": 1, "copies_count": "30", "available_count": "21" },
    { "category": "Sciences", "titles_count": 1, "copies_count": "45", "available_count": "38" }
  ]
}
Module 5

Book Circulation, Issuing & Checkout

POST ?action=loan_issue /loans/issue
Bearer Token

Request Payload:

{
  "book_id": 1,
  "borrower_type": "student",
  "borrower_name": "Sarah Namubiru (Senior 2)",
  "borrower_phone": "+256772111222",
  "loan_type": "borrow",
  "duration_days": 14,
  "due_date": "2026-09-13",
  "due_time": "17:00",
  "notes": "Chemistry practical review checkout"
}

Sample Response (`201 Created`):

{
  "success": true,
  "status_code": 201,
  "message": "Book loan issued successfully for 'Longman Secondary Chemistry Book 4' to Sarah Namubiru (Senior 2)!",
  "data": {
    "id": 2,
    "book_id": 1,
    "borrower_name": "Sarah Namubiru (Senior 2)",
    "issue_date": "2026-08-30",
    "due_date": "2026-09-13",
    "due_time": "17:00:00",
    "duration_days": 14,
    "status": "issued"
  }
}
GET ?action=loans_active /loans/active
Bearer Token

Sample Response (`200 OK`):

{
  "success": true,
  "status_code": 200,
  "message": "Active book loans retrieved",
  "data": [
    {
      "id": 2,
      "book_title": "Longman Secondary Chemistry Book 4",
      "borrower_name": "Sarah Namubiru (Senior 2)",
      "due_date": "2026-09-13",
      "is_overdue": 0,
      "days_overdue": -14,
      "status": "issued"
    }
  ]
}
GET ?action=loans_history&status=returned /loans/history
Bearer Token

Sample Response (`200 OK`):

{
  "success": true,
  "status_code": 200,
  "message": "Circulation loans audit history retrieved",
  "data": [
    {
      "id": 1,
      "book_title": "Advanced Level Pure Mathematics P1 & P2",
      "borrower_name": "Brian Kimuli (Senior 4 (UCE))",
      "return_date": "2026-07-25",
      "status": "returned"
    }
  ]
}
GET ?action=loan_details&loan_id=1 /loans/details
Bearer Token

Sample Response (`200 OK`):

{
  "success": true,
  "status_code": 200,
  "message": "Loan record details retrieved",
  "data": {
    "id": 1,
    "book_title": "Advanced Level Pure Mathematics P1 & P2",
    "borrower_name": "Brian Kimuli (Senior 4 (UCE))",
    "issue_date": "2026-07-22",
    "due_date": "2026-07-25",
    "status": "issued"
  }
}
POST ?action=loan_extend /loans/extend
Bearer Token

Request Payload:

{
  "loan_id": 2,
  "extra_days": 7,
  "reason": "Preparing for midterm chemistry exams"
}

Sample Response (`200 OK`):

{
  "success": true,
  "status_code": 200,
  "message": "Loan extended successfully until Sep 20, 2026",
  "data": { "loan_id": 2, "new_due_date": "2026-09-20" }
}
Module 6

Book Returns & Condition Inspection

POST ?action=loan_return /loans/return
Bearer Token

Request Payload:

{
  "loan_id": 2,
  "return_condition": "Good",
  "fine_amount_ugx": 0.00,
  "notes": "Returned on schedule"
}

Sample Response (`200 OK`):

{
  "success": true,
  "status_code": 200,
  "message": "Book marked as returned successfully in Good condition.",
  "data": { "loan_id": 2, "status": "returned", "return_date": "2026-08-30" }
}
GET ?action=loans_overdue /loans/overdue
Bearer Token

Sample Response (`200 OK`):

{
  "success": true,
  "status_code": 200,
  "message": "Overdue book loans retrieved",
  "data": [
    {
      "id": 1,
      "book_title": "Advanced Level Pure Mathematics P1 & P2",
      "borrower_name": "Brian Kimuli (Senior 4 (UCE))",
      "issue_date": "2026-07-22",
      "due_date": "2026-07-25",
      "days_overdue": 36,
      "status": "issued"
    }
  ]
}
POST ?action=loan_remind /loans/remind
Bearer Token

Request Payload:

{ "loan_id": 1 }

Sample Response (`200 OK`):

{
  "success": true,
  "status_code": 200,
  "message": "Overdue SMS reminder dispatched to +256755575803.",
  "data": { "loan_id": 1, "phone": "+256755575803" }
}
Module 7

Member & Borrower Directory Lookup

GET ?action=search_borrowers&query=Mukasa /borrowers/search
Bearer Token

Sample Response (`200 OK`):

{
  "success": true,
  "status_code": 200,
  "message": "Borrower directory search results",
  "data": [
    {
      "id": 4,
      "borrower_name": "Dr. Robert Mukasa",
      "id_number": "TCH-001",
      "borrower_type": "teacher",
      "class_name": "Staff / Faculty",
      "contact_phone": "+256772111333"
    }
  ]
}
GET ?action=borrower_profile&borrower_name=Brian Kimuli /borrowers/profile
Bearer Token

Sample Response (`200 OK`):

{
  "success": true,
  "status_code": 200,
  "message": "Borrower profile & loan history retrieved",
  "data": {
    "borrower_name": "Brian Kimuli",
    "active_loans": 1,
    "returned_loans": 0,
    "loans_history": [
      {
        "id": 1,
        "book_title": "Advanced Level Pure Mathematics P1 & P2",
        "issue_date": "2026-07-22",
        "due_date": "2026-07-25",
        "status": "issued"
      }
    ]
  }
}
GET ?action=borrowers_classes /borrowers/classes
Bearer Token

Sample Response (`200 OK`):

{
  "success": true,
  "status_code": 200,
  "message": "Classes, enrolled students and staff roster retrieved",
  "data": {
    "classes": [
      { "id": 1, "class_name": "Primary 1", "student_count": 12 }
    ],
    "students": [
      { "id": 8, "class_id": 1, "student_name": "mukibi hr", "class_name": "Primary 1", "student_code": "STU-2026-008" }
    ],
    "teachers": [
      { "id": 4, "teacher_name": "Ms. Grace Akello", "staff_id": "TCH-102" }
    ]
  }
}
Module 8

Book Reservations & Holds

GET ?action=reservations&status=pending /reservations/list
Bearer Token

Sample Response (`200 OK`):

{
  "success": true,
  "status_code": 200,
  "message": "Book reservations retrieved",
  "data": [
    {
      "id": 1,
      "book_id": 2,
      "book_title": "Advanced Level Pure Mathematics P1 & P2",
      "borrower_name": "Sarah Namubiru",
      "reservation_date": "2026-08-30",
      "status": "pending"
    }
  ]
}
POST ?action=reservation_create /reservations/create
Bearer Token

Request Payload:

{
  "book_id": 2,
  "borrower_type": "student",
  "borrower_name": "Sarah Namubiru",
  "borrower_phone": "+256772111222",
  "notes": "Hold copy when returned by Brian Kimuli"
}

Sample Response (`201 Created`):

{
  "success": true,
  "status_code": 201,
  "message": "Book hold reservation placed successfully!",
  "data": { "reservation_id": 1, "status": "pending" }
}
POST ?action=reservation_cancel /reservations/cancel
Bearer Token

Request Payload:

{ "reservation_id": 1 }

Sample Response (`200 OK`):

{
  "success": true,
  "status_code": 200,
  "message": "Reservation cancelled.",
  "data": null
}
POST ?action=reservation_fulfill /reservations/fulfill
Bearer Token

Request Payload:

{ "reservation_id": 1 }

Sample Response (`200 OK`):

{
  "success": true,
  "status_code": 200,
  "message": "Reservation marked as fulfilled.",
  "data": null
}
Module 9

Shelves & Digital E-Books

GET ?action=shelves /shelves/list
Bearer Token

Sample Response (`200 OK`):

{
  "success": true,
  "status_code": 200,
  "message": "Library shelves directory retrieved",
  "data": [
    { "shelf_location": "Shelf A-02", "titles_count": 1, "total_copies": "45" },
    { "shelf_location": "Shelf B-01", "titles_count": 1, "total_copies": "30" }
  ]
}
GET ?action=ebooks /ebooks/list
Bearer Token

Sample Response (`200 OK`):

{
  "success": true,
  "status_code": 200,
  "message": "Digital e-books & curriculum materials retrieved",
  "data": [
    {
      "id": 101,
      "title": "Uganda National Curriculum A-Level Chemistry Digital Guide",
      "subject": "Chemistry",
      "class": "Senior 5 & 6",
      "file_format": "PDF",
      "file_size_mb": 14.5,
      "download_url": "uploads/ebooks/a_level_chemistry_guide.pdf"
    }
  ]
}
Module 10

Shift GPS Attendance & Clock-In

POST ?action=attendance_clock_in /attendance/clock-in
Bearer Token

Request Payload:

{
  "latitude": 0.3541,
  "longitude": 32.5912
}

Sample Response (`200 OK`):

{
  "success": true,
  "status_code": 200,
  "message": "Librarian shift clock-in recorded at 08:00 AM",
  "data": { "action": "clock_in", "check_in_time": "08:00:00", "date": "2026-08-30" }
}
GET ?action=attendance_history&limit=30 /attendance/history
Bearer Token

Sample Response (`200 OK`):

{
  "success": true,
  "status_code": 200,
  "message": "Librarian attendance shift history retrieved",
  "data": [
    { "id": 104, "date": "2026-08-30", "check_in_time": "08:00:00", "status": "present", "location_name": "School Central Library" }
  ]
}
Module 11

Salary & Shift Allowances

GET ?action=payroll_summary /payroll/summary
Bearer Token

Sample Response (`200 OK`):

{
  "success": true,
  "status_code": 200,
  "message": "Librarian salary and payslip records retrieved",
  "data": {
    "salary_structure": {
      "basic_salary_ugx": "750000.00",
      "allowances_ugx": "100000.00",
      "net_salary_ugx": "850000.00"
    },
    "payment_history": [
      { "id": 19, "month_year": "July 2026", "amount_paid": "850000.00", "payment_method": "Bank Transfer" }
    ]
  }
}
Module 12

Messaging & Support Chat

GET ?action=chats /chats
Bearer Token

Sample Response (`200 OK`):

{
  "success": true,
  "status_code": 200,
  "message": "Library support chats retrieved",
  "data": [
    { "id": 12, "ticket_number": "LIB-20260830-4182", "subject": "New Chemistry Textbooks Requisition", "status": "open" }
  ]
}
POST ?action=chat_create /chats/create
Bearer Token

Request Payload:

{
  "subject": "New Chemistry Textbooks Requisition",
  "message": "We need 25 additional copies of Longman Secondary Chemistry Book 4.",
  "category": "library"
}

Sample Response (`201 Created`):

{
  "success": true,
  "status_code": 201,
  "message": "Library support request created successfully!",
  "data": { "chat_id": 12, "ticket_number": "LIB-20260830-4182" }
}
GET ?action=chat_messages&chat_id=12 /chats/messages
Bearer Token

Sample Response (`200 OK`):

{
  "success": true,
  "status_code": 200,
  "message": "Chat messages retrieved",
  "data": {
    "chat": { "id": 12, "subject": "New Chemistry Textbooks Requisition" },
    "messages": [
      { "id": 31, "sender_name": "Tr. Moses Musoke", "message": "We need 25 additional copies.", "created_at": "2026-08-30 11:30:00" }
    ]
  }
}
POST ?action=chat_send /chats/send
Bearer Token

Request Payload:

{
  "chat_id": 12,
  "message": "Order approved by the bursar."
}

Sample Response (`200 OK`):

{
  "success": true,
  "status_code": 200,
  "message": "Message sent successfully",
  "data": { "message_id": 32 }
}
Module 13

Circulars & Alerts

GET ?action=announcements&limit=20 /announcements
Bearer Token

Sample Response (`200 OK`):

{
  "success": true,
  "status_code": 200,
  "message": "School announcements retrieved",
  "data": [
    {
      "id": 7,
      "title": "National Book Week & Reading Challenge",
      "content": "Extended library opening hours until 07:00 PM.",
      "priority": "Normal"
    }
  ]
}
GET ?action=notifications /notifications
Bearer Token

Sample Response (`200 OK`):

{
  "success": true,
  "status_code": 200,
  "message": "Librarian notifications retrieved",
  "data": {
    "unread_count": 1,
    "notifications": [
      {
        "id": 42,
        "title": "Book Hold Fulfilled",
        "message": "Reserved copy of Pure Mathematics returned.",
        "is_read": 0
      }
    ]
  }
}
POST ?action=notification_read /notifications/read
Bearer Token

Request Payload:

{ "id": 42 }

Sample Response (`200 OK`):

{
  "success": true,
  "status_code": 200,
  "message": "Notification marked as read",
  "data": null
}
POST ?action=notifications_read_all /notifications/read-all
Bearer Token

Sample Response (`200 OK`):

{
  "success": true,
  "status_code": 200,
  "message": "All notifications marked as read",
  "data": null
}
Module 14

Academic Calendar & Events

GET ?action=calendar_events&start_date=2026-08-01&end_date=2026-08-31 /calendar/events
Bearer Token

Sample Response (`200 OK`):

{
  "success": true,
  "status_code": 200,
  "message": "Academic calendar events retrieved",
  "data": [
    {
      "id": 4,
      "title": "Annual Library Book Stocktaking Week",
      "start_date": "2026-08-25",
      "end_date": "2026-08-29",
      "event_type": "Academic",
      "color": "#3b82f6"
    }
  ]
}
Module 15

Emergency & Safety Panic Dispatch

GET ?action=emergency_alerts /emergency/alerts
Bearer Token

Sample Response (`200 OK`):

{
  "success": true,
  "status_code": 200,
  "message": "Emergency alerts & hotline directory retrieved",
  "data": {
    "agency_contacts": [
      { "id": 1, "agency_type": "Uganda Police Toll-Free", "phone_primary": "999", "phone_secondary": "112" },
      { "id": 2, "agency_type": "Fire & Rescue Service", "phone_primary": "112", "phone_secondary": "0414342222" }
    ]
  }
}
POST ?action=emergency_panic /emergency/panic-report
SOS Panic Dispatch

Request Payload:

{
  "emergency_type": "Library Archive Fire Outbreak",
  "location": "School Central Library - Archive Section",
  "notes": "Smoke detected near reference archive shelves. Fire extinguisher deployed."
}

Sample Response (`201 Created`):

{
  "success": true,
  "status_code": 201,
  "message": "Emergency panic broadcast dispatched to school administration and rescue units!",
  "data": { "incident_id": 23, "emergency_type": "Library Archive Fire Outbreak", "status": "Dispatched" }
}

SDK Code Examples

React Native / TypeScript Integration librarianApi.ts
import axios from 'axios';

const BASE_URL = 'http://localhost/edupulse/index.php?api=librarian';
export const librarianApi = axios.create({ baseURL: BASE_URL });

export const setLibrarianAuthToken = (token: string) => {
  librarianApi.defaults.headers.common['Authorization'] = `Bearer ${token}`;
};

// 1. Scan Book or Borrower Barcode
export const scanBarcode = async (scannedCode: string) => {
  const res = await librarianApi.post('&action=scan_barcode', { scanned_code: scannedCode });
  return res.data;
};

// 2. Issue Book Loan
export const issueBookLoan = async (payload: {
  book_id: number;
  borrower_type: string;
  borrower_name: string;
  borrower_phone?: string;
  loan_type: 'borrow' | 'permanent_take';
  duration_days: number;
  due_date: string;
  due_time: string;
}) => {
  const res = await librarianApi.post('&action=loan_issue', payload);
  return res.data;
};
Flutter / Dart Integration librarian_api_service.dart
import 'dart:convert';
import 'package:http/http.dart' as http;

class LibrarianApiService {
  static const String baseUrl = 'http://localhost/edupulse/index.php?api=librarian';
  String? _authToken;

  void setToken(String token) {
    _authToken = token;
  }

  Map<String, String> get _headers => {
    'Content-Type': 'application/json',
    if (_authToken != null) 'Authorization': 'Bearer $_authToken',
  };

  // 1. Universal Barcode / ISBN Scanner
  Future<Map<String, dynamic>> scanBarcode(String code) async {
    final response = await http.post(
      Uri.parse('$baseUrl&action=scan_barcode'),
      headers: _headers,
      body: jsonEncode({'scanned_code': code}),
    );
    return jsonDecode(response.body);
  }

  // 2. Issue Book Loan
  Future<Map<String, dynamic>> issueLoan(Map<String, dynamic> payload) async {
    final response = await http.post(
      Uri.parse('$baseUrl&action=loan_issue'),
      headers: _headers,
      body: jsonEncode(payload),
    );
    return jsonDecode(response.body);
  }
}