Student Card API Documentation
Complete API documentation for Student Card Management System
Overview
API Information
- Base URL:
http://localhost/api/v1 - Authentication: Bearer Token (JWT)
- Content-Type: application/json (except file uploads)
- Database: MySQL with Eloquent ORM
- Student Records: 39,070+ imported from tblstd_idcard
- File Upload Limit: 10MB maximum
Database Information
Database Configuration
Current database settings (from .env file):
- Host: localhost
- Database: cardapi
- Username: cardapi
- Charset: utf8mb4
Tables Structure:
- users: API users (id, name, email, password, created_at, updated_at)
- tblstd_idcard: Student data (student_id, people_id, stu_fname, stu_lname, etc.)
- upload: File upload records (id, user_id, student_id, filename, original_name, file_size, created_at)
Authentication
This API provides student card management services with JWT-based authentication.
Protected endpoints require a Bearer token in the Authorization header:
Authorization: Bearer {your_token}
Authentication
POST
/api/v1/auth/login
User login
Parameters
email |
string (required) |
password |
string (required) |
Response
{
"success": "boolean", "token": "string", "user": "object"}
Example Request
curl -X POST \
"http://localhost/api/v1/auth/login" \
-H "Content-Type: application/json" \
-d '{"example": "data"}'
POST
/api/v1/auth/register
User registration
Parameters
name |
string (required) |
email |
string (required) |
password |
string (required) |
Response
{
"success": "boolean", "message": "string", "user": "object"}
Example Request
curl -X POST \
"http://localhost/api/v1/auth/register" \
-H "Content-Type: application/json" \
-d '{"example": "data"}'
Student Management
All endpoints require authentication (Bearer token)
GET
/api/v1/students/search
Example:
/api/v1/students/search?q=123456&type=student_id&page=1&per_page=10
Search students by student_id, people_id, stu_fname, stu_lname
Parameters
q |
string (required) - Search keyword |
type |
string (optional) - Search type: student_id|people_id|stu_fname|stu_lname|all (default: all) |
page |
integer (optional) - Page number (default: 1) |
per_page |
integer (optional) - Items per page (default: 10, max: 50) |
Response
{
"success": "boolean", "data": "array of students", "pagination": "object with current_page, per_page, total, total_pages, from, to"}
Example Request
curl -X GET \
"http://localhost/api/v1/students/search" \
-H "Authorization: Bearer {your_token}"?"example_param=value"
GET
/api/v1/students/{student_id}
Example:
/api/v1/students/123456
Get student details by student_id
Parameters
student_id |
string (required in URL) - Student ID |
Response
{
"success": "boolean", "data": "student object with uploads relationship"}
Example Request
curl -X GET \
"http://localhost/api/v1/students/{student_id}" \
-H "Authorization: Bearer {your_token}"?"example_param=value"
GET
/api/v1/students/{student_id}/image
Example:
/api/v1/students/123456/image
Get student image URL by student_id
Parameters
student_id |
string (required in URL) - Student ID |
Response
{
"success": "boolean", "data": "object with image_url, has_custom_image, filename"}
Example Request
curl -X GET \
"http://localhost/api/v1/students/{student_id}/image" \
-H "Authorization: Bearer {your_token}"?"example_param=value"
File Upload
All endpoints require authentication (Bearer token)
POST
/api/v1/upload
Upload student image to uploads directory (max 10MB) - Uses multipart/form-data
Parameters
student_id |
string (required) - Student ID |
image |
file (required) - Image file (JPG, JPEG, PNG, GIF) |
Response
{
"success": "boolean", "message": "string", "data": "upload object"}
Example Request
curl -X POST \
"http://localhost:8080/api/v1/upload" \
-H "Authorization: Bearer {your_token}" \
-F "student_id=6601001234" \
-F "image=@/path/to/your/image.jpg"
POST
/api/v1/uploadstudent
Upload student image to public/student directory (max 10MB) - Uses multipart/form-data
Parameters
student_id |
string (required) - Student ID (must exist in database) |
image |
file (required) - Image file (JPG, JPEG, PNG, GIF, WebP) |
Response
{
"success": "boolean", "message": "string", "data": "object with upload_id, student_id, filename, file_path, file_size, image_upload_status, uploaded_at"}
Example Request
curl -X POST \
"http://localhost:8080/api/v1/uploadstudent" \
-H "Authorization: Bearer {your_token}" \
-F "student_id=6601001234" \
-F "image=@/path/to/your/image.jpg"
GET
/api/v1/uploads
Get user upload history
Parameters
page |
integer (optional) |
per_page |
integer (optional) |
Response
{
"success": "boolean", "data": "array of uploads", "pagination": "object"}
Example Request
curl -X GET \
"http://localhost/api/v1/uploads" \
-H "Authorization: Bearer {your_token}"?"example_param=value"
Image Access
Public endpoints - No authentication required
GET
/images/{filename}
Get image file from uploads directory
Parameters
filename |
string (required) - Image filename with extension (jpg, jpeg, png, gif, svg) |
Response
{
"success": "Image file content or default.svg if not found", "headers": "
Warning: Array to string conversion in /www/wwwroot/cardApi.kimhun55.com/views/documentation.php on line 180
Array"}
Example Request
curl -X GET \
"http://localhost/images/{filename}" \
-H "Authorization: Bearer {your_token}"?"example_param=value"
Testing Tools
Quick Start Examples
curl -X POST "http://localhost/api/v1/auth/login" \
-H "Content-Type: application/json" \
-d '{
"email": "admin@example.com",
"password": "admin123"
}'
curl -X GET "http://localhost/api/v1/students/search?q=นาย&type=stu_fname&page=1&per_page=5" \
-H "Authorization: Bearer {your_token}"
curl -X POST "http://localhost/api/v1/upload" \
-H "Authorization: Bearer {your_token}" \
-F "student_id=6601001234" \
-F "image=@/path/to/student.jpg"
Deployment with Nginx
Docker Compose Setup
The application is configured to run with Nginx + PHP-FPM in Docker containers:
# Start all services
docker-compose up -d
# Check status
docker-compose ps
# View logs
docker-compose logs nginx
docker-compose logs php
- Nginx: Port 80 (http://localhost)
- PHP-FPM: Internal port 9000
- MySQL: Port 3306
- phpMyAdmin: Port 8081