Skip to content

S3Client.list_objects_v2

rboto-s3==0.4.0 · Service index · Types

Model summary (excerpt): Returns some or all (up to 1,000) of the objects in a bucket with each request. You can use the request parameters as selection criteria to return a subset of the objects in a bucket. A 200 OK response can contain valid or invalid XML. Make sure to design your application to parse the contents of the response and handle it appropriately. For more information about listing objects, see Listing...

Install and imports

python -m pip install "rboto[s3]==0.4.0"
from rboto import S3Client
from collections.abc import Sequence
from rboto_s3.types import (
    EncodingType,
    ListObjectsV2Output,
    OptionalObjectAttributes,
    RequestPayer,
)

Signature

async def list_objects_v2(
    *,
    bucket: str,
    delimiter: str | None = None,
    encoding_type: EncodingType | None = None,
    max_keys: int | None = None,
    prefix: str | None = None,
    continuation_token: str | None = None,
    fetch_owner: bool | None = None,
    start_after: str | None = None,
    request_payer: RequestPayer | None = None,
    expected_bucket_owner: str | None = None,
    optional_object_attributes: Sequence[OptionalObjectAttributes] | None = None,
) -> ListObjectsV2Output: ...

Arguments without defaults are required. None omits an optional request argument. Static types do not validate resource existence, permissions, lengths, ranges, or conditional service requirements.

Arguments

Argument Required Model notes (excerpt)
bucket Yes Directory buckets - When you use this operation with a directory bucket, you must use virtual-hosted-style requests in the format Bucket-name .s3express- zone-id . region-code .amazonaws.com . Path-style requests are not supported. Directory bucket names must be unique in the chosen Zone (Availability Zone or Local Zone). Bucket names must follow the format bucket-base-name -- zone-id --x-s3...
delimiter No A delimiter is a character that you use to group keys. CommonPrefixes is filtered out from results if it is not lexicographically greater than the StartAfter value. Directory buckets - For directory buckets, / is the only supported delimiter. Directory buckets - When you query ListObjectsV2 with a delimiter during in-progress multipart uploads, the CommonPrefixes response parameter contains...
encoding_type No Encoding type used by Amazon S3 to encode the object keys in the response. Responses are encoded only in UTF-8. An object key can contain any Unicode character. However, the XML 1.0 parser can't parse certain characters, such as characters with an ASCII value from 0 to 10. For characters that aren't supported in XML 1.0, you can add this parameter to request that Amazon S3 encode the keys in...
max_keys No Sets the maximum number of keys returned in the response. By default, the action returns up to 1,000 key names. The response might contain fewer keys but will never contain more.
prefix No Limits the response to keys that begin with the specified prefix. Directory buckets - For directory buckets, only prefixes that end in a delimiter ( / ) are supported.
continuation_token No ContinuationToken indicates to Amazon S3 that the list is being continued on this bucket with a token. ContinuationToken is obfuscated and is not a real key. You can use this ContinuationToken for pagination of the list results.
fetch_owner No The owner field is not present in ListObjectsV2 by default. If you want to return the owner field with each key in the result, then set the FetchOwner field to true . Directory buckets - For directory buckets, the bucket owner is returned as the object owner for all objects.
start_after No StartAfter is where you want Amazon S3 to start listing from. Amazon S3 starts listing after this specified key. StartAfter can be any key in the bucket. This functionality is not supported for directory buckets.
request_payer No Confirms that the requester knows that she or he will be charged for the list objects request in V2 style. Bucket owners need not specify this parameter in their requests. This functionality is not supported for directory buckets.
expected_bucket_owner No The account ID of the expected bucket owner. If the account ID that you provide does not match the actual owner of the bucket, the request fails with the HTTP status code 403 Forbidden (access denied).
optional_object_attributes No Specifies the optional fields that you want returned in the response. Fields that you do not specify are not returned. This functionality is not supported for directory buckets.

Output

ListObjectsV2Output.

Read-only native attributes, accessed as response.field. Collection getters materialize Python values; to_dict() recursively materializes a mapping. Streams are consumed once.

Field Type Presence References
is_truncated bool | None Always present —
contents list[ObjectOutput] | None Always present ObjectOutput
name str | None Always present —
prefix str | None Always present —
delimiter str | None Always present —
max_keys int | None Always present —
common_prefixes list[CommonPrefixOutput] | None Always present CommonPrefixOutput
encoding_type EncodingTypeOutput | None Always present EncodingTypeOutput
key_count int | None Always present —
continuation_token str | None Always present —
next_continuation_token str | None Always present —
start_after str | None Always present —
request_charged RequestChargedOutput | None Always present RequestChargedOutput

| None means a value can be absent. Output mappings include every declared key; optional input keys may be omitted. Unknown output enum/union variants are not automatically valid inputs.

EncodingType, ListObjectsV2Output, OptionalObjectAttributes, RequestPayer

Follow these links for nested inputs and outputs; recursive types link back to the same type page.

Pagination and streaming

client.paginators.list_objects_v2(...) accepts the same arguments and returns AsyncIterator[ListObjectsV2Output]. Direct calls return one page. Pages preserve the Output representation above.

Input cursors: continuation_token. Page-size argument: max_keys.

No output stream.

Errors

Import from rboto_s3.exceptions:

NoSuchBucketError.

Other service failures use the service base error; credential, transport and timeout failures use shared errors.

Service guide · Pinned model