User can login using this endpoint by entering their credentials and get back a JWT token
POST /api/user/login
{
data: {
email: String,
password: String
}
}
{
status: 200,
data: {
message: String,
token: String
}
}
{
status: Number {400 || 404 || 422 || 500},
data: {
message: String,
error: Object
}
}
User can register using this endpoint by entering their information and get back a JWT token
POST /api/user/register
{
data: {
name: String
email: String,
phoneNo: String,
password: String,
}
}
{
status: 201,
data: {
message: String,
token: String
}
}
{
status: Number {422 || 500},
data: {
message: String,
error: Object
}
}
Send logged in user's JWT token to get their profile details
GET /api/user
{
headers: {
Authorization: `Bearer ${token}`,
},
};
{
status: 200,
data: {
message: String,
user: Object
}
}
{
status: Number {404 || 500},
data: {
message: String,
error: Object
}
}
Get all the bookings of the currently logged in user
GET /api/user/bookings
{
headers: {
Authorization: `Bearer ${token}`,
}
}
{
status: 200,
data: {
message: String,
bookings: Object[]
}
}
{
status: Number {404 || 500},
data: {
message: String,
error: Object
}
}
Create a new booking
POST /api/bookings/
{
headers: {
Authorization: `Bearer ${token}`,
}
data: {
busId: String,
bookingDate: Date,
status: String,
source: String,
destination: String,
seatNo: Number,
amount: Number,
transactionID: String // OPTIONAL : It will store the transaction ID of the payment gateway
}
}
{
status: 201,
data: {
message: String,
booking: Object[]
}
}
{
status: Number {404 || 422 || 500},
data: {
message: String,
error: Object
}
}
Cancel a previous but not completed booking
PATCH /api/bookings/cancel/:bookingId
{
headers: {
Authorization: `Bearer ${token}`,
}
}
{
status: 200,
data: {
message: String,
}
}
{
status: Number {404 || 500},
data: {
message: String,
error: Object
}
}
Mark a booking as completed
PATCH /api/admin/bookings/complete/:bookingId
{
headers: {
Authorization: `Bearer ${token}`,
}
}
{
status: 200,
data: {
message: String,
}
}
{
status: Number {401 || 404 || 500},
data: {
message: String,
error: Object
}
}
Get all bookings that are yet to begin
{
GET /api/admin/bookings/upcoming
{
headers: {
Authorization: `Bearer ${token}`
},
}
}
{
status: 200,
data: {
message: String,
upcomingBookings: Object[]
}
}
{
status: Number {401 || 500},
data: {
message: String,
error: Object
}
}
Get all bookings that are completed
{
GET /api/admin/bookings/completed
{
headers: {
Authorization: `Bearer ${token}`
},
}
}
{
status: 200,
data: {
message: String,
completedBookings: Object[]
}
}
{
status: Number {401 || 500},
data: {
message: String,
error: Object
}
}
Get all bookings that have been cancelled
{
GET /api/admin/bookings/cancelled
{
headers: {
Authorization: `Bearer ${token}`
},
}
}
{
status: 200,
data: {
message: String,
cancelledBookings: Object[]
}
}
{
status: Number {402|| 500},
data: {
message: String,
error: Object
}
}
Get all bookings for a specific bus
{
GET /api/admin/bookings/bus/:busId
{
headers: {
Authorization: `Bearer ${token}`
},
}
}
{
status: 200,
data: {
message: String,
bookings: Object[]
}
}
{
status: Number {402 || 404 || 500},
data: {
message: String,
error: Object
}
}
Create a new coupon
POST /api/admin/coupons
headers: {
Authorization: `Bearer ${token}`
},
data: {
discountPercentage: Number,
validBefore: Date,
couponName: String,
}
}
{
status: 201,
data: {
message: String,
coupon: Object
}
}
{
status: Number {402 || 422 || 500},
data: {
message: String,
error: Object
}
}
Delete a coupon
DELETE /api/admin/coupons/:couponId
{
headers: {
Authorization: `Bearer ${token}`
},
}
{
status: 200,
data: {
message: String
}
}
{
status: Number {402 || 404|| 500},
data: {
message: String,
error: Object
}
}
Get all valid coupons
{
GET /api/coupons/
headers: {
Authorization: `Bearer ${token}`;
}
}
{
status: 200,
data: {
message: String,
coupons: Object[]
}
}
{
status: Number {402 || 500},
data: {
message: String,
error: Object
}
}
Add a new bus
POST /api/admin/bus
{
headers: {
Authorization: `Bearer ${token}`,
},
data: {
name: String,
busType: String,
cities: [{
cityName: String,
departureTime: Date
}],
numberOfSeats: Number,
dateOfTravel: Date
}
};
{
status: 201,
data: {
message: String,
bus: Object
}
}
{
status: Number {402 || 422 || 500},
data: {
message: String,
error: Object
}
}
Remove a bus
DELETE /api/admin/bus/:busId
{
headers: {
Authorization: `Bearer ${token}`,
},
};
{
status: 200,
data: {
message: String
}
}
{
status: Number {402 || 404 || 500},
data: {
message: String,
error: Object
}
}
Get all available buses for a journey
GET /api/bus
{
headers: {
Authorization: `Bearer ${token}`,
},
data: {
sourceCity: String,
destinationCity: String,
dateOfTravel: Date
}
};
{
status: 200,
data: {
message: String,
buses: Object[]
}
}
{
status: Number {404 || 422 || 500},
data: {
message: String,
error: Object
}
}