> ## Documentation Index
> Fetch the complete documentation index at: https://rideshare.docs.sumit-dhondikar.in/llms.txt
> Use this file to discover all available pages before exploring further.

# Ride History

> Retrieve all rides associated with the authenticated user.

Fetch the complete ride history for the authenticated user. The response includes rides where the user participated as either a rider or a driver.

**Authentication required** — include `Authorization: Bearer <token>` in the request header.

## Request

**`GET /rides/history`**

No query parameters.

## Response

An array of Ride objects. Each object contains the full ride record.

<ResponseField name="id" type="number">
  Unique ride identifier.
</ResponseField>

<ResponseField name="status" type="string">
  Final or current status of the ride. One of `REQUESTED`, `ACCEPTED`, `PICKED`, `COMPLETED`, `CANCELLED`.
</ResponseField>

<ResponseField name="riderId" type="number">
  ID of the rider.
</ResponseField>

<ResponseField name="driverId" type="number">
  ID of the driver, or `null` if the ride was never accepted.
</ResponseField>

<ResponseField name="pickupLocation" type="string">
  Human-readable pickup address.
</ResponseField>

<ResponseField name="dropLocation" type="string">
  Human-readable drop-off address.
</ResponseField>

<ResponseField name="pickupLat" type="number">
  Pickup latitude.
</ResponseField>

<ResponseField name="pickupLon" type="number">
  Pickup longitude.
</ResponseField>

<ResponseField name="dropLat" type="number">
  Drop-off latitude.
</ResponseField>

<ResponseField name="dropLon" type="number">
  Drop-off longitude.
</ResponseField>

<ResponseField name="fare" type="number">
  Fare for the ride.
</ResponseField>

<ResponseField name="paymentMode" type="string">
  Payment method used (e.g., `CASH`, `CARD`, `WALLET`).
</ResponseField>

<ResponseField name="paymentStatus" type="string">
  Current payment status.
</ResponseField>

<ResponseField name="riderRating" type="number">
  Rating the rider submitted (1–5), or `null` if no feedback was given.
</ResponseField>

<ResponseField name="riderFeedback" type="string">
  Written feedback from the rider, or `null`.
</ResponseField>

<ResponseField name="cancellationReason" type="string">
  Reason for cancellation, or `null` if the ride was not cancelled.
</ResponseField>

<ResponseField name="cancelledBy" type="string">
  Identifier of who cancelled the ride, or `null`.
</ResponseField>

<ResponseField name="cancellationFee" type="number">
  Fee charged for cancellation, or `null`.
</ResponseField>

<ResponseField name="createdAt" type="string">
  ISO 8601 timestamp of ride creation.
</ResponseField>

<ResponseField name="acceptedAt" type="string">
  ISO 8601 timestamp of driver acceptance, or `null`.
</ResponseField>

## Example

<CodeGroup>
  ```bash cURL theme={null}
  curl -X GET "http://localhost:8080/rides/history" \
    -H "Authorization: Bearer <token>"
  ```

  ```json Response theme={null}
  [
    {
      "id": 1018,
      "status": "COMPLETED",
      "riderId": 42,
      "driverId": 7,
      "pickupLocation": "MG Road, Bangalore",
      "dropLocation": "Indiranagar, Bangalore",
      "pickupLat": 12.9757,
      "pickupLon": 77.6011,
      "dropLat": 12.9784,
      "dropLon": 77.6408,
      "fare": 145.00,
      "paymentMode": "CASH",
      "paymentStatus": "PAID",
      "riderRating": 5,
      "riderFeedback": "Smooth ride, very punctual.",
      "cancellationReason": null,
      "cancelledBy": null,
      "cancellationFee": null,
      "createdAt": "2026-04-01T08:22:10Z",
      "acceptedAt": "2026-04-01T08:24:00Z"
    },
    {
      "id": 1019,
      "status": "CANCELLED",
      "riderId": 42,
      "driverId": null,
      "pickupLocation": "Koramangala, Bangalore",
      "dropLocation": "Whitefield, Bangalore",
      "pickupLat": 12.9352,
      "pickupLon": 77.6245,
      "dropLat": 12.9698,
      "dropLon": 77.7500,
      "fare": 310.00,
      "paymentMode": "WALLET",
      "paymentStatus": null,
      "riderRating": null,
      "riderFeedback": null,
      "cancellationReason": "Changed plans",
      "cancelledBy": "rider",
      "cancellationFee": 30.00,
      "createdAt": "2026-04-01T14:05:33Z",
      "acceptedAt": null
    }
  ]
  ```
</CodeGroup>

<Note>
  This endpoint returns rides where you appear as either the rider (`riderId`) or the driver (`driverId`), giving both riders and drivers a unified view of their trip history.
</Note>
