API: Get Specific Fare

Request

Retrieve a specific fare by ID:

GET /fares/{id}

Sample Response:


{
  "status": "success",
  "message": "Fare retrieved successfully",
  "data": {
    "id": 1,
    "route_id": 1,
    "start_id": 1,
    "end_id": 2,
    "start_name": "Dhaka",
    "end_name": "Chittagong",
    "distance": 244,
    "duration": "5:30",
    "route_status": 1,
    "seat_plan_id": 1,
    "seat_plan_name": "AC Business",
    "coach_type": 1,
    "seat_type": "Business Class",
    "from_date": "2024-01-01",
    "to_date": "2024-12-31",
    "amount": 1500,
    "status": 1,
    "created_by": 1,
    "updated_by": 1,
    "created_at": "2024-01-01T12:00:00",
    "updated_at": "2024-01-01T12:00:00",
    "deleted_at": null
  }
}
                

Response Details:

  • Route Information - Includes start/end districts, distance, and duration
  • Seat Plan - Shows the associated seat plan name and ID
  • Coach Type - 1 for AC, 2 for Non-AC
  • Seat Type - Class of service (Suite Class, Business Class, Sleeper, Economy)
  • Amount - Fare price in smallest currency unit
  • Validity Period - from_date and to_date show when the fare is valid

Field Descriptions:

Field Type Description
seat_type String Service class: Suite Class, Business Class, Sleeper, Economy
amount Integer Fare price in smallest currency unit (e.g., cents)
coach_type Integer 1 = AC (Air Conditioned), 2 = Non-AC
from_date Date Start date of fare validity (null = no start limit)
to_date Date End date of fare validity (null = no end limit)

Use Cases:

  • Fare Details - Get complete pricing information for booking
  • Route Planning - Check fare details for specific routes
  • Price Display - Show detailed fare breakdown to customers
  • Validation - Verify fare exists before processing bookings

Notes:

  • The fare ID is required in the URL to specify which fare to retrieve.
  • If the fare does not exist or has been deleted, the API will return a 404 error.
  • The response includes joined data from related tables (routes, districts, seat_plans).
  • Amount represents the fare price in the smallest currency unit for precision.
  • Seat type determines the service level and amenities provided.