API Endpoints Draft - Domenicko/medical-booking-system GitHub Wiki
API Endpoints Draft
1. API Overview
The Medical Booking System will use a REST API for communication between the React frontend and the backend.
The API will use HTTP methods such as:
- GET — retrieve data
- POST — create new data
- PUT/PATCH — update existing data
- DELETE — remove or cancel data
The main API base URL will be:
/api
The following endpoints represent the initial API design.
2. User Registration
Method
POST
URL
/api/auth/register
Purpose
Creates a new user account.
Request Body
{
"name": "Ana Bardanashvili",
"email": "[email protected]",
"password": "password123"
}
Expected Response
{
"message": "User registered successfully",
"user": {
"id": 1,
"name": "Ana Bardanashvili",
"email": "[email protected]"
}
}
3. User Login
Method
POST
URL
/api/auth/login
Purpose
Authenticates an existing user.
Request Body
{
"email": "[email protected]",
"password": "password123"
}
Expected Response
{
"message": "Login successful",
"user": {
"id": 1,
"name": "Ana Bardanashvili",
"email": "[email protected]"
}
}
After successful authentication, the backend will set the JWT authentication token in an HttpOnly cookie.
4. Get Doctors
Method
GET
URL
/api/doctors
Purpose
Returns a list of available doctors.
Expected Response
{
"doctors": [
{
"id": 1,
"name": "Nino Beridze",
"specialty": "Cardiologist",
"experience": 10
},
{
"id": 2,
"name": "Giorgi Maisuradze",
"specialty": "Dermatologist",
"experience": 7
}
]
}
This endpoint can later support filtering by medical specialty.
5. Get Doctor by ID
Method
GET
URL
/api/doctors/:id
Purpose
Returns detailed information about a specific doctor and available appointment slots.
Example URL
/api/doctors/1
Expected Response
{
"id": 1,
"name": "Nino Beridze",
"specialty": "Cardiologist",
"experience": 10,
"bio": "Cardiologist with 10 years of professional experience.",
"availableSlots": [
"2026-10-01T10:00:00",
"2026-10-01T11:00:00",
"2026-10-02T14:00:00"
]
}
6. Create Appointment
Method
POST
URL
/api/appointments
Purpose
Creates a new medical appointment for an authenticated user.
Request Body
{
"doctorId": 1,
"date": "2026-10-01",
"time": "10:00",
"reason": "Regular consultation"
}
Expected Response
{
"message": "Appointment booked successfully",
"appointment": {
"id": 101,
"doctorId": 1,
"date": "2026-10-01",
"time": "10:00",
"status": "confirmed"
}
}
This endpoint will require authentication.
7. Get User Appointments
Method
GET
URL
/api/appointments
Purpose
Returns the appointments belonging to the currently authenticated user.
Expected Response
{
"appointments": [
{
"id": 101,
"doctor": "Nino Beridze",
"specialty": "Cardiologist",
"date": "2026-10-01",
"time": "10:00",
"status": "confirmed"
}
]
}
This endpoint will require authentication.
8. Cancel Appointment
Method
DELETE
URL
/api/appointments/:id
Purpose
Cancels an existing appointment belonging to the authenticated user.
Example URL
/api/appointments/101
Expected Response
{
"message": "Appointment cancelled successfully"
}
This endpoint will require authentication.
9. API Endpoint Summary
Authentication
- POST
/api/auth/register - POST
/api/auth/login
Doctors
- GET
/api/doctors - GET
/api/doctors/:id
Appointments
- POST
/api/appointments - GET
/api/appointments - DELETE
/api/appointments/:id
The API design can be expanded during development if additional functionality is required.