http://localhost:8000 (development)
https://api.yourdomain.com (production)
POST /jobs/create
Content-Type: application/json
{
"user_id": "user-123",
"janitor_id": null,
"service_type": "house_cleaning",
"scheduled_date": "2025-11-20",
"scheduled_time": "10:00",
"address": "123 Main St, Ibadan",
"latitude": 7.3775,
"longitude": 3.9470,
"room_data": "[{\"room\":\"bedroom\",\"count\":3}]",
"extras": "{\"kitchen\":true,\"livingRoom\":false}",
"notes": "Please use hypoallergenic products"
}
Response:
{
"message": "Job created successfully",
"job": {
"id": "job-123",
"user_id": "user-123",
"status": "pending",
"payment_status": "unpaid",
"created_at": "2025-11-16T10:30:00Z"
}
}
POST /jobs/book-job
Content-Type: application/json
{
"user_id": "user-123",
"janitor_id": "janitor-456",
"service_type": "house_cleaning",
"scheduled_time": "2025-11-20 10:00",
"location": {
"city": "Ibadan",
"lat": 7.3775,
"lng": 3.9470,
"address_line": "123 Main St"
},
"metadata": {
"priceEstimate": 35000,
"breakdown": [
"Standard House Cleaning (3-4 rooms): β¦35,000",
"+ Kitchen Cleaning: β¦2,000"
],
"notes": "Handle with care",
"rooms": 3,
"toilets": 1
}
}
Response:
{
"message": "Job booked successfully",
"job": {
"id": "job-123",
"user_id": "user-123",
"janitor_id": "janitor-456",
"status": "confirmed",
"payment_status": "pending",
"created_at": "2025-11-16T10:30:00Z"
},
"success": true
}
GET /jobs/{job_id}
Response:
{
"id": "job-123",
"user_id": "user-123",
"janitor_id": "janitor-456",
"service_type": "house_cleaning",
"status": "confirmed",
"payment_status": "pending",
"address": "123 Main St, Ibadan",
"latitude": 7.3775,
"longitude": 3.9470,
"scheduled_date": "2025-11-20",
"scheduled_time": "10:00",
"created_at": "2025-11-16T10:30:00Z"
}
GET /jobs/user/{user_id}?status=pending
Query Parameters:
- status (optional): 'pending', 'confirmed', 'in_progress', 'completed', 'cancelled'
Response:
{
"jobs": [
{
"id": "job-123",
"service_type": "house_cleaning",
"status": "confirmed",
...
}
],
"count": 1
}
PATCH /jobs/{job_id}?status=in_progress&payment_status=paid
Query Parameters:
- status (optional): 'pending', 'confirmed', 'in_progress', 'completed', 'cancelled'
- payment_status (optional): 'unpaid', 'pending', 'paid', 'failed'
Response:
{
"message": "Job updated successfully",
"job": {
"id": "job-123",
"status": "in_progress",
"payment_status": "paid"
}
}
DELETE /jobs/{job_id}
Response:
{
"message": "Job deleted successfully",
"job_id": "job-123"
}
βββββββββββ
β pending β (Job created, awaiting janitor selection)
ββββββ¬βββββ
β
β
ββββββββββββ
βconfirmed β (Janitor assigned, awaiting payment)
ββββββ¬ββββββ
β
β
βββββββββββββββββ
β in_progress β (Janitor working on job)
ββββββ¬βββββββββββ
β
β
βββββββββββββ
β completed β (Job finished)
βββββββββββββ
Alternative: pending β cancelled (user cancels)
unpaid β pending β paid (completed)
β
failed (retry)
// Book a job
const bookJob = async () => {
const response = await fetch('${API_BASE}/jobs/book-job', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${accessToken}`
},
body: JSON.stringify({
user_id: userId,
janitor_id: selectedJanitorId,
service_type: 'house_cleaning',
scheduled_time: '2025-11-20 10:00',
location: { lat, lng, address_line },
metadata: { priceEstimate, breakdown, notes }
})
});
const data = await response.json();
if (!response.ok) throw new Error(data.detail);
return data.job;
};
// Get job status
const getJobStatus = async (jobId) => {
const response = await fetch(`${API_BASE}/jobs/${jobId}`, {
headers: { 'Authorization': `Bearer ${accessToken}` }
});
return response.json();
};
// Update job status
const updateJobStatus = async (jobId, newStatus) => {
const response = await fetch(
`${API_BASE}/jobs/${jobId}?status=${newStatus}`,
{
method: 'PATCH',
headers: { 'Authorization': `Bearer ${accessToken}` }
}
);
return response.json();
};
{
"detail": "Failed to create job"
}
{
"detail": "Job not found"
}
{
"detail": "Internal server error message"
}
house_cleaning - Regular house cleaning
deep_cleaning - Deep cleaning service
laundry - Laundry service
fumigation - Fumigation service
Headers
Content-Type: application/json
Authorization: Bearer <access_token>
GET /test-connection
Response:
{
"status": "ok",
"message": "Successfully connected to database",
"sample_data_count": 5
}
GET /
Response:
{
"status": "ok",
"message": "Hello from CoβJanitors backend"
}