staticfinalStringPROJECT_ID="my-delivery-co-gcp-project";DeliveryServiceBlockingStubdeliveryService=DeliveryServiceGrpc.newBlockingStub(channel);// Tasks requestStringparent="providers/"+PROJECT_ID;ListDeliveryVehiclesRequestlistDeliveryVehiclesRequest=ListDeliveryVehiclesRequest.newBuilder()// No need for the header.setParent(parent).setViewport(Viewport.newBuilder().setHigh(LatLng.newBuilder().setLatitude(37.45).setLongitude(-122.06).build()).setLow(LatLng.newBuilder().setLatitude(37.41).setLongitude(-122.11).build()).setFilter("attributes.my_key = my_value").build();try{ListDeliveryVehiclesResponselistDeliveryVehiclesResponse=deliveryService.listDeliveryVehicles(listDeliveryVehiclesRequest);}catch(StatusRuntimeExceptione){Statuss=e.getStatus();switch(s.getCode()){caseNOT_FOUND:break;casePERMISSION_DENIED:break;}return;}
# Request with a filter# Request sets JWT, PROJECT_ID, and VEHICLE_ID in the local environmentcurl-H"Authorization: Bearer ${JWT}"\
"https://fleetengine.googleapis.com/v1/providers/${PROJECT_ID}/deliveryVehicles?filter=attributes.my_key%20%3D%20my_value%20&viewport.high.latitude=37.45&viewport.high.longitude=-122.06&viewport.low.latitude=37.41&viewport.low.longitude=-122.11"
[null,null,["最后更新时间 (UTC):2025-08-31。"],[[["\u003cp\u003eThis guide explains how to retrieve a list of delivery vehicles, including filtering by attributes and location.\u003c/p\u003e\n"],["\u003cp\u003eYou can list vehicles using attribute filters and viewport bounds, enabling targeted retrieval.\u003c/p\u003e\n"],["\u003cp\u003eList responses are paginated, allowing for the retrieval of large datasets in manageable chunks.\u003c/p\u003e\n"],["\u003cp\u003eExamples are provided for listing vehicles using both the Java gRPC library and REST API.\u003c/p\u003e\n"],["\u003cp\u003eAccess to delivery vehicle listing requires specific authorization using \u003cem\u003eDelivery Fleet Reader\u003c/em\u003e or \u003cem\u003eFleet Engine Delivery Admin\u003c/em\u003e tokens.\u003c/p\u003e\n"]]],[],null,["# List delivery vehicles\n\n| **Note:** **Before constructing a vehicle request** , read the requirements under [Vehicle requests](/maps/documentation/mobility/fleet-engine/essentials/vehicles#vehicle_requests) in the Introduction.\n\nThis document describes how to list delivery vehicles.\n\nEnvironments and limitations\n----------------------------\n\nYou can list delivery vehicles from a server or browser environment. The Driver\nSDK does not support listing delivery vehicles.\n\nListing delivery vehicles requests broad access to delivery vehicles and is\nintended only for trusted users. Use *Delivery Fleet Reader* or *Fleet Engine\nDelivery Admin* tokens when making list delivery vehicles requests.\n\nListed delivery vehicles have the following fields redacted due to their impact\non response size:\n\n- `CurrentRouteSegment`\n- `RemainingVehicleJourneySegments`\n\nUsage\n-----\n\nYou can list vehicles by attribute filters and viewport bounds. If you specify\nno filter or viewport, the response includes all delivery vehicles.\n\n### List with attributes filters\n\nYou can list delivery vehicles by filter using their `attributes` property. For\nexample, to query an attribute with key `my_key` and value `my_value`, use\n`attributes.my_key = my_value`. To query for multiple attributes, join queries\nusing the logical `AND` and `OR` operators as in `attributes.key1 = value1 AND\nattributes.key2 = value2`. See [AIP-160](https://google.aip.dev/160) for a full description\nof filter query syntax. If you combine filters with viewport bounds, the filter\nacts as an `AND` operator to the viewport bound. See [Vehicle attributes filter\nqueries](/maps/documentation/mobility/fleet-engine/essentials/vehicles/scheduled-tasks-vehicle-fields) for details.\n\n### List with viewport bounds\n\nYou can filter listed delivery vehicles by location using the `viewport` request\nparameter. The `viewport` request parameter defines viewports using two bounding\ncoordinates: a `high` (northeast) and `low` (southwest) latitude and longitude\ncoordinates pair. Requests are rejected if they contain a high latitude\nthat is geographically lower than a low latitude.\n\n### List responses\n\nDelivery vehicle lists are paginated by default using a reasonable page size. If\nyou specify a page size, the request returns only the number of vehicles\nspecified by the limit, or fewer. If the requested page size exceeds an internal\nmaximum value, then the internal maximum is used. The default and maximum page\nsizes are both 100 vehicles.\n\nA delivery vehicles list can include a token for reading the next page of\nresults. A page token is only present in a response when more pages of delivery\nvehicles are available for retrieval. To retrieve the next page of tasks, use\nthe page token with a request that is otherwise identical to the previous\nrequest.\n\nList vehicles examples\n----------------------\n\nYou can use the [Java gRPC library](/maps/documentation/mobility/fleet-engine/essentials/client-libraries-tasks#java) or REST to list delivery vehicles in a\nparticular region with a certain attribute. A successful response can still be\nempty. When that happens, it means that no vehicles with the specified attribute\nexist in the specified viewport. \n\n### Java\n\n\n static final String PROJECT_ID = \"my-delivery-co-gcp-project\";\n\n DeliveryServiceBlockingStub deliveryService =\n DeliveryServiceGrpc.newBlockingStub(channel);\n\n // Tasks request\n String parent = \"providers/\" + PROJECT_ID;\n ListDeliveryVehiclesRequest listDeliveryVehiclesRequest =\n ListDeliveryVehiclesRequest.newBuilder() // No need for the header\n .setParent(parent)\n .setViewport(\n Viewport.newBuilder()\n .setHigh(LatLng.newBuilder()\n .setLatitude(37.45)\n .setLongitude(-122.06)\n .build())\n .setLow(LatLng.newBuilder()\n .setLatitude(37.41)\n .setLongitude(-122.11)\n .build())\n .setFilter(\"attributes.my_key = my_value\")\n .build();\n\n try {\n ListDeliveryVehiclesResponse listDeliveryVehiclesResponse =\n deliveryService.listDeliveryVehicles(listDeliveryVehiclesRequest);\n } catch (StatusRuntimeException e) {\n Status s = e.getStatus();\n switch (s.getCode()) {\n case NOT_FOUND:\n break;\n\n case PERMISSION_DENIED:\n break;\n }\n return;\n }\n\n### REST\n\n # HTTP request\n html GET https://fleetengine.googleapis.com/v1/providers/\u003cproject_id\u003e/deliveryVehicles\n\n\n # Request with a filter\n # Request sets JWT, PROJECT_ID, and VEHICLE_ID in the local environment\n curl -H \"Authorization: Bearer ${JWT}\" \\\n \"https://fleetengine.googleapis.com/v1/providers/${PROJECT_ID}/deliveryVehicles?filter=attributes.my_key%20%3D%20my_value%20&viewport.high.latitude=37.45&viewport.high.longitude=-122.06&viewport.low.latitude=37.41&viewport.low.longitude=-122.11\"\n\nIf the lookup is successful, the response body contains data with the following\nstructure: \n\n // JSON representation\n {\n \"deliveryVehicles\": [\n {\n object (DeliveryVehicle)\n }\n ],\n \"nextPageToken\": string,\n \"totalSize\": integer\n }\n\nWhat's next\n-----------\n\n- [Delete Delivery Vehicle](/maps/documentation/mobility/fleet-engine/essentials/vehicles/scheduled-tasks-delete-vehicle)"]]