> [!NOTE]
> **Note:** **Before constructing a vehicle request** , read the requirements under [Vehicle requests](https://developers.google.com/maps/documentation/mobility/fleet-engine/essentials/vehicles.md.txt#vehicle_requests) in the Introduction.

Use the `ListVehicles` method to find all vehicles that satisfy some specific
request options. The `ListVehicles` method returns a paginated list of vehicles
in the project that matches queries across vehicle fields.

## Filter by vehicle attributes

You can also use this method to filter on vehicle attributes, which act as AND
operator when used in conjunction with other field specifications. For details
on filter query syntax, see [Filtering: AIP-160](https://google.aip.dev/160)
for examples. For details on creating vehicle attributes, see [Vehicle
attributes field](https://developers.google.com/maps/documentation/mobility/fleet-engine/essentials/vehicles/on-demand-vehicle-fields#vehicle_attributes_field) in the **Update vehicle fields** guide.

## List vehicle example

This example filters on both the `vehicle_type` and `attributes` fields using
the `filter` string, showing only vehicles of type AUTO and obtaining the LUXURY
value for the custom attribute of `class`.

You can use the [gRPC client libraries](https://developers.google.com/maps/documentation/mobility/fleet-engine/essentials/client-libraries-trips.md.txt) or REST.

### Java

```java
static final String PROJECT_ID = "project-id";

VehicleServiceBlockingStub vehicleService = VehicleService.newBlockingStub(channel);

String parent = "providers/" + PROJECT_ID;
ListVehiclesRequest listVehiclesRequest = ListVehiclesRequest.newBuilder()
    .setParent(parent)
    .addTripTypes(TripType.EXCLUSIVE)
    .addVehicleTypes(VehicleType.newBuilder().setCategory(VehicleType.Category.AUTO))
    .setFilter("attributes.on_trip=\"false\"")
    .setIncludeBackToBack(true) // Fleet Engine includes vehicles that are en route.
    .build();

// Error handling
// If matches are returned and the authentication passed, the request completed
// successfully

try {
  ListVehiclesResponse listVehiclesResponse =
      vehicleService.listVehicles(listVehiclesRequest);
} catch (StatusRuntimeException e) {
  Status s = e.getStatus();
  switch (s.getCode()) {
    case NOT_FOUND:
      break;
    case PERMISSION_DENIED:
      break;
  }
  return;
}
```

### REST

```bash
curl -X POST \
  "https://fleetengine.googleapis.com/v1/providers/project-id/vehicles:list" \
  -H "Authorization: Bearer $JWT" \
  -H "Content-Type: application/json" \
  --data-binary @- << EOM
{
  "vehicleTypes": [{"category": "AUTO"}],
  "filter": "attributes.class=\"LUXURY\"",
}
EOM
```

## What's next

- [Search vehicles](https://developers.google.com/maps/documentation/mobility/fleet-engine/essentials/vehicles/on-demand-search-vehicle.md.txt)