AbuSafar API (v1.0.0)

Download OpenAPI specification:Download

License: Apache 2.0

A comprehensive transportation booking platform API.

Booking History

APIs for viewing user reservation history

Get User's Reservation History

Retrieves a list of all reservations made by the currently authenticated user. Can be filtered by status.

Authorizations:
bearerAuth
query Parameters
status
string
Enum: "UPCOMING_TRIP" "PAST_TRIP" "CANCELLED" "PENDING_PAYMENT"

Optional filter to get reservations by a specific status (e.g., UPCOMING_TRIP, PAST_TRIP, CANCELLED).

Responses

Location Information

APIs for retrieving location data like countries, provinces, and cities

Get Cities

Retrieves a list of all available cities. If a 'name' query parameter is provided, it searches for locations matching that specific city name.

Authorizations:
bearerAuth
query Parameters
name
string

Optional. The name of the city to search for.

Responses

User Authentication

APIs for user sign-up and login

Register a New User

Creates a new user account. Requires either an email or a phone number.

Authorizations:
bearerAuth
Request Body schema: application/json
firstName
required
string^[A-Za-z ''-]{1,100}$
lastName
required
string^[A-Za-z ''-]{1,100}$
city
required
string [ 0 .. 100 ] characters
password
required
string [ 8 .. 2147483647 ] characters
email
string
phoneNumber
string^\+?[1-9][0-9\s().-]{7,20}$

Responses

Request samples

Content type
application/json
{
  • "firstName": "string",
  • "lastName": "string",
  • "city": "string",
  • "password": "stringst",
  • "email": "string",
  • "phoneNumber": "string"
}

Verify OTP and Login

Verifies the provided OTP and, if valid, returns a JWT access token and user information to complete the login process.

Authorizations:
bearerAuth
Request Body schema: application/json
contactInfo
required
string
otp
required
string [ 4 .. 6 ] characters

Responses

Request samples

Content type
application/json
{
  • "contactInfo": "string",
  • "otp": "string"
}

Request OTP for Login

Requests a One-Time Password (OTP) to be sent to the user's registered email or phone number for passwordless login.

Authorizations:
bearerAuth
Request Body schema: application/json
contactInfo
required
string

Responses

Request samples

Content type
application/json
{
  • "contactInfo": "string"
}

Select a specific ticket to view details

Public endpoint to retrieve the full details for a single ticket, including vehicle-specific information and services, before a user commits to booking.

Authorizations:
bearerAuth
Request Body schema: application/json
trip_id
required
integer <int64>
ageCategory
required
string
Enum: "ADULT" "CHILD" "BABY"

Responses

Request samples

Content type
application/json
{
  • "trip_id": 0,
  • "ageCategory": "ADULT"
}

Search for available tickets

Public endpoint to search for one-way tickets based on criteria like origin, destination, date, and vehicle type. Authentication is not required.

Authorizations:
bearerAuth
Request Body schema: application/json
originCity
required
string
originProvince
string
originCountry
string
destinationCity
required
string
destinationProvince
string
destinationCountry
string
departureDate
required
string <date>
object (LocalTime)
vehicleCompany
string
tripVehicle
required
string
Enum: "TRAIN" "BUS" "FLIGHT"
ageCategory
string
Enum: "ADULT" "CHILD" "BABY"
minPrice
number
maxPrice
number
busClass
string
Enum: "VIP" "STANDARD" "SLEEPER"
flightClass
string
Enum: "ECONOMY_CLASS" "BUSINESS_CLASS" "FIRST_CLASS"
trainStars
integer <int32>

Responses

Request samples

Content type
application/json
{
  • "originCity": "string",
  • "originProvince": "string",
  • "originCountry": "string",
  • "destinationCity": "string",
  • "destinationProvince": "string",
  • "destinationCountry": "string",
  • "departureDate": "2019-08-24",
  • "departureTime": {
    },
  • "vehicleCompany": "string",
  • "tripVehicle": "TRAIN",
  • "ageCategory": "ADULT",
  • "minPrice": 0,
  • "maxPrice": 0,
  • "busClass": "VIP",
  • "flightClass": "ECONOMY_CLASS",
  • "trainStars": 0
}

Payment Processing

APIs for processing payments for reservations

Process Payment for a Reservation

Processes the payment for a reserved booking using the specified payment method (e.g., WALLET, CARD). On success, this finalizes the booking and updates the reservation status to 'PAID'.

Authorizations:
bearerAuth
Request Body schema: application/json
reservationId
required
integer <int64>
paymentMeans
required
string
Enum: "CARD" "WALLET" "CRYPTO"

Responses

Request samples

Content type
application/json
{
  • "reservationId": 0,
  • "paymentMeans": "CARD"
}

Ticket Reservation

APIs for creating one-way and two-way reservations

Create a Two-Way (Round-Trip) Reservation

Initiates a new two-way reservation for an outgoing and return ticket. Expects an array of two ticket selections. This holds the tickets for 10 minutes, awaiting payment.

Authorizations:
bearerAuth
Request Body schema: application/json
Array
trip_id
required
integer <int64>
ageCategory
required
string
Enum: "ADULT" "CHILD" "BABY"

Responses

Request samples

Content type
application/json
[
  • {
    }
]

Create a One-Way Reservation

Initiates a new one-way reservation for a single selected ticket. This holds the ticket for 10 minutes, awaiting payment.

Authorizations:
bearerAuth
Request Body schema: application/json
trip_id
required
integer <int64>
ageCategory
required
string
Enum: "ADULT" "CHILD" "BABY"

Responses

Request samples

Content type
application/json
{
  • "trip_id": 0,
  • "ageCategory": "ADULT"
}

User Reports

APIs for submitting user feedback and reports

Submit a New Report

Allows an authenticated user to submit a report related to a reservation or ticket. The report is then reviewable by an admin.

Authorizations:
bearerAuth
Request Body schema: application/json
linkType
required
string
Enum: "RESERVATION" "TICKET"
linkId
required
integer <int64>
topic
required
string [ 0 .. 100 ] characters
content
required
string

Responses

Request samples

Content type
application/json
{
  • "linkType": "RESERVATION",
  • "linkId": 0,
  • "topic": "string",
  • "content": "string"
}

Admin Management

Endpoints for administrative operations

Change a Passenger's Seat Number

Updates the seat number for a specific ticket leg within a reservation.

Authorizations:
bearerAuth
Request Body schema: application/json
reservationId
required
integer <int64>
tripId
required
integer <int64>
newSeatNumber
required
integer <int32>

Responses

Request samples

Content type
application/json
{
  • "reservationId": 0,
  • "tripId": 0,
  • "newSeatNumber": 0
}

Cancel a Reservation (Admin)

Forcefully cancels a reservation on behalf of a user. The logged-in admin's ID is recorded as the canceller.

Authorizations:
bearerAuth
path Parameters
reservationId
required
integer <int64>

The unique ID of the reservation to cancel.

Responses

Get Reservation Details by ID

Fetches the detailed information for a specific reservation, including ticket details.

Authorizations:
bearerAuth
path Parameters
reservationId
required
integer <int64>

The unique ID of the reservation.

Responses

Get All Cancelled Reservations

Retrieves a list of all reservations with the status 'CANCELLED'.

Authorizations:
bearerAuth

Responses

Get All User Reports

Retrieves a list of all reports submitted by users.

Authorizations:
bearerAuth

Responses

Get Report by ID

Fetches a single report by its unique ID.

Authorizations:
bearerAuth
path Parameters
reportId
required
integer <int64>

The unique ID of the report.

Responses

Get All Reports for a Specific User

Retrieves all reports submitted by a specific user, identified by their user ID.

Authorizations:
bearerAuth
path Parameters
userId
required
integer <int64>

The unique ID of the user.

Responses

Get Payment Details by ID

Fetches the full details of a single payment record by its unique ID.

Authorizations:
bearerAuth
path Parameters
paymentId
required
integer <int64>

The unique ID of the payment record.

Responses

Booking Cancellation

APIs for calculating penalties and cancelling reservations

Confirm and Process Reservation Cancellation

Processes the cancellation of a reservation. This is the final step and is irreversible. It updates the reservation status and refunds the user to their wallet after deducting penalties.

Authorizations:
bearerAuth
Request Body schema: application/json
reservationId
required
integer <int64>

Responses

Request samples

Content type
application/json
{
  • "reservationId": 0
}

Calculate Cancellation Penalty

Calculates the penalty fee and total refund amount for cancelling a reservation without actually performing the cancellation. Useful for showing the user the cost beforehand.

Authorizations:
bearerAuth
Request Body schema: application/json
reservationId
required
integer <int64>

Responses

Request samples

Content type
application/json
{
  • "reservationId": 0
}

User Profile

APIs for managing the authenticated user's profile

Update User Profile

Allows an authenticated user to update their own profile information, such as name, city, and contact details.

Authorizations:
bearerAuth
Request Body schema: application/json
firstName
string [ 0 .. 100 ] characters
lastName
string [ 0 .. 100 ] characters
city
string [ 0 .. 100 ] characters
email
string
phoneNumber
string^\+?[1-9][0-9\s().-]{7,20}$
birthdayDate
string <date>

Responses

Request samples

Content type
application/json
{
  • "firstName": "string",
  • "lastName": "string",
  • "city": "string",
  • "email": "string",
  • "phoneNumber": "string",
  • "birthdayDate": "2019-08-24"
}