http://localhost:8000/api/v1
Protected routes use JWT-based auth with HTTP-only cookies and/or Authorization header. Include the header if using bearer tokens directly:
Authorization: Bearer <jwt_token>
Otherwise, authenticate via the login endpoint to receive a cookie and call APIs with withCredentials: true from the client.
- GET
/health - Description: Check if server is running
- Auth: None
- Request: None
- Response:
{
"message": "Server is running!"
}- POST
/users - Description: Register a new user
- Auth: None
- Request Body:
{
"name": "John Doe",
"mobileNo": "9876543210",
"email": "john@example.com",
"address": "123 Main St",
"pinCode": "12345",
"dob": "1990-01-01",
"gender": "male",
"liveLocation": {
"lat": 28.6139,
"lng": 77.2090
},
"profileImg": "https://example.com/image.jpg"
}- Response:
{
"message": "User profile created successfully",
"user": {
"_id": "user_id",
"name": "John Doe",
"email": "john@example.com",
"role": "user",
"createdAt": "2024-01-01T00:00:00.000Z"
}
}- PUT
/users - Description: Update user profile information
- Auth: Required
- Request Body:
{
"name": "John Smith",
"address": "456 New St",
"pinCode": "54321"
}- Response:
{
"message": "User details updated successfully",
"user": {
"_id": "user_id",
"name": "John Smith",
"email": "john@example.com",
"address": "456 New St"
}
}- POST
/vendors - Description: Register a new vendor
- Auth: None
- Request Body:
{
"name": "ABC Services",
"mobileNo": "9876543210",
"email": "vendor@example.com",
"address": "789 Service St",
"pinCode": "12345",
"dob": "1985-01-01",
"gender": "male",
"liveLocation": {
"lat": 28.6139,
"lng": 77.2090
},
"toolsAvailable": ["Hammer", "Drill", "Screwdriver"],
"experience": 5,
"aadhar": "123456789012",
"paymentInfo": {
"accountNo": "1234567890",
"ifsc": "SBIN0001234",
"upiId": "vendor@paytm"
},
"imageUri": "https://example.com/vendor.jpg"
}- Response:
{
"message": "Vendor profile created successfully",
"vendor": {
"_id": "vendor_id",
"name": "ABC Services",
"email": "vendor@example.com",
"role": "vendor",
"isVerify": false,
"createdAt": "2024-01-01T00:00:00.000Z"
}
}- PUT
/vendors - Description: Update vendor profile information
- Auth: Required
- Request Body:
{
"name": "ABC Services Ltd",
"address": "999 Updated St",
"experience": 7,
"toolsAvailable": ["Hammer", "Drill", "Screwdriver", "Wrench"]
}- Response:
{
"message": "Vendor details updated successfully",
"vendor": {
"_id": "vendor_id",
"name": "ABC Services Ltd",
"address": "999 Updated St",
"experience": 7
}
}- GET
/services - Description: Get all available services
- Auth: None
- Query Parameters:
page(optional): Page number (default: 1)limit(optional): Items per page (default: 10)serviceType(optional): Filter by service typevendorId(optional): Filter by vendor IDcategory(optional): Filter by top-level category (e.g., Cleaning, Grooming)popular(optional):trueto return only popular servicespremium(optional):trueto return only premium services
- Response:
{
"services": [
{
"_id": "service_id",
"serviceName": "Plumbing Repair",
"serviceType": "Plumbing",
"rating": 4.5,
"imageUrl": "https://example.com/service.jpg",
"description": "Professional plumbing services",
"vendorId": {
"_id": "vendor_id",
"name": "ABC Services",
"rating": 4.2,
"isVerify": true,
"experience": 5
}
}
],
"totalPages": 5,
"currentPage": 1,
"total": 50
}- GET
/services/search - Description: Search services by name or description
- Auth: None
- Query Parameters:
q(optional): Search queryserviceType(optional): Filter by service typecategory(optional): Filter by categorypopular(optional):trueto restrict to popularpremium(optional):trueto restrict to premiumminRating(optional): Minimum rating filterpage(optional): Page numberlimit(optional): Items per page
- Response: Same as Get All Services
- GET
/services/categories - Description: Get distinct list of service categories
- Auth: None
- Response:
{
"categories": ["Cleaning", "Grooming", "Repair"]
}- GET
/services/home-sections - Description: Aggregated lists for homepage sections
- Auth: None
- Query Parameters:
limit(optional): Items per section (default: 8)
- Response:
{
"popular": [{"_id": "...", "serviceName": "...", "price": 0 }],
"premium": [{"_id": "..."}],
"mostBooked": [{"_id": "...", "bookingCount": 12 }]
}- GET
/services/suggestions - Description: Suggest service names based on query substring
- Auth: None
- Query Parameters:
q(required): Query text
- Response:
{
"suggestions": [
{ "id": "<serviceId>", "name": "<serviceName>", "price": 999 }
]
}- GET
/services/:id - Description: Get detailed service information
- Auth: None
- Response:
{
"service": {
"_id": "service_id",
"serviceName": "Plumbing Repair",
"serviceType": "Plumbing",
"toolsRequired": ["Wrench", "Pipe"],
"rating": 4.5,
"reviews": [
{
"userId": {
"name": "John Doe"
},
"comment": "Great service!",
"rating": 5,
"createdAt": "2024-01-01T00:00:00.000Z"
}
],
"imageUrl": "https://example.com/service.jpg",
"description": "Professional plumbing services",
"location": {
"lat": 28.6139,
"lng": 77.2090
},
"vendorId": {
"_id": "vendor_id",
"name": "ABC Services",
"email": "vendor@example.com",
"mobileNo": "9876543210",
"imageUri": "https://example.com/vendor.jpg",
"rating": 4.2,
"isVerify": true,
"experience": 5,
"toolsAvailable": ["Hammer", "Drill"]
}
}
}- GET
/services/vendor/:vendorId - Description: Get all services offered by a specific vendor
- Auth: None
- Query Parameters:
page(optional): Page numberlimit(optional): Items per page
- Response:
{
"services": [
{
"_id": "service_id",
"serviceName": "Plumbing Repair",
"serviceType": "Plumbing",
"rating": 4.5
}
],
"vendor": {
"name": "ABC Services",
"rating": 4.2,
"isVerify": true,
"experience": 5
},
"totalPages": 2,
"currentPage": 1,
"total": 15
}- POST
/bookings - Description: Create a new service booking
- Auth: Required (User)
- Request Body:
{
"vendorId": "vendor_id",
"serviceId": "service_id",
"serviceDate": "2024-01-15",
"serviceTime": "10:00 AM",
"address": "123 Customer St",
"location": {
"lat": 28.6139,
"lng": 77.2090
},
"price": 500,
"description": "Fix leaking pipe",
"specialInstructions": "Please call before coming",
"paymentMethod": "cash"
}- Response:
{
"message": "Booking created successfully",
"booking": {
"_id": "booking_id",
"userId": {
"_id": "user_id",
"name": "John Doe",
"email": "john@example.com",
"mobileNo": "9876543210"
},
"vendorId": {
"_id": "vendor_id",
"name": "ABC Services",
"email": "vendor@example.com",
"mobileNo": "9876543210"
},
"serviceId": {
"_id": "service_id",
"serviceName": "Plumbing Repair",
"serviceType": "Plumbing"
},
"bookingDate": "2024-01-01T00:00:00.000Z",
"serviceDate": "2024-01-15T00:00:00.000Z",
"serviceTime": "10:00 AM",
"address": "123 Customer St",
"status": "pending",
"price": 500,
"paymentMethod": "cash"
}
}Note: On successful booking creation, the system increments the associated Service's
bookingCount. This powers the "Most Booked" homepage section over time.
- GET
/bookings/user - Description: Get all bookings for the authenticated user
- Auth: Required (User)
- Query Parameters:
page(optional): Page numberlimit(optional): Items per pagestatus(optional): Filter by status (pending, accepted, rejected, completed, cancelled)
- Response:
{
"bookings": [
{
"_id": "booking_id",
"vendorId": {
"_id": "vendor_id",
"name": "ABC Services",
"email": "vendor@example.com",
"mobileNo": "9876543210",
"imageUri": "https://example.com/vendor.jpg",
"rating": 4.2
},
"serviceId": {
"_id": "service_id",
"serviceName": "Plumbing Repair",
"serviceType": "Plumbing",
"imageUrl": "https://example.com/service.jpg"
},
"serviceDate": "2024-01-15T00:00:00.000Z",
"serviceTime": "10:00 AM",
"status": "pending",
"price": 500,
"createdAt": "2024-01-01T00:00:00.000Z"
}
],
"totalPages": 3,
"currentPage": 1,
"total": 25
}- GET
/bookings/vendor - Description: Get all bookings/orders for the authenticated vendor
- Auth: Required (Vendor)
- Query Parameters:
page(optional): Page numberlimit(optional): Items per pagestatus(optional): Filter by status
- Response:
{
"bookings": [
{
"_id": "booking_id",
"userId": {
"_id": "user_id",
"name": "John Doe",
"email": "john@example.com",
"mobileNo": "9876543210"
},
"serviceId": {
"_id": "service_id",
"serviceName": "Plumbing Repair",
"serviceType": "Plumbing",
"imageUrl": "https://example.com/service.jpg"
},
"serviceDate": "2024-01-15T00:00:00.000Z",
"serviceTime": "10:00 AM",
"status": "pending",
"price": 500,
"createdAt": "2024-01-01T00:00:00.000Z"
}
],
"totalPages": 2,
"currentPage": 1,
"total": 15
}- PUT
/bookings/:id/accept - Description: Accept a pending booking (Vendor)
- Auth: Required (Vendor)
- Request Body:
{
"vendorNotes": "Will arrive on time with all tools"
}- Response:
{
"message": "Booking accepted successfully",
"booking": {
"_id": "booking_id",
"status": "accepted",
"vendorNotes": "Will arrive on time with all tools"
}
}- PUT
/bookings/:id/reject - Description: Reject a pending booking (Vendor)
- Auth: Required (Vendor)
- Request Body:
{
"cancellationReason": "Not available on requested date"
}- Response:
{
"message": "Booking rejected successfully",
"booking": {
"_id": "booking_id",
"status": "rejected",
"cancellationReason": "Not available on requested date",
"cancelledBy": "vendor"
}
}- PUT
/bookings/:id/complete - Description: Mark booking as completed (Vendor)
- Auth: Required (Vendor)
- Request Body: None
- Response:
{
"message": "Booking completed successfully",
"booking": {
"_id": "booking_id",
"status": "completed",
"completionDate": "2024-01-15T12:00:00.000Z"
}
}- PUT
/bookings/:id/cancel - Description: Cancel a booking (User)
- Auth: Required (User)
- Request Body:
{
"cancellationReason": "Change of plans"
}- Response:
{
"message": "Booking cancelled successfully",
"booking": {
"_id": "booking_id",
"status": "cancelled",
"cancellationReason": "Change of plans",
"cancelledBy": "user"
}
}- PUT
/bookings/:id/rate - Description: Add rating and review for completed booking (User)
- Auth: Required (User)
- Request Body:
{
"rating": 5,
"review": "Excellent service! Very professional."
}- Response:
{
"message": "Rating and review added successfully",
"booking": {
"_id": "booking_id",
"rating": 5,
"review": "Excellent service! Very professional."
}
}- GET
/admin/dashboard - Description: Get admin dashboard statistics
- Auth: Required (Admin)
- Response:
{
"stats": {
"totalUsers": 150,
"totalVendors": 25,
"totalServices": 100,
"totalBookings": 500,
"pendingBookings": 15,
"completedBookings": 400,
"verifiedVendors": 20
},
"recentBookings": [
{
"_id": "booking_id",
"userId": {
"name": "John Doe"
},
"vendorId": {
"name": "ABC Services"
},
"serviceId": {
"serviceName": "Plumbing Repair"
},
"status": "completed",
"createdAt": "2024-01-01T00:00:00.000Z"
}
]
}- GET
/admin/users - Description: Get all users with pagination
- Auth: Required (Admin)
- Query Parameters:
page(optional): Page numberlimit(optional): Items per pagerole(optional): Filter by role
- Response:
{
"users": [
{
"_id": "user_id",
"name": "John Doe",
"email": "john@example.com",
"mobileNo": "9876543210",
"role": "user",
"createdAt": "2024-01-01T00:00:00.000Z"
}
],
"totalPages": 10,
"currentPage": 1,
"total": 100
}- POST
/admin/users - Description: Create a new user (Admin)
- Auth: Required (Admin)
- Request Body: Same as user registration + optional
rolefield - Response: Same as user registration
- DELETE
/admin/users/:id - Description: Delete a user
- Auth: Required (Admin)
- Response:
{
"message": "User deleted successfully"
}- GET
/admin/vendors - Description: Get all vendors with pagination
- Auth: Required (Admin)
- Query Parameters:
page(optional): Page numberlimit(optional): Items per pageisVerify(optional): Filter by verification status
- Response:
{
"vendors": [
{
"_id": "vendor_id",
"name": "ABC Services",
"email": "vendor@example.com",
"mobileNo": "9876543210",
"isVerify": true,
"rating": 4.2,
"experience": 5,
"createdAt": "2024-01-01T00:00:00.000Z"
}
],
"totalPages": 5,
"currentPage": 1,
"total": 50
}- POST
/admin/vendors - Description: Create a new vendor (Admin)
- Auth: Required (Admin)
- Request Body: Same as vendor registration + optional
isVerifyfield - Response: Same as vendor registration
- DELETE
/admin/vendors/:id - Description: Delete a vendor
- Auth: Required (Admin)
- Response:
{
"message": "Vendor deleted successfully"
}- GET
/admin/services - Description: Get all services with pagination
- Auth: Required (Admin)
- Query Parameters:
page(optional): Page numberlimit(optional): Items per pageserviceType(optional): Filter by service type
- Response:
{
"services": [
{
"_id": "service_id",
"serviceName": "Plumbing Repair",
"serviceType": "Plumbing",
"rating": 4.5,
"vendorId": {
"_id": "vendor_id",
"name": "ABC Services",
"email": "vendor@example.com",
"mobileNo": "9876543210"
},
"createdAt": "2024-01-01T00:00:00.000Z"
}
],
"totalPages": 10,
"currentPage": 1,
"total": 100
}- POST
/admin/services - Description: Create a new service
- Auth: Required (Admin)
- Request Body:
{
"serviceName": "Electrical Repair",
"vendorId": "vendor_id",
"serviceType": "Electrical",
"toolsRequired": ["Multimeter", "Wire Stripper"],
"imageUrl": "https://example.com/service.jpg",
"description": "Professional electrical services",
"location": {
"lat": 28.6139,
"lng": 77.2090
}
}- Response:
{
"message": "Service created successfully",
"service": {
"_id": "service_id",
"serviceName": "Electrical Repair",
"serviceType": "Electrical",
"vendorId": "vendor_id"
}
}- PUT
/admin/services/:id - Description: Update service details
- Auth: Required (Admin)
- Request Body: Any service fields to update
- Response:
{
"message": "Service updated successfully",
"service": {
"_id": "service_id",
"serviceName": "Updated Service Name"
}
}- DELETE
/admin/services/:id - Description: Delete a service
- Auth: Required (Admin)
- Response:
{
"message": "Service deleted successfully"
}- GET
/admin/bookings - Description: Get all bookings with pagination
- Auth: Required (Admin)
- Query Parameters:
page(optional): Page numberlimit(optional): Items per pagestatus(optional): Filter by statusvendorId(optional): Filter by vendoruserId(optional): Filter by user
- Response:
{
"bookings": [
{
"_id": "booking_id",
"userId": {
"_id": "user_id",
"name": "John Doe",
"email": "john@example.com",
"mobileNo": "9876543210"
},
"vendorId": {
"_id": "vendor_id",
"name": "ABC Services",
"email": "vendor@example.com",
"mobileNo": "9876543210"
},
"serviceId": {
"_id": "service_id",
"serviceName": "Plumbing Repair",
"serviceType": "Plumbing"
},
"status": "completed",
"price": 500,
"createdAt": "2024-01-01T00:00:00.000Z"
}
],
"totalPages": 20,
"currentPage": 1,
"total": 200
}- PUT
/admin/bookings/:id/status - Description: Update booking status
- Auth: Required (Admin)
- Request Body:
{
"status": "completed",
"cancellationReason": "Optional reason if cancelling"
}- Response:
{
"message": "Booking status updated successfully",
"booking": {
"_id": "booking_id",
"status": "completed"
}
}- DELETE
/admin/bookings/:id - Description: Delete a booking
- Auth: Required (Admin)
- Response:
{
"message": "Booking deleted successfully"
}{
"message": "Operation successful",
"data": { ... }
}{
"message": "Error description",
"error": "Detailed error message"
}{
"data": [...],
"totalPages": 10,
"currentPage": 1,
"total": 100
}For all protected routes, include:
Authorization: Bearer <clerk_jwt_token>
- Date Format: Use ISO 8601 format (YYYY-MM-DDTHH:mm:ss.sssZ)
- Pagination: All list endpoints support pagination with
pageandlimitparameters - Filtering: Most list endpoints support filtering via query parameters
- Error Handling: Always check for error responses and handle them appropriately
- Loading States: Implement loading states for all API calls
- Validation: Client-side validation should match server-side requirements
- File Uploads: For image uploads, use multipart/form-data format
- Real-time Updates: Consider implementing WebSocket connections for real-time booking updates
- Set up Clerk authentication in your frontend
- Configure the base API URL
- Implement error handling and loading states
- Test all endpoints with proper authentication
- Implement proper form validation
- Add proper TypeScript interfaces for all API responses