API: Get Specific Trip Instance

Request

Retrieve a specific trip instance by ID:

GET /trip-instances/{id}

Sample Request:

GET /trip-instances/4

Sample Response:


{
  "status": "success",
  "code": 200,
  "message": "Trip instance retrieved successfully",
  "data": {
    "trip_instance": {
      "id": 4,
      "coach_id": 2,
      "bus_id": 1,
      "schedule_id": 1,
      "seat_plan_id": 1,
      "route_id": 1,
      "coach_type": 1,
      "driver_id": null,
      "supervisor_id": null,
      "trip_date": "2025-09-18T00:00:00.000000Z",
      "status": 1,
      "migrated_trip_id": null,
      "created_by": 2,
      "updated_by": null,
      "migrated_by": null,
      "created_at": "2025-08-14T10:24:12.000000Z",
      "updated_at": "2025-08-14T10:24:12.000000Z",
      "coach": {
        "id": 2,
        "coach_no": "101",
        "seat_plan_id": 1,
        "coach_type": "1",
        "status": 1
      },
      "bus": {
        "id": 1,
        "registration_number": "123",
        "manufacturer_company": "ad",
        "model_year": 2000,
        "chasis_no": "sad",
        "engine_number": "asd"
      },
      "schedule": {
        "id": 1,
        "name": "11:00",
        "status": 0
      },
      "seat_plan": {
        "id": 1,
        "name": "Bus A",
        "floor": 1,
        "rows": null,
        "cols": null,
        "layout_type": null,
        "floors": [
            {
                "id": 1,
                "seat_plan_id": 1,
                "name": "Lower",
                "layout_type": "2-2",
                "rows": 3,
                "cols": 4,
                "step": 2,
                "is_extra_seat": 1,
            }
        ],
      },
      "route": {
        "id": 1,
        "start_id": 2,
        "end_id": 2,
        "distance": 1300,
        "duration": "02:45",
        "status": "1"
      },
      "driver": null,
      "supervisor": null,
      "migrated_trip": null,
      "creator": {
        "id": 2,
        "user_name": "john_doe",
        "first_name": "John",
        "last_name": "Doe",
        "email": "john@example.com",
        "mobile": "1234567890"
      },
      "updater": null,
      "migrator": null,
      "seat_inventory": [
        {
          "id": 148,
          "seat_id": 1,
          "booking_status": 1,
          "blocked_until": null,
          "booking_id": null,
          "last_locked_user_id": null,
          "seat_plan_floor_id": "1",
          "seat_number": "1A",
          "row_position": 1,
          "col_position": 1,
          "seat_type": "regular",
          "is_disable": 0
        },
        {
          "id": 150,
          "seat_id": 2,
          "booking_status": 1,
          "blocked_until": null,
          "booking_id": null,
          "last_locked_user_id": null,
          "seat_plan_floor_id": "1",
          "seat_number": "1B",
          "row_position": 1,
          "col_position": 2,
          "seat_type": "regular",
          "is_disable": 0
        },
        {
          "id": 152,
          "seat_id": 3,
          "booking_status": 1,
          "blocked_until": null,
          "booking_id": null,
          "last_locked_user_id": null,
          "seat_plan_floor_id": "1",
          "seat_number": "1C",
          "row_position": 1,
          "col_position": 3,
          "seat_type": "VIP",
          "is_disable": 0
        }
      ]
    },
    "partition_info": {
      "current_table": "trip_instances_202509",
      "trip_date": "2025-09-18",
      "partition_month": "2025-09",
      "seat_inventory_auto_created": false,
      "seat_inventory_count": 24
    }
  }
}
                

Response Components:

  • trip_instance - Complete trip details with all related data
  • Related Objects - Includes coach, bus, schedule, seat_plan, route details
  • Staff Information - Driver and supervisor details (if assigned)
  • User Tracking - Creator, updater, and migrator user information
  • seat_inventory - Complete seat inventory with booking status and seat details
  • partition_info - Database partition information and seat inventory metadata

Seat Inventory Details:

  • booking_status - 1 = Available, 2 = Booked, 3 = Blocked
  • seat_type - regular, VIP, premium, etc.
  • seat_number - Human-readable seat identifier
  • row_position, col_position - Physical position in the bus layout
  • blocked_until - Timestamp until which seat is temporarily blocked
  • booking_id - Reference to booking if seat is booked
  • last_locked_user_id - User who last locked the seat for booking

Partition Information:

  • current_table - The specific partition table being used
  • partition_month - Month-year partition identifier
  • seat_inventory_auto_created - Whether seat inventory was automatically created
  • seat_inventory_count - Total number of seats in the inventory

Notes:

  • The trip instance ID is required in the URL to specify which trip to retrieve.
  • If the trip instance does not exist, the API will return a 404 error.
  • The response includes complete seat inventory for booking management.
  • Partition information helps understand the underlying data storage structure.
  • All related objects are loaded for comprehensive trip management.